/* ==========================================================================
   Orva — sales dashboard. Demo project.
   Cream paper, ink, one violet accent. No build step, no dependencies.
   ========================================================================== */

/* Tokens */
:root {
  color-scheme: light;
  --page: #F1ECE3;
  --panel: #FBF8F2;
  --panel-soft: #F5F0E6;
  --ink: #0C0C0B;
  --ink-soft: #2B2925;
  --muted: #5F594E;
  --line: rgba(12, 12, 11, .14);
  --line-strong: rgba(12, 12, 11, .26);

  --accent: #5B21B6;
  --accent-hover: #4C1D95;
  --accent-soft: rgba(91, 33, 182, .08);
  --accent-line: rgba(91, 33, 182, .28);
  --accent-ring: rgba(91, 33, 182, .4);

  --danger: #B42318;
  --danger-soft: rgba(180, 35, 24, .08);
  --ok: #0C6B4B;
  --ok-soft: rgba(12, 107, 75, .09);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;

  --shadow-sm: 0 1px 2px rgba(12, 12, 11, .04);
  --shadow-md: 0 18px 44px -28px rgba(12, 12, 11, .3);

  --font: 'Onest', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dur: 200ms;

  --rail: 224px;
  --pad: clamp(20px, 2.6vw, 40px);
}

/* Base */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(70% 46% at 78% -8%, rgba(255, 255, 255, .55), transparent 70%);
}

h1, h2, h3, p, ul, ol, dl, dd, dt, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

::selection { background: var(--accent); color: var(--panel); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 500;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--page);
  font-size: 13px;
  transform: translateY(-180%);
  transition: transform .2s var(--ease);
}

.skip:focus { transform: none; }

.screen[hidden],
.badge[hidden],
.notice[hidden],
.modal[hidden],
.period__custom[hidden],
.gate[hidden],
.chart__tip[hidden],
.table-empty[hidden],
.modal__error[hidden] { display: none; }

/* Shell */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  min-height: 100vh;
}

/* Rail */
.rail {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 26px 18px 22px;
  border-right: 1px solid var(--line);
  background: var(--page);
}

.rail__brand {
  padding: 0 10px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1;
}

.rail__brand span { color: var(--accent); }

.rail__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail__link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.rail__link svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .9;
}

.rail__link:hover { background: rgba(12, 12, 11, .055); }
.rail__link:active { background: rgba(12, 12, 11, .09); }

.rail__link.is-active {
  background: var(--ink);
  color: var(--panel);
}

.rail__source {
  margin-top: auto;
  padding: 14px 12px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(251, 248, 242, .72);
}

.rail__eyebrow {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.rail__file {
  margin-top: 9px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rail__rows {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.rail__source .btn {
  width: 100%;
  margin-top: 12px;
}

.rail__note {
  padding: 0 10px;
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Work area */
.work {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px var(--pad) 16px;
}

.work__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.work__eyebrow {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.work__title {
  margin-top: 8px;
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.05;
}

.work__sub {
  margin-top: 6px;
  max-width: 54ch;
  font-size: 14px;
  color: var(--muted);
}

.work__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.work__main {
  flex: 1;
  padding: 20px 0 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease),
    color .2s var(--ease), transform .2s var(--ease);
}

.btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn:active { transform: translateY(1px); }

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn--ink {
  background: var(--ink);
  color: var(--panel);
}

.btn--ink:hover:not(:disabled) { background: var(--ink-soft); }

.btn--ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink-soft);
}

.btn--ghost:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(12, 12, 11, .05);
}

.btn--small {
  height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12px;
}

/* Fields */
.input,
.select {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}

.input:hover,
.select:hover { border-color: var(--line-strong); }

.input:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 1px;
  border-color: var(--accent);
}

.input::placeholder {
  color: var(--muted);
  opacity: .85;
}

.select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%235F594E' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px auto;
}

.period {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body.is-empty .period {
  display: none;
}

.period__custom {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.period__field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.input--date {
  width: 138px;
  padding: 0 9px;
  font-family: var(--mono);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.back {
  padding: 8px 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--muted);
  transition: color .2s var(--ease);
}

.back:hover { color: var(--ink); }

/* Notice */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--panel);
  font-size: 13px;
}

.notice__text {
  color: var(--ink-soft);
  line-height: 1.45;
}

.notice__close {
  width: 24px;
  height: 24px;
  flex: none;
  margin-left: auto;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  transition: background-color .2s, color .2s;
}

.notice__close:hover {
  background: rgba(12, 12, 11, .06);
  color: var(--ink);
}

.notice--error { border-left-color: var(--danger); }
.notice--error .notice__text { color: var(--danger); }
.notice--ok { border-left-color: var(--ok); }

/* Screens */
.screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: screen-in .26s var(--ease) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpis--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi {
  display: flex;
  flex-direction: column;
  min-height: 152px;
  padding: 18px 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.kpi__label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi__value {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: clamp(20px, 2vw, 27px);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.kpi__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.delta--up { color: var(--ok); background: var(--ok-soft); }
.delta--down { color: var(--danger); background: var(--danger-soft); }
.delta--flat { color: var(--muted); background: rgba(12, 12, 11, .05); }

.kpi__spark {
  height: 50px;
  margin-top: auto;
  padding-top: 14px;
}

.sparkline {
  width: 100%;
  height: 36px;
  overflow: visible;
}

.sparkline__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline__area {
  fill: var(--accent);
  opacity: .09;
}

/* Panels */
.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.panel--table { padding: 0; }

.panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel--table > .panel__head {
  margin-bottom: 14px;
  padding: 18px 18px 0;
}

.panel__eyebrow {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__title {
  margin-top: 5px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.2;
}

.panel__hint {
  padding-top: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.panel__caption {
  margin-top: 12px;
  max-width: 80ch;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.panel--table > .panel__caption { padding: 0 18px 16px; }

.panel__empty {
  padding: 18px 0;
  font-size: 13px;
  color: var(--muted);
}

.panel-grid {
  display: grid;
  gap: 12px;
}

.panel-grid--main {
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
}

.panel-grid--two {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

/* Segment */
.segment {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 12, 11, .03);
}

.segment__btn {
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}

.segment__btn:hover { color: var(--ink); }

.segment__btn.is-on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(12, 12, 11, .08);
}

/* Charts */
.chart {
  position: relative;
  width: 100%;
}

.chart--area { height: clamp(240px, 25vw, 330px); }
.chart--columns { height: 224px; }

.panel--weekday {
  display: flex;
  flex-direction: column;
}

.panel--weekday .chart--columns {
  flex: 1 1 auto;
  height: auto;
  min-height: 224px;
}

.chart__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart__axis {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .02em;
}

.chart__axis--value {
  fill: var(--ink-soft);
  font-size: 9px;
}

.chart__grid {
  stroke: rgba(12, 12, 11, .1);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart__base {
  stroke: rgba(12, 12, 11, .26);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart__area {
  fill-opacity: .12;
  stroke: none;
}

.chart__line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart__guide {
  stroke: rgba(12, 12, 11, .3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
  transition: opacity .15s var(--ease);
}

.chart__dot {
  stroke: var(--panel);
  stroke-width: 2;
  pointer-events: none;
  transition: opacity .15s var(--ease);
}

.chart__hit { cursor: crosshair; }

.chart__tip {
  position: absolute;
  top: 0;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--panel);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.columns__bar {
  fill: rgba(12, 12, 11, .18);
  transition: fill .2s var(--ease);
}

.columns__bar:hover { fill: var(--accent); }

/* Bars */
.bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bars__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bars__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.bars__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
}

.bars__figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.bars__value {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.bars__note {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.bars__track {
  height: 8px;
  border-radius: 999px;
  background: rgba(12, 12, 11, .08);
  overflow: hidden;
}

.bars__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
  transition: transform .35s var(--ease);
}

/* Insights */
.insights {
  display: flex;
  flex-direction: column;
}

.insight {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.insight:first-child {
  padding-top: 0;
  border-top: 0;
}

.insight:last-child { padding-bottom: 0; }

.insight__label {
  padding-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.insight__text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.insight__text strong {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.insight__text .up { color: var(--ok); }
.insight__text .down { color: var(--danger); }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-soft);
}

.table th:first-child,
.table td:first-child { padding-left: 18px; }

.table th:last-child,
.table td:last-child { padding-right: 18px; }

.table tbody tr {
  transition: background-color .15s var(--ease);
}

.table tbody tr:hover { background: rgba(12, 12, 11, .025); }

.table tbody tr:last-child td { border-bottom: 0; }

.table .num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table th.num { text-align: right; }

.table--orders { min-width: 900px; }
.table--top { min-width: 520px; }
.table--cohort { min-width: 560px; }
.table--products { min-width: 660px; }

.table--orders .cell-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.table--orders .cell-date {
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.cell-clip {
  display: block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table--orders .cell-amount {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
}

/* Sortable headers */
.sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  transition: color .15s var(--ease);
}

.sort:hover { color: var(--ink); }

.sort__mark {
  width: 0;
  height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4.5px solid currentColor;
  opacity: 0;
  transition: opacity .15s var(--ease), transform .2s var(--ease);
}

.sort:hover .sort__mark { opacity: .35; }

.sort.is-on { color: var(--ink); }
.sort.is-on .sort__mark { opacity: 1; }
.sort.is-asc .sort__mark { transform: rotate(180deg); }

/* Status */
.status {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status--paid { background: var(--ok-soft); color: var(--ok); }
.status--refund { background: var(--danger-soft); color: var(--danger); }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field { position: relative; }

.field--search {
  flex: 1 1 230px;
  min-width: 180px;
}

.field--search > svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  pointer-events: none;
}

.field--search .input {
  width: 100%;
  padding-left: 34px;
}

.field--select .select { min-width: 132px; }
.field--tight .select { min-width: 104px; }

.toolbar__export { margin-left: auto; }

.toolbar__meta {
  margin-left: auto;
  font-size: 9.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Table footer */
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px 16px;
}

.table-foot__count {
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager__btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-soft);
  transition: background-color .2s var(--ease), border-color .2s var(--ease);
}

.pager__btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(12, 12, 11, .05);
}

.pager__btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

#orders-page {
  min-width: 54px;
  text-align: center;
  font-size: 9.5px;
  color: var(--muted);
}

.table__empty {
  padding: 36px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.table__empty .btn { margin-top: 12px; }

.table-empty {
  padding: 28px 18px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* Cohorts */
.table--cohort th,
.table--cohort td { padding: 6px 9px; }

.table--cohort th:first-child,
.table--cohort td:first-child { padding-left: 18px; }

.table--cohort th:last-child,
.table--cohort td:last-child { padding-right: 18px; }

.cohort__month {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
}

.cohort__size {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.cohort__cell { padding: 0 3px; }

.cohort__cell span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 30px;
  margin: 3px 0;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.cohort__cell span.is-empty {
  background: transparent;
  color: var(--muted);
  opacity: .55;
}

/* Top customers */
.table--top .cell-rank {
  width: 42px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.table--top .cell-name {
  font-weight: 500;
  color: var(--ink);
}

/* Products */
.table--products .th-rank { width: 46px; }
.table--products .th-share { width: 160px; }

.product__title {
  display: block;
  font-weight: 500;
  color: var(--ink);
}

.product__cat {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.share {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}

.share__track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(12, 12, 11, .08);
  overflow: hidden;
}

.share__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transform-origin: left center;
}

.share__value {
  min-width: 36px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  text-align: right;
}

/* ABC */
.abc {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.abc__card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(241, 236, 227, .42);
}

.abc__key {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
}

.abc__name {
  margin-top: 7px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.abc__stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-soft);
}

.abc__stats span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.abc__stats b {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Empty state and drop zone */
.screen--empty {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 240px);
  padding: 24px 0 48px;
  animation: none;
}

.drop {
  width: min(680px, 100%);
  padding: clamp(32px, 6vw, 64px) clamp(22px, 4vw, 48px);
  border: 1px dashed rgba(12, 12, 11, .3);
  border-radius: var(--r-xl);
  background: var(--panel);
  text-align: center;
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}

.drop:hover { border-color: var(--accent-line); }

.drop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop__icon {
  width: 50px;
  height: 50px;
  margin: 0 auto 20px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop__title {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.15;
}

.drop__text {
  max-width: 46ch;
  margin: 10px auto 0;
  font-size: 14px;
  color: var(--muted);
}

.drop__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.drop__hint {
  margin-top: 18px;
  font-size: 9.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal__scrim {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 11, .38);
}

.modal__box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  animation: modal-in .22s var(--ease) both;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.modal__head { padding: 22px 22px 12px; }

.modal__eyebrow {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.modal__title {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.modal__text {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.modal__body {
  overflow: auto;
  padding: 0 22px;
}

.modal__error {
  margin: 12px 22px 0;
  font-size: 12px;
  color: var(--danger);
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--line);
}

.table--mapping { min-width: 0; }

.table--mapping td:first-child {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.table--mapping select {
  width: 100%;
  min-width: 160px;
  height: 32px;
  font-size: 12px;
}

/* Footer */
.work__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Responsive */
@media (max-width: 1280px) {
  .work__controls { justify-content: flex-start; }
}

@media (max-width: 1180px) {
  .panel-grid--main { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart--area { height: 300px; }
}

@media (max-width: 1080px) {
  .work__head {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar__export { margin-left: 0; }
}

@media (max-width: 900px) {
  .app {
    display: block;
    min-height: 100vh;
  }

  .rail {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    display: block;
    width: 100%;
    height: 64px;
    padding: 0 6px;
    border: 0;
    border-top: 1px solid var(--line);
    background: var(--panel);
  }

  .rail__brand,
  .rail__source,
  .rail__note { display: none; }

  .rail__nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    height: 64px;
    padding: 6px 2px;
  }

  .rail__link {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 0;
    height: 100%;
    padding: 0;
    border-radius: 8px;
    font-size: 9.5px;
  }

  .rail__link svg {
    width: 18px;
    height: 18px;
  }

  .work { padding: 18px var(--pad) 96px; }

  .panel { padding: 16px; border-radius: var(--r-md); }
  .panel--table { padding: 0; }

  .panel-grid--two { grid-template-columns: minmax(0, 1fr); }
  .panel__head { flex-wrap: wrap; }

  .screen--empty { min-height: calc(100vh - 320px); }
}

@media (max-width: 760px) {
  .kpis--three { grid-template-columns: minmax(0, 1fr); }
  .abc { grid-template-columns: minmax(0, 1fr); }
  .chart--area { height: 260px; }
  .chart--columns { height: 200px; }
}

@media (max-width: 620px) {
  .work__head { gap: 16px; }
  .work__controls { gap: 7px; }
  .period { flex: 1 1 100%; }

  .period > .select { flex: 1; }

  #upload-btn { flex: 1 1 100%; }

  .period__custom { width: 100%; }
  .period__field { flex: 1; }
  .input--date { width: 100%; }

  .work__title { font-size: clamp(26px, 8vw, 32px); }
  .work__sub { font-size: 13px; }

  .panel--table > .panel__head { padding: 16px 16px 0; }
  .table th:first-child,
  .table td:first-child { padding-left: 16px; }
  .table th:last-child,
  .table td:last-child { padding-right: 16px; }
  .table-foot { padding: 12px 16px 16px; }

  .toolbar__meta { margin-left: 0; }
  .toolbar__export { width: 100%; }

  .insight {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .drop__actions .btn { flex: 1 1 100%; }
  .drop { border-radius: var(--r-lg); }

  .work__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .modal { padding: 12px; }
  .modal__box { max-height: 92vh; border-radius: var(--r-md); }
  .modal__head { padding: 18px 16px 10px; }
  .modal__body { padding: 0 16px; }
  .modal__error { margin: 10px 16px 0; }
  .modal__foot { padding: 14px 16px 16px; }
  .modal__foot .btn { flex: 1; }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi { min-height: 138px; }
  .drop__title { font-size: 21px; }
}

/* Gate */
html.is-modal,
html.is-modal body { overflow: hidden; }

html.is-gated,
html.is-gated body { overflow: hidden; }

.gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--page);
  color: var(--ink);
}

.gate[hidden] { display: none; }

.gate::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 50% at 50% 28%, rgba(255, 255, 255, .66), transparent 72%);
}

.gate.is-passed {
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease), visibility 0s linear .3s;
}

.gate__box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(440px, 100%);
  text-align: center;
}

.gate__mark {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate__mark span { color: var(--accent); }

.gate__title {
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -.02em;
}

.gate__text {
  max-width: 34ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.gate.is-rejected .gate__title { color: var(--danger); }

.gate__widget {
  display: flex;
  justify-content: center;
  min-height: 72px;
}

.gate__retry {
  margin-top: 4px;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background-color .2s, border-color .2s;
}

.gate__retry:hover { background: rgba(12, 12, 11, .06); }

.gate__retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
