/* Compass — Bookimed analytics. Brand: ink #171717, green #15803d, lime #a3cc0e. */
:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #f9faf7;
  --border: #e3e6df;
  --border-strong: #c9cfc2;
  --ink: #171717;
  --ink-2: #45483f;
  --muted: #6b6e66;
  --brand: #15803d;
  --brand-hover: #116b33;
  --brand-soft: #e8f3ec;
  --lime: #a3cc0e;
  --focus: #2a78d6;
  --good: #0a7d0a;
  --good-bg: #e6f4e6;
  --warning: #8a5a00;
  --warning-bg: #fdf3dc;
  --critical: #b42323;
  --critical-bg: #fbe9e9;
  --info-bg: #eaf2fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e9ebe5;
  --shadow: 0 1px 2px rgba(23, 23, 23, .05), 0 1px 1px rgba(23, 23, 23, .03);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121312;
    --surface: #1a1a19;
    --surface-2: #20211f;
    --border: #2e302c;
    --border-strong: #42453f;
    --ink: #f0efec;
    --ink-2: #c9c8bf;
    --muted: #9b9b93;
    --brand: #2fa65a;
    --brand-hover: #3bb867;
    --brand-soft: #18301f;
    --focus: #5a9be8;
    --good: #5ccf5c;
    --good-bg: #173117;
    --warning: #f2c14e;
    --warning-bg: #352a10;
    --critical: #f08080;
    --critical-bg: #3a1818;
    --info-bg: #172638;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #2a2c28;
    --shadow: none;
  }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #121312; --surface: #1a1a19; --surface-2: #20211f; --border: #2e302c; --border-strong: #42453f; --ink: #f0efec; --ink-2: #c9c8bf; --muted: #9b9b93; --brand: #2fa65a; --brand-hover: #3bb867; --brand-soft: #18301f; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --grid: #2a2c28; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 18px 0 8px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.block { display: block; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; }

/* Shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; flex-direction: column; gap: 6px; padding: 4px 10px 18px; color: var(--ink); text-decoration: none !important; }
.brand-logo { display: block; height: auto; }
.brand-product { display: inline-flex; align-items: center; gap: 6px; font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.compass-mark { width: 22px; height: 22px; color: var(--brand); flex: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { filter: invert(1) brightness(1.1); } }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--ink-2); padding: 8px 10px; border-radius: 8px; font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 14px 6px 0; display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; gap: 10px; align-items: center; }
.who strong { display: block; font-size: 13px; line-height: 1.2; }
.who small { color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.link-button { background: none; border: 0; color: var(--muted); padding: 0; cursor: pointer; font: inherit; font-size: 13px; text-align: left; }
.link-button:hover { color: var(--ink); text-decoration: underline; }
.main { padding: 24px 32px 48px; min-width: 0; }
.dev-ribbon { background: var(--warning-bg); color: var(--warning); border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; margin-bottom: 16px; display: inline-block; }

/* Page structure */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .muted { margin: 0; max-width: 760px; }
.breadcrumb { margin: 0 0 4px; font-size: 12px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 10px; }
.lede { color: var(--ink-2); font-size: 15px; margin: 6px 0 0; max-width: 760px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; color: var(--brand); margin: 0 0 6px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2 .panel { margin-bottom: 18px; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: linear-gradient(120deg, var(--surface) 0%, var(--brand-soft) 140%); border: 1px solid var(--border); border-radius: 14px; padding: 26px 28px; margin-bottom: 18px; }
.hero h1 { font-size: 28px; }
.hero-stats { display: flex; gap: 28px; margin: 0; }
.hero-stats dt { font-size: 12px; color: var(--muted); }
.hero-stats dd { margin: 0; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.project-name { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }

.tile-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tile-list.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; color: var(--ink); background: var(--surface-2); text-decoration: none !important; transition: border-color .15s, background .15s; }
.tile:hover { border-color: var(--brand); background: var(--surface); }
.tile span { color: var(--muted); font-size: 13px; }
.inline-list { list-style: none; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-size: 12px; }

/* Buttons and fields */
.button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.button:hover { border-color: var(--ink-2); }
.button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-hover); }
.button.ghost { border-color: transparent; color: var(--muted); }
.button.small { padding: 4px 9px; font-size: 12px; }
.button.wide { width: 100%; justify-content: center; padding: 11px 14px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; position: sticky; top: 0; z-index: 5; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.field.inline { flex-direction: row; align-items: center; gap: 6px; }
.field select, .field input, .search input, .inline-form input { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 9px; min-height: 34px; }
.search input { min-width: 260px; }
.multi { position: relative; }
.num-input { width: 110px; }
.multi summary { list-style: none; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.multi summary::-webkit-details-marker { display: none; }
.multi summary b { font-weight: 500; color: var(--ink); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 28px 6px 9px; min-height: 34px; min-width: 150px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6e66' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; }
.multi-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px; min-width: 230px; max-height: 300px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); display: flex; flex-direction: column; gap: 2px; }
.multi-menu label { display: flex; gap: 8px; align-items: center; color: var(--ink); font-weight: 500; font-size: 13px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.multi-menu label:hover { background: var(--surface-2); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check-label { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.segmented button, .segmented a { background: var(--surface); border: 0; border-right: 1px solid var(--border); padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; text-decoration: none !important; }
.segmented :last-child { border-right: 0; }
.segmented .on { background: var(--brand-soft); color: var(--brand); }
.switch-form { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px 4px 6px; }
.switch input { appearance: none; width: 30px; height: 18px; border-radius: 999px; background: var(--border-strong); position: relative; margin: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(12px); }
.star { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; vertical-align: 2px; }
.star.on { color: #e0a000; }

/* KPI cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); box-shadow: var(--shadow); text-decoration: none !important; position: relative; }
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--lime); }
.card.clickable { transition: border-color .15s, transform .15s; }
.card.clickable:hover { border-color: var(--brand); transform: translateY(-1px); }
.card-label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.card-value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-note { font-size: 12px; color: var(--warning); background: var(--warning-bg); border-radius: 6px; padding: 2px 7px; align-self: flex-start; }
.card-cta { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--brand); }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.chart-panel { margin: 0 0 18px; }
.chart-panel figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chart { width: 100%; height: 300px; }
.chart-table summary { font-size: 12px; color: var(--muted); cursor: pointer; margin-top: 6px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table.compact td, .table.compact th { padding: 6px 8px; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .check { width: 34px; }
.table.data td { white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 9px; }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { padding-left: 14px; }
.sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; font-weight: 600; }
.sort:hover { color: var(--ink); }
.table-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.export-bar { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.selected-exports { display: inline-flex; gap: 6px; align-items: center; margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--border); }
.table-summary { margin: 4px 0 10px; color: var(--ink-2); }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.context-bar { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 9px; padding: 9px 14px; margin-bottom: 14px; }
.context-bar b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.count { font-size: 18px; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warning { background: var(--warning-bg); color: var(--warning); }
.pill.critical { background: var(--critical-bg); color: var(--critical); }
.pill.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.pill.live { background: var(--brand-soft); color: var(--brand); }
.pill.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: compass 1.6s infinite; }
@keyframes compass { 0% { box-shadow: 0 0 0 0 rgba(21,128,61,.5); } 70% { box-shadow: 0 0 0 7px rgba(21,128,61,0); } 100% { box-shadow: 0 0 0 0 rgba(21,128,61,0); } }
.banner { border-radius: 9px; padding: 10px 14px; margin: 10px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.info { background: var(--info-bg); }
.banner.critical { background: var(--critical-bg); color: var(--critical); }
.export-status { margin-top: 12px; border-radius: 9px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); }
.export-status.ready { border-color: var(--brand); background: var(--brand-soft); }
.export-status.failed { background: var(--critical-bg); color: var(--critical); }
.refresh-status { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; }
.refresh-status.ok { color: var(--good); }
.refresh-status.failed { color: var(--critical); }
.freshness-list { display: flex; flex-direction: column; gap: 10px; }
.freshness-item { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; }
.freshness-item .muted { display: block; font-size: 12px; }
.freshness-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.run-meta { font-size: 11px; margin: 12px 0 0; border-top: 1px solid var(--border); padding-top: 10px; }
.notice { background: var(--warning-bg); color: var(--warning); padding: 10px 12px; border-radius: 8px; }
.error-panel { max-width: 640px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
.htmx-indicator { visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { visibility: visible; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.breakdown-table th.group, .breakdown-table .group-cell { text-align: left; }
.breakdown-table .group-cell { font-weight: 600; color: var(--ink); background: var(--surface-2); vertical-align: top; border-right: 1px solid var(--border); white-space: nowrap; position: static; }
.breakdown-table .subtotal { background: var(--surface-2); color: var(--ink-2); vertical-align: top; border-right: 1px solid var(--border); }
.breakdown-table .bar-col { width: 18%; min-width: 80px; }
.breakdown-table td, .breakdown-table th { padding: 6px 8px; }
.breakdown-table .total-row td, .breakdown-table .total-label { font-weight: 700; border-top: 1px solid var(--border-strong); }
.breakdown-table .total-label { text-align: left; color: var(--ink-2); }
.pivot-table .group-cell { font-weight: 600; background: var(--surface-2); vertical-align: top; border-right: 1px solid var(--border); white-space: nowrap; position: sticky; left: 0; z-index: 1; }
.pivot-table .measure-cell { font-weight: 500; color: var(--ink-2); white-space: nowrap; border-right: 1px solid var(--border); text-align: left; }
.pivot-table td, .pivot-table th { padding: 4px 8px; font-size: 12.5px; }
.pivot-table tr.first-measure td, .pivot-table tr.first-measure th { border-top: 1px solid var(--border-strong); }
.pivot-wrap { max-height: 75vh; }
.pivot-table .total-cell { font-weight: 700; background: var(--surface-2); }
.pivot-table td.traffic.good { background: var(--good-bg); color: var(--good); }
.pivot-table td.traffic.warning { background: var(--warning-bg); color: var(--warning); }
.pivot-table td.traffic.critical { background: var(--critical-bg); color: var(--critical); }
.pivot-table td.traffic a { color: inherit; }
.inline-bar { display: block; height: 12px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.saved-views summary { cursor: pointer; font-weight: 600; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 500px at 10% -10%, var(--brand-soft), transparent), var(--bg); }
.login-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 30px 30px 26px; box-shadow: 0 10px 40px rgba(23,23,23,.08); }
.login-card h1 { display: flex; align-items: center; gap: 8px; font-size: 34px; margin: 14px 0 4px; }
.login-card h1 .compass-mark { width: 32px; height: 32px; }
.login-card .lede { margin-bottom: 22px; }
.fine { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.dev-login { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 14px; }
.dev-login summary { font-size: 12px; font-weight: 700; color: var(--warning); cursor: pointer; }
.dev-login ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.dev-user { width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: var(--ink); }
.dev-user span { color: var(--muted); font-size: 12px; }
.dev-user:hover { border-color: var(--brand); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { flex-direction: row; align-items: center; padding: 0; gap: 10px; }
  .brand-logo { width: 90px; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; overflow-x: auto; }
  .sidebar-foot { display: none; }
  .main { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
  .charts { grid-template-columns: 1fr; }
  .search input { min-width: 0; width: 100%; }
  .export-bar { margin-left: 0; }
  .filters { position: static; }
}
