/* ── InGovern Design System — Governance & Compliance ── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  /* Palette */
  --navy-900:  #0d1b2e;
  --navy-800:  #152338;
  --navy-700:  #1e3250;
  --navy-600:  #254069;
  --navy-500:  #2e5280;
  --blue-400:  #4a90d9;
  --blue-300:  #6aaee8;
  --teal-500:  #0d7a6e;
  --teal-400:  #10a896;
  --red-600:   #b91c1c;
  --red-400:   #ef4444;
  --amber-500: #b45309;
  --amber-400: #f59e0b;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --white:     #ffffff;

  /* Semantic */
  --bg-app:        #f0f2f5;
  --bg-sidebar:    var(--navy-900);
  --bg-panel:      var(--navy-800);
  --bg-surface:    var(--white);
  --bg-surface-2:  #f8fafc;
  --bg-surface-3:  #f1f4f8;
  --bg-header:     #f8fafc;

  --text-primary:  var(--navy-900);
  --text-secondary:var(--slate-600);
  --text-muted:    var(--slate-400);
  --text-sidebar:  #c8d6e8;
  --text-sidebar-active: var(--white);

  --border:        #dde3ec;
  --border-light:  #eaeff5;

  --accent:        var(--navy-700);
  --accent-hover:  var(--navy-600);

  --rec-for:       var(--teal-500);
  --rec-against:   var(--red-600);
  --rec-forstar:   var(--amber-500);

  --sidebar-w:     240px;
  --topbar-h:      56px;
  --font-mono:     'DM Mono', 'Courier New', monospace;
}

[data-theme="dark"] {
  --bg-app:        #0a0f1c;
  --bg-sidebar:    #080e1a;
  --bg-panel:      #0f1729;
  --bg-surface:    #141e30;
  --bg-surface-2:  #1a2540;
  --bg-surface-3:  #1e2d4a;
  --bg-header:     #121b2e;

  --text-primary:  #e2e8f4;
  --text-secondary:#94a8c2;
  --text-muted:    #5a718a;
  --text-sidebar:  #8aa0bc;
  --text-sidebar-active: #ffffff;

  --border:        rgba(255,255,255,0.08);
  --border-light:  rgba(255,255,255,0.05);

  --accent:        #4a8fd4;
  --accent-hover:  #5aa3e8;

  --rec-for:       #0d9e8e;
  --rec-against:   #dc3545;
  --rec-forstar:   #d97706;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* ── Layout Shell (full screen) ── */
.app-outer {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.app-shell {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ── Sidebar ── */
.history-panel {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
  flex-shrink: 0;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1rem 1.125rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  min-height: var(--topbar-h);
}

.sidebar-logo {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--navy-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.history-brand {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.theme-toggle {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-sidebar);
  transition: all 0.15s ease;
  margin-left: auto;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.12); color: white; }

.new-report-btn {
  margin: 0.875rem 1rem;
  width: calc(100% - 2rem);
  justify-content: center;
  flex-shrink: 0;
}

.history-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-sidebar);
  opacity: 0.5;
  padding: 0.5rem 1.125rem 0.3rem;
  flex-shrink: 0;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.625rem 1rem;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.history-empty {
  font-size: 0.78rem;
  color: var(--text-sidebar);
  opacity: 0.5;
  padding: 1rem 0.5rem;
  line-height: 1.6;
}

.history-item-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.history-item-wrap:hover .history-delete-btn {
  opacity: 1;
  pointer-events: auto;
}

.history-item {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
  font-family: inherit;
}
.history-item:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
}
.history-item.active {
  background: rgba(74,144,217,0.15);
  border-color: rgba(74,144,217,0.3);
}

.history-delete-btn {
  flex-shrink: 0;
  margin-left: 3px;
  padding: 4px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.12s ease;
  display: flex;
  align-items: center;
}
.history-delete-btn:hover {
  background: rgba(239,68,68,0.2);
  color: #ef4444;
}

.hi-company {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.hi-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hi-fy { font-size: 0.67rem; color: var(--text-sidebar); opacity: 0.7; font-weight: 500; }
.hi-date { font-size: 0.65rem; color: var(--text-sidebar); opacity: 0.5; }

/* notice type tag in sidebar — small text label, no pill */
.hi-type {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue-300);
  opacity: 0.9;
}

/* ── Main Content Area ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  background: var(--bg-app);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  gap: 1rem;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.topbar-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Session indicator — text only, no pill */
#sessionBadge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0;
  background: none;
  border-radius: 0;
  border: none;
}

/* ── Main Scroll ── */
.app-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  background: var(--bg-app);
}
.app-main::-webkit-scrollbar { width: 5px; }
.app-main::-webkit-scrollbar-track { background: transparent; }
.app-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Views ── */
.view { display: none; animation: fadeUp 0.2s ease; }
.view.active { display: block; }

/* ── Cards ── */
.glass-card-static {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

/* ── Section labels ── */
.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
[data-theme="dark"] .section-label { color: var(--blue-300); }

h2.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
h3.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  border-radius: 5px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-brand {
  background: var(--navy-700);
  color: #fff;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--navy-600);
}
.btn-brand:hover:not(:disabled) {
  background: var(--navy-600);
}

.btn-primary {
  background: var(--navy-700);
  color: #fff;
  padding: 0.5rem 1.125rem;
}
.btn-primary:hover:not(:disabled) { background: var(--navy-600); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-secondary);
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-surface-2); border-color: var(--slate-300); }
[data-theme="dark"] .btn-secondary { background: var(--bg-surface-2); border-color: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-2); border-color: var(--border); }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.75rem; }

/* ── Inputs ── */
.glass-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
[data-theme="dark"] .glass-input { background: var(--bg-surface-2); border-color: var(--border); color: var(--text-primary); }
.glass-input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30,50,80,0.1); }
.glass-input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .glass-input:focus { box-shadow: 0 0 0 2px rgba(74,144,217,0.2); }

/* ── Upload Zone ── */
.upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-surface-2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: rgba(30,50,80,0.04);
}
[data-theme="dark"] .upload-zone:hover { background: rgba(74,144,217,0.06); border-color: var(--blue-400); }
.upload-icon { color: var(--text-muted); margin-bottom: 0.6rem; }

/* ── Badges — minimal, text-first ── */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0;
  white-space: nowrap;
  background: none;
  border-radius: 0;
}
.badge-for      { color: var(--rec-for);     }
.badge-forstar  { color: var(--rec-forstar);  }
.badge-for-star { color: var(--rec-forstar);  }
.badge-against  { color: var(--rec-against);  }
.badge-high     { color: var(--teal-500);    }
.badge-medium   { color: var(--amber-500);   }
.badge-low      { color: var(--red-600);     }

/* notice type — plain uppercase text */
.badge-agm, .badge-egm, .badge-postal, .badge-ncm {
  color: var(--text-secondary);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  background: none;
  padding: 0;
}

.badge-yes      { color: var(--teal-500); font-weight: 700; font-size: 0.75rem; }
.badge-no       { color: var(--rec-against); font-weight: 700; font-size: 0.75rem; }
.badge-special  { color: var(--amber-500); font-weight: 700; font-size: 0.75rem; }
.badge-ordinary { color: var(--text-secondary); font-weight: 600; font-size: 0.75rem; }
.badge-type     { color: var(--text-secondary); }
.badge-info     { color: var(--blue-400); }
.badge-success  { color: var(--teal-500); }
.badge-neutral  { color: var(--text-muted); }
.badge-risk     { color: var(--rec-against); }

/* ── Meta Grid (Notice Details) ── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.meta-item {
  padding: 0.7rem 1rem;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.meta-item:last-child { border-right: none; }

.meta-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.meta-value {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.data-table th {
  background: var(--bg-surface-2);
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-surface-2); }
[data-theme="dark"] .data-table tr:hover td { background: var(--bg-surface-3); }

/* ── Pipeline Steps ── */
.pipeline-progress { display: flex; flex-direction: column; gap: 0; }

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
  transition: all 0.15s ease;
}
.pipeline-step:first-child { border-radius: 6px 6px 0 0; }
.pipeline-step:last-child  { border-bottom: none; border-radius: 0 0 6px 6px; }

.pipeline-step.ps-pending { opacity: 0.5; }
.pipeline-step.ps-running { background: #eff8ff; border-left: 3px solid #3b82f6; }
[data-theme="dark"] .pipeline-step.ps-running { background: rgba(59,130,246,0.08); }
.pipeline-step.ps-done    { background: var(--bg-surface); border-left: 3px solid var(--teal-400); }
.pipeline-step.ps-error   { background: #fff5f5; border-left: 3px solid var(--red-400); }
[data-theme="dark"] .pipeline-step.ps-done  { background: rgba(13,122,110,0.06); }
[data-theme="dark"] .pipeline-step.ps-error { background: rgba(185,28,28,0.06); }

.ps-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
}
.ps-running .ps-icon { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); }
.ps-done    .ps-icon { background: rgba(13,122,110,0.1); border-color: rgba(13,122,110,0.3); }
.ps-error   .ps-icon { background: rgba(185,28,28,0.1);  border-color: rgba(185,28,28,0.3); }

.ps-num { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); font-family: var(--font-mono); }
.ps-running .ps-num { color: #3b82f6; }

.ps-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(59,130,246,0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.ps-body { flex: 1; min-width: 0; }
.ps-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
.ps-desc  { font-size: 0.7rem; color: var(--text-muted); margin-top: 1px; }

.ps-badge { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.ps-running .ps-badge { color: #3b82f6; }
.ps-done    .ps-badge { color: var(--teal-500); }
.ps-error   .ps-badge { color: var(--red-400); }

.pipeline-connector { display: none; }

/* ── Resolution Cards ── */
.resolution-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.res-card-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.875rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-header);
}

.res-num {
  width: 26px; height: 26px;
  border-radius: 4px;
  background: var(--navy-700);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
[data-theme="dark"] .res-num { background: var(--navy-600); }

.res-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.res-recs {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.rec-item { text-align: right; }
.rec-item .meta-label { text-align: right; }

.res-card-body { padding: 1rem 1.25rem; }

/* ── Commentary Sections ── */
.commentary-section {
  margin-bottom: 1rem;
}
.commentary-section-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0.6rem;
}
.commentary-section p {
  font-size: 0.8375rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 0.5rem;
}
.commentary-section li {
  font-size: 0.8375rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.25rem;
  padding-left: 1rem;
  position: relative;
}
.commentary-section li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ── Concern List ── */
.concern-list { list-style: none; padding: 0; margin: 0; }
.concern-item {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 0.45rem 0.75rem;
  border-left: 2px solid var(--amber-400);
  margin-bottom: 0.35rem;
  background: #fffbeb;
  line-height: 1.55;
}
[data-theme="dark"] .concern-item { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.5); }

/* ── Closing Recommendation ── */
.closing-rec {
  padding: 0.6rem 0.875rem;
  border-left: 3px solid var(--navy-700);
  background: var(--bg-surface-2);
  font-size: 0.8375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.5;
  margin-top: 0.875rem;
}
[data-theme="dark"] .closing-rec { border-color: var(--blue-400); background: var(--bg-surface-3); }

/* Recommendation coloring in closing */
.closing-rec.rec-for      { border-color: var(--rec-for);     }
.closing-rec.rec-against  { border-color: var(--rec-against);  }
.closing-rec.rec-forstar  { border-color: var(--rec-forstar);  }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.kpi-card {
  padding: 1rem 1.125rem;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}
.kpi-card:last-child { border-right: none; }
.kpi-label { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-muted); margin-bottom: 0.3rem; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1; font-family: var(--font-mono); }
.kpi-meta  { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.4rem; }
.toast {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.625rem 1rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  min-width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  color: var(--text-primary);
  opacity: 0;
  transform: translateX(16px);
  transition: all 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast.toast-success { border-left: 3px solid var(--teal-500); }
.toast.toast-error   { border-left: 3px solid var(--red-600); }
.toast.toast-info    { border-left: 3px solid var(--blue-400); }

/* ── Home view ── */
#view-home {
  display: none;
}
#view-home.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
}

/* ── Approve modal ── */
#approveModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
#approveModal.open { display: flex; }

/* ── Misc utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4  { padding: 1rem; }
.p-5  { padding: 1.25rem; }
.p-6  { padding: 1.5rem; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.font-bold  { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-mono  { font-family: var(--font-mono); }

/* ── Stagger ── */
.stagger > * { animation: fadeUp 0.2s ease both; }
.stagger > *:nth-child(1)  { animation-delay: 0ms;  }
.stagger > *:nth-child(2)  { animation-delay: 35ms; }
.stagger > *:nth-child(3)  { animation-delay: 70ms; }
.stagger > *:nth-child(4)  { animation-delay: 105ms;}
.stagger > *:nth-child(5)  { animation-delay: 140ms;}
.stagger > *:nth-child(6)  { animation-delay: 175ms;}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Dark mode text safety ── */
[data-theme="dark"] .app-main h1,
[data-theme="dark"] .app-main h2,
[data-theme="dark"] .app-main h3,
[data-theme="dark"] .app-main p,
[data-theme="dark"] .app-main li,
[data-theme="dark"] .app-main label,
[data-theme="dark"] .app-main td { color: var(--text-primary); }
[data-theme="dark"] .app-main th { color: var(--text-muted); }
[data-theme="dark"] .app-main .text-muted,
[data-theme="dark"] .app-main .meta-label { color: var(--text-muted); }
[data-theme="dark"] .app-main .text-secondary,
[data-theme="dark"] .app-main .meta-value { color: var(--text-secondary); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .history-panel { width: 200px; min-width: 200px; }
  .app-main { padding: 1rem; }
}
@media (max-width: 640px) {
  .app-shell { flex-direction: column; }
  .history-panel { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); max-height: 180px; }
  .history-list { display: flex; flex-direction: row; overflow-x: auto; }
  .history-item { min-width: 150px; }
  .app-main { padding: 0.875rem; }
  .res-card-header { grid-template-columns: auto 1fr; }
  .res-recs { grid-column: 1 / -1; flex-direction: row; }
}
