/* L&T IT Helpdesk — base styles */
:root {
  --bg: oklch(99% 0.002 80);
  --bg-elev: oklch(100% 0 0);
  --bg-sub: oklch(97% 0.003 80);
  --bg-hover: oklch(95% 0.005 80);
  --bg-active: oklch(93% 0.008 260);
  --line: oklch(91% 0.005 80);
  --line-strong: oklch(85% 0.008 80);
  --text: oklch(22% 0.01 260);
  --text-muted: oklch(50% 0.01 260);
  --text-subtle: oklch(65% 0.01 260);
  /* Triage brand teal — using exact hex values to match the logo precisely. */
  --accent: #0D9488;
  --accent-soft: #CCFBF1;
  --accent-text: #0F766E;

  --st-new: oklch(50% 0.17 145);
  --st-new-bg: oklch(96% 0.05 145);
  --st-prog: oklch(62% 0.16 68);
  --st-prog-bg: oklch(96% 0.05 80);
  --st-done: oklch(58% 0.12 150);
  --st-done-bg: oklch(96% 0.04 150);
  --st-closed: oklch(50% 0.18 25);
  --st-closed-bg: oklch(97% 0.04 25);

  --pri-urgent: oklch(55% 0.20 25);
  --pri-high: oklch(60% 0.16 50);
  --pri-med: oklch(60% 0.10 250);
  --pri-low: oklch(60% 0.02 260);

  --radius: 6px;
  --radius-sm: 4px;
  --shadow-pop: 0 1px 2px oklch(0% 0 0 / 0.06), 0 8px 24px oklch(0% 0 0 / 0.08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
input, textarea { outline: none; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: 224px 1fr;
  height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  /* Original dark navy. Tried dark teal #134E4A but preferred the navy. */
  background: #1b2638;
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 1px;
  overflow-y: hidden;
  border-right: none;
}
.sb-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-track { background: transparent; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
.sb-brand {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 14px 12px;
  margin: -10px -8px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sb-logo {
  /* Inline SVG version of the Triage primary lockup — scales crisp at
     any size, recoloured for the dark sidebar (white AGE, lighter teal TRI). */
  display: block;
  width: 100%;
  max-width: 200px;
  height: auto;
  margin: 0 auto;
}
.sb-brand img {
  display: block;
  max-width: 200px;
  width: 100%;
  height: auto;
  max-height: 80px;
  object-fit: contain;
  object-position: center;
}
.sb-brand-sub {
  /* The Triage primary logo already includes "IT helpdesk" inside it.
     Hide the duplicate label below the image to avoid doubling up. */
  display: none;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
.sb-group {
  padding: 9px 10px 3px;
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  border-left: 3px solid transparent;
}
.sb-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.95); }
.sb-item.active {
  background: rgba(91,108,255,0.18);
  color: #fff;
  font-weight: 500;
  border-left-color: var(--accent);
}
.sb-item .ico { width: 15px; height: 15px; flex: none; color: currentColor; opacity: 0.9; }
.sb-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.sb-item.active .count { color: rgba(255,255,255,0.7); background: rgba(91,108,255,0.3); }
.sb-footer {
  margin-top: auto;
  padding: 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 9px;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}
.sidebar .btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sidebar .btn.primary:hover { opacity: 0.88; }

/* Main pane */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}
.topbar {
  height: 44px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg);
  flex: none;
}
.topbar .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.topbar .crumb-sep { color: var(--text-subtle); }
.topbar .search {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-sub);
  width: 260px;
}
.topbar .search input {
  border: 0; background: transparent; width: 100%;
  font-size: 12px;
}
.topbar .search .kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-subtle);
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--bg);
}
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  font-size: 12px;
  color: var(--text);
  height: 26px;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { border-color: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { color: var(--pri-urgent); border-color: oklch(85% 0.08 25); }

/* Tickets table view (SysAid-style) */
.tk-table-wrap {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.tk-table {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.tk-grid {
  display: grid;
  align-items: stretch;
  min-width: 1300px;
}
.tk-th.dragging { opacity: 0.4; }
.tk-th.drop-target {
  box-shadow: inset 2px 0 0 var(--accent);
  background: var(--bg-active);
}
.tk-th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg-sub);
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
.tk-th:hover { color: var(--text); }
.tk-th .sort-ind { opacity: 0.4; }
.tk-th.sorted { color: var(--text); }
.tk-th.sorted .sort-ind { opacity: 1; }
.tk-td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  display: flex; align-items: center;
}
.tk-tr {
  display: contents;
}
.tk-tr.row > .tk-td { cursor: pointer; }
.tk-tr.row:hover > .tk-td { background: var(--bg-hover); }
.tk-tr.row.selected > .tk-td { background: var(--bg-active); }
.col-subject { color: var(--text-muted); }
.col-id { font-family: var(--mono); font-size: 11px; color: var(--text-subtle); }
.col-updated { font-family: var(--mono); font-size: 11px; color: var(--text-subtle); }
.col-cat { font-size: 12px; color: var(--text-muted); }
.col-desc { font-size: 12px; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.col-requester, .col-assignee {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.col-assignee.unassigned { color: var(--text-subtle); font-style: italic; }

/* Header checkbox cell + row checkbox cell share styles */
.tk-td.col-check, .tk-th.col-check {
  padding: 8px 0 8px 14px;
  display: flex; align-items: center; justify-content: flex-start;
}
.chk {
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
  display: grid; place-items: center;
  background: var(--bg-elev);
  cursor: pointer;
  flex: none;
}
.chk.on { background: var(--accent); border-color: var(--accent); color: white; }
.chk.indet { background: var(--accent); border-color: var(--accent); }
.chk.indet::after { content: ""; width: 8px; height: 2px; background: white; border-radius: 1px; }

/* Sub-table toolbar - filters */
.tk-toolbar2 {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
}
.tk-toolbar2 .label {
  font-size: 11px; color: var(--text-subtle); letter-spacing: .02em;
  margin-right: 2px;
}
.tk-toolbar2 .spacer { flex: 1; }

/* Detail full-page view */
.tk-detail-full {
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.tk-back {
  height: 40px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-sub);
  flex: none;
}
.tk-back .breadcrumb { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.tk-back .breadcrumb .sep { color: var(--text-subtle); }
.tk-back .breadcrumb b { color: var(--text); font-weight: 600; }
.tk-toolbar {
  height: 40px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 12px;
  gap: 8px;
  background: var(--bg);
}
.tk-filter {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
  border: 1px dashed var(--line-strong);
  background: transparent;
  height: 24px;
}
.tk-filter:hover { color: var(--text); background: var(--bg-hover); }
.tk-filter.on {
  /* Subtle "active" state — teal border + bold text only. The previous
     full light-teal background flood was too aggressive on a header bar. */
  border-style: solid;
  border-color: var(--accent);
  background: transparent;
  color: var(--text);
  font-weight: 600;
}
.tk-rows {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.tk-row {
  display: grid;
  grid-template-columns: 22px 16px 14px minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font-size: 13px;
  position: relative;
}
.tk-row:hover { background: var(--bg-hover); }
.tk-row.selected { background: var(--bg-active); }
.tk-row .check {
  width: 14px; height: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: 3px;
  display: grid; place-items: center;
  background: var(--bg-elev);
}
.tk-row.checked .check {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.tk-row .subject {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tk-row .preview {
  color: var(--text-subtle);
  font-weight: 400;
}
.tk-row .id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
}
.tk-row .meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
  white-space: nowrap;
}
.tk-row .cat {
  font-size: 11px;
  color: var(--text-muted);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
}

/* Dots and chips */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.new { background: var(--st-new); }
.dot.prog { background: var(--st-prog); }
.dot.done { background: var(--st-done); }
.dot.closed { background: var(--st-closed); }

.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-muted);
  white-space: nowrap;
}
.status-chip .dot { width: 6px; height: 6px; }

.pri {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.pri-urgent { color: var(--pri-urgent); background: oklch(96% 0.04 25); }
.pri-high   { color: var(--pri-high);   background: oklch(96% 0.03 50); }
.pri-medium { color: var(--pri-med);    background: oklch(96% 0.02 250); }
.pri-low    { color: var(--pri-low);    background: oklch(96% 0.005 260); }

.pri-bar {
  width: 3px; height: 14px; border-radius: 1px;
}
.pri-bar.urgent { background: var(--pri-urgent); }
.pri-bar.high   { background: var(--pri-high); }
.pri-bar.medium { background: var(--pri-med); }
.pri-bar.low    { background: var(--pri-low); }

/* Avatars */
.av {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10px;
  font-weight: 600;
  color: white;
  font-family: var(--font);
  flex: none;
}
.av.sm { width: 18px; height: 18px; font-size: 9px; }
.av.lg { width: 28px; height: 28px; font-size: 11px; }
.av.empty {
  background: var(--bg-sub);
  color: var(--text-subtle);
  border: 1px dashed var(--line-strong);
  font-weight: 500;
}

/* Ticket detail */
.tk-detail {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.tk-d-head {
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.tk-d-head .row1 {
  display: flex; align-items: center; gap: 10px;
}
.tk-d-head .id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
}
.tk-d-head h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.tk-d-meta {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.tk-d-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  min-height: 0;
  overflow: hidden;
}
.tk-d-main {
  overflow-y: auto;
  padding: 20px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.tk-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 14px 16px;
}
.tk-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.tk-desc-body {
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
}
.tk-solution-card { border-color: oklch(82% 0.10 150); background: oklch(99% 0.01 150); }
.tk-solution-card .tk-card-label { color: oklch(40% 0.12 150); }
.tk-solution-input {
  width: 100%;
  border: 1px solid oklch(85% 0.08 150);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--bg-elev);
  font-size: 13px;
  font-family: var(--font);
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  color: var(--text);
  outline: none;
}
.tk-solution-input:focus { border-color: oklch(65% 0.14 150); box-shadow: 0 0 0 2px oklch(90% 0.06 150); }
.tk-solution-input[readonly] { background: oklch(97% 0.02 150); color: var(--text-muted); cursor: default; }

/* Right rail */
.tk-rail {
  border-left: 1px solid var(--line);
  background: var(--bg);
  padding: 16px 16px 24px;
  overflow-y: auto;
  min-height: 0;
}
.rail-section {
  margin-bottom: 18px;
}
.rail-label {
  font-size: 11px;
  color: var(--text-subtle);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.rail-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  margin-left: -6px;
  margin-right: -6px;
  cursor: pointer;
}
.rail-row:hover { background: var(--bg-hover); }
.rail-row .label { font-size: 12px; }
.rail-row .val { margin-left: auto; font-size: 12px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.rail-row .val.muted { color: var(--text-subtle); }

/* Empty state */
.empty {
  flex: 1;
  display: grid; place-items: center;
  color: var(--text-subtle);
  font-size: 13px;
  text-align: center;
  padding: 40px;
}
.empty h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin: 0 0 4px; }

/* Merge banner */
.merge-banner {
  background: oklch(97% 0.03 85);
  border: 1px solid oklch(88% 0.05 85);
  color: oklch(35% 0.10 70);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.merge-banner .pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  background: oklch(94% 0.04 85);
  border-radius: 3px;
}

/* KB */
.kb {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 0;
}
.kb-side {
  border-right: 1px solid var(--line);
  padding: 16px 8px;
  background: var(--bg-sub);
  overflow-y: auto;
}
.kb-cat {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.kb-cat:hover { background: var(--bg-hover); color: var(--text); }
.kb-cat.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.kb-cat .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-subtle); }
.kb-main {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.kb-tools {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; gap: 10px; align-items: center;
}
.kb-search {
  flex: 1;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  max-width: 480px;
}
.kb-search input { border: 0; background: transparent; flex: 1; }
.kb-tag-row {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.tag {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--bg-elev);
}
.tag:hover { background: var(--bg-hover); color: var(--text); }
.tag.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.kb-list {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.kb-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.kb-item:hover { background: var(--bg-hover); }
.kb-item h3 {
  font-size: 13px; font-weight: 600; margin: 0 0 2px;
  letter-spacing: -0.005em;
}
.kb-item p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.kb-item .meta { font-size: 11px; color: var(--text-subtle); font-family: var(--mono); }

.kb-article {
  overflow-y: auto;
  padding: 28px 40px 64px;
  max-width: 800px;
}
.kb-article h1 { font-size: 22px; font-weight: 600; margin: 0 0 8px; letter-spacing: -0.02em; }
.kb-article .a-meta { font-size: 11px; color: var(--text-subtle); margin-bottom: 16px; font-family: var(--mono); }
.kb-article h2 { font-size: 14px; font-weight: 600; margin: 22px 0 6px; }
.kb-article p, .kb-article li { font-size: 13px; line-height: 1.65; color: var(--text); }
.kb-article ol, .kb-article ul { padding-left: 22px; }
.kb-article code {
  font-family: var(--mono); font-size: 12px;
  background: var(--bg-sub); padding: 1px 5px; border-radius: 3px;
}

/* Stats */
.stats {
  padding: 24px 28px;
  overflow-y: auto;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-elev);
}
.stat-card .label { font-size: 11px; color: var(--text-subtle); letter-spacing: 0.02em; }
.stat-card .val {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  margin-top: 6px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.stat-card .trend { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-card .trend.up { color: var(--st-done); }
.stat-card .trend.down { color: var(--pri-high); }

.charts-row {
  display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; margin-bottom: 12px;
}
.chart-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-elev);
}
.chart-card h3 { font-size: 13px; margin: 0 0 14px; font-weight: 600; }

/* Bars (per-person) */
.bar-row { display: grid; grid-template-columns: 80px 1fr 32px; gap: 10px; align-items: center; padding: 6px 0; }
.bar-row .name { font-size: 12px; }
.bar-row .num { font-family: var(--mono); font-size: 11px; color: var(--text-subtle); text-align: right; }
.bar-track { height: 6px; background: var(--bg-sub); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }

/* Sparkline-ish line area */
.area-wrap { position: relative; height: 200px; }

/* Selection bar */
.sel-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  padding: 8px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  z-index: 56;
}
.sel-bar .sep { width: 1px; height: 18px; background: oklch(40% 0 0); }
.sel-bar button {
  color: var(--bg);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
}
.sel-bar button:hover { background: oklch(35% 0 0); }
.sel-bar button.danger:hover { background: oklch(35% 0.12 25); }

/* Popover */
.popover {
  position: fixed;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  min-width: 200px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  z-index: 60;
  padding: 4px;
  font-size: 12px;
}
.pop-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.pop-item:hover { background: var(--bg-hover); }
.pop-item .kbd {
  margin-left: auto;
  font-family: var(--mono); font-size: 10px;
  color: var(--text-subtle);
}
.pop-divider { height: 1px; background: var(--line); margin: 4px 0; }
.pop-search {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.pop-search input { border: 0; background: transparent; width: 100%; font-size: 12px; }

/* Backdrop */
.backdrop {
  position: fixed; inset: 0; z-index: 55;
}

/* Modal */
.modal-wrap {
  position: fixed; inset: 0; background: oklch(0% 0 0 / 0.3);
  display: flex; align-items: center; justify-content: center;
  /* Padding gives breathing room AND keeps modal off the very edges when
     the screen is small. overflow-y:auto lets us scroll if the modal grows
     taller than the viewport (e.g. when Quill is expanded). */
  padding: 40px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--bg-elev);
  border-radius: 8px;
  width: 640px;
  max-width: 92vw;
  box-shadow: var(--shadow-pop);
}
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; align-items: center; border-radius: 8px 8px 0 0; }
.modal-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.modal-body { padding: 20px 24px; font-size: 13px; overflow: visible; max-height: 75vh; overflow-y: auto; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-sub); border-radius: 0 0 8px 8px; }

/* Form bits */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; color: var(--text-subtle); margin-bottom: 4px; letter-spacing: 0.02em; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: var(--bg-elev);
  font-size: 13px;
}
.field textarea { min-height: 90px; resize: vertical; font-family: var(--font); }

/* Mailbox drawer */
.mailbox-drawer {
  position: fixed;
  top: 0; right: 0;
  bottom: 0;
  width: 520px;
  max-width: 100vw;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  z-index: 95;
  display: flex; flex-direction: column;
  animation: slideIn 180ms ease-out;
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.mailbox-head {
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sub);
}
.mailbox-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.mailbox-head .sub { font-size: 11px; color: var(--text-subtle); margin-top: 4px; font-family: var(--mono); }
.mailbox-head .row { display: flex; align-items: center; gap: 10px; }
.mailbox-body { flex: 1; overflow-y: auto; }
.mailbox-section-head {
  padding: 12px 18px 6px;
  font-size: 11px;
  color: var(--text-subtle);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.mailbox-section-head .pill {
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  background: oklch(95% 0.04 80);
  color: oklch(45% 0.10 60);
  border-radius: 999px;
  letter-spacing: 0;
  text-transform: none;
}
.mail-item {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.mail-item.pending {
  background: oklch(99% 0.02 85);
  border-left: 2px solid oklch(70% 0.16 70);
}
.mail-item .from { font-size: 12px; color: var(--text-muted); }
.mail-item .from b { color: var(--text); font-weight: 600; }
.mail-item .subj { font-size: 13px; font-weight: 500; margin-top: 2px; }
.mail-item .preview {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mail-item .ts { font-family: var(--mono); font-size: 11px; color: var(--text-subtle); white-space: nowrap; }
.mail-item .actions { margin-top: 8px; display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
.mail-item .link {
  font-size: 12px;
  color: var(--accent-text);
  cursor: pointer;
  font-family: var(--mono);
}
.mailbox-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg-sub);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
