/*
 * ANZ PDF Optimizer: web dashboard (M2 #9).
 * Same visual language as the desktop app: Apple HIG palette, Inter / Inter Display, Lucide icons.
 * Self-contained: fonts and icons are served from /static, nothing comes from a CDN.
 */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Inter-Medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Inter-Bold.woff2") format("woff2"); }
@font-face { font-family: "Inter Display"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/InterDisplay-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter Display"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/InterDisplay-Bold.woff2") format("woff2"); }

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #F5F5F7;
  --sidebar: #ECECEF;
  --card: #FFFFFF;
  --elevated: #FFFFFF;
  --text: #1D1D1F;
  --text-2: #6E6E73;
  --text-3: #86868B;
  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-strong: rgba(0, 0, 0, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-hover: rgba(120, 120, 128, 0.18);
  --row-hover: rgba(0, 0, 0, 0.025);
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-text: #0066CC;
  --accent-soft: rgba(0, 113, 227, 0.10);
  --green: #34C759;   --green-text: #248A3D;  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #FF9F0A;  --orange-text: #B25000; --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #FF3B30;     --red-text: #D70015;    --red-soft: rgba(255, 59, 48, 0.11);
  --purple: #AF52DE;  --purple-text: #8944AB; --purple-soft: rgba(175, 82, 222, 0.12);
  --teal: #30B0C7;
  --grey: #8E8E93;    --grey-text: #6E6E73;   --grey-soft: rgba(120, 120, 128, 0.14);
  --shadow-card: 0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px -10px rgba(0, 0, 0, 0.10);
  --shadow-pop: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 12px 40px -8px rgba(0, 0, 0, 0.25);
  --shadow-sheet: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 24px 80px -12px rgba(0, 0, 0, 0.35);
  --scrim: rgba(0, 0, 0, 0.28);
  --toast: rgba(29, 29, 31, 0.92);
  --toast-text: #F5F5F7;
  --focus: 0 0 0 3.5px rgba(0, 113, 227, 0.32);
  --radius-card: 16px;
  --radius-control: 9px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Inter Display", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111113;
    --sidebar: #1A1A1C;
    --card: #1C1C1E;
    --elevated: #2C2C2E;
    --text: #F5F5F7;
    --text-2: #A1A1A6;
    --text-3: #8E8E93;
    --hairline: rgba(255, 255, 255, 0.09);
    --hairline-strong: rgba(255, 255, 255, 0.16);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-hover: rgba(120, 120, 128, 0.32);
    --row-hover: rgba(255, 255, 255, 0.03);
    --accent: #0A84FF;
    --accent-hover: #2997FF;
    --accent-text: #409CFF;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --green: #30D158;   --green-text: #30D158;  --green-soft: rgba(48, 209, 88, 0.16);
    --orange: #FF9F0A;  --orange-text: #FFB340; --orange-soft: rgba(255, 159, 10, 0.18);
    --red: #FF453A;     --red-text: #FF6961;    --red-soft: rgba(255, 69, 58, 0.18);
    --purple: #BF5AF2;  --purple-text: #DA8FFF; --purple-soft: rgba(191, 90, 242, 0.18);
    --grey: #8E8E93;    --grey-text: #A1A1A6;   --grey-soft: rgba(142, 142, 147, 0.20);
    --shadow-card: 0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 12px 40px -8px rgba(0, 0, 0, 0.6);
    --shadow-sheet: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 24px 80px -12px rgba(0, 0, 0, 0.7);
    --scrim: rgba(0, 0, 0, 0.5);
    --toast: rgba(58, 58, 60, 0.95);
    --focus: 0 0 0 3.5px rgba(10, 132, 255, 0.45);
  }
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); text-decoration: none; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); }

.icon {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  width: 252px; flex: none;
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: 0.5px solid var(--hairline);
  padding: 18px 12px 14px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.brand img { width: 32px; height: 32px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--text-2); }

.project-switcher {
  position: relative;
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border: 0; border-radius: 11px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-align: left;
}
.project-switcher:hover { background: var(--elevated); }
.project-switcher .meta { flex: 1; min-width: 0; }
.project-switcher .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-switcher .client { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-switcher .icon { color: var(--text-3); }
.project-badge {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #47A3FF, #0062D6);
  color: #fff; font-weight: 700; font-size: 12px;
}

.popover {
  position: absolute; z-index: 40;
  max-height: 360px; overflow-y: auto;
  background: var(--elevated);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
}
.popover-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left;
}
.popover-item:hover { background: var(--accent); color: #fff; }
.popover-item:hover .muted, .popover-item:hover .icon { color: #fff; }
.popover-item .meta { flex: 1; min-width: 0; }
.popover-item .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popover-item .muted { font-size: 12px; }
.popover-sep { height: 0.5px; margin: 6px 8px; background: var(--hairline-strong); }
.popover-item .check { color: var(--accent); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.nav-section { font-size: 11.5px; font-weight: 600; color: var(--text-3); padding: 14px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--text); font-weight: 500; font-size: 13.5px;
  user-select: none;
}
.nav-link .icon { color: var(--accent); width: 17px; height: 17px; }
.nav-link:hover { background: var(--fill); }
.nav-link.active { background: var(--fill-hover); }
.nav-link .badge {
  margin-left: auto;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--red); color: #fff;
}

.sidebar-footer { margin-top: auto; padding-top: 14px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  background: linear-gradient(180deg, #A1A1A6, #6E6E73); color: #fff;
  font-weight: 600; font-size: 12px;
}
.user-card .meta { flex: 1; min-width: 0; }
.user-card .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .role { font-size: 12px; color: var(--text-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; gap: 16px;
  padding: 26px 36px 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}
.toolbar .titles { flex: 1; min-width: 0; }
.page-title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.15; letter-spacing: -0.022em; }
.page-subtitle { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; }
.toolbar-actions { display: flex; align-items: center; gap: 10px; }
.refresh-meta { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.content { padding: 4px 36px 48px; max-width: 1360px; width: 100%; }
.view-section { animation: fade-in 0.22s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px 22px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 18px 22px 4px; }
.card-title { margin: 0; font-weight: 600; font-size: 15px; letter-spacing: -0.012em; }
.card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-2); }
.card-header .spacer { flex: 1; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* KPI */
.kpi { padding: 18px 20px 18px; display: flex; flex-direction: column; gap: 10px; }
.kpi-head { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.kpi-icon .icon { width: 16px; height: 16px; }
.kpi-icon.green { background: var(--green-soft); color: var(--green-text); }
.kpi-icon.orange { background: var(--orange-soft); color: var(--orange-text); }
.kpi-icon.purple { background: var(--purple-soft); color: var(--purple-text); }
.kpi-icon.red { background: var(--red-soft); color: var(--red-text); }
.kpi-value {
  font-family: var(--font-display); font-weight: 600;
  font-size: 30px; line-height: 1.05; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { font-size: 12.5px; color: var(--text-3); }

/* banner */
.banner { display: flex; align-items: center; gap: 14px; padding: 16px 20px; }
.banner-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--grey); position: relative; }
.banner-dot::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  background: currentColor; opacity: 0.18;
}
.banner-dot.green { background: var(--green); color: var(--green); }
.banner-dot.orange { background: var(--orange); color: var(--orange); }
.banner-dot.red { background: var(--red); color: var(--red); }
.banner-dot.grey { background: var(--grey); color: var(--grey); }
.banner-text { font-weight: 600; font-size: 15px; }
.banner-sub { font-size: 13px; color: var(--text-2); }
.banner .meta { flex: 1; min-width: 0; }
.banner-side { font-size: 12.5px; color: var(--text-3); text-align: right; }
.alert-banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-radius: 14px; background: var(--red-soft); color: var(--red-text); }
.alert-banner.orange { background: var(--orange-soft); color: var(--orange-text); }
.alert-banner .title { font-weight: 600; }
.alert-banner .body { color: var(--text); opacity: 0.85; font-size: 13px; }

/* metrics list (inset grouped) */
.metric-list { display: flex; flex-direction: column; }
.metric-row { display: flex; align-items: center; gap: 12px; padding: 12px 22px; }
.metric-row + .metric-row { border-top: 0.5px solid var(--hairline); margin-left: 22px; padding-left: 0; }
.metric-row .label { flex: 1; color: var(--text-2); }
.metric-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.donut-wrap { display: flex; align-items: center; gap: 26px; padding: 14px 22px 22px; }
.donut { width: 168px; flex: none; position: relative; }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.donut-center .big { font-family: var(--font-display); font-weight: 600; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.donut-center .small { font-size: 12px; color: var(--text-3); }
.legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item .label { flex: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-item .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-item .pct { width: 48px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }

.bars { display: flex; flex-direction: column; gap: 16px; padding: 14px 22px 22px; }
.bar-row .bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 7px; }
.bar-row .bar-label .label { color: var(--text-2); }
.bar-row .bar-label .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; border-radius: 5px; background: var(--fill); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--accent); transition: width 0.6s cubic-bezier(.2,.8,.2,1); }
.bar-fill.green { background: var(--green); }
.bar-fill.grey { background: var(--grey); }
.bar-fill.orange { background: var(--orange); }
.bar-fill.red { background: var(--red); }

.composition { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--fill); gap: 2px; }
.composition > span { display: block; height: 100%; transition: flex-grow 0.6s ease; }

.ring { position: relative; width: 74px; height: 74px; flex: none; }
.ring svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.ring .ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
}

/* daily bars (#13) */
.daily { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 18px 22px 8px; }
.daily-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.daily-stack { flex: 1; width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; background: var(--fill); }
.daily-stack > span { display: block; width: 100%; }
.daily-label { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.daily-legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 4px 22px 18px; font-size: 12.5px; color: var(--text-2); }
.daily-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--c); }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 14px;
  border: 0; border-radius: var(--radius-control);
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
  background: var(--fill); color: var(--text);
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.08s ease;
}
.btn:hover { background: var(--fill-hover); }
.btn:active { transform: scale(0.98); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { filter: brightness(1.06); }
.btn.warning { background: var(--orange); color: #fff; }
.btn.success { background: var(--green); color: #fff; }
.btn.plain { background: transparent; color: var(--accent-text); padding: 0 8px; }
.btn.plain:hover { background: var(--accent-soft); }
.btn.plain.danger { color: var(--red-text); }
.btn.plain.danger:hover { background: var(--red-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn.icon-only { width: 32px; padding: 0; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14.5px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; transform: none; }
.btn.spinning .icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 12px;
  border: 0; border-radius: var(--radius-control);
  background: var(--fill); color: var(--text);
  box-shadow: inset 0 0 0 0.5px var(--hairline);
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
.textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { opacity: 0.45; cursor: not-allowed; }
.input:focus, .select:focus, .textarea:focus { outline: none; background: var(--card); box-shadow: inset 0 0 0 1px var(--accent), var(--focus); }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 15 5 5 5-5'/%3E%3Cpath d='m7 9 5-5 5 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.select.compact { width: auto; height: 32px; font-size: 13px; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 15px; height: 15px; }
.search .input { padding-left: 32px; height: 32px; font-size: 13.5px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }

.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.switch-row + .switch-row { border-top: 0.5px solid var(--hairline); }
.switch-row .meta { flex: 1; }
.switch-row .title { font-weight: 500; }
.switch-row .sub { font-size: 12px; color: var(--text-3); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 11px; background: var(--fill-hover);
  transition: background 0.2s ease; pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s cubic-bezier(.3,.7,.2,1);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill); gap: 2px; }
.segmented button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--text);
}
.segmented button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--hairline); }
.segmented .count { margin-left: 5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--grey-soft); color: var(--grey-text);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill.green { background: var(--green-soft); color: var(--green-text); }
.pill.orange { background: var(--orange-soft); color: var(--orange-text); }
.pill.red { background: var(--red-soft); color: var(--red-text); }
.pill.blue { background: var(--accent-soft); color: var(--accent-text); }
.pill.purple { background: var(--purple-soft); color: var(--purple-text); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; background: var(--fill); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--text-2);
  padding: 12px 14px 10px; border-bottom: 0.5px solid var(--hairline-strong);
  white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 0.5px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--row-hover); }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table .right { text-align: right; }
.table .center { text-align: center; }
.table .primary { font-weight: 600; }
.table .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.table .truncate { max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: nowrap; }
.table .status-row td { text-align: center; color: var(--text-3); padding: 42px 14px; }
.table .status-row.error td { color: var(--red-text); }

.meter { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.meter-line { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.meter-line .label { width: 32px; color: var(--text-3); font-weight: 500; }
.meter-line .bar-track { flex: 1; height: 6px; border-radius: 3px; }
.meter-line .val { width: 36px; text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

.steps { display: flex; gap: 3px; margin-top: 7px; }
.steps span { height: 4px; flex: 1; border-radius: 2px; background: var(--fill); }
.steps span.on { background: var(--accent); }
.steps.done span.on { background: var(--green); }
.steps.failed span.on { background: var(--red); }
.steps.expired span.on { background: var(--orange); }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-top: 0.5px solid var(--hairline); font-size: 13px; color: var(--text-2); }

.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 16px 22px 8px; }

/* empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 64px 24px; }
.empty .icon-wrap {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 6px;
}
.empty .icon-wrap .icon { width: 26px; height: 26px; }
.empty h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.empty p { margin: 0; max-width: 420px; color: var(--text-2); }
.empty .btn { margin-top: 10px; }

/* ------------------------------------------------------------------ modals (sheets) */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 24px;
  background: var(--scrim);
  animation: scrim-in 0.18s ease-out;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 480px; max-height: calc(100vh - 48px); overflow-y: auto;
  background: var(--elevated); border-radius: 18px;
  box-shadow: var(--shadow-sheet);
  animation: sheet-in 0.24s cubic-bezier(.2,.9,.25,1.05);
}
.sheet.wide { max-width: 640px; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.sheet-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 6px; }
.sheet-head .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
.sheet-head .kpi-icon .icon { width: 19px; height: 19px; }
.sheet-title { margin: 0; font-weight: 700; font-size: 17px; letter-spacing: -0.015em; }
.sheet-sub { margin: 3px 0 0; font-size: 13px; color: var(--text-2); }
.sheet-body { padding: 14px 24px 6px; display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px 22px; }
.note { font-size: 12.5px; color: var(--text-2); background: var(--fill); padding: 10px 12px; border-radius: 10px; }
.note.warning { background: var(--orange-soft); color: var(--orange-text); }
.note.danger { background: var(--red-soft); color: var(--red-text); }

.code-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 20px 18px 16px; border-radius: 14px;
  background: var(--fill);
}
.code-box code {
  font-family: var(--font-mono); font-size: 18px; font-weight: 600; letter-spacing: 0.03em;
  white-space: nowrap; user-select: all;
}

/* ------------------------------------------------------------------ toasts */
.toast-container {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 12px 10px 16px; border-radius: 14px;
  background: var(--toast); color: var(--toast-text);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-pop);
  font-size: 13.5px; font-weight: 500;
  animation: toast-in 0.28s cubic-bezier(.2,.9,.25,1.1);
}
.toast .icon { width: 18px; height: 18px; }
.toast.success > .icon { color: var(--green); }
.toast.error > .icon { color: #FF6961; }
.toast.warning > .icon { color: var(--orange); }
.toast.info > .icon { color: #409CFF; }
.toast .close { border: 0; background: transparent; color: inherit; opacity: 0.6; padding: 4px; border-radius: 6px; display: grid; }
.toast .close:hover { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.25s ease, transform 0.25s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ login */
.login {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(0, 113, 227, 0.10), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(175, 82, 222, 0.08), transparent 60%),
    var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 34px 32px 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card .logo { width: 64px; height: 64px; margin: 0 auto 4px; filter: drop-shadow(0 8px 18px rgba(0, 98, 214, 0.28)); }
.login-card h1 { margin: 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: -0.02em; }
.login-card .lead { margin: -8px 0 6px; text-align: center; color: var(--text-2); font-size: 13.5px; }
.login-card .input { height: 40px; font-size: 14.5px; }
.login-error { font-size: 13px; text-align: center; }
.login-error.error { color: var(--red-text); }
.login-error.warning { color: var(--orange-text); }
.login-error.info { color: var(--text-2); }
.login-foot { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { position: relative; width: 100%; height: auto; border-right: 0; border-bottom: 0.5px solid var(--hairline); padding-bottom: 8px; }
  .nav { flex-direction: row; overflow-x: auto; margin-top: 12px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { flex: none; white-space: nowrap; }
  .nav-section, .sidebar-footer .user-card .meta { display: none; }
  .sidebar-footer { position: absolute; top: 14px; right: 12px; margin: 0; padding: 0; }
  .banner-side { display: none; }
  .toolbar { padding: 18px 16px 12px; flex-wrap: wrap; }
  .content { padding: 4px 16px 32px; }
  .grid-3, .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .donut-wrap { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
