/* ============================================================
   Accounts — design system
   A calm, professional fintech/accounting theme. Every page
   shares these primitives (.card, nav, table, .row-inline,
   button, .muted, .error, .badge), so styling lives here.
   ============================================================ */

:root {
  --bg: #eef1f6;
  --bg-accent: #e6eaf2;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;

  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px -6px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(15, 23, 42, 0.05);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);

  --nav-h: 58px;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1100px 520px at 100% -10%, var(--bg-accent), transparent);
  background-repeat: no-repeat;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Navigation ---------- */
nav {
  background: linear-gradient(90deg, #111827 0%, #1e223a 55%, #211a4d 100%);
  color: #e5e7eb;
  padding: 0 22px;
  height: var(--nav-h);
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04), 0 6px 20px -12px rgba(0, 0, 0, 0.6);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
nav > strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  margin-right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
nav > strong::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.5);
}
nav a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 11px;
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
nav a.active { color: #fff; background: rgba(99, 102, 241, 0.28); }
nav .spacer { flex: 1; }
nav .nav-company {
  color: #cbd5e1;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
}
nav .nav-company select {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
nav .nav-company select option { color: #0f172a; }

/* ---------- Layout ---------- */
main {
  max-width: 1120px;
  margin: 28px auto 64px;
  padding: 0 22px;
  animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Typography ---------- */
h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 4px 0 6px;
}
h2 {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}
main > p { color: var(--muted); max-width: 70ch; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 34px 0;
}
strong { font-weight: 650; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card h2:first-child, .card h2[style*="margin-top:0"] { margin-top: 0; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  font-variant-numeric: tabular-nums;
}
.card table { box-shadow: none; }
th, td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
}
thead th {
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--surface-muted); }
tbody tr:last-child td { border-bottom: none; }
tfoot td {
  background: var(--surface-muted);
  font-weight: 650;
  border-top: 2px solid var(--border-strong);
  border-bottom: none;
}
tr.needs-review { background: var(--warning-soft); }
tr.needs-review:hover { background: #fff3d6; }

/* Wide inline-edit tables: keep the page centered by scrolling the table
   inside its own box instead of letting it overflow the layout. */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  background: var(--surface);
}
.table-scroll table { border: none; border-radius: 0; box-shadow: none; margin-bottom: 0; }

/* Row expand toggle */
button.expand-btn {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.expand-btn:hover { background: var(--surface-muted); color: var(--text); }
.cat-select { max-width: 210px; }
tr.detail-row td { background: var(--surface-muted); padding: 12px 16px; }
tr.detail-row:hover { background: var(--surface-muted); }
.detail-grid { display: grid; gap: 6px; font-size: 13px; color: var(--text); }
.detail-grid .lbl {
  display: inline-block;
  min-width: 92px;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 8px;
}

/* ---------- Forms ---------- */
.row-inline {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
label {
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 550;
  line-height: 1.7;
}
label .muted { font-weight: 400; }

input, select, textarea {
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  vertical-align: -3px;
  cursor: pointer;
}
input[type="date"], input[type="number"] { min-height: 36px; }
::placeholder { color: #94a3b8; }

/* ---------- Buttons ---------- */
button, .button-like {
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}
button:hover, .button-like:hover { background: var(--primary-hover); }
button:active, .button-like:active { transform: translateY(1px); }
button:focus-visible, .button-like:focus-visible { outline: none; box-shadow: var(--ring); }
button.secondary { background: #fff; color: var(--text-soft); border: 1px solid var(--border-strong); box-shadow: none; }
button.secondary:hover { background: var(--surface-muted); border-color: var(--muted); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b91c1c; }
/* Compact buttons inside table rows */
td button { padding: 6px 11px; font-size: 12.5px; }
.button-like { background: #fff; color: var(--text-soft); border: 1px solid var(--border-strong); box-shadow: none; font-weight: 550; }
.button-like:hover { background: var(--surface-muted); border-color: var(--muted); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); font-size: 12.5px; }
.error { color: var(--danger); font-size: 13px; font-weight: 500; }
.error:empty { display: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  background: var(--surface-muted);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.badge.ok, .badge.processed, .badge.matched { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.badge.pending, .badge.processing, .badge.pending_review { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.badge.error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.categorized { background: var(--primary-soft); color: var(--primary); border-color: #c7d2fe; }

/* ---------- Auth / centered pages ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-wrap .card {
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  padding: 30px 30px 26px;
}
.auth-wrap h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 0;
}
.auth-wrap h1::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.45);
}
.auth-wrap .brand-sub { color: var(--muted); font-size: 13px; margin: -2px 0 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  nav { height: auto; padding: 10px 16px; }
  main { padding: 0 16px; margin-top: 20px; }
  .row-inline { gap: 10px; }
  h1 { font-size: 20px; }
}
