:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --text: #0f172a;
    --text-secondary: #334155;
    --muted: #64748b;
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --primary-subtle: #f0fdfa;
    --accent: #f59e0b;
    --accent-light: #fffbeb;
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --input-bg: #ffffff;
    --calc-bg: #f0fdfa;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(13, 148, 136, 0.2);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── App shell & top navigation ────────────────────────── */

.app-body {
    overflow-x: hidden;
}

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--topbar-height);
    padding: 0 1.25rem;
}

.header-context {
    padding: 0.65rem 1.25rem 0.75rem;
    background: rgba(0, 0, 0, 0.22);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.header-context-inner {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 1rem 1.75rem;
    max-width: 1400px;
    margin: 0 auto;
}

.context-group {
    display: grid;
    gap: 0.35rem;
    min-width: 0;
}

.context-group:last-child {
    margin-left: auto;
}

.context-group-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    padding-left: 0.15rem;
}

.context-group-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.35rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.context-control {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.context-control-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.header-context-link {
    color: #cbd5e1;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
}

.header-context-link:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    flex-shrink: 0;
    min-width: 0;
}

.brand-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #14b8a6);
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.brand-text {
    display: grid;
    gap: 0.05rem;
    min-width: 0;
}

.brand-kicker {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-text);
    font-weight: 600;
}

.brand-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: #f8fafc;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    cursor: pointer;
    flex-shrink: 0;
}

.nav-toggle-icon-close {
    display: none;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon-open {
    display: none;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-icon-close {
    display: block;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1;
    min-width: 0;
    margin-left: 0.75rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.top-nav::-webkit-scrollbar {
    display: none;
}

.top-nav-pill {
    display: grid;
    gap: 0.3rem;
    flex-shrink: 0;
}

.top-nav-group-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    padding-left: 0.35rem;
}

.top-nav-group-links {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.25rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.top-nav-group {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.top-nav-divider {
    display: none;
}

.top-nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.7rem;
    border-radius: 9px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}

.top-nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.top-nav-link.active {
    background: var(--sidebar-active);
    color: #5eead4;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.15);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
    margin-left: auto;
}

.header-create-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.header-create-btn svg {
    flex-shrink: 0;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-left: 0.65rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.header-user-meta {
    display: grid;
    gap: 0.05rem;
    min-width: 0;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #334155, #475569);
    color: #f8fafc;
    display: grid;
    place-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.user-logout {
    font-size: 0.72rem;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: color var(--transition);
}

.user-logout:hover {
    color: #5eead4;
}

.page-banner {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid var(--border);
}

.page-banner-kicker {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    white-space: nowrap;
}

.page-banner-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 30;
    backdrop-filter: blur(2px);
}

.nav-backdrop.is-visible {
    display: block;
}

.year-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.75rem 0.35rem 0.6rem;
    box-shadow: var(--shadow-xs);
}

.year-switcher-dark {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.year-switcher-dark .year-icon {
    color: #94a3b8;
}

.year-switcher-dark select {
    color: #f1f5f9;
    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='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    min-width: 4.5rem;
}

.company-switcher select {
    max-width: 16rem;
    min-width: 8rem;
}

.year-icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

.year-switcher select {
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    padding: 0.15rem 1.25rem 0.15rem 0;
    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='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
}

.year-switcher select:focus {
    outline: none;
}

.page-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.site-footer {
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.site-footer p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

/* Legacy container (unused in shell, kept for safety) */
.container {
    width: min(1320px, calc(100% - 2rem));
    margin: 0 auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ── Page headers ────────────────────────────────────── */

.dashboard-hero,
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.hero-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    font-weight: 600;
}

.dashboard-hero h2,
.page-head h2 {
    margin: 0 0 0.35rem;
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
}

.subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 52ch;
    line-height: 1.6;
    font-size: 0.925rem;
}

.hero-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* ── KPI cards ─────────────────────────────────────────── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.kpi-card::before {
    display: none;
}

.kpi-top {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 20px;
    height: 20px;
}

.kpi-icon-teal {
    background: var(--primary-subtle);
    color: var(--primary-dark);
}

.kpi-icon-blue {
    background: #eff6ff;
    color: #2563eb;
}

.kpi-icon-amber {
    background: var(--accent-light);
    color: #d97706;
}

.kpi-icon-green {
    background: #ecfdf5;
    color: #059669;
}

.kpi-label {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    line-height: 1.3;
}

.kpi-value {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.kpi-unit {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.kpi-accent .kpi-value { color: #2563eb; }
.kpi-gold .kpi-value { color: var(--accent); }
.kpi-green .kpi-value { color: var(--primary-dark); }

/* ── Cards & panels ────────────────────────────────────── */

.capture-layout {
    display: grid;
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
    align-items: start;
}

.month-panel {
    margin-bottom: 1.25rem;
}

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

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.panel-head h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.panel-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--border-subtle);
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
}

/* ── Month grid ────────────────────────────────────────── */

.month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.month-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.05rem;
    padding: 0.7rem 0.35rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--border-subtle);
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.month-card:hover {
    border-color: rgba(13, 148, 136, 0.4);
    background: var(--primary-subtle);
    box-shadow: var(--shadow-xs);
}

.month-card.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.month-card.has-data .month-status {
    background: var(--primary);
}

.month-abbr {
    font-size: 0.9rem;
    font-weight: 700;
}

.month-year {
    font-size: 0.65rem;
    color: var(--muted);
}

.month-pct {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 0.1rem;
}

.month-status {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
}

/* ── Reports page ──────────────────────────────────────── */

.report-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.report-kpi-grid .kpi-card {
    padding: 1.1rem 1.25rem;
}

.report-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.report-chart-card {
    padding: 1.25rem;
}

.report-chart-wide {
    grid-column: 1 / -1;
}

.chart-desc {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.45;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.legend-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.legend-dot::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-predicted::before {
    background: #6366f1;
}

.legend-actual::before {
    background: var(--primary);
}

.legend-perfect::before {
    background: var(--muted);
    border-radius: 2px;
    width: 14px;
    height: 3px;
}

.chart-canvas {
    margin-top: 0.75rem;
    min-height: 200px;
}

.chart-canvas-scatter {
    min-height: 280px;
}

.report-svg {
    display: block;
    overflow: visible;
}

.chart-axis-label {
    font-size: 10px;
    fill: var(--muted);
    font-family: "Inter", system-ui, sans-serif;
}

.chart-axis-title {
    font-size: 11px;
    fill: var(--text-secondary);
    font-weight: 600;
    font-family: "Inter", system-ui, sans-serif;
}

.chart-point-label {
    font-size: 9px;
    fill: var(--muted);
    font-weight: 600;
    font-family: "Inter", system-ui, sans-serif;
}

.dashboard-chart-note {
    margin: 1rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.dashboard-chart-note a {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.dashboard-chart-note a:hover {
    text-decoration: underline;
}

/* ── Bar chart ─────────────────────────────────────────── */

.chart-block h4 {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 130px;
    padding-top: 0.5rem;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 6px;
}

.bar {
    width: 100%;
    max-width: 32px;
    height: var(--bar-height, 10%);
    min-height: 4px;
    border-radius: 6px 6px 2px 2px;
    background: linear-gradient(180deg, #2dd4bf, var(--primary));
    opacity: 0.45;
    transition: opacity var(--transition), height 0.2s;
}

.bar-col:hover .bar,
.bar-col.active .bar {
    opacity: 1;
}

.bar-col.active .bar {
    box-shadow: 0 -2px 8px rgba(13, 148, 136, 0.25);
}

.bar-label {
    font-size: 0.62rem;
    color: var(--muted);
    font-weight: 500;
}

.bar-col.active .bar-label {
    color: var(--primary-dark);
    font-weight: 600;
}

/* ── Capture panel ─────────────────────────────────────── */

.capture-kicker {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--primary);
    font-weight: 600;
}

.capture-date {
    font-size: 0.8rem;
    color: var(--muted);
    background: var(--border-subtle);
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid var(--border);
}

.input-group,
.calc-group {
    margin-bottom: 1.25rem;
}

.input-group h4,
.calc-group h4 {
    margin: 0 0 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    font-weight: 600;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.field {
    display: grid;
    gap: 0.4rem;
}

.field span {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.capture-input,
.field input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-size: 0.95rem;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-xs);
}

.capture-input:focus,
.field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.calc-tile {
    background: var(--calc-bg);
    border: 1px solid #99f6e4;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    display: grid;
    gap: 0.15rem;
}

.calc-tile.highlight {
    background: linear-gradient(135deg, #ccfbf1, #99f6e4);
    border-color: #5eead4;
}

.calc-tile span {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 500;
}

.calc-tile strong {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
}

.calc-tile small {
    font-size: 0.7rem;
    color: var(--muted);
}

/* ── Tables ────────────────────────────────────────────── */

.annual-table {
    margin-top: 0;
}

.compact-table .data-table {
    min-width: 0;
}

.month-link {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.875rem;
}

.month-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.row-active {
    background: var(--primary-subtle) !important;
}

.row-active td:first-child {
    box-shadow: inset 3px 0 0 var(--primary);
}

.legend {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.legend-item {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-weight: 500;
}

.legend-item.input-field { background: var(--input-bg); }
.legend-item.calc-field { background: var(--calc-bg); }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 700px;
}

.data-table th,
.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 0.875rem;
}

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

.data-table thead th {
    background: var(--border-subtle);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    font-weight: 600;
    position: sticky;
    top: 0;
}

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

.data-table tbody tr:hover {
    background: var(--primary-subtle);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr[hidden] {
    display: none;
}

/* ── Table tools (filters, pagination, export) ─────────── */

.table-tools-bar {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, #f8fafc 0%, var(--surface) 100%);
    box-shadow: var(--shadow-xs);
}

.card > .table-tools-bar,
.annual-table > .table-tools-bar {
    margin-bottom: 1rem;
}

.table-tools-bar button {
    font-family: inherit;
}

.table-tools-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 0.85rem;
}

.table-tools-search {
    flex: 1 1 16rem;
    min-width: min(100%, 16rem);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
}

.table-tools-search-field {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.table-tools-search-field:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

.table-tools-search-icon {
    width: 1rem;
    height: 1rem;
    color: var(--muted);
    flex-shrink: 0;
}

.table-tools-search-field input {
    flex: 1;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.875rem;
    color: var(--text);
    box-shadow: none;
}

.table-tools-search-field input::placeholder {
    color: #94a3b8;
}

.table-tools-search-field input:focus {
    outline: none;
    box-shadow: none;
}

.table-tools-columns {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem 0.75rem;
    flex: 2 1 24rem;
}

.table-tools-field,
.table-tools-page-size {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    min-width: 7.5rem;
}

.table-tools-field select,
.table-tools-page-size select {
    min-width: 7.5rem;
    max-width: 11rem;
    padding: 0.48rem 2rem 0.48rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    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='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.65rem center;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    appearance: none;
    box-shadow: var(--shadow-xs);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.table-tools-page-size select {
    min-width: 4.75rem;
    max-width: 5.5rem;
}

.table-tools-field select:hover,
.table-tools-page-size select:hover {
    border-color: #cbd5e1;
}

.table-tools-field select:focus,
.table-tools-page-size select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

.table-tools-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.table-tools-clear {
    align-self: flex-end;
    margin-bottom: 0.05rem;
}

.table-tools-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.table-tools-meta {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--muted);
    line-height: 1.5;
}

.table-tools-count strong {
    color: var(--text);
    font-weight: 700;
    font-size: 0.9rem;
}

.table-tools-filtered {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.12rem 0.5rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-dark);
    background: var(--primary-subtle);
    border: 1px solid rgba(13, 148, 136, 0.18);
    border-radius: 999px;
    vertical-align: middle;
}

.table-tools-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem 0.85rem;
}

.table-tools-pagination {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.table-tools-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.42rem 0.7rem;
    border: 0;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.table-tools-page-btn svg {
    width: 0.95rem;
    height: 0.95rem;
    flex-shrink: 0;
}

.table-tools-page-btn:hover:not(:disabled) {
    background: var(--border-subtle);
    color: var(--text);
}

.table-tools-page-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.table-tools-page-info {
    padding: 0 0.45rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}

.table-tools-export svg {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .table-tools-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .table-tools-actions {
        justify-content: stretch;
    }

    .table-tools-pagination {
        width: 100%;
        justify-content: space-between;
    }

    .table-tools-export {
        width: 100%;
    }
}

.input-col { background: #fefefe; }
.calc-col { background: var(--calc-bg); color: var(--primary-dark); }

.period-cell { font-weight: 600; }

.input-cell {
    width: 100%;
    min-width: 110px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.6rem;
    font: inherit;
    text-align: right;
    background: #fff;
    font-size: 0.875rem;
}

.input-cell:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.totals-row th {
    background: var(--primary-subtle);
    font-size: 0.875rem;
    font-weight: 700;
    border-top: 2px solid var(--border);
}

/* ── Buttons ───────────────────────────────────────────── */

.form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform 0.1s;
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(13, 148, 136, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    background: var(--border-subtle);
    border-color: #cbd5e1;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--border-subtle);
    color: var(--text-secondary);
}

.btn-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn.disabled,
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Alerts ────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ── Settings & misc ───────────────────────────────────── */

.settings-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1.25rem;
}

.card-note {
    color: var(--muted);
    margin-top: -0.25rem;
    font-size: 0.875rem;
}

.field-grid {
    display: grid;
    gap: 1rem;
}

.formula-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    line-height: 1.7;
    font-size: 0.875rem;
}

/* ── Auth ──────────────────────────────────────────────── */

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    position: relative;
}

.auth-bg {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(13, 148, 136, 0.12), transparent 50%),
        radial-gradient(ellipse 60% 50% at 90% 80%, rgba(245, 158, 11, 0.08), transparent 50%),
        var(--bg);
    z-index: -1;
}

.auth-wrap {
    width: min(420px, 100%);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.auth-brand h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.auth-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.auth-form {
    display: grid;
    gap: 1rem;
    margin-top: 1.25rem;
}

/* ── Year management ───────────────────────────────────── */

.year-list {
    display: grid;
    gap: 0.5rem;
}

.year-list-item {
    display: grid;
    gap: 0.1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    background: var(--surface);
}

.year-list-item:hover {
    border-color: rgba(13, 148, 136, 0.35);
    background: var(--primary-subtle);
    box-shadow: var(--shadow-xs);
}

.year-list-item.active {
    border-color: var(--primary);
    background: var(--primary-subtle);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.year-list-item span {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .calc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .header-bar {
        flex-wrap: wrap;
        padding: 0.65rem 1rem;
        gap: 0.65rem;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .header-user-meta {
        display: none;
    }

    .top-nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-left: 0;
        padding: 0.75rem 0 0.25rem;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        overflow-x: visible;
    }

    .top-nav.is-open {
        display: flex;
    }

    .top-nav-pill {
        width: 100%;
    }

    .top-nav-group-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0.1rem;
        padding: 0.35rem;
    }

    .top-nav-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
    }

    .top-nav-admin {
        padding-top: 0;
        border-top: none;
    }

    .top-nav-link {
        padding: 0.7rem 0.75rem;
    }

    .header-context {
        padding: 0.65rem 1rem 0.75rem;
    }

    .header-context-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
    }

    .context-group:last-child {
        margin-left: 0;
    }

    .context-group-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .context-control {
        width: 100%;
        justify-content: space-between;
    }

    .context-control select {
        flex: 1;
        max-width: none;
    }

    .header-create-btn span {
        display: none;
    }

    .page-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
        padding: 0.75rem 1rem;
    }

    .page-content {
        padding: 1rem;
    }
}

@media (max-width: 1100px) {
    .report-charts {
        grid-template-columns: 1fr;
    }

    .report-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .dashboard-hero,
    .page-head,
    .report-hero {
        flex-direction: column;
        align-items: stretch;
    }

    .kpi-grid,
    .report-kpi-grid {
        grid-template-columns: 1fr;
    }

    .field-row,
    .calc-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .month-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .hero-actions {
        width: 100%;
    }

    .hero-actions .btn {
        flex: 1;
        min-width: 0;
    }
}

/* ── Admin tables & forms ───────────────────────────────── */

.data-table-wrap {
    overflow-x: auto;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}

.status-pill {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pill.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-pill.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.field-full {
    grid-column: 1 / -1;
}

.form-section-title {
    margin: 1.25rem 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 600;
}
