:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #11182a;
  --surface-2: #171f34;
  --border: #28324a;
  --text: #eef2ff;
  --muted: #8e99b4;
  --accent: #9b87f5;
  --blue: #54a6ff;
  --green: #43d39e;
  --amber: #f3b75f;
  --red: #ff7082;
  --shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 80% -20%, rgba(112, 91, 208, .12), transparent 34%), var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
button, input { font: inherit; }
button { color: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; background: rgba(11, 16, 32, .94); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.brand { min-height: 78px; padding: 14px clamp(16px, 3vw, 42px) 10px; display: flex; align-items: center; gap: 14px; }
.logo { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(145deg, #8670ef, #5b50c8); color: white; text-decoration: none; font-size: 25px; box-shadow: 0 8px 24px rgba(116, 93, 222, .3); }
.brand-copy { min-width: 0; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.brand-copy p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.prototype-tag { padding: 3px 8px; border: 1px solid rgba(243, 183, 95, .35); border-radius: 999px; background: rgba(243, 183, 95, .1); color: #ffd28a; font-size: 11px; font-weight: 700; }
.brand-actions { margin-left: auto; display: flex; gap: 8px; }
.brand-actions button { min-height: 38px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.quiet-action, .refresh-action { padding: 0 13px; }
.icon-action { width: 40px; }
.refresh-action { background: #6f5fd6 !important; border-color: #6f5fd6 !important; }
.tabs { padding: 0 clamp(16px, 3vw, 42px); display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar, .filter-scroll::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 44px; padding: 0 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button.active { color: var(--text); border-color: var(--accent); }

.filters { border-bottom: 1px solid var(--border); background: rgba(17, 24, 42, .7); }
.filter-scroll { min-height: 67px; padding: 11px clamp(16px, 3vw, 42px); display: flex; align-items: center; gap: 9px; overflow-x: auto; scrollbar-width: none; }
.seg { display: flex; flex: none; border: 1px solid var(--border); border-radius: 9px; padding: 2px; background: #0d1425; }
.seg button { min-width: 44px; height: 36px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px #35405b; }
.date-filter { flex: none; min-height: 42px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; background: #0d1425; }
.date-filter span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.date-filter strong { font-size: 12px; white-space: nowrap; }
.dropdown-filter, .reset-filter { flex: none; min-height: 42px; padding: 0 11px; border: 1px solid var(--border); border-radius: 8px; background: #0d1425; color: var(--muted); cursor: pointer; }
.dropdown-filter strong { margin-left: 5px; color: var(--text); }.dropdown-filter span { margin-left: 10px; }.reset-filter { border-color: transparent; background: transparent; }

.view { max-width: 1560px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 42px) 40px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { min-height: 118px; padding: 17px 18px; border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(145deg, rgba(23, 31, 52, .9), rgba(17, 24, 42, .9)); box-shadow: var(--shadow); }
.kpi > span { display: block; color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.kpi strong { display: block; margin: 8px 0 3px; font-size: 30px; letter-spacing: -.04em; }
.kpi small { color: var(--muted); }.kpi-alert { border-color: rgba(255, 112, 130, .35); background: linear-gradient(145deg, rgba(74, 29, 47, .48), rgba(17, 24, 42, .9)); }.kpi-alert strong { color: #ff93a2; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel { min-width: 0; min-height: 330px; padding: 19px; border: 1px solid var(--border); border-radius: 12px; background: rgba(17, 24, 42, .92); box-shadow: var(--shadow); }
.panel.wide { grid-column: 1 / -1; }.trend-panel { min-height: 360px; }
.panel-head, .reports-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }.panel p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.legend { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; white-space: nowrap; }.legend span { display: flex; align-items: center; gap: 6px; }.legend strong { color: var(--text); font-size: 13px; }.dot { width: 8px; height: 8px; border-radius: 50%; }.purple { background: var(--accent); }.blue { background: var(--blue); }.muted-dot { background: #56617a; }

.line-chart { position: relative; height: 260px; padding: 0 8px 26px 39px; }.line-chart svg { width: 100%; height: 215px; overflow: visible; }.grid-lines line { stroke: #26314a; stroke-width: 1; }.area { fill: url(#none); fill: rgba(155, 135, 245, .12); }.line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }.y-labels { position: absolute; left: 0; top: -2px; bottom: 47px; display: flex; flex-direction: column; justify-content: space-between; color: #69758f; font-size: 10px; }.x-labels { display: flex; justify-content: space-between; color: #69758f; font-size: 10px; }

.h-bars { display: grid; gap: 17px; padding-top: 3px; }.h-bars div { display: grid; grid-template-columns: minmax(145px, 36%) 1fr 34px; align-items: center; gap: 10px; }.h-bars span { color: #cbd3e8; font-size: 12px; }.h-bars i { position: relative; height: 10px; border-radius: 999px; background: #222c43; overflow: hidden; }.h-bars i::after { content: ""; display: block; width: var(--w); height: 100%; border-radius: inherit; background: linear-gradient(90deg, #7869d9, #aa94ff); }.h-bars strong { text-align: right; font-size: 12px; }

.column-chart { height: 238px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-end; padding: 5px 18px 0; }.columns { width: 100%; height: 100%; display: flex; justify-content: space-around; align-items: flex-end; }.columns > div { width: 25%; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 5px; padding-bottom: 42px; }.columns span { width: 22%; height: var(--h); border-radius: 6px 6px 0 0; }.columns .previous { background: #36415b; }.columns .current { background: linear-gradient(#68b5ff, #408ee5); }.columns strong { position: absolute; bottom: 19px; font-size: 12px; }.columns small { position: absolute; bottom: 1px; color: var(--muted); }

.donut-wrap { min-height: 235px; display: flex; align-items: center; justify-content: center; gap: clamp(28px, 6vw, 70px); }.donut { width: 176px; height: 176px; flex: none; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#9b87f5 0 48%, #54a6ff 48% 79%, #43d39e 79% 95%, #f3b75f 95%); }.donut::before { content: ""; grid-area: 1/1; width: 112px; height: 112px; border-radius: 50%; background: var(--surface); }.donut > div { grid-area: 1/1; z-index: 1; text-align: center; }.donut strong { display: block; font-size: 24px; }.donut span { color: var(--muted); font-size: 11px; }.source-legend { min-width: 190px; display: grid; gap: 15px; }.source-legend div { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px; }.source-legend i { width: 9px; height: 9px; border-radius: 3px; }.source-legend span { color: #cbd3e8; font-size: 12px; }.source-legend strong { font-size: 12px; }.source-one { background: #9b87f5; }.source-two { background: #54a6ff; }.source-three { background: #43d39e; }.source-four { background: #f3b75f; }

.age-cutoff { flex: none; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }.age-cutoff label { display: flex; align-items: center; height: 42px; border: 1px solid var(--border); border-radius: 8px; background: #0d1425; overflow: hidden; }.age-cutoff input { width: 52px; height: 100%; border: 0; border-right: 1px solid var(--border); background: transparent; color: var(--text); text-align: center; outline: none; }.age-cutoff label span { padding: 0 10px; }.age-summary { height: 190px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 14px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); }.age-summary > div { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }.age-summary strong { font-size: 18px; }.age-summary span { color: var(--muted); font-size: 11px; }.age-summary i { width: min(78px, 64%); border-radius: 7px 7px 0 0; }.fresh-bar { height: 38%; background: #46536e; }.stale-bar { height: 70%; background: linear-gradient(#f5c06d, #d89736); }.critical-bar { height: 94%; background: linear-gradient(#ff8290, #d64b62); }.panel-note { margin-top: 14px !important; }

.reports-panel { min-height: 440px; }.reports-head { align-items: center; }.reports-head > div { max-width: 820px; }.row-count { flex: none; padding: 6px 9px; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 12px; }.table-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 13px; flex-wrap: wrap; }.search-control { flex: 1 1 320px; }.search-control input { width: 100%; min-height: 44px; padding: 0 13px; border: 1px solid var(--border); border-radius: 8px; background: #0d1425; color: var(--text); outline: none; }.search-control input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(155, 135, 245, .13); }.chip { min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: #121a2c; color: #bac4dc; cursor: pointer; }.chip[aria-pressed="true"] { border-color: rgba(255, 112, 130, .55); background: rgba(255, 112, 130, .12); color: #ff9eaa; }.chip.passive { opacity: .72; cursor: default; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 9px; }.joint-table { width: 100%; min-width: 1160px; border-collapse: collapse; font-size: 12px; }.joint-table th { position: sticky; top: 0; padding: 11px 12px; background: #171f34; color: #96a2bb; text-align: left; text-transform: uppercase; letter-spacing: .045em; font-size: 10px; white-space: nowrap; }.joint-table td { padding: 13px 12px; border-top: 1px solid var(--border); vertical-align: top; color: #d8def0; }.joint-table tbody tr:hover { background: rgba(155, 135, 245, .045); }.joint-table .stale-row { background: rgba(243, 183, 95, .035); }.category-detail { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; }.task-age { display: inline-flex; align-items: center; min-width: 49px; font-weight: 750; }.task-age.is-stale { color: #ffc66d; }.a-task-cell { display: flex; align-items: center; gap: 7px; }.badge { display: inline-flex; padding: 2px 6px; border-radius: 999px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }.badge-stale { background: rgba(243, 183, 95, .13); color: #ffc66d; }.badge-open { background: rgba(84, 166, 255, .12); color: #7cbcff; }.task-link, .crm-link { display: inline-flex; min-height: 28px; align-items: center; color: #a994ff; text-decoration: none; font-weight: 650; white-space: nowrap; }.crm-link { color: #66b4ff; }.task-link:hover, .crm-link:hover { text-decoration: underline; }.muted { color: #66718a; }.empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 9px; }
.prescription-list { display: grid; gap: 4px; min-width: 150px; }.prescription-item { display: block; line-height: 1.35; }.prescription-item + .prescription-item { padding-top: 4px; border-top: 1px solid rgba(40, 50, 74, .72); }.prescription-count { width: fit-content; padding: 2px 6px; border-radius: 999px; background: rgba(155, 135, 245, .12); color: #b6a7ff; font-size: 9px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }

.foot { padding: 18px clamp(16px, 3vw, 42px) 82px; border-top: 1px solid var(--border); color: #707c96; text-align: center; font-size: 11px; }.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; width: min(680px, calc(100% - 32px)); padding: 13px 16px; border: 1px solid #4e5d80; border-radius: 10px; background: #1d2740; color: var(--text); box-shadow: 0 16px 48px rgba(0,0,0,.45); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s ease; overflow-wrap: anywhere; }.toast.show { opacity: 1; transform: translate(-50%, 0); }.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }.panel.wide { grid-column: 1; }
  .brand-actions .quiet-action, .brand-actions .icon-action { display: none; }
}

@media (max-width: 720px) {
  .brand { min-height: 70px; padding: 11px 16px 8px; }.logo { width: 40px; height: 40px; }.brand-copy p { display: none; }.title-row { gap: 6px; }.prototype-tag { width: fit-content; }.brand-actions button { min-height: 44px; }.refresh-action { width: 44px; padding: 0; font-size: 0; }.refresh-action span { font-size: 19px; }
  .tabs { padding: 0 10px; }.tabs button { min-height: 46px; padding: 0 12px; }
  .filter-scroll { padding: 9px 12px; }.seg button, .dropdown-filter, .reset-filter { min-height: 44px; }.date-filter { min-height: 44px; }
  .view { padding: 14px 12px 30px; }.kpis { gap: 9px; margin-bottom: 9px; }.kpi { min-height: 105px; padding: 14px; }.kpi strong { font-size: 25px; }
  .chart-grid { gap: 9px; }.panel { min-height: 300px; padding: 15px; border-radius: 10px; }.trend-panel { min-height: 330px; }.panel-head { flex-direction: column; }.legend { white-space: normal; }.line-chart { padding-left: 31px; }
  .donut-wrap { gap: 24px; }.donut { width: 140px; height: 140px; }.donut::before { width: 88px; height: 88px; }.source-legend { min-width: 0; }
  .age-cutoff { width: 100%; justify-content: space-between; }.age-cutoff label { height: 46px; }.age-cutoff input { min-height: 44px; }.reports-head { align-items: flex-start; flex-direction: column; }.table-controls { align-items: stretch; }.search-control { flex-basis: 100%; }.chip { flex: 1 1 auto; }
  .table-wrap { overflow: visible; border: 0; }.joint-table { min-width: 0; display: block; }.joint-table thead { display: none; }.joint-table tbody { display: grid; gap: 9px; }.joint-table tr { display: grid; grid-template-columns: 1fr; border: 1px solid var(--border); border-radius: 9px; background: #10182a; overflow: hidden; }.joint-table td { min-width: 0; grid-column: 1; padding: 10px 11px 10px 40%; position: relative; border: 0; border-bottom: 1px solid rgba(40,50,74,.72); overflow-wrap: anywhere; }.joint-table td::before { content: attr(data-label); position: absolute; left: 11px; width: calc(40% - 18px); color: #78849d; font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }.joint-table td:last-child { border-bottom: 0; }.task-link, .crm-link { min-height: 44px; }
  .foot { padding-bottom: 30px; }
}

@media (max-width: 450px) {
  h1 { font-size: 18px; }.prototype-tag { font-size: 9px; }.kpis { grid-template-columns: 1fr 1fr; }.kpi { min-height: 112px; }.kpi > span { min-height: 28px; }.kpi small { font-size: 10px; }.h-bars div { grid-template-columns: 124px 1fr 30px; }.donut-wrap { align-items: flex-start; gap: 16px; }.source-legend div { grid-template-columns: 8px 1fr auto; gap: 6px; }.source-legend span { font-size: 10px; }.age-summary { padding-left: 0; padding-right: 0; }.joint-table tr { grid-template-columns: 1fr 1fr; }
}
