/* ===================================================================
   DR Finance - Nourished Studio V.2 Dark Mode
   Design tokens from dr-branding/tokens/
   =================================================================== */

/* --- Variables --- */
:root {
  /* Backgrounds */
  --bg-deep: #0F1210;
  --bg-page: #1A1F1C;
  --bg-card: #2A2F2C;
  --bg-elevated: #333A36;

  /* Brand colours */
  --pine: #3E4843;
  --fern: #566D49;
  --fern-hover: #6B8F5A;
  --sage: #8AA382;
  --olive: #D0D9A3;
  --deep-blue: #3A708E;
  --coastal: #89B1CC;
  --golden: #F2E280;
  --dusty-yellow: #F7E9A7;
  --clay: #C95235;
  --clay-hover: #D46B4A;
  --wild-plum: #4E3A4C;
  --ivory: #F3E9DE;
  --mist: #C1D7E9;

  /* Semantic */
  --border: #3E4843;
  --text-primary: #F3E9DE;
  --text-secondary: #D0D9A3;
  --text-muted: #8AA382;

  /* Layout */
  --sidebar-width: 220px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(86, 109, 73, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;
}

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

/* --- Typography --- */
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: 1.375rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.9375rem; }

a { color: var(--coastal); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--mist); }

/* --- Focus & Accessibility --- */
:focus-visible {
  outline: 2px solid #2563EB;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Layout --- */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 {
  font-size: 1rem;
  color: var(--olive);
  margin-bottom: 2px;
}

.sidebar-brand span {
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-weight: 400;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px 6px;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: inset 3px 0 0 var(--fern);
}

.nav-icon {
  width: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  opacity: 0.6;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--clay);
  color: white;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.nav-spacer { flex: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--fern);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ivory);
  flex-shrink: 0;
}

.user-name { font-size: 0.75rem; font-weight: 500; }
.user-role { font-size: 0.625rem; color: var(--text-muted); }

/* Main content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.page-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary { background: var(--fern); color: var(--ivory); }
.btn-primary:hover { background: var(--fern-hover); }

.btn-success { background: var(--fern); color: var(--ivory); }
.btn-success:hover { background: var(--fern-hover); }

.btn-danger { background: var(--clay); color: white; }
.btn-danger:hover { background: var(--clay-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-outline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-card); color: var(--text-primary); }

.btn--small { padding: 4px 10px; font-size: 0.6875rem; }
.btn--green { background: var(--fern); color: var(--ivory); }
.btn--green:hover { background: var(--fern-hover); }
.btn--red { background: var(--clay); color: white; }
.btn--red:hover { background: var(--clay-hover); }

.kbd {
  font-size: 0.625rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid var(--border);
}

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}

.badge--green { background: rgba(86, 109, 73, 0.2); color: var(--sage); }
.badge--red { background: rgba(201, 82, 53, 0.15); color: var(--clay); }
.badge--amber { background: rgba(242, 226, 128, 0.15); color: var(--golden); }
.badge--blue { background: rgba(58, 112, 142, 0.2); color: var(--coastal); }
.badge--grey { background: rgba(138, 163, 130, 0.1); color: var(--text-muted); }
.badge--large { font-size: 0.75rem; padding: 4px 12px; }

.badge-high { background: rgba(201, 82, 53, 0.15); color: var(--clay); }
.badge-medium { background: rgba(242, 226, 128, 0.15); color: var(--golden); }
.badge-low { background: rgba(86, 109, 73, 0.2); color: var(--sage); }
.badge-pending { background: rgba(242, 226, 128, 0.15); color: var(--golden); }
.badge-approved { background: rgba(86, 109, 73, 0.2); color: var(--sage); }
.badge-rejected { background: rgba(201, 82, 53, 0.15); color: var(--clay); }

/* --- Alerts --- */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  margin-bottom: 16px;
  border-left: 3px solid;
}

.alert-success, .alert--success { background: rgba(86, 109, 73, 0.1); border-color: var(--fern); color: var(--sage); }
.alert-danger, .alert--error { background: rgba(201, 82, 53, 0.1); border-color: var(--clay); color: var(--clay); }
.alert-warning { background: rgba(242, 226, 128, 0.1); border-color: var(--golden); color: var(--golden); }
.alert-info { background: rgba(58, 112, 142, 0.1); border-color: var(--deep-blue); color: var(--coastal); }

/* --- Forms --- */
.form-group { margin-bottom: 12px; }

.form-label, .filter-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.required::after { content: " *"; color: var(--clay); }

.form-control, .input, input[type="text"], input[type="password"],
input[type="number"], input[type="date"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus, .input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--fern);
  box-shadow: 0 0 0 3px rgba(86, 109, 73, 0.15);
  outline: none;
}

.input-sm, .input--sm { padding: 5px 8px; font-size: 0.75rem; }
.input-inline { display: inline-block; width: auto; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238AA382' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

textarea { min-height: 60px; resize: vertical; }

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row--compact { gap: 8px; margin-bottom: 8px; }

.form-field { flex: 1; min-width: 0; }
.form-field--grow { flex: 2; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.toggle-group {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.toggle-option {
  flex: 1;
  padding: 6px 12px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-card);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.toggle-option:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-option.active, .toggle-option:checked + label { background: var(--fern); color: var(--ivory); }

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group--inline { flex-direction: row; align-items: center; gap: 8px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

/* Entry panel */
.entry-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.entry-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.entry-panel-header:hover { background: var(--bg-elevated); }

.entry-form-wrapper { padding: 0 16px 16px; }
.entry-form { padding-top: 12px; border-top: 1px solid var(--border); }

/* File drop zone */
.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.file-drop-zone:hover { border-color: var(--sage); }
.file-drop-zone--active {
  border-color: var(--fern);
  background: rgba(86, 109, 73, 0.05);
  box-shadow: var(--shadow-glow);
}

/* --- Data Tables (Hybrid Rounded Rows) --- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 0.8125rem;
}

.data-table thead th {
  text-align: left;
  padding: 6px 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text-primary); }
.data-table thead th .sort-arrow { font-size: 0.5625rem; margin-left: 2px; opacity: 0.5; }
.data-table thead th .sort-arrow.active { opacity: 1; color: var(--olive); }

.data-table tbody tr {
  background: var(--bg-elevated);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: rgba(51, 58, 54, 0.8); }

.data-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table tbody td:first-child { border-radius: 6px 0 0 6px; }
.data-table tbody td:last-child { border-radius: 0 6px 6px 0; }

.data-table--compact tbody td { padding: 6px 10px; }

.data-table tfoot td {
  padding: 10px 12px;
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* Table cell types */
.col-date { color: var(--text-muted); font-size: 0.75rem; }
.col-vendor { color: var(--text-primary); font-weight: 500; }
.col-vendor-sub { font-size: 0.6875rem; color: var(--text-muted); font-weight: 400; }
.col-amount {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-align: right;
  font-weight: 500;
}

.amount--expense, .col-amount.expense { color: var(--clay); }
.amount--revenue, .col-amount.revenue { color: var(--sage); }

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Row states */
.row--voided { opacity: 0.4; }
.row--voided td { text-decoration: line-through; }
.row--matched { background: rgba(86, 109, 73, 0.08); }
.row--unmatched-bank { background: rgba(242, 226, 128, 0.06); }
.row--unmatched-tx { background: rgba(201, 82, 53, 0.06); }

/* Table footer */
.table-total-label { font-weight: 600; color: var(--text-primary); }
.table-footer-actions { padding-top: 8px; }

/* Hover actions */
.action-group {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}
tr:hover .action-group { opacity: 1; }

.action-btn {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.action-btn:hover { background: var(--fern); color: var(--ivory); border-color: var(--fern); }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-value {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.card-body { padding: 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.card-action {
  font-size: 0.6875rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
}
.card-action:hover { color: var(--coastal); }

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--sage);
  box-shadow: var(--shadow-glow);
}

.stat-card--amber { border-left: 3px solid var(--golden); }

.stat-card__label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card__value {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.stat-card__value--revenue { color: var(--olive); }
.stat-card__value--expense { color: var(--clay); }
.stat-card__value--info { color: var(--coastal); }

.stat-card__link {
  font-size: 0.6875rem;
  color: var(--coastal);
  text-decoration: none;
}
.stat-card__link:hover { color: var(--mist); }

.stat-card__note {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
}
.stat-trend.up { color: var(--sage); }
.stat-trend.down { color: var(--clay); }

.sparkline { height: 24px; margin-top: 4px; }
.sparkline svg { width: 100%; height: 100%; }

/* --- Tabs --- */
.tabs, .tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab:hover { color: var(--text-primary); }

.tab--active, .tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--fern);
}

.tab-badge {
  font-size: 0.625rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(138, 163, 130, 0.15);
  color: var(--text-muted);
}

.tab-badge--amber { background: rgba(201, 82, 53, 0.15); color: var(--clay); }

.tab-count {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-left: 4px;
}

/* --- Progress Bars --- */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-wrap--large { gap: 12px; }

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--fern);
  transition: width var(--transition-slow);
}

.progress-fill.warn { background: var(--golden); }
.progress-fill.danger { background: var(--clay); }

.progress-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --- Sections --- */
.section {
  margin-bottom: 24px;
}

.section-heading {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* Detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.detail-list dt {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.detail-list dd {
  font-size: 0.8125rem;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.detail-text {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Meta */
.meta-group { display: flex; gap: 16px; }
.meta-label { font-size: 0.6875rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.meta-text { font-size: 0.8125rem; color: var(--text-primary); }

/* --- Reconciliation --- */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.summary-card--green { border-color: var(--fern); }
.summary-card--amber { border-color: var(--golden); }

.summary-label { font-size: 0.625rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.summary-value { font-family: 'Outfit', system-ui, sans-serif; font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }

.recon-section { margin-bottom: 24px; }

.recon-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.recon-section-title--green { background: rgba(86, 109, 73, 0.1); color: var(--sage); }
.recon-section-title--amber { background: rgba(242, 226, 128, 0.1); color: var(--golden); }
.recon-section-title--red { background: rgba(201, 82, 53, 0.1); color: var(--clay); }

/* --- Grant Pipeline --- */
.pipeline {
  display: flex;
  gap: 2px;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 12px;
}

.pipeline-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--ivory);
  white-space: nowrap;
  overflow: hidden;
  transition: filter var(--transition-fast);
}

.pipeline-stage:hover { filter: brightness(1.2); }

/* --- Login --- */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-deep);
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 4px;
  color: var(--olive);
}

.login-box .page-subtitle {
  text-align: center;
  margin-bottom: 24px;
}

.login-box .btn-primary {
  width: 100%;
  padding: 10px;
  font-size: 0.875rem;
  margin-top: 8px;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 16, 0.8);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }

/* --- Empty States --- */
.empty-state, .empty-state-block {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.empty-state-block--sm { padding: 16px; font-size: 0.8125rem; }

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  border-left: 3px solid var(--fern);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in var(--transition-normal) ease forwards;
  max-width: 360px;
}

.toast--error { border-left-color: var(--clay); }
.toast--warning { border-left-color: var(--golden); }
.toast--info { border-left-color: var(--coastal); }

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  margin-left: auto;
  padding: 0 4px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100%); }
}

/* --- Command Palette --- */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 18, 16, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  padding-top: 20vh;
}

.cmd-palette {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-height: 400px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.cmd-input {
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
}

.cmd-input:focus { outline: none; }
.cmd-input::placeholder { color: var(--text-muted); }

.cmd-results {
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}

.cmd-group-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.8125rem;
}

.cmd-item:hover, .cmd-item.active { background: var(--bg-elevated); }

.cmd-item-icon {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
}

.cmd-item-title { color: var(--text-primary); flex: 1; }
.cmd-item-subtitle { color: var(--text-muted); font-size: 0.6875rem; }

.cmd-item-shortcut {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.625rem;
  color: var(--text-muted);
}

/* --- Inline form --- */
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Link styles --- */
.link-subtle {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8125rem;
}
.link-subtle:hover { color: var(--text-primary); }

/* --- Text utilities --- */
.text--muted { color: var(--text-muted); }
.text--danger { color: var(--clay); }
.text-muted { color: var(--text-muted); }

/* --- Spacing utilities --- */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* --- Dashboard specific --- */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

/* Budget items */
.budget-items { display: flex; flex-direction: column; gap: 10px; }
.budget-item-header { display: flex; justify-content: space-between; font-size: 0.6875rem; margin-bottom: 3px; }
.budget-item-name { color: var(--text-muted); }
.budget-item-pct { color: var(--text-primary); font-weight: 500; }
.budget-bar { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.budget-fill { height: 100%; border-radius: 3px; transition: width var(--transition-slow); }
.budget-fill.ok { background: var(--fern); }
.budget-fill.warn { background: var(--golden); }
.budget-fill.danger { background: var(--clay); }

/* Deadline list */
.deadline-list { display: flex; flex-direction: column; gap: 8px; }
.deadline-item { display: flex; gap: 10px; align-items: flex-start; }
.deadline-date {
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 4px 8px;
  text-align: center;
  min-width: 44px;
  flex-shrink: 0;
}
.deadline-day { font-family: 'Outfit', system-ui, sans-serif; font-size: 0.875rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.deadline-month { font-size: 0.5625rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.deadline-title { font-size: 0.75rem; color: var(--text-primary); font-weight: 500; }
.deadline-sub { font-size: 0.625rem; color: var(--text-muted); }
.deadline-urgent .deadline-date { background: rgba(201, 82, 53, 0.15); border: 1px solid rgba(201, 82, 53, 0.3); }
.deadline-urgent .deadline-day { color: var(--clay); }

/* Chart legend */
.chart-legend { display: flex; gap: 16px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.6875rem; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

/* Donut legend */
.donut-legend-item { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; font-size: 0.6875rem; }
.donut-legend-left { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.donut-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-value { color: var(--text-primary); font-weight: 500; font-family: 'JetBrains Mono', monospace; font-size: 0.6875rem; }

/* Page section header */
.page-section-header { margin-bottom: 16px; }
.page-section-header h2 { font-size: 1rem; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .page-header { flex-direction: column; gap: 12px; }
}

/* --- Guide Pages --- */
.guide-content {
  max-width: 720px;
  line-height: 1.7;
}

.guide-content h2 {
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.guide-content h3 {
  margin-top: 24px;
  margin-bottom: 8px;
}

.guide-content p {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.guide-content ul, .guide-content ol {
  margin-bottom: 12px;
  padding-left: 20px;
}

.guide-content li {
  margin-bottom: 6px;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.guide-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--olive);
}

.guide-toc {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 24px 0;
}

.guide-toc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all var(--transition-fast);
  text-decoration: none;
  display: block;
}

.guide-toc-card:hover {
  border-color: var(--sage);
  box-shadow: var(--shadow-glow);
}

.guide-toc-card h3 {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.guide-toc-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.guide-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.guide-nav a {
  font-size: 0.8125rem;
  color: var(--coastal);
}

.guide-nav a:hover {
  color: var(--mist);
}

.role-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  vertical-align: middle;
  margin-left: 6px;
}

.role-badge--viewer { background: rgba(58, 112, 142, 0.2); color: var(--coastal); }
.role-badge--bookkeeper { background: rgba(86, 109, 73, 0.2); color: var(--sage); }
.role-badge--admin { background: rgba(78, 58, 76, 0.2); color: #b89ab6; }

.guide-tip {
  background: rgba(86, 109, 73, 0.08);
  border-left: 3px solid var(--fern);
  padding: 10px 14px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 12px 0;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.guide-tip strong {
  color: var(--sage);
}

.guide-shortcut-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  font-size: 0.8125rem;
  margin: 12px 0;
}

.guide-shortcut-table td {
  padding: 6px 12px;
  background: var(--bg-elevated);
  vertical-align: middle;
}

.guide-shortcut-table td:first-child {
  border-radius: 6px 0 0 6px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--olive);
  width: 120px;
}

.guide-shortcut-table td:last-child {
  border-radius: 0 6px 6px 0;
  color: var(--text-muted);
}

/* --- Help Panel --- */
.help-panel-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 18, 16, 0.5);
}

.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 90vw;
  background: var(--bg-page);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  z-index: 51;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.help-panel.open {
  transform: translateX(0);
}

.help-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.help-panel-header h3 {
  font-size: 0.875rem;
  margin: 0;
}

.help-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.help-panel-close:hover {
  color: var(--text-primary);
}

.help-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.help-section {
  margin-bottom: 16px;
}

.help-section-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 8px 0;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  border-bottom: 1px solid var(--border);
}

.help-section-toggle:hover {
  color: var(--olive);
}

.help-section-arrow {
  font-size: 0.625rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.help-section-body {
  padding: 8px 0 4px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.help-panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.help-panel-footer a {
  font-size: 0.8125rem;
  color: var(--coastal);
  display: flex;
  align-items: center;
  gap: 4px;
}

.help-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.help-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--sage);
}

/* --- Onboarding Tour --- */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 18, 16, 0.85);
  transition: opacity var(--transition-normal);
}

.onboarding-spotlight {
  position: absolute;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(15, 18, 16, 0.85);
  transition: all var(--transition-normal);
  pointer-events: none;
}

.onboarding-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  z-index: 401;
}

.onboarding-tooltip h4 {
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.onboarding-tooltip p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.onboarding-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.onboarding-step {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.onboarding-actions {
  display: flex;
  gap: 8px;
}

.onboarding-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  padding: 6px 10px;
}

.onboarding-skip:hover {
  color: var(--text-primary);
}

.onboarding-next {
  background: var(--fern);
  color: var(--ivory);
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.onboarding-next:hover {
  background: var(--fern-hover);
}

/* --- Feedback Widget --- */
.feedback-trigger {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  box-shadow: var(--shadow-md);
}

.feedback-trigger:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--sage);
}

.feedback-popover {
  position: fixed;
  bottom: 56px;
  right: 16px;
  z-index: 46;
  width: 280px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
}

.feedback-popover h4 {
  font-size: 0.8125rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.feedback-reactions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.feedback-reaction {
  flex: 1;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  text-align: center;
  font-size: 1.25rem;
  transition: all var(--transition-fast);
}

.feedback-reaction:hover {
  border-color: var(--sage);
  background: var(--bg-elevated);
}

.feedback-reaction.selected {
  border-color: var(--fern);
  background: rgba(86, 109, 73, 0.15);
}

.feedback-reaction-label {
  display: block;
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.feedback-comment {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  resize: none;
  height: 48px;
  margin-bottom: 8px;
}

.feedback-comment:focus {
  border-color: var(--fern);
  outline: none;
}

.feedback-submit {
  width: 100%;
  padding: 7px;
  background: var(--fern);
  color: var(--ivory);
  border: none;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.feedback-submit:hover { background: var(--fern-hover); }
.feedback-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Feedback page form */
.feedback-form {
  max-width: 600px;
}

.feedback-form .form-group {
  margin-bottom: 16px;
}
