/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* This app's own names, mapped to the shared tokens (static/ui/tokens.css),
     so light and dark both follow the shared look. */
  --paper: var(--surface);  --paper-soft: var(--surface-2);
  --border: var(--line);    --border-soft: var(--line);
  --ink-soft: var(--muted); --ink-faint: var(--muted);

  /* Reconciliation states */
  --teal: var(--ok);     --teal-soft: var(--ok-bg);
  --amber: var(--wait);  --amber-soft: var(--wait-bg);
  --coral: var(--fail);  --coral-soft: var(--fail-bg);
  --indigo: var(--info); --indigo-soft: var(--info-bg);

  --radius-lg: 6px;
  --sidebar-w: 220px;
  --shadow-sm: none; --shadow-md: var(--shadow); --shadow-lg: var(--shadow);

  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

/* ── Shell layout ──────────────────────────────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--paper);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--indigo) 100%);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.logo-mark svg { width: 18px; height: 18px; stroke: #fff; }
.logo-text { font-family: var(--sans); font-weight: 600; font-size: 17px; letter-spacing: -0.2px; color: var(--ink); }
.logo-sub  { font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.04em; margin-top: -1px; }

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 18px 10px 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  user-select: none;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--paper-soft); color: var(--ink); }
.nav-item.active { background: var(--teal-soft); color: var(--teal); font-weight: 600; }

.nav-badge {
  margin-left: auto;
  background: var(--coral);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; background: var(--bg); }

.page-header {
  padding: 32px 36px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.page-title { font-family: var(--sans); font-size: 26px; font-weight: 600; letter-spacing: -0.3px; color: var(--ink); }
.page-subtitle { font-size: 13.5px; color: var(--ink-faint); margin-top: 4px; }

.page-body { padding: 4px 36px 36px; flex: 1; }

/* ── Dashboard cards ───────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.12s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--bar-color, var(--ink-faint));
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 12px; }
.stat-value { font-size: 36px; font-weight: 600; font-family: var(--mono); letter-spacing: -1px; color: var(--ink); }

.stat-card.teal   { --bar-color: var(--teal); }
.stat-card.amber  { --bar-color: var(--amber); }
.stat-card.coral  { --bar-color: var(--coral); }
.stat-card.indigo { --bar-color: var(--indigo); }

.stat-value.teal   { color: var(--teal); }
.stat-value.amber  { color: var(--amber); }
.stat-value.coral  { color: var(--coral); }
.stat-value.indigo { color: var(--indigo); }

/* ── Inbox page ────────────────────────────────────────────────────────────── */
.inbox-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 580px;
  box-shadow: var(--shadow-sm);
}
.inbox-status { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.status-dot.empty { background: var(--ink-faint); }
.status-dot.ready { background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.status-filename { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.status-label { font-size: 13px; color: var(--ink-faint); }

.inbox-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Run page ──────────────────────────────────────────────────────────────── */
.run-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 580px;
  box-shadow: var(--shadow-sm);
}
.run-status-row { display: flex; align-items: center; gap: 12px; margin: 22px 0 0; }
.run-spinner {
  width: 18px; height: 18px; border: 2.5px solid var(--border);
  border-top-color: var(--teal); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.run-status-text { font-size: 13px; color: var(--ink-soft); }
.run-status-text.success { color: var(--teal); font-weight: 600; }
.run-status-text.error   { color: var(--coral); font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border: none; transition: opacity 0.15s, background 0.15s, box-shadow 0.15s;
  text-decoration: none; font-family: inherit;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary   { background: var(--teal); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-md); opacity: 0.94; }
.btn-secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.btn-danger    { background: var(--coral-soft); color: var(--coral); border: 1px solid transparent; }
.btn-danger:hover:not(:disabled) { border-color: var(--coral); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }

.btn svg { width: 14px; height: 14px; }

/* ── Data tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  text-align: left; padding: 11px 16px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-faint);
  border-bottom: 1.5px solid var(--border-soft);
  white-space: nowrap;
  background: var(--paper-soft);
}
.data-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border-soft);
  color: var(--ink);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--paper-soft); }
.data-table .mono { font-family: var(--mono); font-size: 12.5px; }
.data-table .positive { color: var(--coral); font-weight: 600; }
.data-table .negative { color: var(--teal); font-weight: 600; }
.data-table .neutral  { color: var(--ink-faint); }

.table-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.table-title { font-family: var(--sans); font-size: 16px; font-weight: 600; color: var(--ink); }
.row-count { font-size: 12px; color: var(--ink-faint); font-weight: 500; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 64px 32px; text-align: center; gap: 12px;
}
.empty-state svg { width: 42px; height: 42px; stroke: var(--ink-faint); opacity: 0.5; margin-bottom: 4px; }
.empty-state p   { color: var(--ink-faint); font-size: 13.5px; }

/* ── Upload modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,34,56,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--paper); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); width: 480px; max-width: 95vw;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid var(--border-soft);
}
.modal-header h3 { font-family: var(--sans); font-size: 17px; font-weight: 600; color: var(--ink); }
.modal-close { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 16px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px; }

.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 38px 20px; display: flex; flex-direction: column;
  align-items: center; gap: 9px; transition: border-color 0.15s, background 0.15s;
  cursor: pointer; background: var(--paper-soft);
}
.drop-zone.dragover { border-color: var(--teal); background: var(--teal-soft); }
.drop-icon { width: 38px; height: 38px; stroke: var(--ink-faint); }
.drop-text { font-size: 14px; font-weight: 600; color: var(--ink); }
.drop-sub  { font-size: 12px; color: var(--ink-faint); }

.upload-feedback {
  margin-top: 16px; padding: 13px 15px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
}
.upload-feedback.success { background: var(--teal-soft); color: var(--teal); }
.upload-feedback.error   { background: var(--coral-soft);   color: var(--coral); }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ── Sign-in not set up ──────────────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.auth-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 400px;
  max-width: 95vw;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 22px;
}
.auth-title { font-family: var(--sans); font-size: 22px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }



/* ══ App theme (shared look, mat_ui) ══════════════════════════════════════════
   The Process Registry's structure in the navy and gold brand colours: slim
   navy top bar, narrow sidebar, compact tables. Kept as overrides so the
   class names app.js builds pages with stay the same. */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.topbar {
  height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid var(--bar-line);
  position: relative; z-index: 210;
}
.topbar .sep { flex: 1; }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 24px; height: 27px; background: var(--gold); color: var(--navy);
  clip-path: polygon(50% 0, 96% 14%, 90% 73%, 50% 100%, 10% 73%, 4% 14%); font: 700 15px var(--serif);
}
.brand-name { font: 600 16px var(--serif); }
.brand-app {
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bar-muted); padding-left: 10px; border-left: 1px solid var(--bar-line);
}
.bar-btn {
  display: inline-flex; align-items: center; height: 32px; padding: 0 8px; cursor: pointer;
  background: transparent; color: var(--bar-ink); border: 1px solid var(--bar-line); border-radius: var(--radius);
}
.bar-btn:hover { border-color: var(--bar-muted); }
.bar-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu-btn, .scrim { display: none; }

.shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.sidebar-nav { padding: 8px 0 16px; }
.nav-section-label { font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: .1em; padding: 14px 14px 6px; }
.nav-item { border-radius: 0; border-left: 2px solid transparent; padding: 7px 14px; font-size: 13px; font-weight: 400; }
.nav-item.active { background: var(--active-bg); color: var(--ink); border-left-color: var(--gold); }
.nav-badge { background: var(--fail); color: var(--surface); font-family: var(--mono); font-weight: 500; }

.page-header { padding: 24px 28px 16px; }
.page-title { font-size: 21px; font-weight: 700; }
.page-subtitle { font-size: 13px; }
.page-body { padding: 0 28px 40px; }

.stat-grid { gap: 12px; margin-bottom: 18px; }
.stat-card { padding: 14px 16px; }
.stat-card:hover { transform: none; box-shadow: none; border-color: var(--gold); }
.stat-label { font-family: var(--mono); font-size: 10px; font-weight: 400; letter-spacing: .08em; margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 500; letter-spacing: -.5px; }
.inbox-card, .run-card { padding: 20px; }

.btn { padding: 7px 14px; border-radius: var(--radius); font-size: 13px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { box-shadow: none; opacity: .88; }
.btn-secondary:hover:not(:disabled) { border-color: var(--muted); color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.run-spinner { border-top-color: var(--accent); }

.data-table th { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; padding: 9px 16px; border-bottom-width: 1px; }
.data-table td { padding: 9px 16px; }
.table-toolbar { padding: 12px 16px; }
.table-title { font-size: 14px; }

.modal-overlay { background: rgb(8 20 34 / 55%); backdrop-filter: none; z-index: 220; }
.modal-header { padding: 14px 18px; }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 16px 18px; }
.drop-zone.dragover { border-color: var(--focus); background: var(--active-bg); }

/* "Sign-in is not set up": a centred box under the top bar */
.auth-overlay { top: 52px; }
.auth-card { padding: 22px; width: 380px; gap: 8px; box-shadow: none; }
.auth-overlay[hidden] { display: none; }
.bar-btn[hidden] { display: none; }
.bar-text { color: var(--bar-muted); font-size: 13px; }
@media (max-width: 800px) { .bar-text { display: none; } }
.auth-title { font-size: 15px; font-weight: 700; }

/* Phones and small tablets: the sidebar slides in from the left */
@media (max-width: 800px) {
  .menu-btn { display: inline-flex; }
  .brand-app { display: none; }
  .sidebar {
    position: fixed; top: 52px; bottom: 0; left: 0; width: 250px; z-index: 40;
    transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 52px 0 0 0; z-index: 30; background: rgb(8 20 34 / 45%); }
  .nav-item { padding: 10px 16px; font-size: 14px; }
  .page-header { padding: 16px 14px 12px; flex-wrap: wrap; gap: 10px; }
  .page-title { font-size: 19px; }
  .page-body { padding: 0 14px 32px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-table th, .data-table td { padding: 9px 10px; }
}
