/* ==========================================================================
   LIQUID GLASS DASHBOARD — styles
   1. Design tokens  ← change colors, glass, radius and fonts here
   2. Base
   3. Glass
   4. Layout (sidebar, topbar, grid)
   5. Components (KPIs, charts, activity, table)
   6. Responsive
   7. Accessibility & fallbacks
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
/* The Inter font is loaded by fonts/inter.css (linked in index.html). */

:root {
  /* Type */
  --font: "Inter", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --text-xs: 0.75rem;   /* 12 */
  --text-sm: 0.875rem;  /* 14 */
  --text-md: 1rem;      /* 16 */
  --text-lg: 1.25rem;   /* 20 */
  --text-xl: 1.75rem;   /* 28 */
  --text-2xl: 2.5rem;   /* 40 */

  /* Shape & spacing */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --gap: 20px;
  --sidebar-w: 248px;

  /* Glass recipe */
  --blur: 28px;
  --saturate: 180%;

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 400ms;

  /* Chart palette (series 1–5) */
  --c1: #2f6bff;
  --c2: #8b5cf6;
  --c3: #e2458f;
  --c4: #0e9f8e;
  --c5: #e8930c;
}

/* Light theme (default) */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f8;
  --blob-1: #8fb4ff;
  --blob-2: #c6a8ff;
  --blob-3: #ffb3d1;
  --blob-4: #8fe3d6;

  --text: #15161c;
  --text-muted: #4f5262;
  --border-soft: rgba(20, 22, 40, .08);

  --glass-bg: rgba(255, 255, 255, .58);
  --glass-solid: #f7f8fc;             /* used when blur isn't available */
  --glass-edge: rgba(255, 255, 255, .9);
  --glass-edge-2: rgba(255, 255, 255, .25);
  --glass-shadow: 0 1px 1px rgba(16, 24, 64, .04), 0 12px 32px -8px rgba(16, 24, 64, .14);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, .85);
  --chip-bg: rgba(255, 255, 255, .65);
  --hover: rgba(20, 22, 40, .05);

  --accent: #2557e0;
  --accent-text: #fff;
  --accent-soft: rgba(47, 107, 255, .12);
  --positive: #0a6542;
  --positive-soft: rgba(16, 160, 100, .14);
  --negative: #a8211e;
  --negative-soft: rgba(230, 60, 50, .12);
  --warning: #7c4700;
  --warning-soft: rgba(240, 160, 20, .16);

  --grid-line: rgba(20, 22, 40, .08);
  --focus: #2557e0;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07080d;
  --blob-1: #1d3fb0;
  --blob-2: #5524a8;
  --blob-3: #8a1f5c;
  --blob-4: #0d6b66;

  --text: #f4f5f8;
  --text-muted: #a8abbc;
  --border-soft: rgba(255, 255, 255, .08);

  --glass-bg: rgba(22, 24, 34, .55);
  --glass-solid: #161822;
  --glass-edge: rgba(255, 255, 255, .22);
  --glass-edge-2: rgba(255, 255, 255, .04);
  --glass-shadow: 0 1px 1px rgba(0, 0, 0, .3), 0 16px 40px -8px rgba(0, 0, 0, .55);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, .08);
  --chip-bg: rgba(255, 255, 255, .07);
  --hover: rgba(255, 255, 255, .06);

  --accent: #6d97ff;
  --accent-text: #07080d;
  --accent-soft: rgba(109, 151, 255, .16);
  --positive: #4fd6a0;
  --positive-soft: rgba(79, 214, 160, .14);
  --negative: #ff8a80;
  --negative-soft: rgba(255, 110, 100, .14);
  --warning: #f6c25a;
  --warning-soft: rgba(246, 194, 90, .14);

  --c1: #6d97ff;
  --c2: #a98bff;
  --c3: #f472b6;
  --c4: #2dd4bf;
  --c5: #fbbf24;

  --grid-line: rgba(255, 255, 255, .07);
  --focus: #8fb0ff;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1, h2, p { margin: 0; }
h1 { font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.022em; line-height: 1.2; }
h2 { font-size: var(--text-md); font-weight: 600; letter-spacing: -0.011em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--text-muted); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Animated color blobs behind everything */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.backdrop span {
  position: absolute;
  width: 60vmax; height: 60vmax;
  border-radius: 50%;
  opacity: .75;
  will-change: transform;
  animation: drift 40s var(--ease) infinite alternate;
}
.backdrop span:nth-child(1) { background: radial-gradient(closest-side, var(--blob-1), transparent); top: -20vmax; left: -10vmax; }
.backdrop span:nth-child(2) { background: radial-gradient(closest-side, var(--blob-2), transparent); top: -10vmax; right: -20vmax; animation-duration: 50s; animation-delay: -10s; }
.backdrop span:nth-child(3) { background: radial-gradient(closest-side, var(--blob-3), transparent); bottom: -30vmax; left: 20vmax; animation-duration: 46s; animation-delay: -20s; }
.backdrop span:nth-child(4) { background: radial-gradient(closest-side, var(--blob-4), transparent); bottom: -25vmax; right: -15vmax; animation-duration: 55s; animation-delay: -5s; }
@keyframes drift {
  to { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); }
}

/* ---------- 3. Glass ---------- */
.glass {
  position: relative;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  backdrop-filter: blur(var(--blur)) saturate(var(--saturate));
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-inner), var(--glass-shadow);
  transition: background-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* The shiny 1px edge: bright at top-left, fading out, catching light again bottom-right */
.glass::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, var(--glass-edge), var(--glass-edge-2) 35%, transparent 60%, var(--glass-edge-2) 85%, var(--glass-edge));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* ---------- 4. Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: var(--gap);
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Sidebar */
.sidebar {
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  overflow-y: auto;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.02em; }
.icon-btn.sidebar-close { display: none; margin-left: auto; }

.nav { display: flex; flex-direction: column; flex: 1; gap: 4px; }
.nav ul { display: grid; gap: 2px; }
.nav-bottom { margin-top: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 42px; padding: 0 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background-color 150ms, color 150ms;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] {
  background: var(--chip-bg);
  color: var(--text);
  box-shadow: var(--glass-inner), 0 1px 3px rgba(0, 0, 0, .06);
}
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav-count {
  margin-left: auto;
  min-width: 22px; padding: 0 7px;
  border-radius: 99px;
  background: var(--accent); color: var(--accent-text);
  font-size: var(--text-xs); font-weight: 600; line-height: 20px; text-align: center;
}

.upgrade {
  padding: 16px;
  border-radius: var(--radius-md);
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--c1) 22%, transparent), transparent 60%),
    radial-gradient(120% 100% at 100% 100%, color-mix(in srgb, var(--c2) 22%, transparent), transparent 60%),
    var(--chip-bg);
  box-shadow: var(--glass-inner);
}
.upgrade .icon { color: var(--accent); }
.upgrade-title { margin-top: 8px; font-weight: 600; }
.upgrade-text { margin: 4px 0 14px; color: var(--text-muted); font-size: var(--text-xs); line-height: 1.5; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 16px;
  border: 0; border-radius: 99px;
  font-weight: 600;
  transition: transform 150ms var(--ease), filter 150ms;
}
.btn-primary { width: 100%; background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.97); }

.scrim { display: none; }

/* Shell + topbar */
.shell { min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.topbar {
  position: sticky; top: 16px; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 14px;
  border-radius: 20px;
}
.icon-btn.menu-btn { display: none; }
.search {
  position: relative;
  flex: 1; max-width: 420px;
  display: flex; align-items: center;
}
.search .icon { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.search input {
  width: 100%; height: 40px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--chip-bg);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.search input::placeholder { color: var(--text-muted); opacity: 1; }
.search input:focus-visible { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  position: absolute; right: 10px;
  min-width: 22px; padding: 1px 6px;
  border: 1px solid var(--border-soft); border-radius: 6px;
  font: 500 var(--text-xs)/1.4 var(--font); text-align: center;
  color: var(--text-muted);
}
.search input:focus + kbd, .search input:not(:placeholder-shown) + kbd { display: none; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative;
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  transition: background-color 150ms, color 150ms;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 9px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c3);
  box-shadow: 0 0 0 2px var(--glass-solid);
}
#theme-toggle .icon { grid-area: 1 / 1; transition: transform 500ms var(--ease), opacity 300ms; }
[data-theme="light"] #theme-toggle .icon-sun,
[data-theme="dark"]  #theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }

.profile {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px; margin-left: 4px;
  border: 0; border-radius: 99px;
  background: transparent; text-align: left;
}
.profile:hover { background: var(--hover); }
.profile-text { display: grid; line-height: 1.25; }
.profile-text strong { font-weight: 600; font-size: var(--text-sm); }
.profile-text small { color: var(--text-muted); font-size: var(--text-xs); }

.avatar {
  --hue: 220;
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, hsl(var(--hue) 85% 62%), hsl(calc(var(--hue) + 50) 80% 55%));
  color: #fff;
  font-size: var(--text-xs); font-weight: 650; letter-spacing: .02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .2);
}

/* Main */
main { display: flex; flex-direction: column; gap: var(--gap); outline: none; padding-bottom: 8px; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 8px 4px 0;
}
.page-head p { margin-top: 4px; }

.segmented {
  display: inline-flex; gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--chip-bg);
  box-shadow: var(--glass-inner), 0 0 0 1px var(--border-soft);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.segmented button {
  min-width: 52px; height: 32px; padding: 0 12px;
  border: 0; border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .02em;
  transition: background-color 200ms var(--ease), color 200ms, box-shadow 200ms;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--glass-solid);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 2px 8px -2px rgba(0, 0, 0, .12);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.span-revenue  { grid-column: span 8; }
.span-donut    { grid-column: span 4; }
.span-bars     { grid-column: span 5; }
.span-activity { grid-column: span 7; }
.span-table    { grid-column: 1 / -1; }

.card { padding: 22px; min-width: 0; display: flex; flex-direction: column; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head p { font-size: var(--text-xs); margin-top: 2px; }

/* Entrance animation (skipped with reduced motion) */
.kpi, .card { animation: rise 700ms var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.985); } }

/* ---------- 5. Components ---------- */
/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi { padding: 18px 18px 14px; display: grid; gap: 4px; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-weight: 500; }
.kpi-label { font-size: var(--text-sm); font-weight: 500; letter-spacing: 0; }
.kpi-icon {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--chip-bg); box-shadow: var(--glass-inner);
  color: var(--text);
}
.kpi-icon .icon { width: 17px; height: 17px; }
.kpi-value {
  margin-top: 6px;
  font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.03em; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.kpi-foot .muted { font-size: var(--text-xs); }
.delta {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 8px 2px 5px; border-radius: 99px;
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta .icon { width: 14px; height: 14px; stroke-width: 2.25; }
.delta.up   { color: var(--positive); background: var(--positive-soft); }
.delta.down { color: var(--negative); background: var(--negative-soft); }
.spark { width: 84px; height: 32px; flex: none; overflow: visible; }
.spark path { fill: none; stroke: var(--c1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .spark-area { fill: url(#spark-fill); stroke: none; }

/* Legend */
.legend { display: grid; gap: 10px; }
.legend li { white-space: nowrap; display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: var(--text-xs); font-weight: 500; }
.legend-inline { display: flex; gap: 16px; flex-wrap: wrap; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--sw); flex: none; }
.swatch-dashed { background: none; height: 0; width: 14px; border-radius: 0; border-top: 2px dashed var(--text-muted); }

/* Line chart */
.line-chart { position: relative; height: 280px; }
.line-chart svg { display: block; width: 100%; height: 100%; overflow: visible; border-radius: 8px; }
.line-chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 6px; }
.lc-grid { stroke: var(--grid-line); stroke-width: 1; }
.lc-label { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.lc-prev { fill: none; stroke: var(--text-muted); stroke-opacity: .55; stroke-width: 1.5; stroke-dasharray: 4 5; }
.lc-line {
  fill: none; stroke: var(--c1); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--c1) 40%, transparent));
  stroke-dasharray: 1; stroke-dashoffset: 1;
  animation: draw 1.1s var(--ease) forwards;
}
.lc-area { fill: url(#lc-fill); opacity: 0; animation: fade 900ms 300ms var(--ease) forwards; }
.static .lc-line, .static .lc-area { animation: none; stroke-dashoffset: 0; opacity: 1; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }
.lc-cursor { stroke: var(--text-muted); stroke-opacity: .4; stroke-width: 1; }
.lc-dot { fill: var(--glass-solid); stroke: var(--c1); stroke-width: 2.5; }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 2;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--glass-solid);
  box-shadow: 0 0 0 1px var(--border-soft), 0 8px 24px -6px rgba(0, 0, 0, .25);
  font-size: var(--text-xs); white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}
.chart-tip strong { display: block; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

/* Donut */
.donut-wrap { flex: 1; display: grid; grid-template-columns: minmax(0, 148px) 1fr; align-items: center; gap: 22px; }
.donut { position: relative; aspect-ratio: 1; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 3.6; stroke-linecap: round; transition: stroke-dasharray 900ms var(--ease); }
.donut .track { stroke: var(--grid-line); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center strong { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: var(--text-xs); color: var(--text-muted); }
.donut-wrap .legend li { justify-content: flex-start; }
.donut-wrap .legend .pct { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Bars */
.bars {
  flex: 1; min-height: 220px;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  align-items: end; gap: 10px;
  padding-top: 24px;
}
.bars li { height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 8px; text-align: center; }
.bar-track { position: relative; display: flex; align-items: flex-end; }
.bar {
  position: relative;
  width: 100%; height: var(--h);
  border-radius: 10px 10px 6px 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c1) 55%, transparent), color-mix(in srgb, var(--c1) 18%, transparent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45);
  transform-origin: bottom;
  animation: grow 800ms var(--ease) both;
  animation-delay: calc(var(--i) * 50ms + 200ms);
}
.bars li.is-max .bar { background: linear-gradient(180deg, var(--c1), color-mix(in srgb, var(--c2) 70%, transparent)); }
.bar-value {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity 150ms;
}
.bars li:hover .bar-value, .bars li.is-max .bar-value { opacity: 1; }
@media (hover: none) { .bar-value { opacity: 1; } }  /* touch screens can't hover */
.bar-label { font-size: var(--text-xs); color: var(--text-muted); font-weight: 500; }
@keyframes grow { from { transform: scaleY(0); } }

/* Activity */
.activity { display: grid; }
.activity li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; }
.activity li + li { border-top: 1px solid var(--border-soft); }
.activity .avatar { width: 32px; height: 32px; }
.act-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.activity p { color: var(--text-muted); }
.activity p strong { color: var(--text); font-weight: 600; }
.activity time { font-size: var(--text-xs); color: var(--text-muted); }
.tone { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.tone-accent { background: var(--c1); }
.tone-positive { background: var(--positive); }
.tone-warning { background: var(--c5); }
.tone-negative { background: var(--negative); }

/* Table */
.table-wrap { overflow-x: auto; margin: 0 -22px -10px; padding: 0 22px 10px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th {
  text-align: left; font-size: var(--text-xs); font-weight: 600; color: var(--text-muted);
  padding: 0 12px 10px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 150ms; }
tbody tr:hover { background: var(--hover); }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; }
.order-id { font-weight: 600; font-variant-numeric: tabular-nums; }
.customer { display: flex; align-items: center; gap: 10px; }
.customer .avatar { width: 30px; height: 30px; font-size: 11px; }
.customer small { display: block; color: var(--text-muted); font-size: var(--text-xs); }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 99px;
  font-size: var(--text-xs); font-weight: 600;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-paid     { color: var(--positive); background: var(--positive-soft); }
.status-shipped  { color: var(--accent);   background: var(--accent-soft); }
.status-pending  { color: var(--warning);  background: var(--warning-soft); }
.status-refunded { color: var(--negative); background: var(--negative-soft); }
.empty td { padding: 32px 0; text-align: center; color: var(--text-muted); white-space: normal; }

.foot { padding: 4px; font-size: var(--text-xs); text-align: center; }

/* ---------- 6. Responsive ---------- */
/* Laptop */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-revenue, .span-table { grid-column: 1 / -1; }
  .span-donut, .span-bars { grid-column: span 6; }
  .span-activity { grid-column: 1 / -1; }
}

/* Tablet: icon-only sidebar */
@media (max-width: 1024px) {
  :root { --sidebar-w: 76px; --gap: 16px; }
  .sidebar { padding: 18px 10px; align-items: center; }
  .brand { padding: 4px 0; }
  .brand-name, .nav a > span:not(.nav-count), .upgrade { display: none; }
  .nav { width: 100%; }
  .nav a { justify-content: center; padding: 0; position: relative; }
  .nav-count { position: absolute; top: 2px; right: 2px; min-width: 18px; padding: 0 5px; line-height: 16px; font-size: 10px; }
  .profile-text { display: none; }
  .profile { padding: 4px; }
}

/* Phone: sidebar becomes a slide-in drawer */
@media (max-width: 720px) {
  :root { --gap: 12px; }
  .app { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .sidebar {
    position: fixed; top: 12px; bottom: 12px; left: 12px;
    width: min(300px, calc(100vw - 48px)); height: auto;
    align-items: stretch; padding: 20px 14px;
    transform: translateX(calc(-100% - 24px));
    transition: transform 450ms var(--ease);
    z-index: 50;
    background: var(--glass-solid);
  }
  .sidebar.is-open { transform: none; }
  .brand { padding: 4px 10px; }
  .brand-name, .nav a > span:not(.nav-count), .upgrade { display: revert; }
  .upgrade { display: block; }
  .nav a { justify-content: flex-start; padding: 0 12px; }
  .nav-count { position: static; min-width: 22px; padding: 0 7px; line-height: 20px; font-size: var(--text-xs); }
  .icon-btn.sidebar-close { display: inline-grid; }
  .scrim:not([hidden]) {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(5, 8, 20, .35);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    animation: fade 300ms var(--ease) both;
  }

  .topbar { top: 12px; flex-wrap: wrap; padding: 8px; gap: 4px; }
  .icon-btn.menu-btn { display: inline-grid; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .topbar-actions { gap: 2px; }

  h1 { font-size: 1.5rem; }
  .page-head { align-items: stretch; flex-direction: column; }
  .segmented { align-self: stretch; }
  .segmented button { flex: 1; }

  .kpis { gap: 12px; }
  .kpi { padding: 14px 14px 12px; }
  .kpi-value { font-size: 1.375rem; }
  .spark { width: 56px; height: 26px; }
  .kpi-foot .muted { display: none; }

  .span-donut, .span-bars { grid-column: 1 / -1; }
  .card { padding: 18px; border-radius: 20px; }
  .table-wrap { margin: 0 -18px -8px; padding: 0 18px 8px; }
  .line-chart { height: 220px; }
  .donut-wrap { grid-template-columns: 132px 1fr; gap: 18px; }
}

@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut { width: 160px; }
  .donut-wrap .legend { width: 100%; }
}

/* ---------- 7. Accessibility & fallbacks ---------- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 100;
  padding: 10px 16px; border-radius: 12px;
  background: var(--accent); color: var(--accent-text); font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.nav a:focus-visible, .icon-btn:focus-visible, .segmented button:focus-visible, .profile:focus-visible { outline-offset: 0; }

/* No blur support (or the user asked for less transparency): solid panels */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root, [data-theme] { --glass-bg: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  :root, [data-theme] { --glass-bg: var(--glass-solid); --chip-bg: var(--hover); }
  .glass, .segmented { -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* High contrast / forced colors (Windows) */
@media (forced-colors: active) {
  .glass { border: 1px solid CanvasText; }
  .glass::before, .backdrop { display: none; }
  .segmented button[aria-pressed="true"] { outline: 2px solid Highlight; }
}

/* Calm mode */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .backdrop span { animation: none; }
}
