/* ============================================================
   Nexstar SIM — Site Issue Management
   styles.css — shared styles for every page
   Palette: light theme, validated per dataviz spec
   ============================================================ */

:root {
  color-scheme: light;
  /* surfaces & ink */
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  /* brand / accent (chart slot 1 blue) */
  --accent: #2a78d6;
  --accent-deep: #184f95;
  --accent-wash: rgba(42, 120, 214, 0.08);
  /* chart slot 2 */
  --series-2: #eb6834;
  /* status (fixed, never themed) */
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 14px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ============ Top bar ============ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-deep);
  display: grid;
  place-items: center;
  flex: none;
}
.brand-mark svg { display: block; }

.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-tag {
  color: var(--muted);
  font-size: 12px;
  border-left: 1px solid var(--grid);
  padding-left: 10px;
  margin-left: 2px;
}

.topbar-search {
  flex: 1;
  min-width: 96px;
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--muted);
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13.5px;
  color: var(--ink);
}
.topbar-search input::placeholder { color: var(--muted); }

.topbar-spacer { flex: 1; }

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
  flex: none;
  user-select: none;
}
.avatar.sz-28 { width: 28px; height: 28px; font-size: 11px; }
.avatar.sz-24 { width: 24px; height: 24px; font-size: 10px; }
.avatar.sz-32 { width: 32px; height: 32px; font-size: 12px; }

/* ============ Buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 13px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--page); }
.btn:active { transform: translateY(0.5px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }

.btn-escalate { color: #8f2323; border-color: rgba(208, 59, 59, 0.35); }
.btn-escalate:hover { background: rgba(208, 59, 59, 0.06); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--accent-wash); color: var(--ink); }

.btn[disabled] { opacity: 0.5; cursor: default; }

/* ============ Layout ============ */

.layout {
  display: flex;
  align-items: flex-start;
  max-width: 1280px;
  margin: 0 auto;
}

.sidebar {
  width: 224px;
  flex: none;
  padding: 18px 12px 24px;
  position: sticky;
  top: 56px;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.nav-group { margin-bottom: 18px; }
.nav-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
}
.nav-item svg { flex: none; color: var(--muted); }
.nav-item:hover { background: var(--accent-wash); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--accent-wash); color: var(--accent-deep); font-weight: 650; }
.nav-item.active svg { color: var(--accent-deep); }
.nav-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 7px;
  line-height: 17px;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-count { color: var(--accent-deep); }
.nav-item.dragging { opacity: 0.45; background: var(--accent-wash); }
.nav-item[data-qid] { user-select: none; }

.sidebar-foot {
  margin-top: 22px;
  padding: 10px;
  border-top: 1px solid var(--grid);
  font-size: 12px;
  color: var(--muted);
}
.sidebar-foot button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}
.sidebar-foot button:hover { color: var(--ink-2); }

main {
  flex: 1;
  min-width: 0;
  padding: 22px 24px 60px;
}

.page-head { margin: 2px 0 16px; }
.page-head h1 { font-size: 20px; margin: 0 0 2px; letter-spacing: -0.01em; }
.page-head .sub { color: var(--muted); font-size: 13px; }

/* ============ Cards ============ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px 0;
}
.card-head h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 700;
}
.card-head .when { color: var(--muted); font-size: 12px; }
.card-head .grow { flex: 1; }
.card-body { padding: 14px 16px 16px; }

/* ============ KPI tiles ============ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.tile { padding: 14px 16px 13px; }
.tile .t-label { color: var(--ink-2); font-size: 12.5px; font-weight: 600; }
.tile .t-line {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 3px;
}
.tile .t-value {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.tile .t-spark { margin-left: auto; }
.tile .t-delta {
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-bottom: 3px;
  white-space: nowrap;
}
.tile .t-delta.up-bad, .tile .t-delta.down-bad { color: var(--critical); }
.tile .t-delta.up-good, .tile .t-delta.down-good { color: var(--good-text); }
.tile .t-delta.flat { color: var(--muted); }
.tile .t-caption { color: var(--muted); font-size: 11.5px; margin-top: 5px; }

/* ============ Severity / status / queue badges ============ */

.sev {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px 2px 6px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.sev svg { flex: none; }
.sev-1 { color: #7c1d1d; background: rgba(208, 59, 59, 0.10); border-color: rgba(208, 59, 59, 0.30); }
.sev-1 svg { color: var(--critical); }
.sev-2 { color: #8a3413; background: rgba(236, 131, 90, 0.13); border-color: rgba(236, 131, 90, 0.38); }
.sev-2 svg { color: #d9622f; }
.sev-3 { color: #7a5200; background: rgba(250, 178, 25, 0.14); border-color: rgba(250, 178, 25, 0.45); }
.sev-3 svg { color: #c98500; }
.sev-4 { color: var(--ink-2); background: var(--page); border-color: var(--border); }
.sev-4 svg { color: var(--muted); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-open .dot { background: var(--accent); }
.status-inprogress .dot {
  background: var(--surface);
  border: 2.5px solid var(--accent);
  width: 9px; height: 9px;
}
.status-pending .dot { background: var(--baseline); }
.status-resolved { color: var(--good-text); }
.status-resolved .dot { background: var(--good); }

.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}
.queue-chip svg { color: var(--muted); }

.chips-cell { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.plus-n { color: var(--muted); font-size: 11px; font-weight: 700; }
.person-list { display: flex; flex-direction: column; gap: 7px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-right: -6px; box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar:last-child { margin-right: 0; }

/* clickable people */
.p-link { display: inline-flex; align-items: center; gap: 7px; color: inherit; font-size: 13px; }
.p-link:hover { text-decoration: none; }
.p-link:hover .p-name { color: var(--accent-deep); text-decoration: underline; }

/* inline edit affordances */
.mini-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 650;
}
.mini-btn:hover { background: var(--accent-wash); color: var(--accent-deep); }
.x-btn {
  border: none;
  background: none;
  color: var(--baseline);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 1px 4px;
  border-radius: 4px;
}
.x-btn:hover { color: var(--critical); background: rgba(208, 59, 59, 0.08); }
.add-mini { font-size: 12px; padding: 4px 8px; color: var(--muted); max-width: 160px; }
.edit-inline { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; align-items: center; }
.edit-inline input[type="text"], .edit-inline select { flex: 1; min-width: 130px; font-size: 13px; }
.edit-inline textarea { width: 100%; }
.edit-inline .btn { padding: 5px 11px; font-size: 12.5px; }
.edited-mark { color: var(--muted); font-size: 10.5px; font-style: italic; white-space: nowrap; }

/* attachments: real images, file + link chips */
.photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 138 / 100;
  object-fit: cover;
}
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border: 1px solid rgba(42, 120, 214, 0.3);
  border-radius: 20px;
  padding: 3px 11px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-chip:hover { text-decoration: none; border-color: var(--accent); background: rgba(42, 120, 214, 0.14); }
.link-chip svg { flex: none; }

/* SOP checklist */
.sop-card .card-body { padding-top: 10px; }
.sop-progress { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sop-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 2px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13.5px;
  border-radius: 6px;
}
.sop-step:hover { background: var(--accent-wash); }
.sop-step input { margin-top: 2.5px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; cursor: pointer; }
.sop-step.done { color: var(--muted); text-decoration: line-through; }
.sop-meter {
  height: 5px;
  border-radius: 4px;
  background: #dbe7f7;
  overflow: hidden;
  flex: 1;
  max-width: 180px;
}
.sop-meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* template picker (new ticket) */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.tpl-card {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.tpl-card:hover { background: var(--accent-wash); }
.tpl-card.on { border-color: var(--accent); background: var(--accent-wash); box-shadow: 0 0 0 1px var(--accent); }
.tpl-card .tp-title { font-weight: 650; font-size: 12.5px; line-height: 1.3; }
.tpl-card .tp-sub { color: var(--muted); font-size: 10.5px; margin-top: 4px; display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }

/* schedules */
.sched-badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 3px; }
.cad-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
}
.next-run { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* due dates */
.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 16px;
  white-space: nowrap;
}
.due-chip.today { color: #7a5200; background: rgba(250, 178, 25, 0.14); border-color: rgba(250, 178, 25, 0.45); }
.due-chip.over { color: #7c1d1d; background: rgba(208, 59, 59, 0.10); border-color: rgba(208, 59, 59, 0.35); }

/* meeting flags */
.meet-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #8a3413;
  background: rgba(236, 131, 90, 0.13);
  border: 1px solid rgba(236, 131, 90, 0.4);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 16px;
  white-space: nowrap;
}
.meet-banner {
  background: rgba(236, 131, 90, 0.09);
  border: 1px solid rgba(236, 131, 90, 0.42);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.meet-banner .mb-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #8a3413; font-size: 13px; }
.meet-banner .mb-body { margin-top: 5px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.meet-banner .mb-people { display: flex; align-items: center; gap: 5px; margin-top: 7px; }
.meet-banner .mb-actions { display: flex; gap: 8px; margin-top: 10px; }
.tl-sys.is-meeting { color: #8a3413; font-weight: 600; }

/* attachment delete (two-click arm) + summary */
.photo { position: relative; }
.attdel {
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  border-radius: 50%;
  padding: 0;
}
.attdel.ov {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 21px;
  height: 21px;
  background: rgba(11, 11, 11, 0.55);
  color: #fff;
  display: none;
}
.photo:hover .attdel.ov, .attdel.ov.armed { display: block; }
.attdel:not(.ov) { background: none; color: var(--muted); padding: 0 3px; }
.attdel:not(.ov):hover { color: var(--critical); }
.attdel.armed { background: var(--critical) !important; color: #fff !important; padding: 0 5px; border-radius: 6px; }
.chip-wrap { display: inline-flex; align-items: center; gap: 1px; }
.att-summary .photo-grid { margin-top: 4px; }
.att-summary .chip-row { margin-top: 9px; }

/* quoted replies */
.quote {
  display: block;
  border-left: 3px solid var(--baseline);
  background: var(--page);
  border-radius: 0 8px 8px 0;
  padding: 6px 10px;
  margin: 3px 0 7px;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 520px;
}
.quote:hover { background: var(--accent-wash); text-decoration: none; color: var(--ink-2); border-left-color: var(--accent); }
.quote b { color: var(--ink-2); }
.tl-item.flash, .tl-sys.flash { animation: flash-bg 1.6s ease-out; }
@keyframes flash-bg { 0% { background: rgba(250, 178, 25, 0.28); } 100% { background: transparent; } }
.reply-ctx {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reply-ctx b { color: var(--ink-2); flex: none; }
.reply-ctx .rc-x { margin-left: auto; border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; flex: none; }
.reply-ctx .rc-x:hover { color: var(--critical); }

/* recurring chip on tickets */
.recur-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-deep);
  background: var(--accent-wash);
  border: 1px solid rgba(42, 120, 214, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
}

/* account menu */
.acct { position: relative; }
.acct-btn { border: none; background: none; padding: 0; cursor: pointer; border-radius: 50%; display: inline-flex; }
.acct-menu {
  position: absolute;
  right: 0;
  top: 42px;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(11, 11, 11, 0.14);
  padding: 6px;
  z-index: 80;
}
.acct-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid);
  margin-bottom: 5px;
  font-size: 13px;
}
.acct-biz { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.acct-menu a, .acct-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
}
.acct-menu a:hover, .acct-menu button:hover {
  background: var(--accent-wash);
  color: var(--accent-deep);
  text-decoration: none;
}
.biz-tag { background: var(--accent-wash); border-color: rgba(42, 120, 214, 0.25); color: var(--accent-deep); }
.biz-tag.sm { font-size: 10px; padding: 0 5px; }

/* login page */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(11, 11, 11, 0.08);
  padding: 28px 28px 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.login-brand h1 { font-size: 19px; margin: 0; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 18px; }
.login-people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
.login-person {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}
.login-person:hover { background: var(--accent-wash); }
.login-person.on { border-color: var(--accent); background: var(--accent-wash); box-shadow: 0 0 0 1px var(--accent); }
.login-person .lp-name { font-weight: 650; font-size: 12.5px; line-height: 1.25; }
.login-person .lp-role { color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.login-code { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
.login-code input {
  flex: 1;
  font-size: 16px;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 10px;
}
.login-err { color: var(--critical); font-size: 12.5px; font-weight: 600; margin-top: 9px; display: none; }
.login-foot { color: var(--muted); font-size: 11.5px; margin-top: 18px; border-top: 1px solid var(--grid); padding-top: 12px; }

/* manage page */
.manage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  flex-wrap: wrap;
}
.manage-row + .manage-row, .manage-row + .manage-edit, .manage-edit + .manage-row { border-top: 1px solid var(--grid); }
.manage-row.m-dim { opacity: 0.55; }
.m-who { flex: 1.5; min-width: 180px; }
.m-col { flex: 1; min-width: 140px; color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.m-col a { color: var(--ink-2); }
.m-actions { display: flex; gap: 4px; margin-left: auto; }
.m-role { color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.retired-tag {
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; line-height: 16px;
}
.manage-edit { padding: 12px 16px 15px; background: var(--page); border-top: 1px solid var(--grid); }
.manage-edit .form-grid { gap: 10px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.swatch {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.55);
}
.swatch.on { border-color: var(--ink); }
.icon-pick { display: flex; gap: 5px; flex-wrap: wrap; }
.icon-pick button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 7px;
  width: 30px; height: 28px; cursor: pointer; color: var(--ink-2);
  display: inline-grid; place-items: center;
}
.icon-pick button.on { background: var(--accent-wash); border-color: rgba(42, 120, 214, 0.5); color: var(--accent-deep); }

/* person page */
.avatar.sz-48 { width: 48px; height: 48px; font-size: 17px; }
.person-head { display: flex; align-items: center; gap: 15px; margin: 4px 0 18px; }
.person-head h1 { font-size: 20px; margin: 0; }
.person-head .sub { color: var(--muted); font-size: 13px; margin-top: 1px; }
.stat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.section-gap { margin-bottom: 14px; }

.aging-flag {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  color: #7a5200;
  background: rgba(250, 178, 25, 0.14);
  border: 1px solid rgba(250, 178, 25, 0.45);
  border-radius: 5px;
  padding: 0 6px;
  line-height: 16px;
}

/* ============ Filters row ============ */

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.seg {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg button:hover { background: var(--page); }
.seg button.on { background: var(--accent-wash); color: var(--accent-deep); }

select, input[type="text"], textarea {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; min-height: 72px; }

.result-count { color: var(--muted); font-size: 12.5px; margin-left: auto; }

/* ============ Ticket table ============ */

.tix-table { width: 100%; border-collapse: collapse; }
.tix-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
.tix-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
}
.tix-table tr:last-child td { border-bottom: none; }
.tix-table tbody tr { cursor: pointer; }
.tix-table tbody tr:hover { background: var(--accent-wash); }
.t-id {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.t-title { font-weight: 600; color: var(--ink); }
.t-title-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}
.t-title-sub .mini { display: inline-flex; align-items: center; gap: 3px; }
.t-person { display: flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--ink-2); font-size: 12.5px; }
.t-age { color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

.empty {
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}

/* ============ Ticket detail ============ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.back-link:hover { color: var(--ink-2); text-decoration: none; }

.detail-head { margin-bottom: 14px; }
.detail-head .d-id { color: var(--muted); font-weight: 650; font-size: 13px; font-variant-numeric: tabular-nums; }
.detail-head h1 { font-size: 20px; margin: 2px 0 10px; letter-spacing: -0.01em; line-height: 1.3; }
.detail-badges { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 13px; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 16px;
  align-items: start;
}

.desc-block {
  padding: 13px 16px;
  border-left: 3px solid var(--grid);
  color: var(--ink-2);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
}
.desc-block .d-by { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* timeline */
.tl { position: relative; padding-left: 0; }
.tl-item { display: flex; gap: 11px; padding: 12px 0; }
.tl-item + .tl-item { border-top: 1px solid var(--grid); }
.tl-body { flex: 1; min-width: 0; }
.tl-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tl-name { font-weight: 700; font-size: 13px; }
.tl-role { color: var(--muted); font-size: 11.5px; }
.tl-when { color: var(--muted); font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.tl-text { margin-top: 4px; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: break-word; }

.tl-sys {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 12.5px;
}
.tl-sys + .tl-item, .tl-item + .tl-sys, .tl-sys + .tl-sys { border-top: 1px solid var(--grid); }
.tl-sys svg { flex: none; }
.tl-sys .tl-when { margin-left: auto; }
.tl-sys.is-escalation { color: #8a3413; font-weight: 600; }
.tl-sys.is-resolve { color: var(--good-text); font-weight: 600; }

/* photos */
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.photo {
  width: 138px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--page);
}
.photo svg { display: block; width: 100%; height: auto; }
.photo .photo-cap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--muted);
  padding: 4px 7px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* composer */
.composer { margin-top: 4px; padding: 14px 16px 16px; }
.composer .c-row { display: flex; gap: 10px; }
.composer .c-main { flex: 1; }
.composer .c-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.composer .c-hint { color: var(--muted); font-size: 11.5px; margin-left: auto; }
.pending-photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pending-photos .pp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}
.pending-photos .pp button {
  border: none; background: none; cursor: pointer;
  color: var(--muted); padding: 0; font-size: 13px; line-height: 1;
}

/* meta sidebar */
.meta-card { padding: 6px 0; }
.meta-row { padding: 9px 16px; }
.meta-row + .meta-row { border-top: 1px solid var(--grid); }
.meta-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.meta-val { color: var(--ink-2); font-size: 13px; }
.meta-val.strong { color: var(--ink); font-weight: 600; }
.watchers { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.watch-add {
  border: 1px dashed var(--baseline);
  background: none;
  color: var(--muted);
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.watch-add:hover { color: var(--accent-deep); border-color: var(--accent); }
.tag-row { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 7px;
}

/* ============ Forms (new ticket) ============ */

.form-card { max-width: 680px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.form-field .req { color: var(--critical); }
.form-field input[type="text"], .form-field select, .form-field textarea { width: 100%; }
.chip-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-toggles button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.chip-toggles button.on {
  background: var(--accent-wash);
  border-color: rgba(42, 120, 214, 0.45);
  color: var(--accent-deep);
}
.form-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--grid);
}
.form-error { color: var(--critical); font-size: 12.5px; font-weight: 600; display: none; }

/* ============ Charts ============ */

.charts-row {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 14px;
  margin-bottom: 14px;
}
.chart-card .card-body { position: relative; }
.chart-card svg text { font-family: var(--font); }
.viz-legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--ink-2); }
.viz-legend .k { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .k i {
  display: inline-block;
  width: 16px; height: 0;
  border-top: 2.5px solid;
  border-radius: 2px;
}
.viz-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 1.5px;
  gap: 1px;
}
.viz-toggle button {
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 3px 8px;
  cursor: pointer;
}
.viz-toggle button.on { background: var(--page); color: var(--ink-2); }

.viz-tip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.5;
  box-shadow: 0 4px 14px rgba(11, 11, 11, 0.25);
  opacity: 0;
  transition: opacity 80ms;
  z-index: 20;
  max-width: 220px;
}
.viz-tip.show { opacity: 1; }
.viz-tip .tip-title { color: rgba(255, 255, 255, 0.75); font-size: 11px; margin-bottom: 2px; }
.viz-tip .tip-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.viz-tip .tip-row i {
  display: inline-block;
  width: 12px; height: 0;
  border-top: 2.5px solid;
  border-radius: 2px;
  flex: none;
}
.viz-tip .tip-row b { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.viz-tip .tip-row span { color: rgba(255, 255, 255, 0.75); }

.viz-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.viz-table th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
}
.viz-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.viz-table tr:last-child td { border-bottom: none; }
.viz-table td.num, .viz-table th.num { text-align: right; }

.bar-hit { cursor: pointer; }
.bar-mark { transition: filter 80ms; }
.bar-hit:hover ~ .bar-mark, .bar-mark.lift { filter: brightness(1.14); }

/* needs attention list */
.attn-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px;
  color: inherit;
}
.attn-row + .attn-row { border-top: 1px solid var(--grid); }
.attn-row:hover { background: var(--accent-wash); text-decoration: none; }
.attn-main { min-width: 0; }
.attn-title { display: block; font-weight: 600; font-size: 13px; }
.attn-sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.attn-right { margin-left: auto; text-align: right; color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* ============ SIM Assistant (Claude) ============ */

.ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(42, 120, 214, 0.4);
  background: var(--accent-wash);
  color: var(--accent-deep);
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ai-btn:hover { background: rgba(42, 120, 214, 0.16); }

.ai-panel[hidden] { display: none; }
.ai-panel {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 30px rgba(11, 11, 11, 0.08);
  z-index: 70;
  display: flex;
  flex-direction: column;
}
.ai-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--grid);
}
.ai-head .t { font-weight: 700; font-size: 13.5px; }
.ai-head .s { color: var(--muted); font-size: 11px; }
.ai-head .grow { flex: 1; }

.ai-banner {
  background: rgba(250, 178, 25, 0.12);
  border-bottom: 1px solid rgba(250, 178, 25, 0.4);
  color: #7a5200;
  font-size: 11.5px;
  padding: 7px 14px;
  line-height: 1.45;
}

.ai-thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-msg {
  max-width: 92%;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.ai-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.ai-action {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 650;
  color: var(--good-text);
  background: rgba(12, 163, 12, 0.08);
  border: 1px solid rgba(12, 163, 12, 0.3);
  border-radius: 8px;
  padding: 5px 11px;
}
.ai-action.is-read { color: var(--ink-2); background: var(--page); border-color: var(--border); }
.ai-thinking {
  align-self: flex-start;
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 2px;
}
.ai-thinking i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--baseline);
  animation: ai-pulse 1s infinite alternate;
  display: inline-block;
}
.ai-thinking i:nth-child(2) { animation-delay: 0.22s; }
.ai-thinking i:nth-child(3) { animation-delay: 0.44s; }
@keyframes ai-pulse { from { opacity: 0.35; } to { opacity: 1; transform: translateY(-1.5px); } }

.ai-suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 8px; }
.ai-suggest button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.ai-suggest button:hover { background: var(--accent-wash); color: var(--accent-deep); }

.ai-input {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--grid);
  align-items: flex-end;
}
.ai-input textarea {
  flex: 1;
  min-height: 40px;
  max-height: 130px;
  resize: none;
  font-size: 13px;
}
.ai-refresh {
  align-self: flex-start;
  border: none;
  background: none;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 2px;
}

.ai-settings { padding: 12px 14px; border-bottom: 1px solid var(--grid); background: var(--page); }
.ai-settings label { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin: 8px 0 3px; }
.ai-settings input, .ai-settings select { width: 100%; font-size: 12.5px; }
.ai-settings .note { color: var(--muted); font-size: 11px; margin-top: 8px; line-height: 1.45; }

@media (max-width: 640px) {
  .ai-panel { width: 100vw; top: 56px; }
}

/* ============ Toasts ============ */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--ink);
  color: #fff;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 550;
  box-shadow: 0 6px 20px rgba(11, 11, 11, 0.3);
  animation: toast-in 160ms ease-out;
  max-width: 360px;
}
.toast svg { color: #7fd67f; flex: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ============ Responsive ============ */

@media (max-width: 1020px) {
  .charts-row { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
  }
  .nav-group { margin-bottom: 0; display: flex; gap: 4px; }
  .nav-head { display: none; }
  .nav-item { white-space: nowrap; padding: 6px 10px; }
  .sidebar-foot { display: none; }
  .brand-tag { display: none; }
  main { padding: 16px 14px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .attn-right.ava { display: none; }
}
