:root {
  --ink-900: #0B1F33;
  --ink-700: #16354F;
  --ink-500: #2C5273;
  --paper: #F7F5F0;
  --surface: #FFFFFF;
  --border: #E4E0D6;
  --border-strong: #D2CCBC;
  --text-primary: #1A1A18;
  --text-secondary: #5C5A52;
  --text-muted: #8B8878;
  --accent: #B8862E;
  --accent-ink: #6E4F15;
  --accent-bg: #F3E8D2;
  --danger: #B23A34;
  --danger-bg: #F6E4E2;
  --warning: #C4791F;
  --warning-bg: #F8EAD8;
  --success: #3F7D5C;
  --success-bg: #E4F0EA;
  --radius: 8px;
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text-primary);
  font-size: 14px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
}

/* ---- Auth screen ---- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-900);
}

.auth-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 2.5rem 2.5rem 2rem;
  width: 380px;
  box-shadow: 0 20px 60px rgba(11, 31, 51, 0.35);
}

.auth-logo-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 1.25rem;
}

.sidebar-brand {
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 0.75rem;
}

.sidebar-logo-img {
  width: 100%;
  max-width: 150px;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 4px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 1.5rem;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 14px;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--surface);
}

input:focus {
  outline: none;
  border-color: var(--ink-500);
  box-shadow: 0 0 0 3px rgba(44, 82, 115, 0.12);
}

.btn-primary {
  width: 100%;
  margin-top: 1.5rem;
  padding: 11px;
  background: var(--ink-900);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn-primary:hover { background: var(--ink-700); }

.form-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 14px;
  display: none;
}

.auth-toggle {
  text-align: center;
  margin-top: 1rem;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-toggle a { color: var(--ink-500); cursor: pointer; }

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

.sidebar {
  width: 220px;
  background: var(--ink-900);
  color: #fff;
  flex-shrink: 0;
  padding: 1.25rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 1.25rem;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,0.05); }

.nav-item.active {
  color: #fff;
  border-left-color: var(--accent);
  background: rgba(255,255,255,0.06);
}

.main {
  flex: 1;
  padding: 1.75rem 2rem;
  min-width: 0;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.main-title { font-family: var(--font-display); font-size: 22px; margin: 0; }

.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
}

.btn:hover { background: var(--paper); }

.btn-dark {
  background: var(--ink-900);
  color: #fff;
  border: none;
}

.btn-dark:hover { background: var(--ink-700); }

/* Metric cards */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.metric-label { font-size: 12px; color: var(--text-muted); margin: 0 0 6px; }
.metric-value { font-size: 24px; font-weight: 600; margin: 0; }
.metric-value.danger { color: var(--danger); }
.metric-value.warning { color: var(--warning); }

/* Advisory cards (client view) */
.client-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  cursor: pointer;
}

.client-card:hover { border-color: var(--border-strong); }

.client-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.client-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.client-name { font-weight: 600; font-size: 14px; margin: 0; }
.client-ref { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin: 0; }

.next-action {
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-new { background: var(--accent-bg); color: var(--accent-ink); }
.status-in_review { background: var(--warning-bg); color: var(--warning); }
.status-overdue { background: var(--danger-bg); color: var(--danger); }
.status-complete { background: var(--success-bg); color: var(--success); }

/* Registry table (accounting-style, dense) */
.registry-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.registry-table th { text-align: left; padding: 10px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.registry-table td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
.registry-table tr:last-child td { border-bottom: none; }
.mono { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }

.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11,31,51,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.75rem;
  width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h3 { font-family: var(--font-display); margin: 0 0 1rem; }

.modal-actions { display: flex; gap: 8px; margin-top: 1.5rem; justify-content: flex-end; }

.hidden { display: none !important; }

/* Documents module */
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 12px;
}

.doc-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.doc-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink-700);
}

.doc-name { font-weight: 600; font-size: 14px; margin: 0; }
.doc-meta { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }

.doc-status-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.doc-status-uploaded { background: var(--accent-bg); color: var(--accent-ink); }
.doc-status-analyzing { background: var(--warning-bg); color: var(--warning); }
.doc-status-analyzed { background: var(--success-bg); color: var(--success); }
.doc-status-failed, .doc-status-unsupported { background: var(--danger-bg); color: var(--danger); }

.analysis-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.analysis-section { margin-bottom: 12px; }
.analysis-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 0 0 4px; }
.analysis-text { font-size: 13px; margin: 0; line-height: 1.5; }
.analysis-list { margin: 4px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.6; }

.upload-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 1rem;
}

