/* ---------- Design tokens (Zylentix brand system, validated) ----------
   Brand violet ramp + gray neutrals from D:\zylentix frontend/styles/theme.css.
   Accent: brand-600 #5525BF (light) / brand-400 #9976E5 (dark) — both pass
   the dataviz palette checks against their surfaces. Status colors stay
   fixed (never themed). */
:root {
  --page: #fafafa;            /* gray-50 */
  --surface: #ffffff;
  --text-1: #181d27;          /* gray-900 */
  --text-2: #414651;          /* gray-700 */
  --muted: #717680;           /* gray-500 */
  --grid: #e9eaeb;            /* gray-200 */
  --baseline: #d5d7da;        /* gray-300 */
  --border: rgba(10, 13, 18, 0.10);
  --accent: #5525bf;          /* brand-600 */
  --accent-hover: #481fa2;    /* brand-700 */
  --accent-soft: #f1ecfb;     /* brand-50 */
  /* Solid brand fills keep brand-600 in BOTH modes (white text stays legible),
     matching Zylentix bg-brand-solid. Not overridden in dark. */
  --accent-solid: #5525bf;
  --accent-solid-hover: #481fa2;
  --spark: #d5d7da;           /* de-emphasis for sparklines */
  --delta-good: #006300;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --status-neutral: #717680;
  --sidebar-bg: #f5f5f5;      /* gray-100 */
  --hover-wash: rgba(10, 13, 18, 0.045);
  --shadow: 0 1px 2px rgba(10, 13, 18, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0c0e12;          /* dark gray-950 */
    --surface: #13161b;       /* dark gray-900 */
    --text-1: #f7f7f7;
    --text-2: #cecfd2;        /* dark gray-300 */
    --muted: #85888e;         /* dark gray-500 */
    --grid: #22262f;          /* dark gray-800 */
    --baseline: #373a41;      /* dark gray-700 */
    --border: rgba(255, 255, 255, 0.10);
    --accent: #9976e5;        /* brand-400 */
    --accent-hover: #b9a1ed;  /* brand-300 */
    --accent-soft: rgba(153, 118, 229, 0.16);
    --spark: #373a41;
    --delta-good: #0ca30c;
    --sidebar-bg: #0f1116;
    --hover-wash: rgba(255, 255, 255, 0.055);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --page: #0c0e12;
  --surface: #13161b;
  --text-1: #f7f7f7;
  --text-2: #cecfd2;
  --muted: #85888e;
  --grid: #22262f;
  --baseline: #373a41;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #9976e5;
  --accent-hover: #b9a1ed;
  --accent-soft: rgba(153, 118, 229, 0.16);
  --spark: #373a41;
  --delta-good: #0ca30c;
  --sidebar-bg: #0f1116;
  --hover-wash: rgba(255, 255, 255, 0.055);
  --shadow: none;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-1);
  background: var(--page);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 16px;
  font-weight: 650; font-size: 15px;
}
.brand-mark {
  width: 30px; height: 30px;
  display: block;
  border-radius: 8px; /* the SVG mark carries its own rounded tile */
}
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500;
}
.nav-link svg { width: 17px; height: 17px; fill: currentColor; opacity: 0.85; }
.nav-link:hover { background: var(--hover-wash); color: var(--text-1); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 8px; }
.sidebar-overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.4);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 16px; font-weight: 650; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--hover-wash); }
.icon-btn svg { width: 18px; height: 18px; fill: var(--text-2); }
#sidebar-toggle { display: none; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-solid); color: #fff;
  font-size: 12px; font-weight: 700;
}
.user-name { font-weight: 550; color: var(--text-2); }

.content {
  padding: 20px 24px 40px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
}

/* ---------- Filter row ---------- */
.filter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.range-btn {
  padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2); font-weight: 500;
}
.range-btn:hover { background: var(--hover-wash); }
.range-btn.is-selected {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  font-weight: 600;
}
.range-btn.is-selected::before { content: "✓ "; font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 10px;
}
.card-title { font-size: 14px; font-weight: 650; }
.card-sub { font-size: 12px; color: var(--muted); }
.ghost-btn {
  font-size: 12px; font-weight: 550; color: var(--text-2);
  padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.ghost-btn:hover { background: var(--hover-wash); }
.ghost-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- KPI tiles ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-tile { position: relative; overflow: hidden; }
.stat-label { font-size: 12.5px; color: var(--text-2); }
.stat-value { font-size: 28px; font-weight: 650; line-height: 1.25; margin-top: 2px; }
.stat-delta { font-size: 12px; color: var(--text-2); min-height: 18px; }
.stat-delta .up { color: var(--delta-good); font-weight: 600; }
.stat-delta .down { color: var(--status-critical); font-weight: 600; }
.stat-delta.muted, .stat-delta .vs { color: var(--muted); }
.stat-spark { width: 100%; height: 32px; margin-top: 6px; }

/* ---------- Charts ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 14px;
}
.chart-body { position: relative; }
.chart-body svg.chart { width: 100%; height: auto; }
.chart-empty {
  display: grid; place-items: center;
  min-height: 200px; color: var(--muted); font-size: 13px;
}
.chart-tooltip {
  position: fixed; z-index: 100;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  padding: 8px 11px;
  font-size: 12px;
  min-width: 130px;
}
.chart-tooltip .tt-title { color: var(--muted); margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.chart-tooltip .tt-key { width: 10px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.chart-tooltip .tt-value { font-weight: 650; margin-left: auto; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-label { color: var(--text-2); }

/* status bars */
.status-row-label { font-size: 12.5px; fill: var(--text-1); font-weight: 550; }
.axis-label { font-size: 11px; fill: var(--muted); }
.value-label { font-size: 11.5px; fill: var(--text-2); font-weight: 600; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid);
  color: var(--text-1);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--hover-wash); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .dim { color: var(--muted); }
.empty-note { color: var(--muted); font-size: 13px; padding: 18px 10px; text-align: center; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 550; color: var(--text-2);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* chart table twins */
.chart-table-wrap { max-height: 260px; overflow-y: auto; }

/* ---------- Skeleton loaders (initial connect only) ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--hover-wash);
  border-radius: 7px;
  display: block;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg,
    transparent,
    color-mix(in srgb, var(--text-1) 7%, transparent),
    transparent);
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
@keyframes sk-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}
.sk-line { height: 12px; }
.sk-line-lg { height: 18px; }
.sk-bar { height: 8px; border-radius: 4px; }
.sk-chart { height: 200px; border-radius: 10px; }
.sk-stack { display: flex; flex-direction: column; gap: 9px; }

/* ---------- Monitoring page ---------- */
.monitor-topline {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.live-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 550; color: var(--text-2);
}
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.live-dot.is-live {
  background: var(--status-good);
  animation: live-pulse 2s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--status-good) 40%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 550; color: var(--text-2);
}
.legend-key { width: 14px; height: 3px; border-radius: 2px; flex-shrink: 0; }
.chart-card-full { grid-column: 1 / -1; }

/* resource meters */
.meters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.meter-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.meter-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.meter-value { font-size: 15px; font-weight: 650; }
.meter-track {
  height: 8px; border-radius: 4px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease, background 0.4s ease;
}
.meter-sub { font-size: 11.5px; color: var(--muted); margin-top: 7px; }

/* ---------- Monitoring panel ---------- */
.monitor-meta { display: flex; align-items: center; gap: 10px; }
.monitor-updated { font-size: 12px; color: var(--muted); }
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  transition: opacity 0.15s;
}
.monitor-grid.is-loading { opacity: 0.55; }
.service-tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 5px;
}
.service-name { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.service-status { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 14px; }
.service-detail { font-size: 12px; color: var(--muted); }
.service-detail .err { color: var(--status-critical); }
.monitor-tasks {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: baseline;
  border-top: 1px solid var(--grid);
  margin-top: 14px; padding-top: 12px;
  font-size: 12.5px; color: var(--text-2);
}
.mt-stat strong { font-size: 15px; color: var(--text-1); margin-right: 4px; }
.mt-failures { flex-basis: 100%; }
.mt-failures ul { list-style: none; margin-top: 4px; display: flex; flex-direction: column; gap: 3px; }
.mt-failures li { color: var(--muted); }
.mt-failures .f-task { color: var(--status-critical); font-weight: 600; }

/* status pill variants (server-rendered) */
.st-completed .status-dot { background: var(--status-good); }
.st-processing .status-dot { background: var(--status-warning); }
.st-pending .status-dot { background: var(--status-neutral); }
.st-failed .status-dot { background: var(--status-critical); }
.table-link { color: var(--accent); font-weight: 550; }
.table-link:hover { text-decoration: underline; }

/* ---------- Upload page ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 36px 20px;
  border: 1.5px dashed var(--baseline);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); border-style: solid; }
.dropzone.is-busy { opacity: 0.6; pointer-events: none; }
.dropzone svg { width: 28px; height: 28px; fill: var(--muted); margin-bottom: 4px; }
.dz-title { font-weight: 600; color: var(--text-1); }
.dz-sub { font-size: 12.5px; color: var(--muted); }
.dz-browse { color: var(--accent); font-weight: 550; }

.upload-progress { margin-top: 14px; }
.up-row { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.up-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-pct { color: var(--text-2); font-weight: 600; }
.progress-track {
  height: 6px; border-radius: 3px;
  background: var(--accent-soft);
}
.progress-fill {
  height: 100%; width: 0; border-radius: 3px;
  background: var(--accent);
  transition: width 0.15s ease;
}
.upload-error {
  margin-top: 12px; font-size: 13px; font-weight: 550;
  color: var(--status-critical);
}

/* upload wizard modal */
.upload-modal { width: min(620px, calc(100vw - 32px)); }
.upload-actions { display: flex; align-items: center; gap: 10px; }
.wizard-steps {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0 16px;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.wstep {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.wstep.is-active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.wstep-sep { color: var(--baseline); }
.map-hint { font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
.req-star { color: var(--status-critical); font-weight: 700; }
.map-table-wrap { max-height: 46vh; overflow-y: auto; border: 1px solid var(--grid); border-radius: 9px; }
.map-table-wrap .data-table td { white-space: normal; }
.map-select { width: 100%; padding: 6px 10px; font-size: 13px; }
.map-note { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.st-awaiting_mapping .status-dot { background: var(--accent); }

/* step 3: preview (modal grows to XL) */
.upload-modal.modal-xl { width: min(1180px, calc(100vw - 32px)); }
.preview-table-wrap {
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--grid);
  border-radius: 9px;
}
.preview-table-wrap .data-table th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.prev-col-mapped { color: var(--accent); font-weight: 700; display: block; }
.prev-col-original {
  display: block;
  font-size: 10.5px; font-weight: 400;
  color: var(--muted);
  text-transform: none; letter-spacing: 0;
}
.prev-col-passthrough { color: var(--muted); font-weight: 600; display: block; }
.prev-key-mapped { color: var(--accent); font-weight: 650; }
.prev-key-passthrough { color: var(--muted); font-weight: 650; }

/* ---------- Detail page ---------- */
.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}
.breadcrumb a { color: var(--accent); font-weight: 550; }
.breadcrumb a:hover { text-decoration: underline; }
.crumb-current { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 8px 0 4px;
}
.summary-item dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.summary-item dd { font-size: 20px; font-weight: 650; margin-top: 2px; }

.processing-note {
  display: flex; align-items: center; gap: 9px;
  margin-top: 10px; font-size: 13px; color: var(--text-2);
}
.spinner {
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 14px; }
.chip-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.chip {
  font-size: 12px; font-weight: 550; color: var(--text-2);
  background: var(--hover-wash);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
}

.error-card { border-left: 3px solid var(--status-critical); }
.error-list { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.error-list li { color: var(--text-2); }
.err-row {
  font-weight: 650; color: var(--status-critical);
  margin-right: 8px; font-variant-numeric: tabular-nums;
}

.pagination {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding-top: 14px;
}
.page-btn {
  font-size: 13px; font-weight: 550; color: var(--accent);
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 8px;
}
.page-btn:hover { background: var(--hover-wash); }
.page-info { font-size: 12.5px; color: var(--muted); }

/* ---------- Flash messages ---------- */
.messages { display: flex; flex-direction: column; gap: 8px; }
.flash {
  font-size: 13px; font-weight: 550;
  border-radius: 9px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-1);
}
.flash-success { border-color: color-mix(in srgb, var(--status-good) 35%, transparent); color: var(--delta-good); }
.flash-error { border-color: color-mix(in srgb, var(--status-critical) 35%, transparent); color: var(--status-critical); }

/* ---------- User management ---------- */
.btn-primary {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--accent-solid);
  color: #fff !important;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-solid-hover); text-decoration: none; }

.search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.input {
  font: inherit; color: var(--text-1);
  background: var(--page);
  border: 1px solid var(--baseline);
  border-radius: 9px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-input { flex: 1; max-width: 380px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.user-cell-name { display: block; font-weight: 600; }
.user-cell-full { display: block; font-size: 11.5px; color: var(--muted); }
.row-inactive td { opacity: 0.55; }
.row-inactive .actions-cell { opacity: 1; }

.role-pill {
  display: inline-block;
  font-size: 11.5px; font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.role-pill.role-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.role-pill.role-staff { border-color: var(--accent); color: var(--accent); }

.actions-cell { white-space: nowrap; }
.inline-form { display: inline; }
.mini-btn {
  display: inline-block;
  font-size: 12px; font-weight: 550;
  color: var(--text-2);
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-left: 4px;
  background: none;
}
.mini-btn:hover { background: var(--hover-wash); color: var(--text-1); }
.mini-btn-danger { color: var(--status-critical); border-color: color-mix(in srgb, var(--status-critical) 30%, transparent); }
.mini-btn-danger:hover { background: color-mix(in srgb, var(--status-critical) 8%, transparent); color: var(--status-critical); }

.form-card { max-width: 560px; }
.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px;
}
.form-field input:not([type="checkbox"]), .form-field select {
  width: 100%;
  font: inherit; color: var(--text-1);
  background: var(--page);
  border: 1px solid var(--baseline);
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field input:focus, .form-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.field-hint ul { margin-left: 16px; }
.field-error { font-size: 12px; font-weight: 550; color: var(--status-critical); margin-top: 4px; }
.form-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); }
.form-check label { font-size: 13px; font-weight: 600; cursor: pointer; }
.check-hint { display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; }

/* ---------- Confirm modal ---------- */
.confirm-modal {
  margin: auto;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.confirm-modal::backdrop {
  background: rgba(10, 13, 18, 0.45);
  backdrop-filter: blur(2px);
}
.modal-title { font-size: 16px; font-weight: 650; margin-bottom: 6px; }
.modal-message { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px;
}
.btn-danger, .btn-danger:hover { background: var(--status-critical); }
.btn-danger:hover { filter: brightness(0.92); }
.user-modal { width: min(460px, calc(100vw - 32px)); }
.user-modal .form-field input { background: var(--page); }

/* ---------- Auth (login) page ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--page);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 30px 26px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand-name { font-size: 15px; font-weight: 650; }
.auth-title { font-size: 22px; font-weight: 700; }
.auth-sub { font-size: 13px; color: var(--muted); margin: 4px 0 18px; }
.auth-error {
  font-size: 13px; font-weight: 550;
  color: var(--status-critical);
  background: color-mix(in srgb, var(--status-critical) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--status-critical) 25%, transparent);
  border-radius: 9px;
  padding: 9px 12px;
  margin-bottom: 16px;
}
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block;
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 5px;
}
.auth-field input {
  width: 100%;
  font: inherit; color: var(--text-1);
  background: var(--page);
  border: 1px solid var(--baseline);
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-submit {
  width: 100%;
  margin-top: 6px;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--accent-solid);
  color: #fff;
  font-weight: 650;
  transition: background 0.15s;
}
.auth-submit:hover { background: var(--accent-solid-hover); }
.auth-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-foot {
  margin-top: 18px;
  font-size: 12px; color: var(--muted);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  #sidebar-toggle { display: grid; }
  .user-name { display: none; }
  .content { padding: 14px 14px 32px; }
  .kpi-row { grid-template-columns: 1fr; }
  .topbar { padding: 8px 14px; }
}

/* ── Import progress + per-minute rate ─────────────────────────────────── */
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
  margin: 4px 0 2px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.rate-table .mono { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.rate-table .rate-phase { color: var(--text-muted); font-size: 12px; }
/* a bar behind the number, so a burst minute is obvious at a glance */
.rate-bar {
  display: inline-block;
  width: var(--pct, 0%);
  max-width: 90px;
  height: 10px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 2px;
  background: var(--accent-soft);
}
