/* ═══════════════════════════════════════════════════════════
   Ledger by Langtind — Stylesheet
   Design: Clean, airy, indigo accent, mobile-first.
   ═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #f8fafc;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --text-muted:#64748b;
  --primary:   #6366f1;
  --primary-h: #4f46e5;
  --accent:    #f59e0b;
  --danger:    #ef4444;
  --success:   #22c55e;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
  --sidebar-w: 240px;
  --font:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; }
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: .85rem; }

/* ── Layout ───────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  z-index: 95;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.25rem 1.25rem 1rem;
  font-weight: 700; font-size: 1.1rem;
}
.sidebar-brand small {
  font-weight: 400; font-size: .7rem; color: var(--text-muted);
  margin-left: -.3rem; align-self: flex-end; margin-bottom: 2px;
}
.sidebar-user {
  margin: 0 1rem 1rem;
  padding: .95rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
}
.sidebar-user-label {
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sidebar-user-name {
  font-size: 1rem;
  font-weight: 700;
  margin-top: .3rem;
}
.sidebar-user-meta,
.sidebar-user-role {
  color: var(--text-muted);
  font-size: .82rem;
  margin-top: .15rem;
}
.sidebar-nav { flex: 1; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .2rem; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; color: var(--text-muted);
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: #eef2ff; color: var(--primary); }
.sidebar-toggle,
.mobile-nav-toggle {
  display: none;
  position: fixed; top: .75rem; left: .75rem; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .6rem; cursor: pointer;
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ── Main ─────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1; padding: 2rem 2.5rem;
  max-width: 1280px;
}
.sidebar.hidden + .main {
  margin-left: 0;
  max-width: none;
  padding: 0;
}

/* ── Landing Page ─────────────────────────────────────── */
.landing-shell {
  min-height: 100vh;
  padding: 1.5rem clamp(1.25rem, 4vw, 4rem) 3rem;
  background:
    radial-gradient(circle at top left, rgba(99,102,241,.18), transparent 28%),
    radial-gradient(circle at right 20%, rgba(245,158,11,.12), transparent 24%),
    linear-gradient(135deg, #eff6ff, #f8fafc 46%, #fff7ed 100%);
}
.landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.landing-brand {
  display: flex;
  align-items: center;
  gap: .85rem;
}
.landing-brand strong {
  display: block;
  font-size: 1rem;
}
.landing-brand span {
  display: block;
  color: var(--text-muted);
  font-size: .82rem;
}
.landing-topbar-actions,
.landing-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}
.landing-hero {
  min-height: calc(100vh - 7rem);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 480px);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}
.landing-copy {
  max-width: 42rem;
}
.landing-copy h1 {
  font-size: clamp(2.7rem, 6vw, 5.4rem);
  line-height: .94;
  margin: .75rem 0 1rem;
  max-width: 11ch;
}
.landing-copy p {
  max-width: 40rem;
  font-size: 1.05rem;
  color: #334155;
}
.landing-card-grid {
  display: grid;
  gap: 1rem;
}
.landing-card {
  padding: 1.3rem 1.35rem;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 24px;
  background: rgba(255,255,255,.8);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .08);
}
.landing-card-featured {
  padding: 1.6rem;
}
.landing-card h2,
.landing-card h3 {
  margin-bottom: .4rem;
}
.landing-card p {
  color: #475569;
}
.landing-kicker,
.landing-stat {
  display: inline-flex;
  margin-bottom: .65rem;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #1d4ed8;
}

/* ── Auth Screens ─────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 430px);
  gap: clamp(1.5rem, 4vw, 5rem);
  align-items: center;
  padding: 0 clamp(1.25rem, 4vw, 4rem);
  background:
    radial-gradient(circle at top left, rgba(99,102,241,.18), transparent 34%),
    linear-gradient(135deg, #eff6ff, #f8fafc 48%, #fff7ed 100%);
}
.auth-shell:not(.invite-shell) {
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: start;
  padding-top: clamp(1.5rem, 5vw, 3rem);
  padding-bottom: 2rem;
}
.auth-panel {
  padding: 4rem 0;
}
.auth-panel-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  max-width: 42rem;
}
.auth-shell:not(.invite-shell) .auth-panel {
  padding: 0;
}
.auth-shell:not(.invite-shell) .auth-panel-intro {
  position: static;
  width: min(100%, 38rem);
  padding: 0;
  text-align: center;
  align-items: center;
  gap: .45rem;
  margin: 0 auto .9rem;
}
.auth-shell:not(.invite-shell) .auth-panel-intro h1 {
  max-width: none;
  font-size: clamp(1.9rem, 4vw, 3rem);
}
.auth-shell:not(.invite-shell) .auth-panel-intro p {
  max-width: 30rem;
  font-size: .98rem;
}
.auth-shell:not(.invite-shell) .auth-points {
  display: none;
}
.auth-panel-intro h1 {
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  line-height: .98;
  max-width: 10ch;
}
.auth-panel-intro p {
  font-size: 1.05rem;
  max-width: 44ch;
  color: #334155;
}
.eyebrow {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #1d4ed8;
}
.auth-points {
  display: grid;
  gap: .85rem;
  margin-top: 1.25rem;
  max-width: 36rem;
}
.auth-points div {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(148, 163, 184, .26);
  border-radius: 18px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 20px 40px rgba(15, 23, 42, .05);
  font-weight: 500;
}
.auth-panel-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
}
.auth-shell:not(.invite-shell) .auth-panel-form {
  width: 100%;
  justify-content: flex-start;
}
.auth-form {
  width: 100%;
  max-width: 400px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 28px;
  padding: 1.35rem 1.25rem;
  box-shadow: 0 28px 60px rgba(15, 23, 42, .12);
}
.auth-form h2 {
  margin-bottom: .2rem;
}
.auth-form > .muted {
  margin-bottom: .7rem;
  line-height: 1.4;
}
.auth-tabs {
  width: 100%;
  max-width: 400px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem;
  padding: .35rem;
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(226,232,240,.9);
  border-radius: 999px;
  margin-bottom: .75rem;
}
.auth-tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: .8rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}
.auth-tab.active {
  background: #1d4ed8;
  color: #fff;
}
.auth-submit {
  width: 100%;
  justify-content: center;
  margin-top: .15rem;
}
.auth-form-links {
  display: flex;
  justify-content: flex-end;
  margin-top: .35rem;
}
.auth-form-links-center {
  justify-content: center;
  margin-top: 1rem;
}
.auth-link {
  border: none;
  background: transparent;
  color: #1d4ed8;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}
.auth-link:hover {
  color: #1e40af;
  text-decoration: underline;
}
.form-error,
.form-success {
  margin: .65rem 0 0;
  padding: .8rem .95rem;
  border-radius: var(--radius);
  font-size: .88rem;
}
.form-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.form-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.empty-state-card {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
}
.pending-state {
  max-width: 680px;
  margin: 0 auto;
  gap: .85rem;
}
.invite-shell {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
}
.invite-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1rem;
}
.invite-meta-pill {
  padding: .6rem .9rem;
  border-radius: 999px;
  background: rgba(255,255,255,.74);
  border: 1px solid rgba(148,163,184,.25);
  font-size: .88rem;
}

/* ── Admin Panels ─────────────────────────────────────── */
.stack-list {
  display: grid;
  gap: .85rem;
}
.stack-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.stack-card-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.stack-card-button:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stack-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.stack-meta {
  color: var(--text-muted);
  font-size: .84rem;
  text-align: right;
}
.invite-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  align-items: end;
  margin-bottom: 1rem;
}
.invite-button-wrap {
  margin-bottom: .85rem;
}
.invite-button-wrap .btn {
  width: 100%;
  justify-content: center;
}
.admin-invite-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  align-items: end;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
.admin-invite-action .btn {
  width: 100%;
  justify-content: center;
}
#view-admin {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
#view-superadmin {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
#view-admin .view-header {
  margin-bottom: 0;
}
#view-superadmin .view-header {
  margin-bottom: 0;
}
#adminStatsGrid {
  margin-bottom: 0;
}
#superadminStatsGrid {
  margin-bottom: 0;
}
.member-card {
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}
.member-info {
  flex: 1;
  min-width: 0;
}
.member-name {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .2rem;
}
.member-meta {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .1rem;
  line-height: 1.45;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.role-badge.role-org_admin { background: #ede9fe; color: #5b21b6; }
.role-badge.role-finance    { background: #d1fae5; color: #065f46; }
.role-badge.role-approver   { background: #dbeafe; color: #1d4ed8; }
.role-badge.role-member     { background: #f1f5f9; color: #475569; }
.invitation-card {
  align-items: center;
}
.admin-project-card {
  align-items: center;
}
.subsection-title {
  margin: 1.4rem 0 .8rem;
  font-size: 1rem;
}
.member-controls {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── View Header ──────────────────────────────────────── */
.view-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: .75rem;
}
.header-actions { display: flex; gap: .5rem; }
.export-actions { display: flex; gap: .5rem; }
.report-actions { flex-wrap: wrap; justify-content: flex-end; }
.report-expense-actions { margin-top: 1rem; justify-content: center; }
.report-expense-toolbar { justify-content: flex-start; margin-top: 0; margin-bottom: 1rem; }
.report-presets {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1rem;
}
.report-save-form {
  margin-bottom: 1rem;
}
.saved-report-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.saved-report-meta {
  color: var(--text-muted);
  font-size: .84rem;
}
.supplier-alias-form {
  align-items: end;
}
.supplier-alias-submit {
  min-width: 160px;
}
.supplier-alias-submit .btn {
  width: 100%;
  justify-content: center;
}
.supplier-alias-list {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .55rem;
}
.supplier-alias-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text);
  font-size: .78rem;
}
.btn-link {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }

/* Toggle buttons for permissions */
.toggle-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.2rem; height: 2.2rem; border-radius: var(--radius);
  font-size: .75rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); transition: all .15s;
}
.toggle-btn:hover { background: #f1f5f9; }
.toggle-btn.active { background: #f0fdf4; color: var(--success); border-color: var(--success); }
.toggle-btn.active:hover { background: #dcfce7; }
.toggle-btn.role-active { background: #f0fdf4; color: var(--success); border-color: var(--success); }
.toggle-btn.role-active:hover { background: #dcfce7; }
.toggle-btn.status-active { background: #f0fdf4; color: var(--success); border-color: var(--success); }
.toggle-btn.status-active:hover { background: #dcfce7; }
.toggle-btn.status-inactive { background: var(--danger); color: #fff; border-color: var(--danger); }
.toggle-btn.status-inactive:hover { background: var(--danger-h, #dc2626); }
.toggle-btn.inactive { background: #fef2f2; color: #dc2626; border-color: #f87171; }
.toggle-btn.inactive:hover { background: #fee2e2; }

/* Role selection modal */
.role-options {
  display: flex; flex-direction: column; gap: 1rem;
}
.role-option {
  padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s;
}
.role-option:hover {
  background: #f8fafc; border-color: var(--primary);
}
.role-option.selected {
  background: #f0fdf4; border-color: var(--success);
}
.role-option-header {
  display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
}
.role-option-header i {
  width: 1.25rem; height: 1.25rem;
}
.role-option p {
  margin: 0; font-size: 0.85rem; color: var(--text-muted);
}

/* Member controls */
.member-controls {
  display: flex; flex-direction: row; gap: 0.6rem; align-items: flex-end; flex-wrap: wrap;
}
.permission-group {
  display: flex; flex-direction: column; gap: 0.15rem; align-items: center; min-width: 3rem;
}
.permission-label {
  font-size: 0.65rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; text-align: center; line-height: 1;
}
.role-buttons, .status-buttons, .perm-buttons {
  display: flex; gap: 0.25rem;
}

/* ── Inputs ───────────────────────────────────────────── */
.input {
  width: 100%; padding: .55rem .75rem; font-size: .9rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
  font-family: var(--font);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* Custom select styling */
select.input {
  appearance: none;
  background: var(--surface);
  position: relative;
}
select.input::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 0.375rem solid transparent;
  border-right: 0.375rem solid transparent;
  border-top: 0.375rem solid var(--text-muted);
  pointer-events: none;
}
select.input:focus::after {
  border-top-color: var(--primary);
}

.form-group { margin-bottom: .85rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: .25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Stats Grid ───────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  display: flex; flex-direction: column; gap: .25rem;
  box-shadow: var(--shadow);
}
.stat-card-button {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
}
.stat-card-button:hover {
  border-color: var(--primary);
}
.stat-card-button:active {
  transform: translateY(1px);
}
.stat-card.accent { border-left: 4px solid var(--accent); }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 700; }

/* ── Project Cards ────────────────────────────────────── */
.section-title { margin-bottom: 1rem; }
.dashboard-panels {
  display: grid;
  gap: 1rem;
}
.mobile-only {
  display: none;
}
.mobile-dashboard-grid {
  gap: .9rem;
  margin-bottom: 1rem;
}
.compact-card {
  padding: 1rem 1.15rem;
}
#managerDashboardSection {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
#managerDashboardSection .stats-grid {
  margin-bottom: 0;
}
#managerDashboardSection .section-title {
  margin-bottom: .5rem;
}
#managerDashboardSection .project-grid {
  margin-bottom: 0;
}
.report-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
#view-reports {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
#view-reports .view-header {
  margin-bottom: 0;
}
.mobile-summary-list {
  display: grid;
  gap: .7rem;
}
.mobile-summary-item {
  display: grid;
  gap: .15rem;
  padding: .8rem .85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
}
.mobile-summary-item.clickable {
  cursor: pointer;
}
.mobile-summary-item.clickable:active {
  transform: scale(.99);
}
.mobile-summary-top,
.mobile-summary-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.mobile-summary-title {
  font-size: .92rem;
  font-weight: 700;
}
.mobile-summary-meta,
.mobile-summary-note {
  color: var(--text-muted);
  font-size: .8rem;
}
.mobile-summary-value {
  font-size: .95rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.mobile-summary-stack {
  display: grid;
  gap: .25rem;
}
.mobile-summary-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.project-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem;
  cursor: pointer; transition: box-shadow .2s, transform .15s;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 4px; background: var(--card-color, var(--primary));
}
.project-card h3 { font-size: 1rem; margin-bottom: .25rem; }
.project-card .pc-meta { font-size: .8rem; color: var(--text-muted); }
.project-card .pc-total { font-size: 1.3rem; font-weight: 700; margin-top: .6rem; }
.project-card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .9rem;
}
.project-card-metric {
  padding: .7rem .75rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
}
.project-card-metric span {
  display: block;
  font-size: .74rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.project-card-metric strong {
  display: block;
  font-size: .98rem;
}

/* ── Upload Zone ──────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 3rem 2rem; text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  max-width: 500px; margin: 0 auto;
}
.upload-zone.drag-over { border-color: var(--primary); background: #eef2ff; }
.upload-zone svg { margin: 0 auto 1rem; }
.upload-zone-actions {
  display: flex;
  gap: .75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ── Spinner ──────────────────────────────────────────── */
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-text { color: var(--text-muted); font-size: 1rem; }

/* ── Verification Workspace ───────────────────────────── */
.verify-workspace {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2rem;
  align-items: start;
}
.verify-image {
  background: #f1f5f9; border-radius: var(--radius-lg);
  padding: 1rem; display: flex; flex-direction: column;
  min-height: 300px; max-height: 70vh; overflow: hidden;
}
.verify-image-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}
.verify-zoom-controls {
  display: flex;
  gap: .5rem;
}
.verify-zoom-level {
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
}
.verify-image-viewport {
  flex: 1;
  min-height: 320px;
  max-height: 60vh;
  overflow: hidden;
  border-radius: var(--radius);
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
}
.verify-image-viewport.zoomed {
  cursor: grab;
}
.verify-image-viewport.zoomed.is-dragging {
  cursor: grabbing;
}
.verify-image img {
  border-radius: var(--radius);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform .12s ease-out;
  will-change: transform;
  user-select: none;
  touch-action: none;
}
.verify-image-hint {
  margin-top: .75rem;
}
.verify-form {
  padding: .5rem 0;
  min-width: 0;
}
.verify-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
}
.modal-heading-block {
  display: grid;
  gap: .45rem;
}
.modal-support-copy {
  margin-top: .55rem;
}
.modal-info-stack {
  display: grid;
  gap: .75rem;
}
.compact-info-box {
  margin-top: 0;
}
.compact-info-box .muted {
  line-height: 1.45;
}
.compact-meta-row {
  margin-top: 0;
}
.modal-first-field {
  margin-top: 1rem;
}
.ocr-notice {
  margin-bottom: 1rem;
  padding: .75rem .9rem;
  border-radius: var(--radius);
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-size: .85rem;
}
.ocr-notice.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}
.inline-info-box {
  margin-top: 1rem;
  padding: .85rem .95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.inline-info-box strong {
  display: block;
  margin-bottom: .25rem;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow);
}
.settings-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.settings-inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .75rem;
  margin-bottom: 1rem;
}
#view-profile {
  display: grid;
  gap: 1.25rem;
}
#view-profile .view-header {
  margin-bottom: 0;
}
.list-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
  margin-bottom: 1rem;
}
.filter-grow {
  min-width: 0;
  grid-column: span 2;
}
.category-list {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
}
.category-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  flex-wrap: wrap;
}
.category-actions {
  display: flex;
  gap: .5rem;
  flex-shrink: 0;
}
.category-account-number {
  font-size: .75rem;
  font-weight: 600;
  color: #4f46e5;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  padding: .1rem .4rem;
  margin-left: .4rem;
  letter-spacing: .02em;
}

/* ── Project Detail ───────────────────────────────────── */
.pd-summary {
  display: flex; align-items: baseline; gap: .5rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
}
.pd-total { font-size: 2rem; font-weight: 700; }
.pd-currency { font-size: 1rem; color: var(--text-muted); font-weight: 600; }
.pd-count { font-size: .85rem; color: var(--text-muted); margin-left: 1rem; }
.budget-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.budget-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.budget-card strong {
  font-size: 1.05rem;
}
.accent-border {
  border-left: 4px solid var(--success);
}

/* ── Expense List ─────────────────────────────────────── */
.expense-list { display: flex; flex-direction: column; gap: .6rem; }
.expense-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 1rem;
  align-items: center; padding: .85rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: box-shadow .15s;
}
.expense-row:hover { box-shadow: var(--shadow-lg); }
.report-expense-row {
  grid-template-columns: auto 52px 1fr auto;
}
.report-expense-row.is-selected {
  border-color: var(--primary);
  background: #eef2ff;
}
.report-expense-select {
  display: flex;
  align-items: center;
  justify-content: center;
}
.report-expense-select input {
  width: 1rem;
  height: 1rem;
}
.report-expense-side {
  display: grid;
  gap: .5rem;
  justify-items: end;
}
.report-row-actions {
  justify-content: flex-end;
}
.expense-thumb {
  width: 52px; height: 52px; border-radius: 8px;
  object-fit: cover; background: #e2e8f0;
}
.expense-thumb-missing {
  width: 52px; height: 52px; border-radius: 8px;
  background: #e2e8f0; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 1.4rem; flex-shrink: 0;
}
.expense-thumb-missing::after { content: '🧾'; }
.img-missing-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .75rem; padding: 3rem 1rem; color: #94a3b8; font-size: .9rem;
  min-height: 160px; width: 100%;
}

/* Payment source toggle */
.payment-source-toggle { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .25rem; }
.pst-option { display: flex; align-items: center; gap: .4rem; cursor: pointer; padding: .45rem .85rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .85rem; transition: border-color .15s, background .15s; user-select: none; }
.pst-option:has(input:checked) { border-color: var(--primary); background: #eef2ff; color: var(--primary); font-weight: 600; }
.pst-option input[type="radio"] { display: none; }
.payment-source-extra { margin-top: .75rem; padding: .85rem; border: 1px solid var(--border); border-radius: 14px; background: #f8fafc; display: grid; gap: .75rem; }
.checkbox-row { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; }
.checkbox-row input[type="checkbox"] { width: 1rem; height: 1rem; }

/* Payment source badge in expense rows and modal read-only */
.payment-source-badge { display: inline-flex; align-items: center; padding: .12rem .5rem; border-radius: 99px; font-size: .68rem; font-weight: 700; margin-left: .3rem; vertical-align: middle; }
.payment-source-badge.org-paid { background: #dbeafe; color: #1d4ed8; }
.payment-source-badge.personal { background: #f1f5f9; color: #475569; }
.payment-source-badge.reimbursed { background: #dcfce7; color: #166534; }

/* Bilagsnummer badge */
.voucher-badge { display: inline-flex; align-items: center; padding: .1rem .45rem; border-radius: 99px; font-size: .68rem; font-weight: 700; background: #fef9c3; color: #854d0e; margin-left: .35rem; vertical-align: middle; letter-spacing: .01em; }

/* Income list */
.income-row { display: flex; align-items: flex-start; gap: .75rem; flex-wrap: wrap; padding: .75rem 0; }
.income-meta { display: flex; align-items: center; gap: .4rem; font-size: .78rem; min-width: 160px; flex-shrink: 0; }
.income-bilag { font-weight: 700; color: #854d0e; background: #fef9c3; padding: .1rem .4rem; border-radius: 99px; font-size: .7rem; }
.income-desc { flex: 1; font-size: .88rem; min-width: 0; }
.income-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; margin-left: auto; }
.income-amount { font-weight: 700; font-size: .95rem; color: #15803d; }
.income-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; align-items: end; margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.income-form-submit .btn { width: 100%; justify-content: center; }

/* P&L (Resultatregnskap) */
.pl-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.pl-card { padding: 1rem 1.25rem; border-radius: var(--radius); border: 1px solid var(--border); }
.pl-card.income { background: #f0fdf4; border-color: #86efac; }
.pl-card.expense { background: #fff7ed; border-color: #fdba74; }
.pl-card.result { background: #f8fafc; }
.pl-card.pl-positive { background: #f0fdf4; border-color: #86efac; }
.pl-card.pl-negative { background: #fff1f2; border-color: #fca5a5; }
.pl-label { font-size: .78rem; color: var(--text-muted); margin-bottom: .25rem; }
.pl-value { font-size: 1.25rem; font-weight: 700; }
.pl-card.income .pl-value { color: #15803d; }
.pl-card.expense .pl-value { color: #c2410c; }
.pl-months { overflow-x: auto; }
.pl-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.pl-table th, .pl-table td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.pl-table th { font-weight: 600; color: var(--text-muted); font-size: .78rem; }
.pl-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pl-positive { color: #15803d; font-weight: 600; }
.pl-negative { color: #b91c1c; font-weight: 600; }

/* ── Bank Transactions Table ─────────────────────────── */
.reconciliation-shell {
  display: grid;
  gap: 1rem;
}
.reconciliation-import-card {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.08), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.reconciliation-kicker {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .22rem .55rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.10);
  color: var(--primary-h);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .55rem;
}
.reconciliation-import-card h3 {
  font-size: 1.05rem;
  margin-bottom: .25rem;
}
.reconciliation-import-form {
  margin-bottom: 0;
}
.reconciliation-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .9rem;
}
.reconciliation-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.6fr) auto auto auto;
  gap: .85rem;
  align-items: end;
}
.reconciliation-search-group {
  margin-bottom: 0;
}
.reconciliation-filter-group {
  display: grid;
  gap: .38rem;
}
.reconciliation-filter-label {
  color: var(--text-muted);
  font-size: .76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.reconciliation-chip-row {
  display: flex;
  gap: .45rem;
  flex-wrap: wrap;
}
.reconciliation-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: .45rem .75rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.reconciliation-chip:hover {
  border-color: var(--primary);
  color: var(--primary-h);
}
.reconciliation-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 10px 18px rgba(99, 102, 241, 0.18);
}
.reconciliation-reset-btn {
  white-space: nowrap;
}
.reconciliation-toolbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.reconciliation-help-note {
  margin-top: .15rem;
  padding: .8rem .95rem;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #f8fbff;
  color: var(--text-muted);
  font-size: .84rem;
  line-height: 1.45;
}
.reconciliation-help-note strong {
  color: var(--text);
}
.match-suggestions-panel {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  padding: .85rem;
}
.match-suggestions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
}
.match-suggestions-list {
  display: grid;
  gap: .5rem;
}
.match-suggestion-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: .7rem .8rem;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.match-suggestion-card.is-primary {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.match-suggestion-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
}
.match-suggestion-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.06);
}
.match-suggestion-card:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.match-suggestion-main {
  display: grid;
  gap: .2rem;
}
.match-suggestion-side {
  display: grid;
  gap: .35rem;
  justify-items: end;
}
.match-suggestion-main span,
.match-suggestion-empty {
  color: var(--text-muted);
  font-size: .8rem;
}
.match-suggestion-flag {
  display: inline-flex;
  align-items: center;
  margin-right: .4rem;
  border-radius: 999px;
  padding: .12rem .42rem;
  font-size: .68rem;
  font-weight: 700;
  vertical-align: middle;
}
.match-suggestion-flag.reimbursement {
  background: #dbeafe;
  color: #1d4ed8;
}
.match-suggestion-confidence {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .18rem .5rem;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.match-suggestion-confidence.high {
  background: #dcfce7;
  color: #166534;
}
.match-suggestion-confidence.medium {
  background: #fef3c7;
  color: #92400e;
}
.match-suggestion-confidence.low {
  background: #e2e8f0;
  color: #475569;
}
.match-suggestion-amount {
  white-space: nowrap;
  font-weight: 700;
}
.match-suggestion-empty {
  padding: .5rem 0;
}
.reconciliation-inline-suggestion {
  display: grid;
  gap: .35rem;
  justify-items: start;
  margin-bottom: .45rem;
}
.reconciliation-inline-match {
  width: fit-content;
}
.reconciliation-flag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .14rem .48rem;
  margin-right: .35rem;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.reconciliation-flag.reimbursement {
  background: #e0f2fe;
  color: #075985;
}
.reconciliation-inline-suggestion-text {
  color: var(--text-muted);
  font-size: .77rem;
  line-height: 1.35;
}
.create-income-advanced {
  display: grid;
  gap: .75rem;
}
.reconciliation-stat-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: .3rem;
  min-height: 120px;
  padding: 1rem 1.05rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.reconciliation-stat-card::after {
  content: "";
  position: absolute;
  top: -28px;
  right: -18px;
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.10);
}
.reconciliation-stat-card.is-good::after {
  background: rgba(34, 197, 94, 0.12);
}
.reconciliation-stat-card.is-alert::after {
  background: rgba(239, 68, 68, 0.12);
}
.reconciliation-stat-label {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.reconciliation-stat-value {
  position: relative;
  z-index: 1;
  font-size: 1.8rem;
  line-height: 1;
}
.reconciliation-stat-meta {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font-size: .82rem;
}
.reconciliation-table-wrap {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, #fcfdff 0%, #ffffff 100%);
  overflow: hidden;
}
.reconciliation-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
}
.reconciliation-batch-copy {
  display: grid;
  gap: .15rem;
}
.reconciliation-batch-copy span {
  color: var(--text-muted);
  font-size: .8rem;
}
.reconciliation-batch-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.reconciliation-batch-actions .btn:disabled,
.reconciliation-reset-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.reconciliation-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.75);
}
.reconciliation-table-head h3 {
  font-size: 1rem;
  margin-bottom: .2rem;
}
.reconciliation-legend {
  display: flex;
  align-items: center;
  gap: .85rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: .8rem;
}
.reconciliation-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}
.reconciliation-legend .dot {
  width: .6rem;
  height: .6rem;
  border-radius: 999px;
  display: inline-block;
}
.reconciliation-legend .dot.is-good {
  background: #16a34a;
}
.reconciliation-legend .dot.is-alert {
  background: #dc2626;
}
.reconciliation-legend .dot.is-neutral {
  background: #64748b;
}
.reconciliation-table-container {
  max-height: 720px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.reconciliation-select-col {
  width: 42px;
  text-align: center;
}
.reconciliation-select-col input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}
.reconciliation-sticky-totals {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
  padding: .9rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(252, 253, 255, 0.78), rgba(255, 255, 255, 0.98));
  backdrop-filter: blur(8px);
}
.reconciliation-total-block {
  display: grid;
  gap: .15rem;
}
.reconciliation-total-label {
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.reconciliation-total-value {
  font-size: 1rem;
  font-weight: 700;
}
.reconciliation-total-value.is-good {
  color: #15803d;
}
.reconciliation-total-value.is-alert {
  color: #b91c1c;
}
.reconciliation-table th {
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  background: #f8fafc;
}
.reconciliation-sort-button {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.reconciliation-sort-button::after {
  content: "";
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .35;
  transform: translateY(1px);
}
.reconciliation-sort-button.active::after {
  opacity: .8;
}
.reconciliation-sort-button[data-direction="asc"]::after {
  transform: rotate(180deg) translateY(1px);
}
.reconciliation-row td {
  vertical-align: top;
}
.reconciliation-row.matched {
  background: rgba(34, 197, 94, 0.04);
}
.reconciliation-row.unmatched {
  background: rgba(254, 242, 242, 0.8);
}
.reconciliation-row.ignored {
  background: rgba(241, 245, 249, 0.9);
}
.reconciliation-date-cell,
.reconciliation-reference-cell,
.reconciliation-description-cell,
.reconciliation-status-cell {
  display: grid;
  gap: .22rem;
}
.reconciliation-date-cell strong,
.reconciliation-reference-cell strong,
.reconciliation-description-cell strong {
  font-size: .92rem;
}
.reconciliation-date-cell span,
.reconciliation-reference-cell span,
.reconciliation-description-cell span,
.reconciliation-status-cell span,
.reconciliation-action-hint {
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.35;
}
.reconciliation-description-cell strong {
  word-break: break-word;
}
.reconciliation-amount {
  text-align: right;
  white-space: nowrap;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.reconciliation-amount.positive {
  color: #15803d;
}
.reconciliation-amount.negative {
  color: #b91c1c;
}
.reconciliation-type-pill,
.reconciliation-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  border-radius: 999px;
  padding: .28rem .6rem;
  font-size: .74rem;
  font-weight: 700;
}
.reconciliation-type-pill.inn {
  background: #dcfce7;
  color: #166534;
}
.reconciliation-type-pill.ut {
  background: #fee2e2;
  color: #991b1b;
}
.reconciliation-status-pill.matched {
  background: #dcfce7;
  color: #166534;
}
.reconciliation-status-pill.unmatched {
  background: #fef3c7;
  color: #92400e;
}
.reconciliation-status-pill.ignored {
  background: #e2e8f0;
  color: #475569;
}
.reconciliation-actions-cell {
  min-width: 180px;
}
.reconciliation-actions-cell .btn {
  margin-right: .4rem;
  margin-bottom: .45rem;
}
.reconciliation-action-hint {
  display: block;
}
.reconciliation-empty {
  padding: 2.25rem 1rem !important;
  text-align: center;
}
.reconciliation-empty strong,
.reconciliation-empty span {
  display: block;
}
.reconciliation-empty strong {
  margin-bottom: .35rem;
}
.reconciliation-empty span {
  color: var(--text-muted);
}
.expense-info { min-width: 0; }
.expense-supplier { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-date { font-size: .78rem; color: var(--text-muted); }
.expense-amount { font-weight: 700; font-size: 1rem; text-align: right; white-space: nowrap; }
.expense-status {
  display: inline-block; font-size: .7rem; font-weight: 600;
  padding: .15rem .5rem; border-radius: 99px; margin-top: .2rem;
}
.status-pending  { background: #fef3c7; color: #92400e; }
.status-submitted { background: #dbeafe; color: #1d4ed8; }
.status-rejected { background: #fee2e2; color: #b91c1c; }
.status-verified { background: #dcfce7; color: #166534; }
.status-paid { background: #e0e7ff; color: #3730a3; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2rem; max-width: 900px; width: 100%; max-height: 90vh;
  overflow-y: auto; position: relative; box-shadow: var(--shadow-lg);
}
.modal-sm { max-width: 420px; }
.modal-close {
  position: absolute; top: .75rem; right: 1rem;
  font-size: 1.5rem; background: none; border: none;
  cursor: pointer; color: var(--text-muted); line-height: 1;
}
.modal-meta-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .5rem;
  flex-wrap: wrap;
}
.modal-actions {
  display: flex;
  gap: .75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

/* ── Responsive ───────────────────────────────────────── */
@media (min-width: 640px) {
  .member-card {
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .main { margin-left: 0; padding: 1rem; padding-top: 4.75rem; }
  .sidebar.hidden + .main { padding: 0; }
  .landing-shell { padding: 1rem 1rem 2rem; }
  .landing-topbar,
  .landing-actions,
  .landing-topbar-actions { align-items: stretch; }
  .landing-hero { grid-template-columns: 1fr; min-height: auto; padding-top: 2rem; }
  .landing-copy h1 { max-width: none; font-size: clamp(2.3rem, 10vw, 3.8rem); }
  .auth-shell,
  .invite-shell { grid-template-columns: 1fr; }
  .auth-shell {
    gap: 0;
    padding: 0;
  }
  .auth-panel { padding: 2rem 1.25rem; }
  .auth-panel-intro { padding-top: 4rem; }
  .auth-panel-form { justify-content: center; }
  .auth-shell:not(.invite-shell) .auth-panel-intro {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    width: auto;
    padding: 4rem 1.25rem 0;
  }
  .auth-shell:not(.invite-shell) .auth-points {
    display: grid;
  }
  .auth-form,
  .auth-tabs { width: 100%; }
  .stack-card { align-items: flex-start; flex-direction: column; }
  .stack-meta { text-align: left; }
  .invite-grid { grid-template-columns: 1fr; }
  .member-controls { flex-wrap: wrap; width: 100%; }
  .verify-workspace {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .verify-image {
    padding: .85rem;
    min-height: 0;
    max-height: none;
  }
  .upload-zone-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .upload-zone-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .verify-image-toolbar {
    flex-wrap: wrap;
    align-items: center;
  }
  .verify-zoom-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .verify-zoom-controls .btn {
    justify-content: center;
  }
  .verify-zoom-level {
    width: 100%;
    text-align: center;
  }
  .verify-image-viewport {
    min-height: 220px;
    max-height: 42vh;
  }
  .verify-form {
    padding: 0 0 4.75rem;
  }
  .verify-form h2 {
    font-size: 1.1rem;
    margin-bottom: .35rem;
  }
  .verify-actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: 1rem;
    padding-top: .85rem;
    background: linear-gradient(180deg, rgba(248,250,252,0), rgba(248,250,252,.92) 18%, rgba(248,250,252,1) 40%);
    display: grid;
    grid-template-columns: 1fr;
  }
  .verify-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .settings-inline-form { grid-template-columns: 1fr; }
  .list-filters { grid-template-columns: 1fr; }
  .filter-grow { grid-column: auto; }
  .stats-grid { grid-template-columns: 1fr; gap: .75rem; }
  .mobile-only { display: grid; }
  .stat-card {
    grid-template-columns: minmax(0, 1fr) auto;
    display: grid;
    align-items: center;
    gap: .35rem .75rem;
    padding: 1rem 1.05rem;
  }
  .stat-value { font-size: 1.25rem; text-align: right; }
  .project-grid { grid-template-columns: 1fr; }
  .project-card {
    padding: 1rem;
  }
  .project-card-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .expense-row {
    grid-template-columns: 44px 1fr;
    gap: .75rem;
    align-items: start;
    padding: .8rem .85rem;
  }
  .report-expense-row {
    grid-template-columns: auto 44px 1fr;
  }
  .expense-thumb {
    width: 44px;
    height: 44px;
  }
  .expense-supplier {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
  }
  .expense-date {
    line-height: 1.45;
  }
  .expense-amount {
    grid-column: 2;
    text-align: left;
    margin-top: .25rem;
    font-size: .95rem;
  }
  .report-expense-side {
    grid-column: 2 / span 2;
    justify-items: start;
  }
  .report-row-actions {
    justify-content: flex-start;
  }
  .view-header {
    margin-bottom: 1.1rem;
  }
  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .header-actions .btn {
    justify-content: center;
  }
  .report-actions {
    grid-template-columns: 1fr;
  }
  .report-presets .btn {
    width: 100%;
    justify-content: center;
  }
  .export-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }
  .export-actions .btn {
    justify-content: center;
  }
  .pd-summary {
    display: grid;
    gap: .25rem;
    margin-bottom: 1rem;
  }
  .pd-count {
    margin-left: 0;
  }
  .budget-overview {
    margin-bottom: 1rem;
  }
  .reconciliation-table-head {
    flex-direction: column;
  }
  .reconciliation-batch-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .reconciliation-toolbar {
    grid-template-columns: 1fr;
  }
  .reconciliation-toolbar-actions {
    justify-content: flex-start;
  }
  .reconciliation-import-form {
    grid-template-columns: 1fr;
  }
  .reconciliation-actions-cell {
    min-width: 150px;
  }
  .reconciliation-sticky-totals {
    grid-template-columns: 1fr 1fr;
  }
  .modal-overlay {
    padding: 0;
    align-items: stretch;
  }
  .modal {
    max-width: none;
    max-height: 100vh;
    min-height: 100vh;
    border-radius: 0;
    padding: 1rem .9rem 1.25rem;
  }
  .modal-close {
    position: sticky;
    top: 0;
    margin-left: auto;
    display: block;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--border);
    z-index: 5;
  }
  .modal .verify-image {
    position: sticky;
    top: 2.9rem;
  }
  .modal .verify-form {
    padding-bottom: 5.25rem;
  }
  .modal-heading-block h2 {
    font-size: 1.15rem;
    line-height: 1.25;
    padding-right: 2.5rem;
  }
  .modal-info-stack {
    gap: .6rem;
  }
  .compact-info-box {
    padding: .75rem .8rem;
  }
  .compact-info-box strong {
    font-size: .88rem;
    margin-bottom: .15rem;
  }
  .compact-info-box .muted {
    font-size: .79rem;
  }
  .modal-first-field {
    margin-top: .8rem;
  }
  .modal-meta-row {
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
  }
  .modal-actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.94) 18%, rgba(255,255,255,1) 40%);
    padding-top: .85rem;
    display: grid;
    grid-template-columns: 1fr;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .reconciliation-summary-grid {
    grid-template-columns: 1fr 1fr;
  }
  .reconciliation-stat-card {
    min-height: 110px;
  }
  .reconciliation-stat-value {
    font-size: 1.45rem;
  }
  .reconciliation-table th,
  .reconciliation-table td {
    padding: .65rem .55rem;
  }
  .reconciliation-sticky-totals {
    grid-template-columns: 1fr;
  }
  .stack-card {
    padding: .9rem;
  }
  .stack-actions {
    width: 100%;
  }
  .stack-actions .btn {
    flex: 1;
    justify-content: center;
  }
  .stack-meta {
    text-align: left;
  }
}
@media (max-width: 480px) {
  .form-row { grid-template-columns: 1fr; }
  .mobile-nav-toggle {
    top: .65rem;
    left: .65rem;
  }
  .main {
    padding-left: .85rem;
    padding-right: .85rem;
  }
  .project-card-metrics {
    grid-template-columns: 1fr;
  }
  .header-actions {
    grid-template-columns: 1fr;
  }
  .verify-image-viewport {
    min-height: 180px;
    max-height: 34vh;
  }
  .verify-image-hint {
    font-size: .78rem;
  }
  .modal {
    padding-left: .75rem;
    padding-right: .75rem;
  }
  .modal-heading-block h2 {
    font-size: 1.05rem;
  }
  .compact-info-box .muted {
    font-size: .76rem;
  }
}

/* ── Audit log ──────────────────────────────────────────── */
.audit-log-list {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.audit-log-entry {
  display: grid;
  grid-template-columns: 120px 130px 1fr 1fr;
  gap: .4rem .75rem;
  align-items: baseline;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  font-size: .82rem;
  border-bottom: 1px solid var(--border);
}
.audit-log-entry:last-child { border-bottom: none; }
.audit-action {
  font-weight: 700;
  color: #4f46e5;
  text-transform: uppercase;
  font-size: .7rem;
  letter-spacing: .04em;
}
.audit-entity { color: var(--text-muted); font-weight: 600; }
.audit-change { word-break: break-all; }
.audit-meta { font-size: .74rem; text-align: right; }
@media (max-width: 768px) {
  .audit-log-entry { grid-template-columns: 1fr 1fr; }
  .audit-change, .audit-meta { grid-column: 1 / -1; }
}

/* ── Budget lines ───────────────────────────────────────── */
#budgetSection { margin-bottom: 1.5rem; }

.budget-add-form {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .75rem 0 1rem;
  border-bottom: 1px solid var(--border);
}
.budget-add-form select,
.budget-add-form input { flex: 1; min-width: 120px; }

.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  margin-top: .25rem;
}
.budget-table th,
.budget-table td {
  padding: .55rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.budget-table th { font-weight: 600; color: var(--text-muted); font-size: .78rem; }
.budget-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.budget-total-row td { border-top: 2px solid var(--border); border-bottom: none; }

.budget-line-over td { background: #fff1f2; }

.budget-bar-cell { min-width: 140px; display: flex; align-items: center; gap: .5rem; }
.budget-bar-wrap {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}
.budget-bar {
  height: 100%;
  background: #6366f1;
  border-radius: 99px;
  transition: width .3s;
}
.budget-bar.over { background: #ef4444; }
.budget-pct { font-size: .75rem; font-weight: 600; color: var(--text-muted); min-width: 36px; text-align: right; }
.budget-over { color: #b91c1c !important; }
.text-muted-sm { color: var(--text-muted); font-size: .82rem; }
.hidden-col { display: none; }
.btn-danger-ghost { color: #b91c1c; }
.btn-danger-ghost:hover { background: #fee2e2; }

/* ── User guide rendered markdown ───────────────────────── */
.guide-content {
  padding: 1rem 0 .5rem;
  line-height: 1.7;
  color: var(--text);
  font-size: .92rem;
}
.guide-content h1 { font-size: 1.4rem; margin: 1.5rem 0 .5rem; }
.guide-content h2 { font-size: 1.1rem; font-weight: 700; margin: 1.75rem 0 .4rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem; }
.guide-content h3 { font-size: .97rem; font-weight: 700; margin: 1.25rem 0 .3rem; }
.guide-content p  { margin: .5rem 0; }
.guide-content ul, .guide-content ol { padding-left: 1.4rem; margin: .4rem 0; }
.guide-content li { margin: .25rem 0; }
.guide-content table { border-collapse: collapse; width: 100%; margin: .75rem 0; font-size: .85rem; }
.guide-content th, .guide-content td { border: 1px solid var(--border); padding: .45rem .7rem; text-align: left; }
.guide-content th { background: #f1f5f9; font-weight: 600; }
.guide-content code { background: #f1f5f9; border-radius: 4px; padding: .1rem .35rem; font-size: .85em; font-family: monospace; }
.guide-content pre { background: #f1f5f9; border-radius: var(--radius); padding: 1rem; overflow-x: auto; margin: .75rem 0; }
.guide-content pre code { background: none; padding: 0; }
.guide-content blockquote { border-left: 3px solid #6366f1; margin: .75rem 0; padding: .3rem .9rem; color: var(--text-muted); background: #f8fafc; border-radius: 0 var(--radius) var(--radius) 0; }
.guide-content hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
