/* ───────────────────────────────────────────────
   Company Prognosis — Modern SaaS Dashboard
   ─────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Surfaces */
  --bg: #0d1117;
  --sidebar-bg: #010409;
  --sidebar-text: #8b949e;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-accent: #3b82f6;
  --panel: #161b22;
  --panel-hover: #1c2128;
  --panel-soft: #1c2128;
  --surface-2: #21262d;

  /* Text */
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;

  /* Brand / Accent */
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-border: rgba(59, 130, 246, 0.3);

  /* Semantic */
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --info: #6366f1;

  /* Borders & shadows */
  --border: #30363d;
  --border-light: #21262d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.4);

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Sidebar width */
  --sidebar-w: 260px;
}

/* ── Reset ──────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, p {
  margin: 0;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
h3 { font-size: 1rem; font-weight: 600; color: var(--text); }

p { color: var(--text-secondary); }

/* ── Mobile navigation (drawer) ─────────────── */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.mobile-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-primary, #fff);
  font-size: 0.95rem;
}

.brand-icon--sm {
  width: 28px;
  height: 28px;
  min-width: 28px;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hamburger-btn {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0 8px;
}

.hamburger-btn span {
  display: block;
  height: 2px;
  background: var(--text-primary, #fff);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.hamburger-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  animation: fadeIn 0.15s ease;
}

.mobile-drawer-backdrop[hidden] { display: none; }

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(82vw, 320px);
  background: var(--panel);
  border-right: 1px solid var(--border);
  z-index: 60;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.mobile-drawer__close {
  background: transparent;
  border: none;
  color: var(--text-primary, #fff);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.mobile-drawer__items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.6rem;
  overflow-y: auto;
  flex: 1;
}

.mobile-drawer__items .tab {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary, #fff);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.mobile-drawer__items .tab:hover {
  background: rgba(255, 255, 255, 0.05);
}

.mobile-drawer__items .tab.active {
  background: rgba(59, 130, 246, 0.18);
  color: #93bbfc;
}

.mobile-drawer__items .tab--import {
  margin-top: auto;
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93bbfc;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Desktop: hide mobile nav */
.tabs,
.mobile-drawer,
.mobile-drawer-backdrop,
.mobile-topbar {
  display: none;
}

/* ── App Shell ──────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.content-area {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  align-content: start;
  max-width: 1400px;
  min-width: 0;
}

/* ── Sidebar ────────────────────────────────── */
.dashboard-sidebar {
  background: var(--sidebar-bg);
  border: none;
  border-radius: 0;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}

.brand-block {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.5rem;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.brand-block h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.brand-block p {
  font-size: 0.75rem;
  color: var(--sidebar-text);
  opacity: 0.7;
}

#workspaceMeta {
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.25rem;
}

#workspaceMeta p {
  color: var(--sidebar-text);
  font-size: 0.78rem;
  line-height: 1.5;
  opacity: 0.8;
}

#workspaceMeta strong {
  color: #e2e8f0;
}

.sidebar-menu {
  padding-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  align-content: flex-start;
}

.menu-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
  opacity: 0.5;
  font-weight: 600;
  padding: 0.5rem 0.6rem 0.3rem;
}

.side-link {
  text-align: left;
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.28rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.side-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}

.side-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: #93bbfc;
  font-weight: 600;
}

.sidebar-actions {
  display: grid;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-actions button {
  font-size: 0.82rem;
  padding: 0.55rem 0.7rem;
}

.sidebar-actions .ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text);
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-actions .ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.side-link--import {
  margin-top: 0.5rem;
  background: rgba(59, 130, 246, 0.15);
  color: #93bbfc;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius);
  font-weight: 600;
}

.side-link--import:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #fff;
}

/* ── Import Modal ─────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

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

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  line-height: 1;
}

.modal-close:hover { background: var(--surface-2, #f4f4f5); color: var(--text); }

.modal-tabs {
  display: flex;
  gap: 0;
  padding: 0.75rem 1.4rem 0;
  border-bottom: 1px solid var(--border);
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: -1px;
}

.modal-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.import-tab-panel.hidden { display: none; }

.import-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.import-status-msg {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Newly imported rows ──────────────────────── */
.simple-table tr.row--new td {
  background: rgba(16, 185, 129, 0.08) !important;
  border-left: 3px solid #10b981;
  animation: row-flash 0.6s ease;
}

@keyframes row-flash {
  from { background: rgba(16, 185, 129, 0.25) !important; }
  to   { background: rgba(16, 185, 129, 0.08) !important; }
}

.upgrade-card {
  margin-top: auto;
  border: 1px solid rgba(59, 130, 246, 0.2);
  background: rgba(59, 130, 246, 0.08);
  border-radius: var(--radius-lg);
  padding: 0.9rem;
  display: grid;
  gap: 0.5rem;
}

.upgrade-card h3 {
  color: #93bbfc;
  font-size: 0.88rem;
}

.upgrade-card p {
  color: var(--sidebar-text);
  font-size: 0.78rem;
  opacity: 0.8;
}

.upgrade-card button {
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  background: var(--accent);
  border: none;
}

.upgrade-card button:hover {
  background: var(--accent-hover);
}

/* ── Cards ──────────────────────────────────── */
.card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card.wide {
  grid-column: 1 / -1;
}

/* ── Overview section ───────────────────────── */
.overview-view {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 0;
}

.dashboard-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  padding-bottom: 10rem;
  min-width: 0;
}

/* ── Toolbar ────────────────────────────────── */
.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-left input[type="search"] {
  min-width: 300px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.toolbar-left input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.badge {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 600;
  font-size: 0.78rem;
}

/* ── Cost filter total ──────────────────────── */
.cost-filter-total-wrap {
  min-height: 1.5rem;
}

.cost-filter-total {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.cost-filter-total__sep {
  color: var(--border);
  user-select: none;
}

.cost-filter-total__row {
  white-space: nowrap;
}

/* ── Controls section ───────────────────────── */
.dashboard-controls {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.overview-controls-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
}

.control-group {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.control-import input[type='file'] {
  min-width: 260px;
  font-size: 0.82rem;
}

#scenarioNameInput {
  min-width: 180px;
}

#openingCashInput {
  min-width: 160px;
}

.dashboard-controls p {
  font-size: 0.85rem;
}

/* ── KPI Grid ───────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 0.75rem;
  min-width: 0;
}

.kpi-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  display: grid;
  gap: 0.3rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card--warning {
  border-color: var(--danger, #ef4444);
  background: color-mix(in srgb, var(--danger, #ef4444) 6%, var(--panel));
}

.kpi-card--success {
  border-color: var(--success, #22c55e);
  background: color-mix(in srgb, var(--success, #22c55e) 6%, var(--panel));
}

.kpi-card h3 {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
}

.kpi-change {
  color: var(--success);
  font-weight: 600;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.kpi-change.bad {
  color: var(--danger);
}

/* ── Charts ─────────────────────────────────── */
.insight-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.chart-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.chart-card h2 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.cash-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.legend {
  display: flex;
  gap: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.cashflow-svg {
  width: 100%;
  height: 260px;
  display: block;
  background: var(--panel-soft);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.cashflow-svg-wrap {
  position: relative;
}

/* ── Drag-and-drop dashboard cards ───────────── */
[data-sortable] > [data-card-id] {
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

[data-sortable] > [data-card-id][draggable="true"]:hover .drag-handle {
  opacity: 1;
}

.drag-handle {
  display: inline-block;
  cursor: grab;
  color: var(--text-secondary, #94a3b8);
  opacity: 0.4;
  font-weight: 700;
  letter-spacing: -2px;
  user-select: none;
  transition: opacity 0.15s ease;
  margin-right: 0.4rem;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle--overlay {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  z-index: 2;
  background: rgba(15, 17, 22, 0.5);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 0.9rem;
}

.card--dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.cashflow-legend label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  user-select: none;
}

.cashflow-legend input[type="checkbox"] {
  accent-color: var(--accent, #3b82f6);
  width: 13px;
  height: 13px;
  margin: 0;
}

.cashflow-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 17, 22, 0.96);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-primary, #fff);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  min-width: 170px;
  z-index: 5;
}

.cashflow-tooltip .tt-title {
  font-weight: 700;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
}

.cashflow-tooltip > div:not(.tt-title) {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 2px 0;
}

.cashflow-tooltip .tt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.x-labels {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  font-size: 0.72rem;
  margin-top: 0.5rem;
  color: var(--text-muted);
}

.x-labels span {
  text-align: center;
}

/* ── Donut ──────────────────────────────────── */
.donut-wrap {
  display: grid;
  gap: 1rem;
  justify-items: center;
}

.donut {
  width: 200px;
  height: 200px;
  border-radius: 999px;
  position: relative;
  box-shadow: var(--shadow);
}

.donut::after {
  content: '';
  position: absolute;
  inset: 22px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border-light);
}

.donut-total {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  z-index: 1;
  text-align: center;
}

.donut-total span {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.donut-total strong {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.donut-legend {
  width: 100%;
  display: grid;
  gap: 0.35rem;
}

.donut-legend div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.25rem 0;
}

.donut-legend strong {
  font-weight: 600;
  font-size: 0.82rem;
}

/* ── Bar chart ──────────────────────────────── */
.cashflow-card {
  grid-column: 1 / -1;
}

.bar-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.25rem;
  align-items: end;
  min-height: 200px;
}

.bar-stack {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  min-height: 150px;
}

.bar-month-wrap {
  position: relative;
}

.bar {
  border-radius: var(--radius-sm);
  min-height: 6px;
  width: 12px;
  transition: opacity 0.15s ease;
}

.bar-current,
.bar-income {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
}

.bar-previous,
.bar-expense,
.bar-cost {
  background: linear-gradient(180deg, #f87171, #ef4444);
}

.bar-payroll {
  background: linear-gradient(180deg, #34d399, #10b981);
}

.bar-mynt {
  background: linear-gradient(180deg, #a78bfa, #8b5cf6);
}

.bar-month {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-weight: 500;
}

.bar-pct {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.bar-pct--pos { color: var(--success); }
.bar-pct--neg { color: var(--danger, #ef4444); }

.bar-hover {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 8px);
  transform: translateX(-50%);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-md);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: none;
  min-width: 170px;
  z-index: 10;
  font-size: 0.82rem;
}

.bar-hover strong {
  display: block;
  margin-bottom: 0.2rem;
  font-weight: 600;
}

.bar-hover span {
  display: block;
  color: var(--text-secondary);
}

.bar-month-wrap:hover .bar-hover {
  display: block;
}

.bar-month-wrap:hover .bar {
  opacity: 0.85;
}

/* ── Forms & Inputs ─────────────────────────── */
input,
select,
button {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s ease;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder {
  color: var(--text-muted);
}

button {
  background: var(--accent);
  color: white;
  border-color: transparent;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

button:active {
  transform: scale(0.98);
}

button.ghost {
  background: var(--panel);
  color: var(--text-secondary);
  border-color: var(--border);
  font-weight: 500;
}

button.ghost:hover {
  background: var(--panel-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Row / Stack layouts ────────────────────── */
.row,
.stack {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.stack {
  flex-direction: column;
  align-items: flex-start;
}

/* ── Lists ──────────────────────────────────── */
.list {
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 0.4rem;
}

#revenueList.list,
#costList.list,
#myntLoadsList.list,
#myntEntriesList.list {
  max-height: none;
  overflow: visible;
}

.item {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.item:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

/* ── Metrics ────────────────────────────────── */
.metrics {
  display: grid;
  gap: 0.5rem;
}

.metric {
  background: var(--panel-soft);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  transition: background 0.15s ease;
}

.metric:hover {
  background: var(--accent-soft);
}

.metric strong {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.metric--total {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.metric--total strong {
  color: var(--accent);
}

/* ── Table toolbar (sort/filter above lists) ── */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.sort-select {
  appearance: none;
  -webkit-appearance: none;
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.28rem 1.8rem 0.28rem 0.65rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--panel-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e7681' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 0.55rem center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.sort-select:hover {
  border-color: var(--accent);
  color: var(--text);
}

.sort-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Cost list toolbar ──────────────────────── */
.cost-list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.cost-list-toolbar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.cost-list-toolbar__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.toolbar-sort-group,
.toolbar-bulk-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.cost-stats-row {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.cost-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.cost-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

.cost-stat-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.table-toolbar-sep {
  width: 1px;
  height: 1.2rem;
  background: var(--border);
  margin: 0 0.15rem;
}

.bulk-value-input {
  width: 110px !important;
  font-size: 0.76rem !important;
  padding: 0.28rem 0.6rem !important;
  border-radius: var(--radius-xl) !important;
}

.toolbar-btn {
  font-size: 0.76rem !important;
  padding: 0.28rem 0.75rem !important;
  border-radius: var(--radius-xl) !important;
}

/* ── Description totals list ────────────────── */
.desc-totals-list {
  columns: 3;
  column-gap: 1.5rem;
  margin-bottom: 0.75rem;
  width: 100%;
  grid-column: 1 / -1;
}

.dtl-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) minmax(40px, 100px) 90px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
  break-inside: avoid;
}

.dtl-row:hover {
  background: var(--panel-soft);
}

.dtl-rank {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dtl-name {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dtl-bar {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.dtl-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.dtl-amount {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dtl-pct {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.dtl-row--total {
  border-top: 1px solid var(--border-light);
  margin-top: 0.2rem;
  padding-top: 0.35rem;
}

.dtl-row--total .dtl-name,
.dtl-row--total .dtl-amount {
  color: var(--text);
  font-weight: 600;
}

/* ── Tables ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

.simple-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
}

.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.simple-table th,
.simple-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.simple-table th {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--panel-soft);
  position: sticky;
  top: 0;
}

.simple-table tbody tr {
  transition: background 0.1s ease;
}

.simple-table tbody tr:hover {
  background: var(--accent-soft);
}

.simple-table tr.month-separator-row td {
  color: var(--text-muted, #6b7280);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.3rem 0.85rem;
  border-top: 2px solid var(--border);
}

.simple-table tr.month-group-0 td { background: rgba(59,130,246,0.05); }
.simple-table tr.month-group-1 td { background: rgba(16,185,129,0.05); }
.simple-table tr.month-group-2 td { background: rgba(245,158,11,0.05); }
.simple-table tr.month-group-3 td { background: rgba(139,92,246,0.05); }

.simple-table tr.month-separator-row.month-group-0 td { background: rgba(59,130,246,0.14); border-top-color: rgba(59,130,246,0.3); color: #93bbfc; }
.simple-table tr.month-separator-row.month-group-1 td { background: rgba(16,185,129,0.14); border-top-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.simple-table tr.month-separator-row.month-group-2 td { background: rgba(245,158,11,0.14); border-top-color: rgba(245,158,11,0.3); color: #fcd34d; }
.simple-table tr.month-separator-row.month-group-3 td { background: rgba(139,92,246,0.14); border-top-color: rgba(139,92,246,0.3); color: #c4b5fd; }

.simple-table tr.month-group-0:hover td { background: rgba(59,130,246,0.1); }
.simple-table tr.month-group-1:hover td { background: rgba(16,185,129,0.1); }
.simple-table tr.month-group-2:hover td { background: rgba(245,158,11,0.1); }
.simple-table tr.month-group-3:hover td { background: rgba(139,92,246,0.1); }

.simple-table tr.month-separator-row:hover td { filter: brightness(0.96); }
.simple-table tr.month-separator-row { cursor: pointer; user-select: none; }
.group-chevron { display: inline-block; margin-right: 0.4rem; font-size: 0.7rem; transition: transform 0.15s; }
.group-row-hidden { display: none; }

.simple-table tr.month-separator-row td.month-sep-total {
  text-align: right;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: none;
}

.goals-monthly-wrap { margin-top: 1rem; }

.goals-monthly-table th,
.goals-monthly-table td {
  white-space: nowrap;
  text-align: center;
  padding: 0.5rem 0.4rem;
}

.goals-monthly-table th:first-child,
.goals-monthly-table td:first-child {
  text-align: left;
  padding-left: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.goal-input {
  width: 90px;
  padding: 0.35rem 0.4rem;
  font-size: 0.82rem;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.goal-row-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  min-width: 120px;
}

.simple-table td:last-child,
.simple-table th:last-child {
  text-align: right;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--border-light);
  padding: 0.5rem 0.6rem;
  text-align: right;
  font-size: 0.85rem;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Sticky entry forms ─────────────────────── */
[data-view-panel='revenue'],
[data-view-panel='costs'],
[data-view-panel='mynt'] {
  padding-bottom: 7.5rem;
}

.sticky-entry-form {
  position: fixed;
  left: calc(var(--sidebar-w) + 2.5rem);
  right: 1.5rem;
  bottom: 1rem;
  z-index: 30;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(12px);
}

/* ── Revenue / Cost / Mynt summary ──────────── */
#revenueSummary,
#costSummary,
#myntSummary {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  align-items: stretch;
}

/* ── Revenue form ───────────────────────────── */
.form-list-split {
  display: grid;
  gap: 1rem;
}

.revenue-layout {
  grid-template-columns: 1fr;
}

.editor-pane,
.list-pane {
  display: grid;
  gap: 0.8rem;
  align-content: start;
}

#revenueForm.revenue-form-grid,
#costForm.cost-form-grid,
#myntForm.mynt-form-grid {
  display: grid !important;
  grid-template-columns: minmax(140px, 1.5fr) minmax(120px, 1fr) 70px minmax(120px, 1fr) minmax(130px, 1.2fr) minmax(110px, 1fr) auto auto;
  grid-template-areas: "desc amount vat date rec end submit cancel";
  gap: 0.55rem;
  align-items: end;
}

#revenueSubmitBtn { grid-area: submit; }
#revenueCancelEditBtn { grid-area: cancel; }

#costSubmitBtn { grid-area: submit; }
#costCancelEditBtn { grid-area: cancel; }

#myntSubmitBtn { grid-area: submit; }
#myntCancelEditBtn { grid-area: cancel; }

/* ── Goals ──────────────────────────────────── */
.goals-annual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  width: 100%;
  gap: 0.6rem;
}

#monthlyGoalsBody input {
  width: 100%;
}

/* ── Workers ────────────────────────────────── */
#payrollMetrics {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.workers-metrics-row {
  margin-bottom: 1rem;
}

/* ── Worker table ───────────────────────────── */
.worker-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.worker-table {
  width: 100%;
  border-collapse: collapse;
}

.worker-table thead th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.worker-table thead th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.worker-table thead th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.worker-row td {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.worker-row:last-child td { border-bottom: none; }

.worker-row:hover td { background: var(--panel-hover); }

.worker-avatar-cell { width: 48px; padding-right: 0; }

.worker-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.worker-name-cell { min-width: 120px; }

.worker-name {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.worker-start {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.worker-salary-cell { min-width: 160px; }

.worker-gross-amt {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.worker-bar-track {
  width: 140px;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.worker-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.worker-badge-cell { min-width: 120px; }

.worker-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.worker-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.worker-breakdown-cell {
  min-width: 200px;
}

.worker-pill {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.worker-pill strong {
  color: var(--text);
  font-weight: 600;
}

.worker-override-mark {
  font-size: 0.7rem;
  color: var(--accent);
  opacity: 0.8;
}

.worker-cost-cell {
  min-width: 140px;
}

.worker-cost-month {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.worker-cost-year {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  display: block;
}

.worker-cost-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.worker-actions-cell {
  white-space: nowrap;
  text-align: right;
}

.worker-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.worker-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.worker-icon-btn--danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ── Sticky add-worker form ─────────────────── */
.worker-sticky-form {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  margin: 0 -1.25rem -1.25rem;
}

.wf-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 110px;
}

.wf-field--grow { flex: 1 1 140px; }
.wf-field--narrow { min-width: 72px; max-width: 88px; }

.wf-label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.wf-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.88rem;
  padding: 0.45rem 0.6rem;
  width: 100%;
  box-sizing: border-box;
}

.wf-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wf-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-self: flex-end;
}

.worker-form-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.3rem 0 0;
  min-height: 1.2em;
}

.workers-spec {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--panel-soft);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.workers-spec p {
  font-size: 0.82rem;
}

.workers-list,
#workerList {
  margin-top: 0.75rem;
  max-height: none;
  overflow: visible;
}

.workers-list .item {
  background: var(--panel-soft);
}

/* ── Link buttons ───────────────────────────── */
.link-btn {
  background: transparent;
  color: var(--accent);
  border: none;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.link-btn:hover {
  background: var(--accent-soft);
  box-shadow: none;
}

.danger-link {
  color: var(--danger);
}

.danger-link:hover {
  background: var(--danger-soft);
}

/* ── Priority badges ────────────────────────── */
.priority-high {
  color: var(--danger);
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--danger-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.priority-medium {
  color: var(--warn);
  font-weight: 700;
  font-size: 0.78rem;
  background: var(--warn-soft);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.priority-low {
  color: var(--info);
  font-weight: 700;
  font-size: 0.78rem;
  background: #eef2ff;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ── Card headers ───────────────────────────── */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
}

/* ── Overview lower grid ────────────────────── */
.overview-lower-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

/* ── Sidebar icons ──────────────────────────── */
.side-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.side-link svg {
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 0.15s ease;
  width: 13px;
  height: 13px;
}

.side-link.active svg,
.side-link:hover svg {
  opacity: 1;
}

/* ── Utility ────────────────────────────────── */
.hidden {
  display: none;
}

/* ── Dashboard lower grid ───────────────────── */
.dashboard-lower {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── VAT Report section ─────────────────────── */
#vatReportMetrics,
#vatQuarterMetrics {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  margin-bottom: 0.5rem;
}

#goalsSummary {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  width: 100%;
}

/* ── Import result summary ──────────────────── */
#importResultSummary .item {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

#importResultSummary .item p {
  font-size: 0.82rem;
}

/* ── Scrollbar styling ──────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 1300px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .dashboard-controls {
    left: 0;
  }

  .dashboard-sidebar {
    display: none;
  }

  .mobile-topbar {
    display: flex;
  }

  /* Drawer element is always in DOM but hidden via transform */
  .mobile-drawer {
    display: flex;
  }

  .content-area {
    padding: 1rem;
  }

  .sticky-entry-form {
    left: 1rem;
    right: 1rem;
  }

  .toolbar-left input[type="search"] {
    min-width: 220px;
  }

  .overview-controls-row {
    flex-wrap: wrap;
  }
}

/* ── Mobile FAB + form-sheet (desktop defaults: hidden) ─ */
.mobile-fab {
  display: none;
}

.mobile-form-close {
  display: none;
}

/* ── Mobile polish (<=720px) ────────────────── */
@media (max-width: 720px) {
  html, body {
    overflow-x: hidden;
  }

  .dashboard-main {
    padding-bottom: 4rem;
    gap: 0.75rem;
  }

  /* Controls stack and fill width */
  .dashboard-controls {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .overview-controls-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .overview-controls-row .control-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .overview-controls-row select,
  .overview-controls-row input,
  .overview-controls-row button {
    flex: 1 1 auto;
    min-width: 0;
  }

  #scenarioNameInput,
  #openingCashInput {
    min-width: 0;
    width: 100%;
  }

  .control-import input[type='file'] {
    min-width: 0;
    width: 100%;
  }

  /* Toolbar wraps and search fills */
  .dashboard-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.6rem 0.75rem;
    gap: 0.6rem;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    gap: 0.4rem;
  }

  .toolbar-left input[type="search"] {
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
  }

  /* KPI cards tighter */
  .kpi-card {
    padding: 0.75rem 0.9rem;
  }

  .kpi-card h3 {
    font-size: 0.7rem;
  }

  .kpi-value {
    font-size: 1.35rem;
    word-break: break-word;
  }

  .kpi-change {
    font-size: 0.78rem;
  }

  /* Cards general padding */
  .card {
    padding: 0.85rem;
    border-radius: var(--radius);
  }

  /* Cashflow chart responsive */
  .cashflow-svg-wrap,
  .cashflow-svg-wrap svg {
    max-width: 100%;
    height: auto;
  }

  .cashflow-legend {
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
    font-size: 0.72rem;
  }

  /* Tables become horizontally scrollable instead of overflowing the page */
  .card :is(table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Mobile drawer width fills screen more comfortably */
  .mobile-drawer {
    max-width: 86vw;
  }

  /* Hide drag handles on mobile (drag-and-drop is awkward on touch) */
  .drag-handle {
    display: none !important;
  }

  /* Prevent filter chips from forcing overflow */
  .filters-row,
  .chip-row {
    flex-wrap: wrap;
  }

  /* Reduce excessive sticky bottom padding on overview */
  .overview-view .dashboard-main {
    padding-bottom: 2rem;
  }

  /* ── Floating action button (always visible) ── */
  .mobile-fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 35;
    padding: 0.9rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.35);
    cursor: pointer;
  }

  .mobile-fab:active {
    transform: translateY(1px);
  }

  /* Hide the FAB while the form sheet is open */
  [data-view-panel='revenue'].is-form-open .mobile-fab,
  [data-view-panel='costs'].is-form-open .mobile-fab,
  [data-view-panel='mynt'].is-form-open .mobile-fab {
    display: none;
  }

  /* Hide the entry form by default on mobile — slide up when open */
  [data-view-panel='revenue'] .sticky-entry-form,
  [data-view-panel='costs'] .sticky-entry-form,
  [data-view-panel='mynt'] .sticky-entry-form {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 45;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    padding: 1rem 0.9rem 1.25rem;
    transform: translateY(110%);
    transition: transform 0.25s ease;
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.4);
  }

  [data-view-panel='revenue'].is-form-open .sticky-entry-form,
  [data-view-panel='costs'].is-form-open .sticky-entry-form,
  [data-view-panel='mynt'].is-form-open .sticky-entry-form {
    transform: translateY(0);
  }

  /* Backdrop when form sheet is open */
  body.mobile-form-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    z-index: 40;
  }

  /* Close-X button inside the sheet */
  .mobile-form-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 34px;
    height: 34px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    grid-area: unset;
    padding: 0;
  }

  /* Extra bottom padding so list isn't hidden behind the FAB */
  [data-view-panel='revenue'],
  [data-view-panel='costs'],
  [data-view-panel='mynt'] {
    padding-bottom: 5rem;
  }
}

@media (max-width: 1024px) {
  .kpi-grid,
  .dashboard-lower,
  .overview-lower-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .insight-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .revenue-card {
    grid-column: auto;
  }

  .form-list-split {
    grid-template-columns: 1fr;
  }

  .control-group {
    flex-wrap: wrap;
  }

  #revenueForm.revenue-form-grid,
  #costForm.cost-form-grid,
  #myntForm.mynt-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "desc amount"
      "vat date"
      "rec end"
      "submit cancel";
  }

}

@media (max-width: 720px) {
  .content-area {
    padding: 0.5rem;
  }

  .kpi-grid,
  .dashboard-lower {
    grid-template-columns: minmax(0, 1fr);
  }



  #revenueForm.revenue-form-grid,
  #costForm.cost-form-grid,
  #myntForm.mynt-form-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "desc"
      "amount"
      "vat"
      "date"
      "rec"
      "end"
      "submit"
      "cancel";
  }

  .goals-annual-grid {
    grid-template-columns: 1fr;
  }

  .bar-grid {
    min-width: 720px;
  }

  /* Wrap bar-grid in a scroll container on mobile */
  .chart-card:has(.bar-grid) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  [data-view-panel='revenue'],
  [data-view-panel='costs'],
  [data-view-panel='mynt'] {
    padding-bottom: 10rem;
  }

  .sticky-entry-form {
    bottom: 0.5rem;
    left: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
  }
}

/* ── Login overlay ──────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-error {
  color: #f87171;
  font-size: 0.82rem;
  margin: 0;
  text-align: center;
}

.login-submit {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.login-submit:hover { background: var(--accent-hover); }
.login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Logout button ──────────────────────────── */
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-logout:hover {
  border-color: #f87171;
  color: #f87171;
}
