/* Tidemark — business intelligence (studio demonstration). Light, dense, calm. */
:root {
  --bg: #F6F7F5; --surface: #FFFFFF; --sunk: #F1F3F0; --line: #E3E6E1; --line-2: #D3D8D1;
  --ink: #142019; --ink-2: #4E5A53; --ink-3: #87918B; --brand: #17312A; --brand-2: #DDEFE7;
  --online: #0E8A63; --retail: #4F63D8; --wholesale: #D0622E;
  --good: #137A4C; --good-bg: #E3F3EA; --warn: #9A6200; --warn-bg: #FBF0D9; --bad: #B4381F; --bad-bg: #FBE6E0;
  --font: "Geist", "Segoe UI", system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
#view:focus { outline: none; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 13.5px/1.5 var(--font); font-feature-settings: "tnum", "cv11"; -webkit-font-smoothing: antialiased; }
body.lock { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--online); outline-offset: 2px; }
.app { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 32px); }

/* sidebar */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 10px; border-right: 1px solid var(--line); background: var(--surface); }
.ws { display: flex; align-items: center; gap: 10px; padding: 8px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.ws-logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #DDEFE7; font-weight: 700; }
.ws strong { display: block; font-size: 13.5px; font-weight: 600; } .ws small { color: var(--ink-3); font-size: 11.5px; }
.nav-h { margin: 14px 10px 4px; color: var(--ink-3); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.side nav a:hover { background: var(--sunk); color: var(--ink); }
.side nav a.on { background: var(--brand-2); color: var(--brand); }
.side nav .count { margin-left: auto; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--sunk); font-size: 11px; text-align: center; }
.side-foot { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.side-foot small { display: block; color: var(--ink-3); font-size: 11px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--online); margin-right: 6px; }

/* top + filters */
.main { min-width: 0; padding: 18px clamp(14px, 2.2vw, 30px) 50px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.crumb { margin: 0 0 2px; color: var(--ink-3); font-size: 12px; }
h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.005em; }
.top-acts { display: flex; gap: 8px; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--brand); border-radius: 7px; background: var(--brand); color: #fff; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #0F241E; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: default; }
.filters { position: sticky; top: 0; z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; margin: 0 -8px 12px; background: rgba(246,247,245,.94); backdrop-filter: blur(6px); }
.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.seg button { height: 26px; min-width: 40px; padding: 0 9px; border: 0; border-radius: 6px; background: none; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--brand); color: #fff; }
.chips { display: flex; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink-3); cursor: pointer; font-weight: 500; }
.chip i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); opacity: .3; }
.chip[aria-pressed="true"] { color: var(--ink); } .chip[aria-pressed="true"] i { opacity: 1; }
.sel { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 2px 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--ink-3); font-size: 12px; }
.sel select { height: 28px; border: 0; background: transparent; color: var(--ink); font-weight: 500; cursor: pointer; }
.link { border: 0; background: none; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 12.5px; }
.range { margin: 0 0 0 auto; color: var(--ink-3); font-size: 12px; }
.scope-note { margin: -4px 0 12px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); color: var(--ink-2); font-size: 12.5px; }

/* cards + layout */
.grid { display: grid; gap: 12px; }
.g-6 { grid-template-columns: repeat(6, 1fr); } .g-21 { grid-template-columns: 2fr 1fr; } .g-11 { grid-template-columns: 1fr 1fr; } .g-4 { grid-template-columns: repeat(4, 1fr); }
.card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.card-h p { margin: 2px 0 0; color: var(--ink-3); font-size: 12px; }
.mb { margin-bottom: 12px; }
.kpi { padding: 12px 14px 10px; }
.kpi h3 { margin: 0; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.kpi strong { display: block; margin: 4px 0 1px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.delta { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.delta.up { background: var(--good-bg); color: var(--good); } .delta.down { background: var(--bad-bg); color: var(--bad); } .delta.flat { background: var(--sunk); color: var(--ink-2); }
.vs { margin-left: 4px; color: var(--ink-3); font-size: 11.5px; }
.spark { display: block; width: 100%; height: 26px; margin-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--ink-2); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.legend i.dash { height: 0; border-top: 2px dashed var(--c); background: none; width: 14px; border-radius: 0; }
.chart { position: relative; height: 280px; }
.chart.sm { height: 200px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.axis text { fill: var(--ink-3); font-size: 11px; }
.gridl line { stroke: var(--line); }
.hit { fill: transparent; cursor: crosshair; }

/* insights */
.ins { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ins li { padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--s); border-radius: 8px; }
.ins .tag { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--s); }
.ins h3 { margin: 3px 0 2px; font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.ins p { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.ins button { margin-top: 6px; padding: 0; border: 0; background: none; color: var(--brand); font-weight: 600; font-size: 12.5px; cursor: pointer; }

/* tables */
.tw { overflow-x: auto; margin: 0 -14px -14px; }
table { width: 100%; border-collapse: collapse; }
th { position: sticky; top: 0; padding: 0; background: var(--sunk); border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: 11.5px; font-weight: 600; text-align: left; white-space: nowrap; }
th button, th span.h { display: flex; align-items: center; gap: 4px; width: 100%; height: 32px; padding: 0 12px; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: inherit; }
th.num button, th.num span.h { justify-content: flex-end; }
th[aria-sort] button { color: var(--ink); }
th[aria-sort="ascending"] button::after { content: "↑"; } th[aria-sort="descending"] button::after { content: "↓"; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: #FAFBF9; }
tfoot td { font-weight: 600; background: var(--sunk); border-bottom: 0; }
.muted { color: var(--ink-3); }
.sw { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 2px; background: var(--c); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-bg); color: var(--good); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.neutral { background: var(--sunk); color: var(--ink-2); }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell i { display: block; height: 6px; border-radius: 0 3px 3px 0; background: var(--online); min-width: 2px; }
.tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.search { position: relative; }
.search input { width: 260px; height: 30px; padding: 0 10px 0 30px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.search svg { position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px 0; color: var(--ink-3); font-size: 12px; }
.pager div { display: flex; gap: 6px; }
.pl td:first-child { position: sticky; left: 0; background: var(--surface); min-width: 190px; }
.pl tr.sub td { color: var(--ink-2); } .pl tr.sub td:first-child { padding-left: 26px; }
.pl tr.total td { font-weight: 600; border-top: 1px solid var(--line-2); }
.pl tr.key td { font-weight: 700; background: var(--brand-2); } .pl tr.key td:first-child { background: var(--brand-2); }
.pl tr.ratio td { color: var(--ink-2); font-style: normal; font-size: 12.5px; }
.neg { color: var(--bad); }

/* states */
.sk { position: relative; overflow: hidden; border-radius: 6px; background: var(--sunk); }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: sh 1.1s infinite; }
@keyframes sh { to { transform: translateX(100%); } }
.empty { display: grid; place-items: center; gap: 6px; padding: 40px 16px; text-align: center; color: var(--ink-2); }
.empty svg { width: 36px; height: 36px; stroke: var(--ink-3); fill: none; stroke-width: 1.4; }
.empty strong { color: var(--ink); font-size: 14px; }
.empty .btn { margin-top: 6px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid #F0D4CB; border-radius: 8px; background: var(--bad-bg); color: #7A2716; font-size: 13px; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(520px, 100vw); overflow: auto; padding: 18px 20px 30px; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(20,32,25,.12); transform: translateX(100%); visibility: hidden; transition: transform .3s cubic-bezier(.2,.7,.1,1), visibility .3s; }
.drawer.open { transform: none; visibility: visible; }
.drawer .x { float: right; width: 30px; height: 30px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface); cursor: pointer; font-size: 16px; }
.drawer h2 { font-size: 18px; margin: 4px 0 2px; }
.drawer .dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.drawer .dl div { padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.drawer .dl dt { color: var(--ink-3); font-size: 11.5px; } .drawer .dl dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; }
.drawer section { margin-top: 16px; }
.drawer h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(20,32,25,.25); }

.tip { position: fixed; z-index: 60; pointer-events: none; min-width: 180px; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); box-shadow: 0 10px 30px rgba(20,32,25,.14); font-size: 12px; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); } .tip div span:last-child { color: var(--ink); font-weight: 500; }
.toast { position: fixed; left: 50%; bottom: 20px; z-index: 70; padding: 10px 14px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.saved { display: grid; gap: 8px; }
.saved li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
.saved small { display: block; color: var(--ink-3); }
.form-row { display: flex; gap: 8px; margin-top: 10px; }
.form-row input { flex: 1; height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 7px; }
.foot { margin: 24px 0 0; color: var(--ink-3); font-size: 12px; text-align: center; }

@media (max-width: 1200px) { .g-6 { grid-template-columns: repeat(3, 1fr); } .g-21 { grid-template-columns: 1fr; } .range { flex-basis: 100%; margin: 0; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30; height: auto; flex-direction: row; padding: 4px; border-right: 0; border-top: 1px solid var(--line); }
  .ws, .side-foot, .nav-h { display: none; }
  .side nav { display: flex; width: 100%; justify-content: space-around; }
  .side nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; text-align: center; }
  .side nav a .count { display: none; }
  .main { padding-bottom: 90px; }
  .g-11, .g-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .g-6, .g-11 { grid-template-columns: 1fr 1fr; } .g-4 { grid-template-columns: 1fr 1fr; }
  .g-11.stack { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; } .top-acts { width: 100%; } .top-acts .btn { flex: 1; justify-content: center; }
  .seg { width: 100%; } .seg button { flex: 1; }
  .chips { width: 100%; } .chip { flex: 1; justify-content: center; padding: 0 4px; }
  .sel { flex: 1; } .sel select { width: 100%; }
  .chart { height: 220px; }
  .search, .search input { width: 100%; }
  .kpi strong { font-size: 19px; }
  .drawer .dl { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
