:root {
  color-scheme: dark;
  --bg: #080d16;
  --rail: #0b111c;
  --panel: #0e1623;
  --panel-2: #121d2c;
  --panel-3: #172435;
  --line: #233247;
  --line-soft: #1a2839;
  --text: #edf4fc;
  --muted: #91a2b7;
  --dim: #66778c;
  --cyan: #42d4c7;
  --cyan-soft: #143b3c;
  --amber: #f6ad55;
  --red: #fa6e6e;
  --blue: #70a9ff;
  --radius: 10px;
  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; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0%, rgba(55, 208, 194, .09), transparent 38%), var(--bg); }
.auth-card { width: min(420px, 100%); display: grid; gap: 24px; padding: 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 24px 80px rgba(0, 0, 0, .28); }
.auth-card .mark { width: 42px; height: 42px; margin: 0; }
.auth-card h1 { margin: 5px 0 8px; font-size: 1.75rem; }
.auth-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.auth-card form { display: grid; gap: 16px; }
.auth-card label { display: grid; gap: 7px; color: var(--muted); font-weight: 650; }
.auth-card input { min-height: 44px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; color: var(--text); background: var(--panel-2); }
.auth-card input:focus { outline: 2px solid rgba(66, 212, 199, .4); outline-offset: 1px; border-color: var(--cyan); }
.auth-card .primary-button { min-height: 44px; }
.auth-error { min-height: 20px; color: var(--red) !important; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 64px minmax(0, 1fr); }
.rail { background: var(--rail); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; align-items: center; padding: 18px 10px; position: sticky; top: 0; height: 100vh; }
.mark { width: 34px; height: 34px; display: grid; place-items: center; background: var(--cyan); color: #061416; font-weight: 900; font-size: 17px; border-radius: 9px 3px 9px 3px; margin-bottom: 34px; }
.rail nav { display: grid; gap: 10px; }
.rail-button, .icon-button { border: 0; background: transparent; cursor: pointer; }
.rail-button { width: 40px; height: 40px; border-radius: 8px; color: var(--dim); font-size: 19px; }
.rail-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.rail-button:hover, .rail-button.active { color: var(--cyan); background: var(--cyan-soft); }
.rail-bottom { margin-top: auto; display: grid; justify-items: center; gap: 14px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #364862; color: #dce8f6; font-size: 11px; font-weight: 800; }
.workspace { min-width: 0; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; border-bottom: 1px solid var(--line-soft); }
.eyebrow { font-size: 11px; color: var(--cyan); letter-spacing: .14em; font-weight: 800; }
h1 { font-size: 22px; line-height: 1.1; margin: 5px 0 0; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.search { width: min(390px, 31vw); height: 40px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; display: flex; align-items: center; padding: 0 11px; gap: 8px; color: var(--muted); }
.search input { flex: 1; min-width: 0; color: var(--text); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search-icon { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search kbd { color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; font-size: 10px; }
.icon-button { position: relative; width: 40px; height: 40px; color: var(--muted); }
.icon-button:disabled { cursor: default; opacity: .65; }
.primary-button { height: 40px; border: 0; border-radius: 7px; padding: 0 15px; background: var(--cyan); color: #061416; font-weight: 800; cursor: pointer; }
.primary-button:hover { background: #6ce3d8; }
.pulse { height: 92px; display: grid; grid-template-columns: repeat(4, 1fr) 1.35fr; align-items: center; border-bottom: 1px solid var(--line-soft); padding: 0 26px; background: #0a111c; }
.metric { min-width: 0; border-right: 1px solid var(--line-soft); padding: 0 22px; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; }
.metric:first-child { padding-left: 0; }
.metric strong { font-size: 24px; letter-spacing: -.04em; }
.metric span { color: var(--muted); font-size: 12px; }
.metric small { grid-column: 2; color: var(--dim); font-size: 11px; margin-top: 2px; }
.metric.warning strong { color: var(--amber); }
.metric small.good { color: var(--cyan); }
.queue-health { padding-left: 26px; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.queue-health span { grid-column: 1 / -1; color: var(--dim); font-size: 10px; letter-spacing: .13em; font-weight: 800; }
.queue-health b { color: var(--cyan); font-size: 12px; }
.health-track { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; }
.health-track i { display: block; height: 100%; background: var(--cyan); }
.workbench { height: calc(100vh - 174px); display: grid; grid-template-columns: minmax(330px, 390px) minmax(0, 1fr); }
.case-pane { min-width: 0; border-right: 1px solid var(--line); background: #0b121d; display: flex; flex-direction: column; }
.case-toolbar { padding: 15px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.segmented { display: flex; gap: 3px; padding: 3px; background: #080d16; border: 1px solid var(--line-soft); border-radius: 8px; }
.segmented button { flex: 1; border: 0; background: transparent; color: var(--dim); padding: 7px 5px; border-radius: 5px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.segmented button.active { background: var(--panel-3); color: var(--text); }
.segmented span { color: var(--muted); font-size: 10px; margin-left: 3px; }
.toolbar-row { display: flex; justify-content: space-between; margin-top: 11px; }
.ghost-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px 7px; }
.ghost-button:hover { color: var(--text); }
.filter-count { background: var(--cyan-soft); color: var(--cyan); padding: 2px 5px; border-radius: 8px; font-size: 10px; }
.case-list { overflow: auto; }
.case-row { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line-soft); border-left: 3px solid transparent; background: transparent; padding: 15px 16px 14px 15px; cursor: pointer; }
.case-row:hover { background: #101a28; }
.case-row.active { background: var(--panel-2); border-left-color: var(--cyan); }
.case-row-top, .case-row-meta, .case-row-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.case-id { color: var(--dim); font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.priority { font-size: 10px; font-weight: 900; padding: 3px 7px; border: 1px solid transparent; border-radius: 8px; white-space: nowrap; }
.priority.p1 { color: #ffaaaa; background: #421b22; border-color: #71303b; }
.priority.p2 { color: #ffc078; background: #402b17; border-color: #6d4724; }
.priority.p3 { color: #9fc5ff; background: #1c3150; border-color: #294d7c; }
.priority.p4 { color: #8de3bd; background: #153a31; border-color: #225b4c; }
.case-row h3 { font-size: 14px; margin: 8px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-row-meta { color: var(--muted); font-size: 12px; }
.case-row-meta > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-product { max-width: 46%; color: #8eb7d9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.case-row-foot { margin-top: 11px; color: var(--dim); font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 5px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); }
.status.attention::before { background: var(--amber); }
.status.awaiting::before { background: #9f8cff; }
.status.escalated::before { background: var(--red); }
.mini-avatar { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; background: #33465e; color: #d9e8f7; font-size: 8px; font-weight: 800; }
.case-detail { overflow: auto; background: var(--panel); }
.detail-header { padding: 22px 26px 18px; border-bottom: 1px solid var(--line-soft); }
.detail-headline { display: flex; justify-content: space-between; gap: 20px; }
.detail-headline h2 { font-size: 21px; letter-spacing: -.025em; margin: 6px 0 8px; }
.detail-headline p { margin: 0; color: var(--muted); max-width: 680px; line-height: 1.5; }
.case-actions { display: flex; align-items: flex-start; gap: 8px; flex-shrink: 0; }
.outline-button { min-height: 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel-2); color: var(--text); padding: 0 12px; cursor: pointer; }
.outline-button:hover { border-color: #3a526e; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.tag { padding: 4px 8px; background: #162538; border: 1px solid #263a52; color: #a9bad0; border-radius: 5px; font-size: 11px; }
.priority-control { display: flex; align-items: center; gap: 6px; padding: 3px 5px 3px 8px; background: #162538; border: 1px solid #263a52; color: #a9bad0; border-radius: 5px; font-size: 11px; }
.priority-control select { border: 0; border-radius: 4px; padding: 1px 4px; background: #0b1522; color: var(--text); font-weight: 750; cursor: pointer; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .75fr); gap: 16px; padding: 16px 26px 28px; }
.detail-main, .detail-side { display: grid; align-content: start; gap: 14px; }
.card { border: 1px solid var(--line); background: #0c1521; border-radius: var(--radius); overflow: hidden; }
.card-head { min-height: 45px; display: flex; justify-content: space-between; align-items: center; padding: 0 15px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin: 0; color: #bdcadd; }
.card-head span { color: var(--dim); font-size: 11px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); }
.fact { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--line-soft); }
.fact:last-child { border: 0; }
.fact label { display: block; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.fact b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finding { display: grid; grid-template-columns: 5px 1fr auto; gap: 12px; padding: 14px 15px; border-bottom: 1px solid var(--line-soft); align-items: start; }
.finding:last-child { border: 0; }
.severity-bar { width: 5px; height: 36px; border-radius: 3px; background: var(--amber); }
.severity-bar.high { background: var(--red); }
.severity-bar.info { background: var(--blue); }
.finding h4 { margin: 0 0 4px; font-size: 13px; }
.finding p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.confidence { color: var(--dim); font-size: 10px; white-space: nowrap; }
.package { padding: 14px 15px; }
.package-name { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.package-name strong { font: 700 12px ui-monospace, SFMono-Regular, monospace; }
.accepted { color: var(--cyan); font-size: 11px; }
.progress { height: 4px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; width: 100%; height: 100%; background: var(--cyan); }
.package-meta { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 10px; color: var(--dim); font-size: 10px; }
.empty-inline { padding: 22px 15px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.next-action { padding: 16px; border-left: 3px solid var(--cyan); }
.next-action .eyebrow { margin-bottom: 7px; }
.next-action h3 { margin: 0 0 7px; font-size: 15px; }
.next-action p { margin: 0 0 14px; color: var(--muted); line-height: 1.5; font-size: 12px; }
.next-action button { width: 100%; }
.assignment { padding: 14px 15px; display: grid; gap: 13px; }
.person { display: grid; grid-template-columns: 32px 1fr auto; gap: 9px; align-items: center; }
.person .mini-avatar { width: 32px; height: 32px; font-size: 10px; }
.person strong, .person span { display: block; }
.person span { color: var(--dim); font-size: 10px; margin-top: 2px; }
.person button { color: var(--cyan); border: 0; background: transparent; cursor: pointer; font-size: 11px; }
.sla { border-top: 1px solid var(--line-soft); padding-top: 12px; }
.sla-row { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 11px; color: var(--muted); }
.sla-row b { color: var(--amber); }
.sla-row b.not-recorded { color: var(--dim); font-weight: 650; }
.timeline { padding: 4px 15px 12px; }
.event { position: relative; padding: 10px 0 8px 20px; border-left: 1px solid var(--line); margin-left: 4px; }
.event::before { content: ""; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--line); left: -4px; top: 15px; }
.event:first-child::before { background: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.event strong { font-size: 11px; }
.event p { color: var(--muted); font-size: 11px; margin: 3px 0; line-height: 1.4; }
.event time { color: var(--dim); font-size: 9px; }
.note-form { padding: 12px 15px; border-top: 1px solid var(--line-soft); }
.note-form textarea { width: 100%; min-height: 66px; resize: vertical; border: 1px solid var(--line); border-radius: 6px; color: var(--text); background: #08111c; padding: 9px; outline: none; font-size: 12px; }
.note-form textarea:focus { border-color: var(--cyan); }
.note-form div { display: flex; justify-content: flex-end; margin-top: 8px; }
.empty-state { padding: 60px 24px; color: var(--muted); text-align: center; }
dialog { border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--panel-2); width: min(520px, calc(100vw - 32px)); padding: 0; box-shadow: 0 24px 80px #000a; }
dialog::backdrop { background: #03070dbb; }
dialog form { padding: 20px; display: grid; gap: 15px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; }
.dialog-head h2 { margin: 5px 0 0; font-size: 20px; }
.dialog-head button { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
dialog label { color: var(--muted); font-size: 12px; display: grid; gap: 7px; }
dialog input, dialog select { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: #09111b; color: var(--text); padding: 0 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.user-admin-dialog { width: min(880px, calc(100vw - 32px)); }
.user-admin-shell { padding: 22px; display: grid; gap: 18px; }
.user-admin-dialog .dialog-head p { margin: 7px 0 0; max-width: 620px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.user-list { max-height: 360px; overflow: auto; display: grid; border: 1px solid var(--line); border-radius: 8px; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1.4fr) 90px minmax(140px, .8fr) auto; gap: 12px; align-items: center; padding: 12px; border-bottom: 1px solid var(--line-soft); }
.user-row:last-child { border-bottom: 0; }
.user-identity { min-width: 0; }
.user-identity strong, .user-identity span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-identity span { margin-top: 3px; color: var(--dim); font-size: 11px; }
.user-initials, .user-role { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; background: #09111b; color: var(--text); }
.user-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.user-state { color: var(--cyan); font-size: 11px; }
.user-state.disabled { color: var(--red); }
.master-state { color: var(--cyan); font-size: 11px; font-weight: 750; white-space: nowrap; }
.master-admin .user-initials, .master-admin .user-role { opacity: .62; cursor: not-allowed; }
.danger-button { height: 34px; border: 1px solid #59323b; border-radius: 6px; padding: 0 10px; background: #26141a; color: #ff9ba7; cursor: pointer; }
.user-row.disabled .user-identity { opacity: .58; }
.user-admin-dialog form { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #0b1420; }
.user-admin-dialog form h3 { margin: 0; font-size: 14px; }
.form-help { margin: 0; color: var(--dim); font-size: 11px; }
.toast { position: fixed; z-index: 20; right: 22px; bottom: 22px; background: #17283b; border: 1px solid #31506b; color: var(--text); padding: 11px 15px; border-radius: 8px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 1080px) {
  .pulse { grid-template-columns: repeat(4, 1fr); }
  .queue-health { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { height: auto; padding: 14px 16px; align-items: flex-start; }
  .search { width: 42px; border: 0; background: transparent; }
  .search input, .search kbd { display: none; }
  .primary-button { padding: 0 11px; }
  .pulse { height: auto; grid-template-columns: 1fr 1fr; padding: 12px 16px; gap: 12px; }
  .metric { padding: 4px 8px; border: 0; }
  .workbench { height: auto; min-height: calc(100vh - 176px); grid-template-columns: 1fr; }
  .case-pane { max-height: 360px; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-headline { flex-direction: column; }
  .detail-grid { padding: 14px 16px 24px; }
  .detail-header { padding: 18px 16px; }
  .user-row { grid-template-columns: 1fr 80px; }
  .user-actions { justify-content: start; }
}
@media (max-width: 520px) {
  .topbar .eyebrow, .icon-button { display: none; }
  .topbar h1 { margin-top: 4px; font-size: 19px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .fact:nth-child(2) { border-right: 0; }
  .fact:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .detail-side, .form-grid { grid-template-columns: 1fr; }
}
