/* ==========================================================================
   Insight Analytics — D2C sales dashboard demo
   Palette "Midnight Violet": deep indigo rail, lavender-grey canvas,
   violet / teal / saffron / rose / sky data colours.
   Type: Sora (interface) + IBM Plex Mono (figures)
   1. Tokens  2. Base  3. Layout  4. Sidebar  5. Top bar  6. Primitives
   7. KPIs  8. Cards & charts  9. Table  10. Regions & notes  11. Overlays
   12. Responsive
   ========================================================================== */

/* ------------------------------ 1. Tokens ------------------------------ */
:root {
  --bg: #F3F2F8;
  --surface: #FFFFFF;
  --surface-2: #F8F7FC;
  --ink: #17162B;
  --muted: #5C5975;
  --faint: #7D7A96;
  --line: #E5E3EF;
  --line-2: #EFEDF5;

  --rail: #17153A;
  --rail-2: #221F4F;
  --rail-ink: #C4C0EC;
  --rail-dim: #9A95CF;

  --violet: #5B4BF0;
  --violet-ink: #4535D6;
  --violet-soft: #ECEAFE;
  --teal: #12A196;
  --saffron: #E89A1E;
  --rose: #E0457B;
  --sky: #3593E6;
  --slate: #8E8AA8;

  --up: #0B7A53;
  --up-bg: #E2F4EB;
  --down: #B3363A;
  --down-bg: #FBE8E8;

  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 22, 43, .04), 0 10px 30px -18px rgba(23, 22, 43, .22);
  --sans: 'Sora', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --side-w: 248px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* ------------------------------- 2. Base ------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--violet); color: #fff; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.skip:focus { top: 12px; }

/* ------------------------------ 3. Layout ------------------------------ */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 8px 28px 40px; outline: none; }
.sec { scroll-margin-top: 92px; }

/* ------------------------------ 4. Sidebar ----------------------------- */
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px 18px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(91, 75, 240, .32), transparent 60%),
    var(--rail);
  color: var(--rail-ink);
  overflow-y: auto;
}
.side__brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.logo { display: inline-flex; }
.side__name { font-weight: 700; font-size: 18px; color: #fff; letter-spacing: -.02em; line-height: 1.1; display: flex; flex-direction: column; }
.side__name small { font-weight: 500; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--rail-dim); }

.side__store { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); }
.store__av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #17153A; background: linear-gradient(135deg, #F7C873, #E89A1E); }
.store__txt { display: flex; flex-direction: column; min-width: 0; }
.store__txt strong { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store__txt small { font-size: 11.5px; color: var(--rail-dim); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__label { font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--rail-dim); padding: 0 10px 6px; }
.nav__link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; font-weight: 500; font-size: 13.5px; color: var(--rail-ink); transition: background .2s, color .2s; }
.nav__link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav__link.is-active { background: var(--violet); color: #fff; box-shadow: 0 8px 20px -10px rgba(91, 75, 240, .9); }
.nav__link:focus-visible { outline-color: #fff; }

.side__panel { margin-top: auto; padding: 14px; border-radius: 14px; background: var(--rail-2); border: 1px solid rgba(255, 255, 255, .07); }
.side__panel-title { font-size: 12px; font-weight: 600; color: #fff; margin-bottom: 8px; }
.sources li { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; color: var(--rail-ink); }
.sources i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.sources em { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 10.5px; color: var(--rail-dim); }
.side__panel-note { font-size: 11.5px; line-height: 1.5; color: var(--rail-dim); margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side__foot { padding: 0 6px; font-size: 11.5px; color: var(--rail-dim); }

/* ------------------------------ 5. Top bar ----------------------------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 28px;
  background: rgba(243, 242, 248, .86);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top__head { min-width: 0; }
.top__crumb { font-size: 12px; color: var(--muted); }
.top__crumb span { margin: 0 4px; color: var(--faint); }
.top__title { font-size: 22px; font-weight: 700; letter-spacing: -.03em; line-height: 1.2; }
.demo-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; color: #6A4A06;
  background: #FFF1D6; border: 1px solid #F3D59A;
}
.demo-badge__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--saffron); box-shadow: 0 0 0 3px rgba(232, 154, 30, .22); }
.top__tools { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.me { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--violet), var(--rose)); }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.seg__btn { border: 0; background: none; padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s; }
.seg__btn:hover { color: var(--ink); }
.seg__btn[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------------------------- 6. Primitives ---------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 11px; padding: 9px 14px; font-size: 13px; font-weight: 600; transition: background .2s, border-color .2s, transform .2s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn--sm { padding: 7px 12px; font-size: 12.5px; }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: #CFCBE3; }
.btn--primary { background: var(--violet); color: #fff; }
.btn--primary:hover { background: var(--violet-ink); }
.btn--soft { background: var(--violet-soft); color: var(--violet-ink); }
.btn--soft:hover { background: #E0DCFD; }
.btn .ico { width: 16px; height: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 500; color: var(--muted); transition: border-color .2s, background .2s, color .2s; }
.chip:hover { color: var(--ink); border-color: #CFCBE3; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--slate)); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip--star .ico { width: 15px; height: 15px; }
.chip--star[aria-pressed="true"] { background: #FFF1D6; border-color: #F3D59A; color: #6A4A06; }
.chip--star[aria-pressed="true"] .ico { fill: var(--saffron); stroke: var(--saffron); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 999px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.delta--up { color: var(--up); background: var(--up-bg); }
.delta--down { color: var(--down); background: var(--down-bg); }
.delta--flat { color: var(--muted); background: var(--line-2); }

.select, .field input, .search input, .target__form input {
  height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 11px; font-size: 13px;
}
.select { padding-right: 30px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%235C5975' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
.select:focus, .field input:focus, .search input:focus, .target__form input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(91, 75, 240, .18); }
.field-err { color: var(--down); font-size: 12px; min-height: 0; }
.field-err:empty { display: none; }
input[aria-invalid="true"] { border-color: var(--down) !important; }

/* ------------------------------- 7. KPIs ------------------------------- */
.filterbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 0 14px; }
.period { font-size: 13px; font-weight: 600; }
.period__vs { font-weight: 400; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; padding: 16px 18px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c); }
.kpi__label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi__value { font-size: 28px; font-weight: 700; letter-spacing: -.035em; font-variant-numeric: tabular-nums; margin: 6px 0 6px; line-height: 1.15; }
.kpi__foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.kpi__spark { position: absolute; right: 14px; top: 16px; width: 92px; height: 34px; }

/* -------------------------- 8. Cards & charts -------------------------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card { min-width: 0; padding: 18px 20px 20px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.card--rev, .card--wide { grid-column: span 2; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card__title { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.card__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend--sm { justify-content: center; margin-top: 6px; }
.lg { display: inline-block; width: 18px; height: 3px; border-radius: 3px; }
.lg--cur { background: var(--violet); }
.lg--prev { background: repeating-linear-gradient(90deg, #B6B2CC 0 4px, transparent 4px 7px); }
.lg--note { width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); background: var(--saffron); }
.lg--bar { width: 10px; height: 10px; border-radius: 3px; background: var(--violet); }
.lg--ghost { width: 10px; height: 10px; border-radius: 3px; background: #E3E0F0; }

.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart--line { min-height: 290px; }
.chart--line svg { touch-action: pan-y; }
.chart--line svg:focus-visible { outline-offset: 4px; }
.chart--bars { min-height: 262px; }
.chart .grid-line { stroke: var(--line-2); stroke-width: 1; }
.chart .axis { font-family: var(--mono); font-size: 10.5px; fill: var(--faint); }
.chart .axis--x { font-family: var(--sans); }
.chart .line-cur { fill: none; stroke: var(--violet); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-prev { fill: none; stroke: #B6B2CC; stroke-width: 1.8; stroke-dasharray: 5 4; }
.chart .note-line { stroke: var(--saffron); stroke-width: 1.2; stroke-dasharray: 3 3; }
.chart .note-mark { fill: var(--saffron); stroke: #fff; stroke-width: 2; }
.chart .xh-line { stroke: var(--ink); stroke-opacity: .25; stroke-width: 1; }
.chart .xh-cur { fill: var(--violet); stroke: #fff; stroke-width: 2.5; }
.chart .xh-prev { fill: #fff; stroke: #9C97B8; stroke-width: 2; }

.bar { cursor: pointer; outline: none; }
.bar__ghost { fill: #E9E7F3; }
.bar__val { font-family: var(--mono); font-size: 10.5px; font-weight: 600; fill: var(--ink); }
.bar__name { font-size: 10.5px; fill: var(--muted); }
.bar.is-dim .bar__cur, .bar.is-dim .bar__val { opacity: .28; }
.bar:hover .bar__cur, .bar:focus .bar__cur { filter: brightness(1.08); }
.bar:focus-visible .bar__hit { stroke: var(--violet); stroke-width: 2; rx: 8px; }
.bar.is-sel .bar__name { fill: var(--ink); font-weight: 700; }

@media (prefers-reduced-motion: no-preference) {
  .bar__cur { transform-box: fill-box; transform-origin: 50% 100%; animation: grow .55s var(--ease) both; }
  .slice { transition: transform .2s var(--ease); }
}
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.chart--donut { width: 196px; height: 196px; }
.slice { cursor: pointer; transform-box: view-box; transform-origin: 50% 50%; stroke: #fff; stroke-width: 2; outline: none; }
.slice:hover, .slice:focus { transform: scale(1.04); }
.slice:focus-visible { stroke: var(--ink); }
.donut-total { font-size: 20px; font-weight: 700; letter-spacing: -.03em; fill: var(--ink); }
.donut-lbl { font-size: 10.5px; fill: var(--muted); }
.cat-list { width: 100%; display: grid; gap: 7px; }
.cat-list li { display: grid; grid-template-columns: 10px 1fr auto 46px; align-items: center; gap: 9px; font-size: 12.5px; }
.cat-list i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.cat-list b { font-family: var(--mono); font-weight: 500; font-size: 12px; }
.cat-list em { font-style: normal; text-align: right; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

/* Target */
.target { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.ring { width: 132px; height: 132px; flex: none; }
.ring__track { fill: none; stroke: var(--line-2); stroke-width: 12; }
.ring__val { fill: none; stroke: url(#ringGrad); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease); }
.ring__pct { font-size: 26px; font-weight: 700; letter-spacing: -.04em; fill: var(--ink); }
.ring__lbl { font-size: 10.5px; fill: var(--muted); }
.target__stats { display: grid; gap: 10px; min-width: 0; }
.target__stats dt { font-size: 11.5px; color: var(--muted); }
.target__stats dd { margin: 1px 0 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.target__stats dd small { font-family: var(--sans); font-size: 11.5px; font-weight: 500; }
.target__form { border-top: 1px solid var(--line-2); padding-top: 14px; display: grid; gap: 7px; }
.target__form label { font-size: 12px; font-weight: 500; color: var(--muted); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; font-family: var(--mono); }

/* ------------------------------- 9. Table ------------------------------ */
.card__head--tools { align-items: center; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { position: relative; display: inline-flex; align-items: center; }
.search .ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 32px; width: 210px; }
.table-wrap { position: relative; overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 0 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; }
.table td.num { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.table tfoot td { font-weight: 600; border-bottom: 0; padding-top: 12px; color: var(--ink); }
.sort { border: 0; background: none; padding: 2px 0; font-size: inherit; font-weight: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort::after { content: ""; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor; opacity: .25; }
.sort:hover { color: var(--ink); }
[aria-sort="ascending"] .sort, [aria-sort="descending"] .sort { color: var(--violet-ink); }
[aria-sort="ascending"] .sort::after { border-top: 0; border-bottom: 5px solid currentColor; opacity: 1; }
[aria-sort="descending"] .sort::after { opacity: 1; }
.col-star { width: 34px; }
.star { border: 0; background: none; padding: 4px; border-radius: 8px; color: #BDB9D3; display: inline-flex; }
.star:hover { color: var(--saffron); }
.star[aria-pressed="true"] { color: var(--saffron); }
.star[aria-pressed="true"] .ico { fill: var(--saffron); }
.prod { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.prod__sw { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff; background: var(--c); }
.prod__name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.prod__sku { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }
.prod__cat { font-family: var(--sans); color: var(--muted); margin-left: 6px; display: inline-flex; align-items: center; gap: 5px; }
.prod__cat i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.share-bar { display: inline-block; vertical-align: middle; width: 32px; height: 5px; border-radius: 5px; background: var(--line-2); margin-left: 8px; overflow: hidden; }
.share-bar span { display: block; height: 100%; background: var(--violet); border-radius: 5px; }
.empty { padding: 28px 0 8px; text-align: center; color: var(--muted); }
.table-more { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.table-more [hidden] { display: none; }

/* ------------------------- 10. Regions & notes ------------------------- */
.regions { display: grid; gap: 11px; }
.reg { display: grid; grid-template-columns: minmax(0, 1fr) auto 74px; align-items: center; column-gap: 10px; row-gap: 5px; font-size: 13px; }
.reg .delta { justify-self: end; }
.reg__name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reg__rank { font-family: var(--mono); font-size: 11px; color: var(--faint); width: 16px; flex: none; }
.reg__val { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.reg__val small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.reg__bar { grid-column: 1 / -1; display: block; height: 6px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.reg__bar span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--violet), #8F84FF); transition: width .6s var(--ease); }

.notes { display: grid; gap: 8px; margin-bottom: 14px; }
.note { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 10px 11px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-2); }
.note__mark { width: 9px; height: 9px; margin-top: 5px; border-radius: 2px; transform: rotate(45deg); background: var(--saffron); }
.note.is-out .note__mark { background: #CFCBE3; }
.note__date { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.note__text { font-size: 13px; line-height: 1.4; }
.note__del { border: 0; background: none; padding: 4px; border-radius: 8px; color: var(--faint); display: inline-flex; }
.note__del:hover { color: var(--down); background: var(--down-bg); }
.note__del .ico { width: 15px; height: 15px; }
.note-form { display: grid; gap: 10px; border-top: 1px solid var(--line-2); padding-top: 14px; }
.note-form .btn { justify-self: start; }
.note-form__row { display: flex; gap: 8px; flex-wrap: wrap; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field--grow { flex: 1 1 160px; }
.field input { width: 100%; }
.field input[type="date"] { font-family: var(--mono); font-size: 12.5px; }

.mob-credit { display: none; }

/* ----------------------------- 11. Overlays ---------------------------- */
.tip {
  position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none;
  min-width: 170px; max-width: 260px; padding: 10px 12px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 12px; line-height: 1.45;
  box-shadow: 0 16px 36px -12px rgba(23, 22, 43, .5);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s;
}
.tip.is-on { opacity: 1; transform: none; }
.tip__t { font-weight: 600; margin-bottom: 5px; color: #fff; }
.tip__row { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #CFCBE8; }
.tip__row b { font-family: var(--mono); font-weight: 600; color: #fff; }
.tip__row i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.tip__note { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .14); color: #FCD9A0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 70;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 11px 16px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: 0 16px 36px -12px rgba(23, 22, 43, .5); transition: opacity .25s, transform .25s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------- 12. Responsive --------------------------- */
@media (max-width: 1280px) {
  .search input { width: 170px; }
}
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card--rev, .card--wide { grid-column: span 2; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --side-w: 0px; }
  .app { display: block; }
  body { padding-bottom: 74px; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 40;
    height: auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    flex-direction: row; overflow: visible;
    background: var(--rail); box-shadow: 0 -10px 30px -12px rgba(23, 21, 58, .5);
  }
  .side__brand, .side__store, .side__panel, .side__foot, .nav__label, .nav__link--desk { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 4px; }
  .nav__link { flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 10.5px; text-align: center; min-width: 0; }
  .nav__link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .nav__link.is-active { box-shadow: none; }
  .top { padding: 12px 16px; gap: 10px; }
  .top__title { font-size: 19px; }
  .top__tools { margin-left: 0; width: 100%; }
  .content { padding: 4px 16px 28px; }
  .sec { scroll-margin-top: 150px; }
  .mob-credit { display: block; text-align: center; font-size: 12px; color: var(--muted); margin-top: 22px; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card--rev, .card--wide { grid-column: auto; }
  .card { padding: 16px 16px 18px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px 14px 12px; }
  .kpi__value { font-size: 21px; }
  .kpi__spark { display: none; }
  .kpi__foot span:last-child { display: none; }
  .hide-sm { display: none; }
  .top { position: relative; }
  .sec { scroll-margin-top: 12px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; position: relative; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .prod { min-width: 0; }
  .prod__sw { display: none; }
  .prod__cat { display: none; }
  .tools { width: 100%; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .chart--line { min-height: 220px; }
  .target { flex-direction: column; align-items: flex-start; }
  .me { display: none; }
  .btn--ghost span { display: none; }
  .btn--ghost::after { content: "Reset"; }
  .seg { flex: 1; }
  .seg__btn { flex: 1; padding: 7px 6px; }
}
@media (max-width: 1000px) and (min-width: 641px) {
  .hide-md { display: none; }
}
@media (max-width: 640px) {
  .hide-md { display: none; }
}
@media (min-width: 1600px) {
  .content { padding-left: 36px; padding-right: 36px; }
  .kpi__value { font-size: 30px; }
}
