:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #687386;
  --line: #dce1e8;
  --line-strong: #c8d0da;
  --surface: #ffffff;
  --canvas: #f5f6f8;
  --nav: #172033;
  --blue: #2457a7;
  --blue-dark: #1d4789;
  --paid: #6d3fa0;
  --danger: #b42318;
  --warning: #9a6700;
  --success: #16794b;
}

* { box-sizing: border-box; }

body,
.app-body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a { color: inherit; }

.login-body { min-height: 100vh; background: #eef1f5; }
.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(360px, 44%) minmax(420px, 1fr); }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: 42px 48px 56px; background: var(--nav); color: #fff; }
.login-intro .brand { padding-left: 0; }
.login-intro > div:last-child { max-width: 540px; }
.login-intro h1 { max-width: 520px; margin: 12px 0 16px; font-size: clamp(30px, 4vw, 46px); font-weight: 650; letter-spacing: -.035em; line-height: 1.08; }
.login-intro p:last-child { max-width: 470px; margin: 0; color: #b9c4d5; font-size: 15px; line-height: 1.65; }
.login-intro .section-kicker { color: #8fa4c4; }
.login-card { display: grid; align-self: center; width: min(420px, calc(100% - 48px)); margin: 36px auto; padding: 30px; gap: 18px; }
.login-heading h2 { margin: 4px 0 5px; font-size: 24px; font-weight: 680; }
.login-heading p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.login-card .notice { margin: 0; }
.notice.error { border-color: #efc5c1; background: #fff7f6; color: var(--danger); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 57px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.app-main {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.app-sidebar {
  width: 248px;
  min-height: 100%;
  padding: 22px 14px;
  border-right: 1px solid #273248;
  background: var(--nav);
  color: #dce4f2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .05em;
}

.brand-name { color: #fff; font-size: 16px; font-weight: 650; }
.brand-caption { margin-top: 1px; color: #9eabc0; font-size: 11px; }
.nav-section-label { margin: 22px 11px 7px; color: #7f8ca1; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.app-nav { gap: 2px; padding: 0; }
.app-nav li > a { min-height: 36px; border-radius: 5px; color: #bec9d9; font-size: 13px; }
.app-nav li > a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.app-nav li > a.active { background: #26344d; color: #fff; font-weight: 600; }
.page-context { color: #667085; font-size: 13px; }
.user-name { margin-right: 8px; color: #344054; font-size: 13px; font-weight: 600; }
.menu-icon { display: block; width: 18px; height: 12px; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-header h1,
.ticket-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -.02em;
  line-height: 1.22;
}

.page-header p,
.surface-header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.section-kicker { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.section-title { margin: 4px 0 0; font-size: 25px; line-height: 1.2; font-weight: 680; }
.section-subtitle { max-width: 680px; margin: 6px 0 0; color: var(--muted); }

.surface,
.panel-card,
.ticket-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}

.surface-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.surface-header h2 { margin: 0; font-size: 15px; font-weight: 680; }
.text-link { color: var(--blue); font-size: 13px; font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }

.btn { min-height: 38px; height: 38px; border-radius: 5px; font-size: 13px; font-weight: 600; text-transform: none; }
.btn-sm { min-height: 32px; height: 32px; }
.btn-primary { border-color: var(--blue); background: var(--blue); color: white; }
.btn-primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn-outline { border-color: var(--line-strong); background: #fff; color: #344054; }
.btn-ghost { color: #475467; }
.input,
.select,
.textarea {
  width: 100%;
  border-color: var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}
.input,
.select { min-height: 38px; height: 38px; }
.textarea { min-height: 100px; line-height: 1.55; }
.input:focus,
.select:focus,
.textarea:focus { border-color: #6d91c9; outline: 2px solid #dce9fa; outline-offset: 0; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span,
.label-text { color: #596579; font-size: 12px; font-weight: 600; line-height: 1.3; white-space: normal; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.metric-item { display: flex; min-height: 91px; flex-direction: column; justify-content: center; padding: 15px 18px; border-right: 1px solid var(--line); text-decoration: none; }
.metric-item:last-child { border-right: 0; }
.metric-item:hover { background: #f8fafc; }
.metric-item span { color: var(--muted); font-size: 12px; }
.metric-item strong { margin-top: 5px; color: #26354f; font-size: 27px; font-weight: 680; }
.metric-paid strong { color: var(--paid); }

.attention-panel,
.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid #efc5c1;
  border-radius: 6px;
  background: #fff7f6;
}
.attention-panel div,
.notice > div { display: grid; gap: 2px; }
.attention-panel span,
.notice span { color: var(--muted); font-size: 12px; }
.notice.success { border-color: #adddc6; background: #f1fbf6; color: #11683f; }
.notice.info { border-color: #bfd3ef; background: #f3f7fd; }
.notice.warning { border-color: #ead39d; background: #fff9e9; color: #755000; }
.notice.paid { border-color: #d6c4e7; background: #faf7fd; color: #59327f; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; }
.priority-queue { align-self: start; }
.attention-list { display: grid; }
.attention-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); text-decoration: none; }
.attention-row:last-child { border-bottom: 0; }
.attention-row:hover { background: #f8fafc; }
.attention-row > div { display: grid; min-width: 0; gap: 3px; }
.attention-row strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.attention-row span:not(.status-pill) { color: var(--muted); font-size: 12px; }

.queue-tabs { display: flex; gap: 3px; margin-bottom: 14px; overflow-x: auto; border-bottom: 1px solid var(--line-strong); }
.queue-tabs a { flex: none; padding: 10px 13px; border-bottom: 2px solid transparent; color: #596579; font-size: 13px; font-weight: 600; text-decoration: none; }
.queue-tabs a:hover { color: var(--ink); }
.queue-tabs a.active { border-bottom-color: var(--blue); color: var(--blue); }

.filter-panel { margin-bottom: 14px; padding: 16px; }
.filter-grid { display: grid; grid-template-columns: minmax(230px, 1.5fr) repeat(5, minmax(130px, 1fr)) auto; gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 5px; }
.queue-surface { overflow: hidden; }
.bulk-bar { display: flex; align-items: center; gap: 8px; min-height: 50px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: #f8f9fb; }
.bulk-bar > span { margin-right: auto; color: #596579; font-size: 12px; font-weight: 600; }
.bulk-bar .select { width: auto; max-width: 210px; }
.access-note { padding: 11px 15px; border: 1px solid #cbd8e8; border-radius: 6px; background: #f4f7fb; color: #526176; font-size: 12px; }
.queue-surface > .access-note { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }

.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { height: 39px; padding: 8px 12px; border-bottom: 1px solid var(--line-strong); background: #f7f8fa; color: #5b6678; font-size: 10px; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--line); color: #3c4759; font-size: 12px; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fafbfc; }
.ticket-table { min-width: 1080px; }
.compact-table { min-width: 760px; }
.check-cell { width: 38px; padding-right: 2px !important; text-align: center; }
.ticket-link { display: grid; max-width: 360px; gap: 2px; color: inherit; text-decoration: none; }
.ticket-link span { color: var(--blue); font-size: 11px; font-weight: 700; }
.ticket-link strong { overflow: hidden; color: #25324a; font-size: 13px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.ticket-link:hover strong { color: var(--blue); text-decoration: underline; }
.cell-primary,
.cell-secondary { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-primary { color: #344054; font-weight: 600; }
.cell-secondary { margin-top: 2px; color: var(--muted); font-size: 11px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 #d92d20; }
.row-note { display: inline-block; margin-top: 4px; font-size: 10px; font-weight: 650; }
.row-note.danger { color: var(--danger); }
.row-note.warning { color: var(--warning); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 54px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination { display: flex; gap: 4px; }

.status-pill { display: inline-flex; align-items: center; width: max-content; min-height: 22px; padding: 3px 7px; border-radius: 4px; font-size: 10px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.status-new { background: #eaf2ff; color: #2457a7; }
.status-progress,
.status-reply { background: #e8f5f0; color: #16704a; }
.status-waiting,
.status-paid-pending { background: #fff3d7; color: #805b08; }
.status-paid { background: #f0e8f7; color: #6d3fa0; }
.status-declined { background: #f3edf0; color: #765366; }
.status-resolved { background: #e9f6eb; color: #26703c; }
.status-closed { background: #eceff3; color: #596579; }
.status-overdue { background: #fdecea; color: var(--danger); }
.status-risk { background: #fff3d7; color: var(--warning); }
.priority-label { font-size: 11px; font-weight: 650; }
.priority-low { color: #39725a; }
.priority-medium { color: #486a98; }
.priority-high { color: #966400; }
.priority-critical { color: var(--danger); }
.paid-flag { color: var(--paid); font-size: 11px; font-weight: 700; }
.paid-flag.pending { color: var(--warning); }

.breadcrumbs-line { display: flex; gap: 7px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.breadcrumbs-line a { color: var(--blue); text-decoration: none; }
.ticket-header { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(420px, .9fr); gap: 28px; margin-bottom: 14px; padding: 20px; }
.ticket-heading-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.ticket-number { color: var(--blue); font-size: 12px; font-weight: 750; }
.ticket-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 22px; margin: 0; }
.ticket-facts div,
.detail-list div { min-width: 0; }
.ticket-facts dt,
.detail-list dt { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.ticket-facts dd,
.detail-list dd { margin: 4px 0 0; overflow-wrap: anywhere; color: #344054; font-size: 12px; font-weight: 600; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.ticket-main,
.ticket-sidebar { display: grid; gap: 14px; min-width: 0; }
.reply-panel form { display: grid; gap: 12px; padding: 16px 18px 18px; }
.form-footer { display: flex; justify-content: flex-end; }
.thread-list { display: grid; }
.thread-message { padding: 17px 18px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.thread-message:last-child { border-bottom: 0; }
.thread-message.incoming { border-left-color: #6d91c9; }
.thread-message.outgoing { border-left-color: #69a989; background: #fbfdfc; }
.thread-message header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.thread-message header > div { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.thread-message header strong { color: #344054; font-size: 12px; }
.thread-message time { flex: none; color: var(--muted); font-size: 11px; }
.message-direction { padding: 2px 6px; border: 1px solid var(--line-strong); border-radius: 3px; color: #596579; font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.message-subject { margin-top: 11px; color: #344054; font-size: 13px; font-weight: 650; }
.message-body { margin-top: 10px; color: #3d4859; font-size: 13px; line-height: 1.58; }
.message-body pre { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font: inherit; }
.message-body .prose p { margin: .55em 0; }
.action-panel { padding-bottom: 12px; }
.action-form { display: grid; gap: 9px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.action-form .btn { justify-self: start; }
.paid-action { width: calc(100% - 30px); height: auto; min-height: 38px; margin: 13px 15px; border-color: #bba2d2; color: var(--paid); white-space: normal; }
.paid-button { border-color: var(--paid); background: var(--paid); color: #fff; }
.paid-button:hover { border-color: #56317e; background: #56317e; }
.danger-zone { margin: 0 15px; padding-top: 11px; border-top: 1px solid #efd3d0; }
.info-panel { padding-bottom: 8px; }
.detail-list { display: grid; gap: 13px; margin: 0; padding: 15px 17px; }
.details-panel { overflow: hidden; }
.details-panel summary { padding: 14px 16px; cursor: pointer; color: #344054; font-size: 13px; font-weight: 650; }
.details-panel[open] summary { border-bottom: 1px solid var(--line); }
.audit-list,
.duplicate-list { display: grid; max-height: 320px; overflow: auto; }
.audit-list > div { display: grid; gap: 2px; padding: 11px 15px; border-bottom: 1px solid var(--line); }
.audit-list strong { font-size: 11px; }
.audit-list span { color: var(--muted); font-size: 10px; }
.duplicate-list a { padding: 10px 15px; border-bottom: 1px solid var(--line); color: var(--blue); font-size: 11px; text-decoration: none; }
.support-modal .modal-box { max-width: 520px; border-radius: 8px; }
.support-modal h2 { margin: 0; font-size: 19px; }
.support-modal p { margin: 13px 0; color: #475467; line-height: 1.5; }
.support-modal blockquote { margin: 12px 0; padding: 13px 15px; border-left: 3px solid var(--paid); background: #f8f4fb; color: #4b2d68; line-height: 1.55; }

.empty-state { display: grid; place-items: center; gap: 6px; min-height: 120px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state strong { color: #475467; }
.empty-state span { font-size: 12px; }
.error-page { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: var(--canvas); }
.error-panel { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; text-align: center; }
.error-panel h1 { margin: 6px 0 8px; font-size: 21px; }
.error-panel p { margin: 0 0 20px; color: var(--muted); }
.error-code { color: var(--blue); font-size: 12px; font-weight: 800; }
.button { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 0 15px; border-radius: 5px; font-size: 13px; font-weight: 650; text-decoration: none; }
.button-primary { background: var(--blue); color: #fff; }
.is-loading { opacity: .62; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.truncate { min-width: 0; }
iframe { border: 0; }
.rounded-2xl,
.rounded-3xl { border-radius: 8px !important; }

@media (max-width: 1250px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-search { grid-column: span 2; }
  .filter-actions { align-self: end; }
  .metric-strip { grid-template-columns: repeat(3, 1fr); }
  .metric-item:nth-child(3) { border-right: 0; }
  .metric-item:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 1023px) {
  .login-layout { grid-template-columns: minmax(300px, 38%) minmax(380px, 1fr); }
  .login-intro { padding: 32px 30px 44px; }
  .app-main { padding: 22px 20px 40px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .ticket-layout { grid-template-columns: 1fr; }
  .ticket-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-panel { grid-row: span 2; }
}

@media (max-width: 760px) {
  .login-layout { display: block; padding: 24px 0; }
  .login-intro { min-height: 150px; margin: 0 12px; padding: 22px; border-radius: 8px 8px 0 0; }
  .login-intro > div:last-child { display: none; }
  .login-card { width: calc(100% - 24px); margin: 0 auto; border-top: 0; border-radius: 0 0 8px 8px; box-shadow: none; }
  .app-main { padding: 18px 12px 32px; }
  .page-header { align-items: flex-start; }
  .page-header h1,
  .ticket-heading h1 { font-size: 21px; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-item { border-bottom: 1px solid var(--line); }
  .metric-item:nth-child(2n) { border-right: 0; }
  .metric-item:nth-last-child(-n+2) { border-bottom: 0; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .field-search { grid-column: span 2; }
  .filter-actions { grid-column: span 2; }
  .bulk-bar { align-items: stretch; flex-direction: column; }
  .bulk-bar .select { width: 100%; max-width: none; }
  .ticket-header { grid-template-columns: 1fr; padding: 16px; }
  .ticket-facts { grid-template-columns: 1fr 1fr; }
  .ticket-sidebar { grid-template-columns: 1fr; }
  .thread-message header { flex-direction: column; }
  .attention-panel,
  .notice { align-items: flex-start; flex-direction: column; }
  .table-footer { align-items: flex-start; flex-direction: column; }
}
.attachment-list { display: grid; gap: 10px; margin: 12px 0 20px; padding: 0; list-style: none; }
.attachment-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; padding: 10px 12px; background: #f3f6f8; border-radius: 8px; overflow-wrap: anywhere; }
.attachment-list a { color: #0f766e; text-decoration: underline; }
.attachment-preview-link, .attachment-hint, .attachment-selection { font-size: 13px; }
.attachment-input { display: block; max-width: 100%; padding: 10px 0; }
.attachment-selection { overflow-wrap: anywhere; margin: 8px 0; }
.message-attachments { margin-top: 18px; border-top: 1px solid #e5e7eb; padding-top: 12px; }
