/* ============================================================================
   AutoAce — Arctic enterprise SaaS design system
   Plain CSS custom properties + reusable component classes. Light theme only:
   pale-blue canvas, white/translucent cards, navy headings, electric-blue
   accents. No framework, no build step.
   ========================================================================== */

:root {
  /* Surfaces */
  --background: #e8f1fc;
  --background-soft: #f3f8fe;
  --surface: #ffffff;
  --surface-translucent: rgba(255, 255, 255, 0.78);
  --surface-hover: #eef3fa;

  /* Text */
  --text-primary: #1e293b;
  --text-heading: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-placeholder: #94a3b8;

  /* Borders */
  --border: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(148, 163, 184, 0.4);
  --border-card: rgba(226, 232, 240, 0.7);

  /* Accent */
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: #dbeafe;
  --accent-text: #ffffff;

  /* Semantic (badges, messages) */
  --success-bg: #dcfce7;
  --success-text: #15803d;
  --warning-bg: #fef9c3;
  --warning-text: #a16207;
  --danger-bg: #fee2e2;
  --danger-text: #b91c1c;
  --purple-bg: #f3e8ff;
  --purple-text: #7e22ce;
  --info-bg: #dbeafe;
  --info-text: #1d4ed8;

  /* Radii */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 14px;

  /* Depth */
  --shadow-card:
    0 1px 2px rgba(15, 23, 42, 0.03),
    0 4px 12px rgba(15, 23, 42, 0.04),
    0 0 0 1px rgba(59, 130, 246, 0.02);
  --shadow-pop: 0 12px 34px rgba(15, 23, 42, 0.14);
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.15);

  /* Layout */
  --content-max: 1120px;

  --font-sans: 'Sora', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

/* Component classes below set `display`, which would otherwise win over the UA
   [hidden] rule on equal specificity — keep the attribute authoritative. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-primary);
  background:
    linear-gradient(
      135deg,
      #f3f8fe 0%,
      #e8f2fd 25%,
      #f0f7ff 50%,
      #f5faff 75%,
      #f3f8fe 100%
    );
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  color: var(--text-heading);
  font-weight: 650;
  letter-spacing: -0.025em;
  margin: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--accent-soft);
  color: var(--info-text);
  padding: 0.05em 0.4em;
  border-radius: 5px;
}

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

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

/* Lucide-style outline icons (inline sprite, ~1.75px stroke) */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
}

/* ============================================================================
   Top bar (logo + page title + account) — no sidebar
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 32px;
  background: var(--surface-translucent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--border);
  flex: none;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.03em;
  color: var(--text-heading);
}

.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  flex: none;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px 32px 56px;
  display: grid;
  gap: 24px;
}

/* Grid/flex children default to min-width:auto, which lets wide content (a long
   error cell, a long file name) blow the track out past the viewport. Force
   every layout child to be allowed to shrink so inner scroll containers work. */
.content-inner > *,
.columns > * { min-width: 0; }

/* ============================================================================
   Cards / panels
   ========================================================================== */

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card);
  padding: 22px;
  min-width: 0;
}

.panel > h2,
.card > h2 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.panel > h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 4px 0 12px;
}

.section-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: -4px 0 16px;
  max-width: 60ch;
}

.columns {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

/* ============================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
    color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn svg { width: 17px; height: 17px; }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; transform: none !important; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  background: var(--surface-translucent);
  border-color: var(--border-strong);
  color: var(--text-heading);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text-heading); }
.btn-ghost svg { color: var(--text-muted); }

.btn-block { width: 100%; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }

/* Subtle text-link button (housekeeping affordance) */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  padding: 8px 0 2px;
  margin-top: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s var(--ease);
}
.link-btn svg { width: 13px; height: 13px; }
.link-btn:hover { color: var(--danger-text); }
.link-btn:disabled { color: var(--text-placeholder); text-decoration: none; cursor: default; }
.link-btn:focus-visible { box-shadow: var(--focus-ring); }

/* ============================================================================
   Inputs & upload controls
   ========================================================================== */

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.text-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.text-input::placeholder { color: var(--text-placeholder); }
.text-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }

/* Segmented control for the standalone / folder / ZIP selector */
.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--background-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}
.segmented label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.segmented label svg { width: 15px; height: 15px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:hover { color: var(--text-heading); }
.segmented label:has(input:checked) {
  background: var(--surface);
  color: var(--accent-hover);
  box-shadow: var(--shadow-card);
}
.segmented label:has(input:focus-visible) { box-shadow: var(--focus-ring); }

/* Upload drop zone */
.uploader {
  background: var(--surface-translucent);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.uploader:hover { border-color: var(--accent); }
.uploader.dragover { border-color: var(--accent); background: var(--accent-soft); }
.uploader.dragover .dz-files { pointer-events: none; }
.uploader:focus-within { box-shadow: var(--focus-ring); }

.dz-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  padding: 24px 20px;
  cursor: pointer;
}
.dz-icon {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.dz-icon svg { width: 22px; height: 22px; }
.dz-primary { font-weight: 600; color: var(--text-heading); font-size: 14px; }
.dz-primary .dz-link { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
.dz-hint { font-size: 12.5px; color: var(--text-muted); }

/* Compact prompt once files are staged */
.uploader.has-files .dz-prompt {
  flex-direction: row;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.uploader.has-files .dz-icon,
.uploader.has-files .dz-hint { display: none; }
.uploader.has-files .dz-primary { font-size: 13px; font-weight: 500; color: var(--text-muted); }

/* Staged-file chips */
.dz-files {
  list-style: none;
  margin: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.dz-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: 13px;
}
.dzf-fileicon { flex: none; color: var(--accent); }
.dzf-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
}
.dzf-size { flex: none; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.dzf-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px; height: 26px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent-hover);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.dzf-play .icon { width: 13px; height: 13px; }
.dzf-play:hover { background: var(--accent-soft); border-color: var(--accent); }
.dzf-play:focus-visible { box-shadow: var(--focus-ring); }
.dzf-play.playing { background: var(--accent); border-color: var(--accent); color: #fff; }

.dzf-remove {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.dzf-remove:hover { background: var(--danger-bg); color: var(--danger-text); }
.dzf-remove:focus-visible { box-shadow: var(--focus-ring); }
.dzf-remove .icon { width: 15px; height: 15px; }

.file-summary {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 12px 0 16px;
  min-height: 1.2em;
}
.file-summary:empty { margin: 0; min-height: 0; }
.file-summary.invalid { color: var(--danger-text); font-weight: 500; }

.limits-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 20px;
  color: var(--text-secondary);
  font-size: 13px;
}
.limits-list li {
  position: relative;
  padding-left: 18px;
}
.limits-list li::before {
  content: '';
  position: absolute;
  left: 2px; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* ============================================================================
   Upload progress
   ========================================================================== */

.progress-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.progress-list:empty { margin: 0; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--background-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12.5px;
}
.progress-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.progress-row .bar-track {
  width: 140px;
  height: 6px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-row .bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s var(--ease);
}
.progress-row .pct { color: var(--text-muted); min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; }
.progress-row.done .bar-fill { background: var(--success-text); }
.progress-row.done .pct { color: var(--success-text); font-weight: 600; }
.progress-row.failed .bar-fill { background: var(--danger-text); }
.progress-row.failed .pct { color: var(--danger-text); font-weight: 600; }

/* ============================================================================
   Badges / status chips
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
  flex: none;
}
.badge.no-dot::before { display: none; }

/* Blue — informational / in progress */
.badge.status-processing,
.badge.status-validating,
.badge.status-pending,
.badge.status-awaiting_upload,
.badge.status-uploading {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: transparent;
}
/* Green — completed / accepted */
.badge.status-completed,
.badge.status-accepted {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: transparent;
}
/* Amber — queued / partial / warnings */
.badge.status-queued,
.badge.status-partially_accepted,
.badge.status-completed_with_errors {
  background: var(--warning-bg);
  color: var(--warning-text);
  border-color: transparent;
}
/* Red — failed / rejected */
.badge.status-failed,
.badge.status-rejected {
  background: var(--danger-bg);
  color: var(--danger-text);
  border-color: transparent;
}
/* Purple — secondary category (upload kind) */
#summary-kind.badge {
  background: var(--purple-bg);
  color: var(--purple-text);
  border-color: transparent;
}

/* Live pulse pill (top bar) */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--success-bg);
  color: var(--success-text);
}
.pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ============================================================================
   Status panel + summary
   ========================================================================== */

.summary-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
/* Upload id claims the whole first line; the badges wrap onto the next. */
.summary-row #summary-id {
  flex-basis: 100%;
  min-width: 0;
  word-break: break-all;
}
.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.error-text {
  color: var(--danger-text);
  font-size: 13px;
  margin-bottom: 10px;
}
.error-text:empty { display: none; }

.manifest-errors {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--warning-text);
  font-size: 12.5px;
}
.manifest-errors:empty { display: none; }

/* ============================================================================
   Data table
   ========================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  margin-top: 6px;
  max-width: 100%;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
/* The error column can carry a long sanitized message — let it wrap and cap its
   width so one bad file can't force the whole table (and page) wide. */
.data-table th:last-child,
.data-table td:last-child {
  white-space: normal;
  min-width: 12rem;
  max-width: 22rem;
  word-break: break-word;
}
.data-table td:first-child { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.data-table thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--background-soft);
}
.data-table tbody tr { transition: background 0.12s var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.num { font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* ============================================================================
   Analysis result cards
   ========================================================================== */

.analysis-results { margin-top: 20px; }
.analysis-results:empty { display: none; }
.analysis-results h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.analysis-card {
  border: 1px solid var(--border-card);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--background-soft);
}
.analysis-card:last-child { margin-bottom: 0; }
.ac-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ac-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 18px;
  font-size: 13px;
}
.ac-k { color: var(--text-muted); }
.ac-v { color: var(--text-primary); font-weight: 500; }

/* ============================================================================
   History list
   ========================================================================== */

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 30rem;
  overflow-y: auto;
}
.history-list:empty::after {
  content: 'No uploads from this browser yet.';
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 2px;
}
.history-list li {
  padding: 10px 12px;
  border: 1px solid var(--border-card);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.history-list li:hover { border-color: var(--accent); background: var(--surface-hover); }
.history-list li.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.history-list li:focus-visible { box-shadow: var(--focus-ring); }
.history-list .h-id {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-list .h-meta { color: var(--text-muted); font-size: 11.5px; }

/* ============================================================================
   Downloads / export controls
   ========================================================================== */

.downloads { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; }
.downloads a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-translucent);
  color: var(--text-heading);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.downloads a svg { width: 16px; height: 16px; color: var(--accent); }
.downloads a:hover { background: var(--surface-hover); border-color: var(--accent); }

/* ============================================================================
   Empty states
   ========================================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .es-icon {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent-hover);
  margin-bottom: 4px;
}
.empty-state .es-icon svg { width: 22px; height: 22px; }
.empty-state .es-icon.es-icon-warn { background: var(--warning-bg); color: var(--warning-text); }
.empty-state strong { color: var(--text-heading); font-weight: 600; font-size: 14px; }
.empty-state span { font-size: 13px; max-width: 40ch; }
.empty-state .btn { margin-top: 6px; }

.icon.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-muted); font-size: 13px; }

/* ============================================================================
   Toasts
   ========================================================================== */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 380px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  color: var(--text-primary);
  animation: toast-in 0.2s var(--ease);
}
.toast.leaving { animation: toast-out 0.2s var(--ease) forwards; }
.toast .t-icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.toast.toast-error { border-left: 3px solid var(--danger-text); }
.toast.toast-error .t-icon { color: var(--danger-text); }
.toast.toast-success { border-left: 3px solid var(--success-text); }
.toast.toast-success .t-icon { color: var(--success-text); }
.toast.toast-info { border-left: 3px solid var(--accent); }
.toast.toast-info .t-icon { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ============================================================================
   Confirmation modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.32);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in 0.15s var(--ease);
}
.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 22px;
  animation: modal-in 0.18s var(--ease);
}
.modal h3 {
  font-size: 16px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.modal p { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-danger { background: var(--danger-text); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a01a1a; transform: translateY(-1px); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ============================================================================
   Login screen
   ========================================================================== */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-main { width: 100%; max-width: 384px; }
.login-head {
  text-align: center;
  margin-bottom: 20px;
}
.login-head .brand-mark {
  width: 46px; height: 46px;
  border-radius: var(--r-md);
  margin: 0 auto 14px;
}
.login-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.login-head p { margin: 6px 0 0; color: var(--text-muted); font-size: 13.5px; }

.login-panel {
  background: var(--surface-translucent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-panel .btn { margin-top: 2px; }

/* ============================================================================
   Responsive
   ========================================================================== */

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; }
  .topbar-divider { display: none; }
  .page-title { display: none; }
  .brand-name { font-size: 15px; }
  .content-inner { padding: 18px 16px 44px; gap: 18px; }

  .columns { grid-template-columns: 1fr; }
  .panel, .card { padding: 18px; }
}

/* Table → stacked cards on small screens */
@media (max-width: 680px) {
  .table-wrap { border: none; border-radius: 0; overflow: visible; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tr {
    border: 1px solid var(--border-card);
    border-radius: var(--r-md);
    margin-bottom: 10px;
    padding: 6px 12px;
    background: var(--background-soft);
  }
  .data-table tbody tr:hover { background: var(--background-soft); }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--border);
    white-space: normal;
  }
  .data-table td:first-child,
  .data-table td:last-child { max-width: none; min-width: 0; }
  .data-table td:last-child { text-align: right; }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex: none;
  }
  .data-table td:empty { display: none; }

  .ac-grid { grid-template-columns: 1fr; gap: 3px 0; }
  .ac-grid .ac-k { margin-top: 8px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
  .ac-grid .ac-k:first-child { margin-top: 0; }

  .segmented { display: grid; grid-template-columns: 1fr 1fr 1fr; width: 100%; }
  .segmented label { justify-content: center; padding: 9px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
