@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-400-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-500-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-600-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-400-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-600-latin.woff2") format("woff2");
}

:root {
  --navy: #0b1f3a;
  --blue: #1a5cff;
  --blue-lt: #0d4dee;
  --teal: #00c4b4;
  --teal-text: #006f66;
  --danger: #d62240;
  --surface-page: #edf1f7;
  --grey-bg: #e3eaf3;
  --grey-text: #52657b;
  --grey-text-strong: #3a4e65;
  --border: #b6c3d7;
  --white: #ffffff;
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --shadow: 0 8px 28px rgba(11, 31, 58, 0.08);
  --bar-height: 64px;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--navy);
  background: var(--surface-page);
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: var(--blue);
}

img {
  max-width: 100%;
  height: auto;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-150%);
  background: var(--navy);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 4px;
  z-index: 30;
}

.skip-link:focus {
  transform: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: var(--bar-height);
  padding: 0 24px;
  background: var(--navy);
  color: var(--white);
  border-bottom: 3px solid var(--teal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--white);
  text-decoration: none;
}

.brand img {
  height: 28px;
  width: auto;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
}

.brand-product {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.app-nav {
  display: flex;
  gap: 8px;
}

.app-nav a {
  color: var(--white);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
}

.app-nav a:hover,
.app-nav a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
}

.app-bar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.agent-name {
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.is-login main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.login-card,
.table-card,
.card,
.empty,
.thread,
.ticket-panel,
.composer,
.note-form {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(420px, 100%);
  padding: 32px;
}

.login-logo {
  height: 36px;
  width: auto;
}

.login-card h1 {
  margin-top: 20px;
  font-size: 28px;
}

.lede,
.hint,
.count,
.requester-email {
  color: var(--grey-text);
}

.lede {
  margin: 8px 0 24px;
}

label {
  display: block;
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
}

textarea {
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--blue-lt);
}

.btn-quiet {
  background: var(--white);
  border-color: var(--border);
  color: var(--navy);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--grey-bg);
}

.btn-danger {
  background: var(--white);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-on-navy {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--white);
  padding: 6px 12px;
}

.btn-on-navy:hover {
  background: rgba(255, 255, 255, 0.1);
}

.login-card .btn-primary,
.form-card .btn-primary {
  margin-top: 20px;
  width: 100%;
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--border);
}

.flash-error {
  border-color: var(--danger);
  color: var(--danger);
}

.flash-success {
  border-color: var(--teal-text);
  color: var(--teal-text);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
}

.queue-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-card {
  display: grid;
  gap: 2px;
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--navy);
  text-decoration: none;
}

.stat-card:hover {
  border-color: var(--blue);
}

.stat-number {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
}

.stat-label {
  color: var(--grey-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
}

.stat-total {
  box-shadow: inset 3px 0 0 var(--blue);
}

.stat-new {
  box-shadow: inset 3px 0 0 var(--blue);
}

.stat-open {
  box-shadow: inset 3px 0 0 var(--teal);
}

.stat-waiting {
  box-shadow: inset 3px 0 0 var(--navy);
}

.stat-on_hold {
  box-shadow: inset 3px 0 0 var(--grey-text);
}

.stat-card.is-current {
  border-color: var(--blue);
}

.page-head h1,
.thread-head h1,
.empty h1,
.empty h2 {
  font-size: 28px;
  font-weight: 600;
}

.count {
  margin-top: 4px;
}

.mailbox-check {
  margin: 2px 0 0;
  color: var(--grey-text);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: 220px 220px 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.filters label {
  margin: 0 0 6px;
}

.filters .btn {
  height: 42px;
}

.table-card {
  overflow: auto;
}

.queue,
.users {
  width: 100%;
  border-collapse: collapse;
}

.queue th,
.queue td,
.users th,
.users td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.queue th,
.users th {
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--grey-text);
  background: var(--white);
}

.queue thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.queue-row {
  cursor: pointer;
}

.queue-row:hover {
  background: color-mix(in srgb, var(--blue) 4%, var(--white));
}

.queue-row.needs-attention {
  background: color-mix(in srgb, var(--blue) 9%, var(--white));
  box-shadow: inset 3px 0 0 var(--blue);
}

.queue-row.needs-attention:hover {
  background: color-mix(in srgb, var(--blue) 14%, var(--white));
}

.status-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ticket-link {
  color: var(--navy);
  font-weight: 600;
  text-decoration: none;
}

.ticket-number-link {
  font-family: var(--mono);
}

.ticket-link:hover {
  color: var(--blue);
}

.requester-name,
.requester-email {
  display: block;
}

.requester-email {
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-new {
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 10%, var(--white));
}

.pill-open {
  color: var(--teal-text);
  background: color-mix(in srgb, var(--teal) 14%, var(--white));
}

.pill-waiting {
  color: var(--navy);
  background: transparent;
  border-color: var(--navy);
}

.pill-attention {
  color: var(--white);
  background: var(--blue);
}

.attention-note {
  margin-top: 8px;
  color: var(--blue);
  font-weight: 600;
}

.pill-on_hold,
.pill-closed {
  color: var(--grey-text-strong);
  background: var(--grey-bg);
}

.empty {
  padding: 48px 32px;
}

.empty p {
  margin-top: 8px;
  color: var(--grey-text);
}

.back-link {
  margin: 0 0 16px;
}

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.thread,
.ticket-panel {
  padding: 24px;
}

.ticket-number {
  margin: 0;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--grey-text);
}

.thread-head {
  margin-bottom: 20px;
}

.messages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.message {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--white);
}

.message-out {
  background: color-mix(in srgb, var(--blue) 5%, var(--white));
}

.message-note {
  background: color-mix(in srgb, var(--teal) 8%, var(--white));
  border-color: color-mix(in srgb, var(--teal) 30%, var(--white));
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 14px;
}

.message-kind {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--grey-text);
}

.message-meta time {
  margin-left: auto;
  color: var(--grey-text);
  font-size: 13px;
}

.message-recipients {
  margin: 0 0 8px;
  color: var(--grey-text);
  font-size: 13px;
}

.message-text {
  white-space: pre-wrap;
}

.message-body {
  overflow-x: auto;
  line-height: 1.45;
}

.message-body :first-child {
  margin-top: 0;
}

.message-body table {
  max-width: 100%;
}

.message-body img {
  max-width: 100%;
  height: auto;
}

.attachment-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: start;
}

.preview-open {
  display: grid;
  gap: 6px;
  width: 180px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  color: var(--navy);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
  overflow: hidden;
}

.preview-open img {
  width: 180px;
  height: 120px;
  object-fit: cover;
  background: var(--surface-page);
}

.preview-open span {
  padding: 0 8px 8px;
  font-size: 13px;
  line-height: 1.3;
  word-break: break-word;
}

.attachment-download {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.image-preview {
  border: 0;
  padding: 12px;
  border-radius: 12px;
  max-width: min(960px, calc(100vw - 32px));
  background: var(--white);
}

.image-preview::backdrop {
  background: rgb(11 31 58 / 72%);
}

.image-preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.image-preview-bar p {
  margin: 0;
  font-weight: 600;
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  width: auto;
  height: auto;
  margin: 0 auto;
}

.composer,
.note-form {
  margin-top: 12px;
  padding: 16px;
  box-shadow: none;
}

.composer + .messages,
.messages + .note-form {
  margin-top: 12px;
}

.composer:not(.is-open) .composer-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.composer:not(.is-open) textarea {
  min-height: 46px;
  resize: none;
}

.composer.is-open textarea {
  min-height: 180px;
}

.hint {
  margin-top: 8px;
  font-size: 14px;
}

.composer-actions,
.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.reply-action {
  display: grid;
  gap: 4px;
  align-content: start;
  max-width: 320px;
}

.reply-action .hint {
  margin: 0;
}

.ticket-panel {
  position: sticky;
  top: calc(var(--bar-height) + 16px);
  display: grid;
  gap: 24px;
}

.ticket-panel h2 {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--grey-text);
  margin-bottom: 8px;
}

.panel-name {
  font-weight: 600;
}

.is-current {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.split {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.form-card {
  padding: 24px;
}

.form-card h2,
.form-card h1 {
  font-size: 20px;
}

.form-card-narrow {
  max-width: 520px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.row-actions form {
  margin: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check input {
  width: auto;
}

@media (max-width: 860px) {
  .filters,
  .ticket-layout,
  .split {
    grid-template-columns: 1fr;
  }

  .ticket-panel {
    position: static;
    order: -1;
  }

  .app-bar {
    flex-wrap: wrap;
    padding: 12px 16px;
    height: auto;
  }

  .app-bar-end {
    margin-left: 0;
  }

  .queue thead {
    display: none;
  }

  .queue tr {
    display: block;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  .queue td {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    border: 0;
    padding: 4px 16px;
  }

  .queue td::before {
    content: attr(data-label);
    color: var(--grey-text);
    font-size: 13px;
    font-weight: 600;
  }

  .queue thead th {
    position: static;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
