:root {
  --navy: #17385f;
  --navy-dark: #102a49;
  --blue: #2463a8;
  --blue-light: #e8f2fb;
  --teal: #177d71;
  --green: #217a4c;
  --green-light: #e9f7ef;
  --amber: #a35b08;
  --amber-light: #fff5db;
  --red: #ad2c2c;
  --red-light: #fdecec;
  --ink: #172332;
  --muted: #637083;
  --line: #d9e0e8;
  --surface: #ffffff;
  --canvas: #f5f7fa;
  --shadow: 0 10px 30px rgba(23, 56, 95, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.app-header { position: sticky; top: 0; z-index: 20; min-height: 68px; padding: 0 28px; display: flex; align-items: center; gap: 30px; color: white; background: var(--navy-dark); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.app-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 750; letter-spacing: -.01em; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: white; background: linear-gradient(145deg, #347cc5, #185694); font-weight: 800; box-shadow: 0 8px 20px rgba(24,86,148,.22); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 12px; box-shadow: none; }
.brand-mark.danger { background: var(--red); }
.app-nav { display: flex; align-items: stretch; gap: 6px; align-self: stretch; }
.app-nav a { display: flex; align-items: center; padding: 0 13px; color: #dce8f5; text-decoration: none; font-size: 14px; }
.app-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; }
.user-menu form { margin: 0; }
.link-button { border: 0; padding: 0; color: #dce8f5; background: transparent; text-decoration: underline; }

.page-shell { max-width: 1500px; margin: 0 auto; padding: 34px 28px 60px; }
.page-heading { margin-bottom: 26px; }
.page-heading h1, .record-heading h1 { margin: 4px 0 6px; color: var(--navy-dark); font-size: clamp(28px, 4vw, 42px); line-height: 1.08; letter-spacing: -.035em; }
.eyebrow { margin: 0; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); }
.block { display: block; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.split-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 14px; color: var(--navy-dark); font-size: 19px; }
.panel h3 { margin: 22px 0 8px; color: var(--navy); font-size: 13px; letter-spacing: .03em; text-transform: uppercase; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.panel-heading h2 { margin-bottom: 4px; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; padding: 9px 15px; font-weight: 720; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .12s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: white; background: var(--blue); box-shadow: 0 5px 14px rgba(36,99,168,.22); }
.button-primary:hover:not(:disabled) { background: #1d5797; }
.button-secondary { border-color: #bfd0e2; color: var(--navy); background: #f7faff; }
.button-secondary:hover:not(:disabled) { background: var(--blue-light); }
.button-quiet { border-color: var(--line); color: var(--muted); background: transparent; }
.button-call { color: white; background: var(--green); box-shadow: 0 5px 16px rgba(33,122,76,.22); }
.button-call::before { content: "☎"; }
.button-large { min-height: 48px; padding: 12px 20px; }
.full-width { width: 100%; }
.text-link { color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.message-stack { position: fixed; top: 82px; right: 24px; z-index: 50; width: min(430px, calc(100vw - 48px)); display: grid; gap: 8px; }
.notice { border: 1px solid #b9d2ea; border-radius: 10px; padding: 12px 14px; color: var(--navy); background: var(--blue-light); box-shadow: var(--shadow); }
.notice-success { border-color: #addbc2; color: #155a38; background: var(--green-light); }
.notice-warning { border-color: #ead18d; color: #764100; background: var(--amber-light); }
.notice-danger, .notice-error { border-color: #e5b0b0; color: #812020; background: var(--red-light); }

.session-panel { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.session-panel form { margin: 0; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 800; }
.status-pill.active { color: #14623c; background: var(--green-light); }
.status-pill.paused { color: #855000; background: var(--amber-light); }
.status-pill.ended { color: var(--muted); background: #eef1f4; }
.pause-menu { position: relative; }
.pause-menu summary { list-style: none; }
.pause-menu summary::-webkit-details-marker { display: none; }
.popover-form { position: absolute; top: 50px; right: 0; z-index: 30; width: 300px; padding: 16px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 18px 40px rgba(23,56,95,.2); }

.metric-grid { margin-bottom: 24px; display: grid; grid-template-columns: repeat(8, minmax(120px, 1fr)); gap: 10px; }
.metric-card { min-height: 110px; padding: 16px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; background: white; }
.metric-card span { min-height: 35px; color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1.25; }
.metric-card strong { margin-top: auto; color: var(--navy-dark); font-size: 24px; letter-spacing: -.025em; }
.metric-card small { margin-top: 3px; color: var(--muted); }
.metric-card.accent { border-color: #9ec4e9; background: linear-gradient(145deg, #f2f8fe, #e5f1fb); }

.queue-toolbar { margin-bottom: 16px; padding: 16px; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.queue-toolbar > div { display: flex; align-items: center; gap: 18px; }
.queue-toolbar form { margin: 0; }
.queue-summary { color: var(--muted); font-size: 14px; }
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
input, select, textarea { width: 100%; border: 1px solid #c7d1dd; border-radius: 8px; padding: 10px 11px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,99,168,.12); }
.filter-form input { width: 250px; }
.filter-form select { width: 180px; }
label { display: grid; gap: 6px; color: var(--navy-dark); font-size: 13px; font-weight: 700; }

.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 12px 14px; color: white; background: var(--navy); text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #e7ecf1; vertical-align: top; }
tbody tr:hover { background: #f7fbff; }
tbody tr:last-child td { border-bottom: 0; }
.empty-state { padding: 42px; color: var(--muted); text-align: center; }
.priority { display: inline-flex; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 850; white-space: nowrap; }
.priority-urgent { color: #8d1f1f; background: var(--red-light); }
.priority-high { color: #855000; background: var(--amber-light); }
.priority-routine { color: #175d78; background: #e6f5fb; }
.priority-hold { color: #7c2020; background: #f8dddd; }
.classification { display: inline-flex; border: 1px solid #cdd9e6; border-radius: 6px; padding: 3px 7px; color: #40536a; background: #f5f8fb; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }

.record-heading { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); text-decoration: none; }
.record-title-line { display: flex; gap: 8px; }
.record-actions { display: flex; align-items: center; gap: 10px; }
.record-actions form { margin: 0; }
.record-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.record-main, .record-sidebar { display: grid; gap: 18px; }
.context-card, .note-card, .classification-panel, .record-sidebar .panel { padding: 22px; }
.objective { margin: 0; color: var(--navy); font-size: 19px; font-weight: 650; line-height: 1.45; }
.note-card textarea { min-height: 230px; margin-top: 14px; resize: vertical; font-size: 16px; line-height: 1.55; }
.save-status { color: var(--muted); font-size: 12px; }
.note-actions, .panel-footer { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.classification-panel { border-color: #94bde5; background: #fbfdff; }
.confidence { border-radius: 999px; padding: 5px 10px; color: #155a38; background: var(--green-light); font-size: 12px; font-weight: 800; }
.form-grid { margin-top: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.full-span { grid-column: 1 / -1; }
.confirmation-box { margin-top: 16px; padding: 13px; display: flex; grid-template-columns: 20px 1fr; align-items: flex-start; gap: 9px; border: 1px solid #e3adad; border-radius: 9px; color: #812020; background: var(--red-light); }
.confirmation-box input { width: auto; margin-top: 2px; }
.detail-list { margin: 0; display: grid; gap: 0; }
.detail-list > div { padding: 11px 0; border-bottom: 1px solid #e8edf2; }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.detail-list dd { margin: 4px 0 0; line-height: 1.45; }
.attempt-summary { padding: 12px 0; border-bottom: 1px solid #e8edf2; }
.attempt-summary:last-child { border-bottom: 0; }
.attempt-summary span { margin-left: 7px; color: var(--muted); font-size: 12px; }
.attempt-summary p { margin: 7px 0 0; color: #40536a; font-size: 13px; line-height: 1.4; }
.hidden { display: none !important; }
.summary-chip { min-width: 210px; padding: 15px 18px; display: flex; flex-direction: column; border: 1px solid #a8c7e6; border-radius: 12px; background: var(--blue-light); }
.summary-chip strong { color: var(--navy); font-size: 28px; }
.summary-chip span { color: var(--muted); font-size: 13px; }

.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 28px; background: radial-gradient(circle at top, #eef6fd, #f5f7fa 45%, #e9eef4); }
.auth-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 25px 70px rgba(23,56,95,.16); }
.auth-card .brand-mark { margin: 0 auto 20px; }
.auth-card h1 { margin: 0; color: var(--navy-dark); text-align: center; font-size: 30px; letter-spacing: -.03em; }
.auth-card > p { text-align: center; }
.auth-card form { margin-top: 24px; display: grid; gap: 14px; }
.auth-domain { color: var(--muted); font-size: 12px; }
.auth-break-glass { display: block; margin-top: 22px; text-align: center; font-size: 12px; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .queue-toolbar { align-items: flex-start; flex-direction: column; }
  .filter-form { width: 100%; justify-content: flex-start; }
}

@media (max-width: 820px) {
  .app-header { padding: 0 16px; flex-wrap: wrap; gap: 8px 16px; }
  .app-nav { order: 3; width: 100%; min-height: 42px; overflow-x: auto; }
  .user-menu span { display: none; }
  .page-shell { padding: 24px 14px 50px; }
  .split-heading, .record-heading { align-items: stretch; flex-direction: column; }
  .session-panel { justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .record-layout { grid-template-columns: 1fr; }
  .record-actions { align-items: stretch; flex-direction: column; }
  .record-actions .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .note-actions, .panel-footer { align-items: stretch; flex-direction: column; }
  .note-actions > *, .panel-footer .button { width: 100%; }
  .quick-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .filter-form input, .filter-form select { width: 100%; }
}
