/* Williams Stanley house style: navy sidebar, light blue canvas, white cards. */
:root {
  --navy: #002143;          /* sidebar, headings, primary actions */
  --navy-2: #0a2f57;        /* sidebar hover / active */
  --navy-3: #13406f;
  --sidebar-text: #ccd3d9;
  --coral: #e5484d;         /* brand mark and active indicator */

  --bg: #eff6ff;            /* page background */
  --surface: #ffffff;       /* cards and visuals */
  --subtle: #f5f9ff;        /* tinted areas inside cards */
  --border: #dbe4ef;
  --text: #0f2236;
  --muted: #5d6b7a;
  --accent: #0b5cad;        /* links and focus */
  --accent-text: #ffffff;
  --danger: #c93535;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 33, 67, 0.06), 0 4px 14px rgba(0, 33, 67, 0.06);

  --s-todo: #5d6b7a;
  --s-in_progress: #0b5cad;
  --s-done: #1f9254;

  --p-low: #8792a2;
  --p-medium: #0b5cad;
  --p-high: #d97a06;
  --p-critical: #c93535;

  --sidebar-width: 260px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 800; color: var(--navy); letter-spacing: -0.01em; margin: 0 0 18px; }
h2 { font-size: 16px; font-weight: 700; color: var(--navy); margin: 24px 0 12px; }
svg.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 28px 32px 64px; }

/* Brand mark: white "WS" on navy with a coral underline, as in Insights / AutoAP */
.ws-logo {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none; border-radius: 8px;
  background: var(--navy-2); border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: 0.02em; overflow: hidden;
}
.ws-logo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--coral); }

/* Sidebar */
.sb {
  position: sticky; top: 0; height: 100vh; width: var(--sidebar-width); flex: none;
  display: flex; flex-direction: column; background: var(--navy); color: var(--sidebar-text);
  z-index: 30; transition: width 0.15s ease;
}
.sb a { color: inherit; text-decoration: none; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-app { color: #fff; font-weight: 800; font-size: 19px; white-space: nowrap; }
.sb-collapse {
  margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--navy-2); color: var(--sidebar-text); display: inline-flex; align-items: center; justify-content: center;
}
.sb-collapse:hover { background: var(--navy-3); color: #fff; }
.sb-collapse svg.icon { width: 15px; height: 15px; }
.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 16px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 2px; }
.sb-nav > *, .sb-sub > * { min-width: 0; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 3px; }
.sb-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: none; background: none; cursor: pointer;
  color: var(--sidebar-text); font: inherit; font-size: 14.5px; text-align: left;
}
.sb-item:hover { background: var(--navy-2); color: #fff; }
.sb-item.active { background: var(--navy-2); color: #fff; font-weight: 600; }
.sb-item.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--coral); }
.sb-item .sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-item .chev { width: 15px; height: 15px; opacity: 0.7; transition: transform 0.15s ease; }
.sb-item[aria-expanded="true"] .chev { transform: rotate(90deg); }
.sb-sub { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; padding: 2px 0 6px 20px; }
.sb-sub .sb-item { font-size: 13.5px; padding: 6px 10px; gap: 10px; }
.sb-sub .sb-item.active::before { left: -30px; }
.sb-empty { padding: 4px 10px 6px; font-size: 12.5px; opacity: 0.6; }
.sb-section {
  display: flex; align-items: center; gap: 4px; margin: 16px 0 4px; padding: 0 4px 0 10px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(204, 211, 217, 0.7);
}
.sb-section span { flex: 1; }
.sb-icon-btn {
  width: 26px; height: 26px; border-radius: 6px; border: none; background: none; cursor: pointer;
  color: var(--sidebar-text); display: inline-flex; align-items: center; justify-content: center;
}
.sb-icon-btn:hover { background: var(--navy-2); color: #fff; }
.sb-icon-btn svg.icon { width: 16px; height: 16px; }
.sb-sublabel { padding: 6px 10px 2px; font-size: 12px; font-weight: 600; color: rgba(204, 211, 217, 0.6); }
.project-avatar {
  width: 24px; height: 24px; border-radius: 6px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 0.02em;
}
.sb-footer { display: flex; align-items: center; gap: 8px; padding: 14px 12px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sb-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 8px; }
.sb-user:hover { background: var(--navy-2); }
.sb-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--navy-3); color: #fff; font-weight: 700; font-size: 13px;
}
.sb-user-text { min-width: 0; display: grid; line-height: 1.3; }
.sb-user-text strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-text small { font-size: 12px; color: var(--sidebar-text); }

/* Collapsed sidebar: icons only */
.shell.collapsed .sb { width: 68px; }
.shell.collapsed .sb-app,
.shell.collapsed .sb-label,
.shell.collapsed .sb-item .chev,
.shell.collapsed .sb-section,
.shell.collapsed .sb-sub,
.shell.collapsed .sb-sublabel,
.shell.collapsed .sb-empty,
.shell.collapsed .sb-user-text,
.shell.collapsed .sb-footer .sb-icon-btn { display: none; }
.shell.collapsed .sb-head { flex-direction: column; padding: 16px 8px 12px; }
.shell.collapsed .sb-collapse { margin: 0; transform: rotate(180deg); }
.shell.collapsed .sb-item { justify-content: center; padding: 10px 0; }
.shell.collapsed .sb-footer { justify-content: center; }

/* Top bar */
.pagebar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.pagebar .pagebar-menu { display: none; padding: 7px 8px; }
.pagebar-search { position: relative; flex: 1; max-width: 560px; }
.pagebar-search svg.icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.pagebar-search input { width: 100%; padding: 9px 12px 9px 36px; border-radius: 8px; background: var(--subtle); }
.pagebar-search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 11px/1 inherit; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; background: var(--surface);
}
.pagebar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sb-scrim { display: none; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--navy); font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 33, 67, 0.05);
}
.btn:hover { text-decoration: none; border-color: #b9c7d8; background: var(--subtle); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-3); border-color: var(--navy-3); }
.btn svg.icon { width: 16px; height: 16px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; font-weight: 500; }
.btn-ghost:hover { background: var(--subtle); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { width: 100%; min-height: 120px; resize: vertical; }

.form { display: grid; gap: 14px; max-width: 640px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 8px; }
.error { color: var(--danger); min-height: 1em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}

/* Auth page */
.auth-page { position: fixed; inset: 0; overflow-y: auto; background: var(--navy); display: grid; place-items: center; padding: 24px; }
.auth { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .sb-app { font-size: 24px; }
.auth h1 { font-size: 20px; text-align: center; color: var(--navy); margin-bottom: 4px; }
.auth .card { padding: 28px; }

/* Filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { min-width: 220px; flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* Ticket table */
.table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 13.5px; font-weight: 600; color: #fff; background: var(--navy); border-bottom: none; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--subtle); }
.table .key { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* Badges */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid currentColor;
}
.status-todo { color: var(--s-todo); }
.status-in_progress { color: var(--s-in_progress); }
.status-done { color: var(--s-done); }
.prio-low { color: var(--p-low); }
.prio-medium { color: var(--p-medium); }
.prio-high { color: var(--p-high); }
.prio-critical { color: var(--p-critical); }
.type { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.label {
  display: inline-block; padding: 0 6px; margin: 0 4px 2px 0; border-radius: 4px;
  background: var(--bg); border: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.overdue { color: var(--danger); font-weight: 600; }

/* Board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; align-items: start; padding-bottom: 8px; }
.column { background: #e4edf8; border: 1px solid transparent; border-top: 3px solid var(--s-todo); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.column.cat-in_progress { border-top-color: var(--s-in_progress); }
.column.cat-done { border-top-color: var(--s-done); }
.column-head { padding: 8px 8px 8px 12px; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.column-title { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.column-title[title] { cursor: text; }
.column-title[title]:hover { color: var(--text); }
.column-rename { flex: 1; min-width: 0; padding: 3px 6px; font-size: 13px; }
.column-count { font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, 0.7); border-radius: 4px; padding: 0 6px; }
.column-body { padding: 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; align-content: start; }
.column-footer { padding: 0 8px 8px; }
.column.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column-create { width: 100%; text-align: left; font: inherit; color: var(--muted); background: none; border: none; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.column-create:hover { background: rgba(255, 255, 255, 0.6); color: var(--navy); }
.column-add { min-height: 0; border: 1px dashed #b9c7d8; background: transparent; padding: 8px; }

.column-menu { margin-left: auto; position: relative; }
.column-menu > summary { list-style: none; cursor: pointer; padding: 0 8px; border-radius: 4px; color: var(--muted); font-weight: 700; line-height: 24px; }
.column-menu > summary::-webkit-details-marker { display: none; }
.column-menu > summary:hover, .column-menu[open] > summary { background: var(--bg); color: var(--text); }
.column-menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); padding: 6px; display: grid; gap: 2px;
}
.column-menu-panel button { text-align: left; font: inherit; background: none; border: none; color: var(--text); padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.column-menu-panel button:hover { background: var(--bg); }
.column-menu-panel button.selected { font-weight: 600; }
.column-menu-panel button.danger { color: var(--danger); }
.column-menu-panel .hint { padding: 2px 8px; display: block; }
.column-menu-panel select { width: 100%; margin-top: 4px; }
.column-menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 8px 8px 2px; border-top: 1px solid var(--border); margin-top: 4px; }

.board-done-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -4px 0 14px; font-size: 13px; }
.board-done-bar .btn { margin-left: auto; }
.column-older { display: block; padding: 0 16px 12px; font-size: 13px; }
.load-more { display: flex; justify-content: center; margin-top: 16px; }

.composer { display: grid; gap: 6px; background: var(--surface); border: 2px solid var(--accent); border-radius: 6px; padding: 8px; }
.composer textarea, .composer input { min-height: 0; border: none; padding: 2px; resize: none; }
.composer textarea:focus, .composer input:focus { outline: none; }
.composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.composer-actions select { font-size: 12px; padding: 3px 4px; }
.composer-actions .btn { padding: 3px 10px; font-size: 13px; }
.composer-spacer { flex: 1; }

.tcard { display: block; color: inherit; background: var(--surface); border: 1px solid transparent; border-radius: 8px; padding: 10px 12px; cursor: grab; box-shadow: 0 1px 2px rgba(0, 33, 67, 0.12); }
.tcard:hover { border-color: #b9c7d8; text-decoration: none; }
.tcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
a.row-link { color: inherit; }
a.row-link:hover { color: var(--accent); }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.password-row td { background: var(--subtle); }
.password-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.password-form input[type="password"], .password-form input[type="text"] { min-width: 240px; }
.password-form label { display: inline-flex; align-items: center; gap: 4px; }
/* Development panel and PR badges. GitHub's own state colours, always with the state name. */
.development { margin-top: 8px; }
.pr-list { display: grid; gap: 8px; margin-bottom: 10px; }
.pr-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.pr-main { flex: 1; min-width: 0; }
.pr-main a { font-weight: 600; overflow-wrap: anywhere; }
.pr-state { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.pr-state svg.icon { width: 14px; height: 14px; }
.pr-open { background: #1f883d; }
.pr-draft, .pr-linked { background: #6e7781; }
.pr-merged { background: #8250df; }
.pr-closed { background: #cf222e; }
.pr-form { display: flex; gap: 8px; margin-bottom: 4px; }
.development h3 { font-size: 14px; color: var(--navy); margin: 16px 0 8px; }
.development > .muted { margin: -4px 0 4px; }
.dev-list { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dev-list > p { margin: 0; padding: 10px 12px; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.dev-row:last-child { border-bottom: none; }
.dev-row svg.icon { width: 16px; height: 16px; color: var(--muted); }
.dev-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-row .muted { white-space: nowrap; }
.dev-row.deleted .dev-name { color: var(--muted); text-decoration: line-through; }
.dev-sha { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.automation-panel { margin-bottom: 16px; }
.automation-panel h2 { margin-top: 0; }
.automation-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.automation-rules label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; }
.pr-form input { flex: 1; min-width: 0; }
.pr-chip { display: inline-flex; align-items: center; gap: 3px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; }
.pr-chip svg.icon { width: 12px; height: 12px; }
.tcard-meta .tcard-assignee { margin-left: auto; }

.ticket-crumbs { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ticket-crumbs p { margin: 0; }
.tcard.dragging { opacity: 0.4; }
.tcard-title { margin: 4px 0 6px; color: var(--text); overflow-wrap: anywhere; }
.tcard-meta { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* Ticket detail */
.detail { display: grid; grid-template-columns: 1fr 280px; gap: 24px; align-items: start; }
.detail-title { display: flex; gap: 8px; align-items: baseline; }
.detail-title input { font-size: 20px; font-weight: 600; flex: 1; }
.description { white-space: pre-wrap; word-wrap: break-word; }
.sidebar { display: grid; gap: 12px; }
.sidebar label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sidebar .meta { font-size: 12px; color: var(--muted); }

.timeline { display: grid; gap: 12px; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.comment-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.comment-body { overflow-wrap: anywhere; }
.event { font-size: 12px; color: var(--muted); padding-left: 14px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; margin-bottom: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 18px 16px; text-align: center; border-right: 1px solid var(--border); }
.stat:last-child { border-right: none; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 100; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 860px) {
  /* Sidebar becomes an off-canvas drawer opened from the top bar. */
  .sb { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.2s ease; width: 280px; }
  .shell.nav-open .sb { transform: none; }
  .shell.nav-open .sb-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 33, 67, 0.45); z-index: 25; }
  .shell.collapsed .sb { width: 280px; }
  .sb-collapse { display: none; }
  .pagebar { padding: 10px 16px; gap: 10px; }
  .pagebar .pagebar-menu { display: inline-flex; }
  .pagebar-search kbd, .pagebar-create-label { display: none; }
  .main { padding: 20px 16px 48px; }
  .detail { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .table { display: block; overflow-x: auto; }
}

/* ---------- Reports ---------- */
.report-intro { margin: -8px 0 18px; max-width: 760px; }
.report-custom { display: flex; align-items: center; gap: 6px; }
.report-summary { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; align-items: stretch; }
.report-hero { display: grid; align-content: center; gap: 4px; }
.report-hero-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.report-hero-value { font-size: 56px; font-weight: 700; line-height: 1.05; color: var(--navy); }
.report-stats { margin: 0; }
.report-stats .stat { display: grid; align-content: center; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 8px; }
.report-card h2 { margin: 0; }
.report-card > .muted { margin: 2px 0 14px; }

.bar-chart { display: grid; gap: 6px; margin-bottom: 16px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 10px; padding: 3px 0; border-radius: 4px; }
.bar-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bar-row[tabindex] { cursor: default; }
.bar-label { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; border-left: 1px solid var(--border); padding-right: 64px; }
/* One series, one hue; 16px thick with a 4px rounded data-end, square at the baseline. */
.bar { height: 16px; flex: none; background: #0b5cad; border-radius: 0 4px 4px 0; }
.bar-row:hover .bar, .bar-row:focus .bar { background: var(--navy); }
.bar-value { font-size: 12.5px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; margin-right: -64px; }
.bar-track > .bar-value:only-child { color: var(--muted); padding-left: 6px; }

.report-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.report-table th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.report-table td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table tr:last-child td { border-bottom: none; }

.table th.sortable { padding: 0; }
.table th.sortable button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 11px 14px; cursor: pointer; font-weight: 600; }
.table th.sortable button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num button { text-align: right; }

.chart-tooltip {
  position: fixed; z-index: 200; pointer-events: none; max-width: 280px;
  background: var(--navy); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow);
}
.chart-tooltip-title { font-weight: 700; }

@media (max-width: 860px) {
  .report-summary { grid-template-columns: 1fr; }
  .report-hero-value { font-size: 48px; }
}

/* ---------- Import ---------- */
.import-upload p { margin-top: 0; }
.import-upload .toolbar { margin: 0; }
.import-review { display: grid; gap: 16px; margin-top: 16px; }
.import-review h2 { margin-top: 0; }
.import-review ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.import-review .report-table td:last-child, .import-review .report-table th:last-child { text-align: left; }
.import-people select { max-width: 320px; }
.import-progress { width: 100%; height: 10px; accent-color: var(--navy); }

/* ---------- Markdown content ---------- */
.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1 { font-size: 24px; margin: 24px 0 12px; }
.markdown h2 { font-size: 19px; margin: 22px 0 10px; }
.markdown h3 { font-size: 16px; margin: 18px 0 8px; }
.markdown p, .markdown ul, .markdown ol, .markdown blockquote, .markdown table, .markdown pre { margin: 0 0 12px; }
.markdown ul, .markdown ol { padding-left: 24px; }
.markdown li > input[type="checkbox"] { margin-right: 6px; }
.markdown ul:has(> li > input[type="checkbox"]) { list-style: none; padding-left: 4px; }
.markdown code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.markdown pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; }
.markdown pre code { background: none; border: none; padding: 0; }
.markdown blockquote { border-left: 4px solid var(--accent); background: var(--bg); padding: 8px 14px; border-radius: 0 6px 6px 0; color: var(--text); }
.markdown blockquote > :last-child { margin-bottom: 0; }
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.markdown th { background: var(--bg); }
.markdown img { max-width: 100%; }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.ticket-link { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }

.small { font-size: 12px; }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.banner { background: var(--bg); border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Knowledge base ---------- */
.space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.space-card { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.space-card:hover { border-color: var(--accent); text-decoration: none; }
.space-card-head { display: flex; justify-content: space-between; gap: 8px; }
.kb-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }

.kb-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.kb-sidebar { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; display: grid; gap: 10px; padding-right: 4px; }
.kb-space-name { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.kb-space-name a { color: var(--text); }
.kb-sidebar-heading { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; margin-top: 6px; }
.kb-sidebar-links { display: grid; gap: 4px; font-size: 13px; border-top: 1px solid var(--border); padding-top: 10px; }
.tree { list-style: none; margin: 0; padding: 0 0 0 12px; }
.kb-sidebar > .tree { padding-left: 0; }
.tree-item { display: flex; align-items: center; gap: 2px; border-radius: 6px; padding: 2px 4px; }
.tree-item a { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 0; }
.tree-item.current { background: var(--surface); box-shadow: inset 2px 0 0 var(--accent); }
.tree-item.current a { font-weight: 600; }
.tree-toggle { width: 18px; height: 18px; flex: none; border: none; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 11px; }
.tree-toggle.leaf { visibility: hidden; }

.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.kb-title { font-size: 28px; margin-bottom: 6px; }
.kb-meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.kb-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.kb-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.kb-labels .label { margin: 0; }
.kb-body { font-size: 15px; line-height: 1.65; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 28px; }
.kb-children { margin-top: 8px; }
.kb-history-actions { display: flex; gap: 10px; align-items: center; }
.search-results { list-style: none; padding: 0; display: grid; gap: 14px; }
.search-results li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 4px; }

.kb-editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.kb-title-input { font-size: 24px; font-weight: 700; padding: 8px 10px; }
.kb-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tool { font: inherit; font-size: 12px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); cursor: pointer; }
.tool:hover { border-color: var(--muted); }
.kb-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.kb-pane { display: grid; grid-template-rows: auto 1fr; min-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.kb-pane-head { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 12px; border-bottom: 1px solid var(--border); background: var(--bg); }
.kb-editor-area { border: none; border-radius: 0; min-height: 60vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.6; padding: 12px; }
.kb-preview { overflow-y: auto; max-height: 75vh; }
.kb-preview .kb-body { border: none; border-radius: 0; padding: 12px 16px; }

.diff { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 0; overflow-x: auto; font-size: 13px; }
.diff > div { padding: 0 12px; white-space: pre-wrap; }
.diff-add { background: rgba(31, 146, 84, 0.15); }
.diff-del { background: rgba(201, 53, 53, 0.15); text-decoration: line-through; text-decoration-color: rgba(201, 53, 53, 0.5); }
ins { background: rgba(31, 146, 84, 0.15); text-decoration: none; }
del { background: rgba(201, 53, 53, 0.15); }

@media (max-width: 860px) {
  .kb-layout { grid-template-columns: 1fr; }
  .kb-sidebar { position: static; max-height: none; }
  .kb-split { grid-template-columns: minmax(0, 1fr); }
  .kb-body { padding: 16px; }
}

@media print {
  .sb, .pagebar, .kb-sidebar, .kb-actions, .kb-labels button, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  .main { padding: 0; max-width: none; }
  .kb-layout { display: block; }
  .kb-body { border: none; padding: 0; }
}
