:root {
  color-scheme: light;
  --ink: #182234;
  --muted: #667085;
  --line: #dce2ea;
  --paper: #ffffff;
  --canvas: #f3f6f9;
  --brand: #175cd3;
  --brand-dark: #1248a8;
  --accent: #0e9384;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }

.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #10213f 0%, #0b1830 100%);
  border-bottom: 3px solid #d92d20;
  color: white;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #2e90fa; font-weight: 800; }
.brand-logo { display: block; width: auto; height: 42px; max-width: 174px; object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { color: #ffffff; }
.brand small { margin-top: 2px; color: #d7e3f4; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.language-switcher {
  width: auto;
  min-width: 76px;
  padding: 7px 9px;
  border-color: rgba(255, 255, 255, 0.24);
  background: #13223f;
  color: white;
}
.identity { font-size: 14px; color: #d1dded; }
.source-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.source-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ticket-key { display: inline-flex; align-items: center; gap: 6px; }

.shell { max-width: 1540px; margin: 0 auto; padding: 42px 32px 72px; }
.hero, .panel-heading, .detail-heading, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.hero { margin-bottom: 24px; }
.hero-cta { position: sticky; top: 88px; z-index: 5; box-shadow: 0 10px 24px rgba(23, 92, 211, 0.24); }
.refresh-status { display: inline-flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.freshness-caption { font-size: 14px; white-space: nowrap; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.035em; }
h2 { margin-bottom: 4px; font-size: 21px; }
.eyebrow { margin-bottom: 7px; color: var(--brand); font-weight: 750; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }
.ticket-notice { margin-bottom: 16px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 24px rgba(26, 39, 61, 0.05); }
.auth-panel { padding: 30px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 36px; }
.auth-copy { display: grid; align-content: center; gap: 10px; }
.auth-logo { display: block; width: auto; height: 44px; max-width: 180px; object-fit: contain; }
.auth-fields, .ticket-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.auth-fields { align-content: center; }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cbd3df; border-radius: 9px; padding: 11px 12px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #84adff; box-shadow: 0 0 0 3px #dce8ff; }
textarea { resize: vertical; }
.attachment-dropzone {
  position: relative;
  padding: 14px;
  border: 1px dashed #9eb7df;
  border-radius: 12px;
  background: #f8fbff;
}
.attachment-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.attachment-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.attachment-picker-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.attachment-picker-summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}
.attachment-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.attachment-file, .attachment-preview {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-width: 210px;
  margin: 0;
}
.attachment-name, .attachment-caption {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.attachment-thumbnail {
  width: 160px;
  height: 110px;
  border: 1px solid #cbd3df;
  border-radius: 8px;
  padding: 0;
  background: #f8fafc;
  cursor: pointer;
  overflow: hidden;
}
.attachment-thumbnail:disabled { cursor: progress; }
.attachment-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.attachment-card {
  border: 1px solid #cbd3df;
  border-radius: 999px;
  padding: 6px 10px;
  background: white;
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.attachment-action {
  border: 1px solid #b2ccff;
  border-radius: 999px;
  padding: 6px 10px;
  background: #eff4ff;
  color: #1849a9;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.attachment-action:disabled { cursor: progress; opacity: 0.65; }
.wide { grid-column: 1 / -1; }
.button { border: 0; border-radius: 9px; padding: 10px 16px; cursor: pointer; font-weight: 700; }
.button.primary { background: var(--brand); color: white; }
.auth-fields .button.primary { min-height: 72px; font-size: 18px; }
.button.primary:hover { background: var(--brand-dark); }
.button.quiet { background: #eef3f8; color: #344054; }
.status-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 12px;
  font-weight: 800;
}
.status-badge.operational { background: #ecfdf3; color: #027a48; }
.status-badge.degraded { background: #fff7ed; color: #9a3412; }
.version-reload-prompt {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff7ed;
  color: #9a3412;
  border-bottom: 1px solid #fed7aa;
  font-weight: 800;
}

#new-ticket-panel { padding: 26px; margin-bottom: 24px; }
.support-email-banner {
  margin-bottom: 24px;
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid #b2ddff;
  border-radius: 16px;
  background: #eff8ff;
}
.support-help-copy { display: grid; gap: 6px; }
.support-help-copy strong { font-size: 18px; }
.support-help-copy p { margin-bottom: 0; }
.support-help-address { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding-top: 28px; }
.support-email-banner a { color: var(--brand-dark); font-weight: 750; }
.desk-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.desk-grid.customer-desk { grid-template-columns: minmax(0, 1fr); }
.desk-scope-toggle { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.desk-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.desk-stat-tile {
  padding: 18px;
  display: grid;
  gap: 8px;
  border-color: #d6e4ff;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.desk-stat-tile[aria-pressed="true"] { outline: 2px solid var(--brand); outline-offset: 2px; }
.desk-stat-tile .desk-count { font-size: 34px; }
.desk-stat-us { border-color: #b2ddff; }
.desk-stat-you { border-color: #fedf89; }
.desk-stat-resolved { border-color: #abefc6; }
.desk-card { padding: 18px; display: grid; align-content: start; gap: 12px; }
.desk-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.desk-card-title { margin: 0; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.desk-card-heading { color: var(--ink); font-size: 22px; font-weight: 850; letter-spacing: -0.03em; }
.desk-count { color: var(--ink); font-size: 32px; font-weight: 850; letter-spacing: -0.04em; }
.desk-list { display: grid; gap: 8px; }
.desk-row {
  width: 100%;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.desk-row:hover { background: #f0f6ff; border-color: #b2ccff; }
.desk-row strong { font-size: 13px; }
.desk-meta { display: flex; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.desk-empty { color: var(--muted); font-size: 13px; }
.team-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.team-overview-card { grid-column: 1 / -1; }
.team-overview-card .team-stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.team-stat { padding: 10px; border-radius: 10px; background: #f8fafc; }
.team-stat strong { display: block; font-size: 20px; }
.workspace-grid { display: grid; grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.35fr); gap: 24px; align-items: start; }
.ticket-list-panel, .ticket-detail { min-height: 560px; }
.ticket-list-panel .panel-heading, .ticket-detail { padding: 24px; }
.list-controls {
  padding: 0 24px 18px;
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) minmax(130px, 0.8fr);
  gap: 12px;
  align-items: end;
}
.quick-filters {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.filter-chip {
  border: 1px solid #cbd3df;
  border-radius: 999px;
  padding: 7px 11px;
  background: white;
  color: #344054;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.filter-chip[aria-pressed="true"] {
  border-color: var(--brand);
  background: #eaf2ff;
  color: #1849a9;
}
.list-summary {
  margin: 0;
  padding: 0 24px 14px;
  color: var(--muted);
  font-size: 13px;
}
.pagination-controls {
  padding: 16px 24px 20px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
}
.pagination-controls .button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.ticket-list { border-top: 1px solid var(--line); }
.ticket-card { width: 100%; padding: 18px 24px; display: grid; gap: 8px; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: white; cursor: pointer; }
.ticket-card:hover, .ticket-card.active { background: #f5f8ff; }
.ticket-card-top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.ticket-card strong { font-size: 15px; color: var(--ink); }
.ticket-card-badges { display: flex; gap: 7px; flex-wrap: wrap; }
.status-pill, .priority-pill, .type-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 750;
}
.status-pill { background: #eaf2ff; color: #1849a9; }
.status-pill.status-new {
  background: #dbeafe;
  color: #1d4ed8;
  box-shadow: inset 0 0 0 1px #93c5fd;
}
.priority-low { background: #fef7c3; color: #854d0e; }
.priority-normal { background: #ffecb3; color: #7a4b00; }
.priority-high { background: #fed7aa; color: #9a3412; }
.priority-critical { background: #fee2e2; color: #991b1b; }
.type-pill { background: #eef2ff; color: #3538cd; }
.ticket-classification { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pill-field { margin: 0; padding: 0; border: 0; display: grid; gap: 7px; }
.pill-field legend { padding: 0; color: #344054; font-size: 13px; font-weight: 650; }
.pill-selector { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  border-radius: 999px;
  padding: 5px 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  box-shadow: inset 0 0 0 1px rgba(24, 34, 52, 0.08);
}
.pill-button[aria-pressed="true"] {
  border-color: currentColor;
  box-shadow: 0 0 0 3px #dce8ff;
}
.pill-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}
.pill-field.readonly .pill-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px currentColor;
}
.detail-meta { display: flex; gap: 18px; flex-wrap: wrap; margin: 16px 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.turn-banner {
  margin: 14px 0 18px;
  padding: 12px 14px;
  border: 1px solid #b2ddff;
  border-radius: 10px;
  background: #eff8ff;
  color: #1849a9;
  font-weight: 750;
}
.turn-banner.customer {
  border-color: #fedf89;
  background: #fffaeb;
  color: #93370d;
}
.turn-banner.approval {
  display: grid;
  gap: 10px;
  border-color: #c7d7fe;
  background: #eef4ff;
  color: #253b80;
}
.approval-form {
  display: grid;
  gap: 10px;
}
.approval-form textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
}
.conversation { display: grid; gap: 14px; position: relative; }
.timeline-item { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 12px; align-items: start; }
.timeline-marker {
  width: 10px;
  height: 10px;
  margin-top: 18px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px #eaf2ff;
}
.timeline-card {
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.timeline-message.outbound .timeline-marker { background: var(--accent); box-shadow: 0 0 0 4px #e6fffb; }
.message { padding: 14px 16px; border-radius: 12px; background: #f1f5f9; }
.message.customer { margin-right: 38px; }
.message.agent, .message.admin, .message.supervisor { margin-left: 38px; background: #e8f2ff; }
.message-meta { margin-bottom: 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.message-body-stack { display: grid; gap: 10px; }
.migration-note {
  margin: 0;
  padding: 12px;
  border: 1px solid #abefc6;
  border-radius: 10px;
  background: #ecfdf3;
  color: #05603a;
  font-weight: 700;
}
.message-body, .message-original {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
}
.message-original {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  color: #344054;
}
.message-original-toggle {
  width: fit-content;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 800;
}
.message-attachments {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(102, 112, 133, 0.22);
}
.attachment-heading { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.reply-form { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.reply-form .form-actions { margin-top: 12px; }
.empty { display: grid; place-items: center; }
.empty-state { padding: 60px 24px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 50px; height: 50px; margin: 0 auto 18px; border-radius: 50%; background: #eaf2ff; color: var(--brand); font-size: 24px; font-weight: 800; }
.empty-list { padding: 50px 24px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .auth-panel, .workspace-grid, .desk-grid, .desk-stat-grid, .list-controls { grid-template-columns: 1fr; }
  .ticket-list-panel, .ticket-detail { min-height: auto; }
  .hero-cta { position: static; }
}
@media (max-width: 620px) {
  .topbar { padding: 0 18px; }
  .shell { padding: 28px 16px 50px; }
  .auth-fields, .ticket-form { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .hero { align-items: flex-start; }
  .support-email-banner { align-items: flex-start; flex-direction: column; }
  .support-help-address { padding-top: 0; }
  .ticket-classification { grid-template-columns: 1fr; }
}
