/* ═══════════════════════════════════════════════════════════════════
   GLASS design system — one sheet, two skins.
   The client portal (/app) and the staff admin (/admin) share every
   component; the admin flips the sidebar dark via [data-theme="admin"].
   Keep it token-driven and DRY — see docs/15-GLASS.md.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #98a2b3;
  --line: #e4e9f2;

  --accent: #2643e9;
  --accent-dark: #1d34bd;
  --accent-soft: #eef1fe;
  --green: #0e9f6e;
  --green-soft: #e7f8f1;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --violet: #7c3aed;
  --violet-soft: #f3eefe;

  --nav-bg: #ffffff;
  --nav-ink: #475467;
  --nav-ink-dim: #98a2b3;
  --nav-active-bg: #eef1fe;
  --nav-active-ink: #2643e9;
  --nav-line: #e4e9f2;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px -6px rgba(16, 24, 40, .08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="admin"] {
  --nav-bg: #0e1526;
  --nav-ink: #9daac6;
  --nav-ink-dim: #5b6880;
  --nav-active-bg: #1d2a4a;
  --nav-active-ink: #ffffff;
  --nav-line: #1c2540;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.015em; }

/* ───────── shell: sidebar + main ───────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 18px 12px;
}
.sidebar .wordmark {
  display: flex; align-items: baseline; gap: 7px;
  padding: 4px 10px 18px;
}
.wordmark .glyph {
  font-size: 21px; font-weight: 800; letter-spacing: .06em;
  color: var(--nav-active-ink);
}
[data-theme="admin"] .wordmark .glyph { color: #fff; }
.wordmark .by { font-size: 10.5px; color: var(--nav-ink-dim); letter-spacing: .08em; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--nav-ink); font-weight: 500;
  transition: background .12s ease;
}
.nav-item:hover { background: var(--nav-active-bg); text-decoration: none; }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-ink); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item .count {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px;
}
.nav-section { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--nav-ink-dim); padding: 16px 12px 5px; }
.sidebar .spacer { flex: 1; }
.sidebar .whoami { padding: 10px 12px; font-size: 12px; color: var(--nav-ink-dim); border-top: 1px solid var(--nav-line); }
.sidebar .whoami b { color: var(--nav-ink); display: block; font-size: 12.5px; }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; }

/* ───────── masquerade banner ───────── */

.masq-banner {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #101828, #26324d);
  color: #fff; border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.masq-banner .dot { width: 8px; height: 8px; border-radius: 99px; background: #ffd166; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.masq-banner form { margin-left: auto; }

/* ───────── page header ───────── */

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--ink-2); font-size: 13.5px; margin-top: 3px; }
.page-head .right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* marketplace switcher */
.mkt-switch { display: flex; gap: 6px; flex-wrap: wrap; }
.mkt {
  padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.mkt.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.mkt.soon { opacity: .45; font-weight: 500; }

/* ───────── cards & grids ───────── */

.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: 1.6fr 1fr; }
.grid.halves { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .grid.two, .grid.halves { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card .card-title { font-size: 13px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.card .card-title .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.card-head { display: flex; align-items: center; margin-bottom: 12px; }
.card-head .right { margin-left: auto; }

.kpi .label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.kpi .delta { font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }
.kpi .note { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

/* ───────── badges, chips, pills ───────── */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2.5px 9px; border-radius: 99px;
}
.badge.low       { background: #eef2f7; color: #5b6880; }
.badge.medium    { background: var(--accent-soft); color: var(--accent); }
.badge.high      { background: var(--amber-soft); color: var(--amber); }
.badge.critical  { background: var(--red-soft); color: var(--red); }
.badge.green     { background: var(--green-soft); color: var(--green); }
.badge.red       { background: var(--red-soft); color: var(--red); }
.badge.amber     { background: var(--amber-soft); color: var(--amber); }
.badge.violet    { background: var(--violet-soft); color: var(--violet); }
.badge.neutral   { background: #eef2f7; color: #5b6880; }
.badge.sample    { background: #fff8e6; color: #a16207; border: 1px dashed #eab308; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
}
.chip .dot { width: 7px; height: 7px; border-radius: 99px; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); }
.dot.red { background: var(--red); } .dot.critical { background: #7f1d1d; }
.dot.gray { background: var(--ink-3); }

/* SLA state colouring */
.sla.on_track { color: var(--green); font-weight: 600; }
.sla.at_risk { color: var(--amber); font-weight: 700; }
.sla.breached { color: var(--red); font-weight: 700; }
.sla.met { color: var(--ink-3); }

/* progress stages for customer-owned tickets */
.stages { display: inline-flex; gap: 4px; align-items: center; }
.stage { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; background: #eef2f7; color: #98a2b3; }
.stage.hit { background: var(--green-soft); color: var(--green); }

/* ───────── buttons & forms ───────── */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  border-radius: 10px; padding: 8px 16px; cursor: pointer;
  border: 1px solid transparent; transition: filter .12s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.danger { background: var(--red-soft); color: var(--red); border-color: #f5c2c2; }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn.sm { font-size: 12.5px; padding: 5px 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  font-family: var(--font); font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }

/* ───────── tables & list rows ───────── */

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3); padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.click:hover { background: var(--surface-2); cursor: pointer; }

.rowlist .row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.rowlist .row:last-child { border-bottom: none; }
.row .title { font-weight: 600; }
.row .meta { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.row .right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ───────── inventory runway ───────── */

.runway { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.runway .track { flex: 1; height: 9px; border-radius: 99px; background: #edf0f7; overflow: hidden; }
.runway .fill { height: 100%; border-radius: 99px; }
.fill.green { background: var(--green); } .fill.amber { background: var(--amber); }
.fill.red { background: var(--red); } .fill.critical { background: #7f1d1d; }
.runway .days { font-size: 12.5px; font-weight: 700; width: 46px; text-align: right; }

/* ───────── ticket timeline ───────── */

.timeline { margin-top: 14px; }
.tl-event { display: flex; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.tl-event:last-child { border-bottom: none; }
.tl-icon { width: 30px; height: 30px; border-radius: 99px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-head b { color: var(--ink); }
.tl-text { margin-top: 4px; white-space: pre-wrap; }
.tl-event.internal { background: var(--amber-soft); border-radius: var(--radius-sm); padding: 11px 12px; border-bottom: none; margin: 4px 0; }
.tl-event.internal .tl-icon { background: #fff; }

/* ───────── landing & login ───────── */

.landing { min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 500px at 70% -10%, #dfe6ff 0%, transparent 60%), var(--bg); }
.landing-nav { display: flex; align-items: center; padding: 22px 48px; }
.landing-nav .right { margin-left: auto; }
.hero { max-width: 880px; margin: 60px auto 30px; text-align: center; padding: 0 24px; }
.hero h1 { font-size: 52px; letter-spacing: -0.03em; line-height: 1.06; }
.hero h1 .grad { background: linear-gradient(90deg, var(--accent), #7c3aed);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 17px; color: var(--ink-2); max-width: 620px; margin: 18px auto 26px; }
.feature-band { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px; max-width: 1020px; margin: 30px auto 80px; padding: 0 24px; }
.landing-foot { margin-top: auto; padding: 22px 48px; color: var(--ink-3); font-size: 12.5px; }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 400px at 50% -5%, #dfe6ff 0%, transparent 60%), var(--bg); }
.auth-card { width: 400px; max-width: calc(100vw - 32px); }
.auth-card .card { padding: 30px; }
.form-error { background: var(--red-soft); color: var(--red); border-radius: 10px;
  padding: 10px 13px; font-size: 13px; font-weight: 600; margin-top: 12px; display: none; }

/* ───────── report page ───────── */

.report-wrap { max-width: 900px; margin: 0 auto; padding: 40px 24px 80px; }
.report-band { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.score-cell { text-align: center; padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.score-cell .n { font-size: 26px; font-weight: 800; }
.opt-block { background: var(--green-soft); border: 1px solid #bfe9d9; border-radius: var(--radius-sm); padding: 12px 15px; margin-top: 10px; }
.cur-block { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 15px; }
.wm-list { margin: 8px 0 0; padding-left: 0; list-style: none; }
.wm-list li { padding: 3px 0 3px 24px; position: relative; font-size: 13.5px; }
.wm-list li.y::before { content: "✓"; position: absolute; left: 4px; color: var(--green); font-weight: 800; }
.wm-list li.n::before { content: "✕"; position: absolute; left: 4px; color: var(--red); font-weight: 800; }

/* ───────── misc ───────── */

.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; }
.muted { color: var(--ink-3); font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.right-al { margin-left: auto; }

#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #101828; color: #fff; border-radius: 12px; padding: 11px 20px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 60;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }

.chart { width: 100%; height: 320px; }
.chart.tall { height: 380px; }
.chart.short { height: 230px; }

/* ───────── Ask Glass chat ───────── */

.chat-layout { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
@media (max-width: 950px) { .chat-layout { grid-template-columns: 1fr; } }
.chat-list .thread {
  display: block; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid transparent; margin-bottom: 4px; color: var(--ink);
}
.chat-list .thread:hover { background: var(--surface-2); text-decoration: none; }
.chat-list .thread.on { background: var(--accent-soft); border-color: #d5dcfb; }
.chat-list .t-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list .t-meta { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; }

.chat-pane { display: flex; flex-direction: column; min-height: 60vh; }
.chat-scroll { flex: 1; overflow-y: auto; max-height: 62vh; padding: 6px 2px; }
.bubble-row { display: flex; margin: 10px 0; gap: 10px; }
.bubble-row.self { justify-content: flex-end; }
.bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.bubble.customer  { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.bubble.assistant { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.staff     { background: var(--violet-soft); border: 1px solid #e2d5fb; border-bottom-left-radius: 5px; }
.bubble-tag { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 3px; display: flex; gap: 8px; align-items: center; }
.bubble .att { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; margin-right: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: rgba(255,255,255,.22); color: inherit; border: 1px solid rgba(0,0,0,.08); }
.bubble.assistant .att, .bubble.staff .att { background: #fff; color: var(--accent); }
.bubble img.att-img { max-width: 260px; border-radius: 9px; display: block; margin-top: 8px; }
.seen-tag { font-size: 10.5px; font-weight: 600; }
.seen-tag.seen { color: var(--green); }
.seen-tag.unseen { color: var(--ink-3); }

.chat-composer { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 10px; }
.chat-composer textarea { min-height: 64px; }
.pending-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.typing { display: inline-flex; gap: 4px; padding: 12px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 99px; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .25 } 50% { opacity: 1 } }

/* two-column compare (creative studio) */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .compare { grid-template-columns: 1fr; } }
.compare .col-label { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; margin-bottom: 7px; }
.compare .current .col-label { color: var(--ink-3); }
.compare .proposed .col-label { color: var(--green); }
.compare .box { border-radius: var(--radius-sm); padding: 13px 15px; height: 100%; }
.compare .current .box { background: var(--surface-2); border: 1px solid var(--line); }
.compare .proposed .box { background: var(--green-soft); border: 1px solid #bfe9d9; }
