:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-subtle: #f9fafb;
    --surface-muted: #f3f5f7;
    --text: #111827;
    --muted: #6b7280;
    --muted-strong: #4b5563;
    --border: #dfe3e8;
    --border-soft: #edf0f3;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --primary-soft: #e7f4f2;
    --blue: #2563eb;
    --blue-soft: #eaf1ff;
    --amber: #b7791f;
    --amber-soft: #fff4df;
    --red: #dc2626;
    --red-soft: #feecec;
    --green: #15803d;
    --green-soft: #eaf7ef;
    --radius: 8px;
    --sidebar-width: 260px;
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

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

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(180deg, #f3f5f8 0%, #f8fafb 44%, var(--bg) 100%);
    color: var(--text);
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: inherit;
}

.app-layout {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    border-right: 1px solid var(--border);
    background: var(--surface);
}

.app-main {
    min-width: 0;
    flex: 1;
}

.content-shell {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    /* Extra top padding reserves a band for the fixed language/theme controls
       so they don't overlap the page header action buttons. */
    padding: 64px 32px 48px;
}

.brand {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    color: var(--text);
    text-decoration: none;
}

.brand-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 18px;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    font-weight: 700;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-nav a {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--muted-strong);
    font-weight: 600;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.sidebar-nav i {
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    display: grid;
    gap: 8px;
    margin-top: auto;
}

.mobile-topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.mobile-topbar .brand {
    margin: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.page-description {
    max-width: 720px;
    margin: 6px 0 0;
    color: var(--muted);
}

.page-actions,
.inline-actions,
.button-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.section-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.panel,
.panel-card,
.metric-card,
.mini-metric,
.category-card,
.transaction-card,
.auth-panel,
.form-panel,
.side-panel,
.danger-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel,
.panel-card,
.auth-panel,
.form-panel,
.side-panel,
.danger-panel {
    padding: 16px;
}

.panel-header,
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.panel-subtitle {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.kpi-grid,
.stats-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.mini-metric {
    min-height: 118px;
    padding: 14px;
}

.metric-card span,
.mini-metric span,
.metric-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.metric-card strong,
.mini-metric strong,
.metric-value {
    display: block;
    margin-top: 6px;
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
}

.metric-card small,
.mini-metric small {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
}

.metric-change {
    display: inline-flex;
    align-items: center;
    margin-top: 10px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.metric-change.positive {
    background: var(--green-soft);
    color: var(--green);
}

.metric-change.negative {
    background: var(--amber-soft);
    color: var(--amber);
}

.metric-change.neutral {
    background: var(--surface-muted);
    color: var(--muted-strong);
}

.dashboard-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 20px;
}

.toolbar-controls {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 10px;
}

.segmented-control,
.filter-chip-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.segmented-control a,
.filter-chip {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 0;
    border-radius: 6px;
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.segmented-control a:hover,
.filter-chip:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.segmented-control a.active,
.filter-chip.active {
    background: var(--primary);
    color: #fff;
}

.date-control {
    display: flex;
    align-items: end;
    gap: 8px;
}

.period-nav,
.filter-form-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
    gap: 14px;
}

.dashboard-column {
    display: grid;
    gap: 14px;
}

.dashboard-grid .panel {
    padding: 14px;
}

.dashboard-grid .panel-header {
    margin-bottom: 12px;
}

.chart-wrap {
    position: relative;
    width: 100%;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-wrap-lg {
    min-height: 260px;
}

.chart-wrap-md {
    min-height: 215px;
}

.chart-wrap-sm {
    min-height: 200px;
}

.summary-list,
.transaction-feed,
.category-list-compact {
    display: grid;
    gap: 8px;
}

.summary-row,
.share-row,
.transaction-card {
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.summary-row {
    display: grid;
    gap: 6px;
}

.summary-row-head,
.share-row-head,
.transaction-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.share-bar {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e5e7eb;
}

.share-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
}

.insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.insight-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}

.insight-item:nth-last-child(-n + 2) {
    border-bottom: 0;
}

.insight-item span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.insight-item strong {
    display: block;
    margin-top: 3px;
    font-size: 18px;
}

.data-toolbar,
.filter-surface {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.data-toolbar > *,
.filter-surface > * {
    min-width: 0;
}

.toolbar-col-2 {
    grid-column: span 2;
}

.toolbar-col-3 {
    grid-column: span 3;
}

.toolbar-col-4 {
    grid-column: span 4;
}

.table-shell {
    overflow: hidden;
}

.finance-table {
    --bs-table-bg: transparent;
    margin: 0;
}

.finance-table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

.finance-table td {
    padding: 12px;
    border-color: var(--border-soft);
    vertical-align: middle;
}

.finance-table tbody tr:hover {
    background: var(--surface-subtle);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.category-grid .empty-state {
    grid-column: 1 / -1;
}

.category-card {
    min-height: 168px;
    display: flex;
    flex-direction: column;
    padding: 14px;
}

.category-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.category-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
}

.category-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.status-pill,
.category-group-pill,
.badge-soft {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
}

.dot,
.swatch {
    display: inline-block;
    flex-shrink: 0;
    border-radius: 999px;
}

.dot {
    width: 10px;
    height: 10px;
}

.swatch {
    width: 14px;
    height: 14px;
}

.amount {
    white-space: nowrap;
    font-weight: 700;
}

.member-list {
    display: grid;
    gap: 8px;
}

.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.member-identity,
.member-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.member-identity small,
.member-identity strong {
    display: block;
}

.member-identity small {
    color: var(--muted);
}

.avatar-badge {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 700;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
}

.role-pill-owner {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 16px;
}

.form-panel {
    padding: 18px;
}

.side-panel {
    align-self: start;
}

.form-control,
.form-select {
    min-height: 38px;
    border-color: var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

textarea.form-control {
    min-height: 110px;
}

.form-control-color {
    min-height: 38px;
    padding: 4px;
}

.form-label {
    margin-bottom: 6px;
    color: var(--muted-strong);
    font-size: 13px;
    font-weight: 700;
}

.form-check {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-subtle);
}

.form-check .form-check-input {
    margin: 0;
    float: none;
}

.help-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.help-list li {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.help-list li:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.help-list strong {
    display: block;
    margin-bottom: 3px;
}

.public-shell {
    min-height: 100vh;
    display: grid;
    align-items: center;
    padding: 24px;
}

.auth-shell {
    width: min(100%, 1040px);
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.8fr);
    gap: 24px;
    align-items: stretch;
    margin: 0 auto;
}

.auth-copy {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 28px 0;
}

.auth-copy p {
    max-width: 620px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 16px;
}

.auth-proof-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.auth-proof-grid article {
    min-height: 130px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.7);
}

.auth-proof-grid strong,
.auth-proof-grid span {
    display: block;
}

.auth-proof-grid strong {
    margin-bottom: 8px;
}

.auth-proof-grid span {
    color: var(--muted);
    font-size: 13px;
}

.auth-panel {
    padding: 24px;
}

.auth-panel-header {
    margin-bottom: 20px;
}

.auth-panel-header h2 {
    margin: 4px 0 6px;
    font-size: 20px;
    font-weight: 700;
}

.auth-panel-header p {
    margin: 0;
    color: var(--muted);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.danger-panel {
    width: min(100%, 560px);
    margin: 0 auto;
}

.danger-panel p {
    margin: 10px 0 18px;
    color: var(--muted);
}

.delete-summary {
    display: grid;
    gap: 0;
    margin: 0 0 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.delete-summary div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-subtle);
}

.delete-summary div:last-child {
    border-bottom: 0;
}

.delete-summary dt,
.delete-summary dd {
    margin: 0;
}

.delete-summary dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.delete-summary dd {
    font-weight: 700;
    text-align: right;
}

.stacked-form {
    display: grid;
    gap: 14px;
}

.empty-state {
    padding: 32px 16px;
    text-align: center;
}

.empty-state h3 {
    margin-bottom: 6px;
}

.message-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.public-messages {
    position: fixed;
    top: 16px;
    left: 50%;
    width: min(420px, calc(100% - 32px));
    transform: translateX(-50%);
}

.app-alert {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--muted-strong);
}

.app-alert-success {
    border-color: #b7e0c3;
    background: var(--green-soft);
    color: var(--green);
}

.app-alert-danger,
.app-alert-error {
    border-color: #f7b4b4;
    background: var(--red-soft);
    color: var(--red);
}

.btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
}

.btn-sm {
    min-height: 32px;
    font-size: 13px;
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
}

.btn-accent {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-dark);
    --bs-btn-hover-border-color: var(--primary-dark);
    color: #fff;
}

.btn-accent:hover {
    color: #fff;
}

.icon-btn {
    width: 38px;
    padding: 0;
}

.mobile-nav {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.12);
}

.mobile-nav a {
    min-height: 48px;
    display: grid;
    place-items: center;
    gap: 2px;
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.mobile-nav a.active {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

@media (max-width: 1199.98px) {
    .dashboard-grid,
    .form-layout {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 991.98px) {
    .app-layout {
        display: block;
    }

    .app-sidebar {
        display: none;
    }

    .content-shell {
        padding: 20px 16px 88px;
    }

    .dashboard-toolbar {
        grid-template-columns: 1fr;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-copy {
        padding: 0;
    }

    .auth-proof-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid,
    .stats-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    body {
        font-size: 14px;
    }

    .page-header,
    .panel-header,
    .panel-head,
    .summary-row-head,
    .share-row-head,
    .transaction-card,
    .member-row,
    .member-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-actions,
    .inline-actions,
    .button-row,
    .toolbar-controls,
    .date-control,
    .period-nav,
    .filter-form-row {
        width: 100%;
    }

    .page-actions .btn,
    .inline-actions .btn,
    .button-row .btn,
    .toolbar-controls .btn,
    .date-control .btn,
    .period-nav .btn,
    .filter-form-row .btn {
        flex: 1 1 auto;
    }

    .kpi-grid,
    .stats-strip,
    .category-grid,
    .insight-grid {
        grid-template-columns: 1fr;
    }

    .data-toolbar,
    .filter-surface {
        grid-template-columns: 1fr;
    }

    .toolbar-col-2,
    .toolbar-col-3,
    .toolbar-col-4 {
        grid-column: auto;
    }

    .finance-table thead {
        display: none;
    }

    .finance-table,
    .finance-table tbody,
    .finance-table tr,
    .finance-table td {
        display: block;
        width: 100%;
    }

    .finance-table tr {
        padding: 12px;
        border-bottom: 1px solid var(--border-soft);
    }

    .finance-table td {
        padding: 4px 0;
        border: 0;
    }

    .finance-table td.text-end {
        text-align: left !important;
    }
}

/* ===== Floating controls (language + theme) ===== */
.app-controls {
    /* Absolute (not fixed) so the controls sit in the reserved top band and
       scroll away with the page instead of covering header buttons. */
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 40px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.lang-option {
    min-width: 34px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted-strong);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.lang-option:hover {
    color: var(--text);
}

.lang-option.active {
    background: var(--primary);
    color: #fff;
}

.theme-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted-strong);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.theme-toggle .bi {
    font-size: 17px;
    line-height: 1;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: inline-flex;
}

/* On mobile the top bar shows a "+" action in the corner — sit beside it. */
@media (max-width: 991.98px) {
    .app-controls {
        top: 13px;
        right: 66px;
    }
}

/* ===== Dark mode ===== */
[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0e1117;
    --surface: #161a21;
    --surface-subtle: #1b2027;
    --surface-muted: #222832;
    --text: #e6e8ec;
    --muted: #8b94a3;
    --muted-strong: #b6bdc8;
    --border: #2a313c;
    --border-soft: #222831;
    --primary: #14b8a6;
    --primary-dark: #0f9d8f;
    --primary-soft: rgba(20, 184, 166, 0.16);
    --blue: #60a5fa;
    --blue-soft: rgba(96, 165, 250, 0.14);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.14);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.14);
    --green: #4ade80;
    --green-soft: rgba(74, 222, 128, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] body {
    background: linear-gradient(180deg, #0b0e13 0%, #0d1015 44%, var(--bg) 100%);
}

[data-theme="dark"] .share-bar {
    background: #2a313c;
}

[data-theme="dark"] .table {
    --bs-table-color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border-soft);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea.form-control {
    background-color: var(--surface-subtle);
    color: var(--text);
    border-color: var(--border);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--muted);
}

[data-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--muted-strong);
    --bs-btn-border-color: var(--border);
    --bs-btn-bg: transparent;
    --bs-btn-hover-bg: var(--surface-muted);
    --bs-btn-hover-border-color: var(--border);
    --bs-btn-hover-color: var(--text);
    --bs-btn-active-bg: var(--surface-muted);
    --bs-btn-active-border-color: var(--border);
    --bs-btn-active-color: var(--text);
}

[data-theme="dark"] .app-alert-success {
    border-color: rgba(74, 222, 128, 0.35);
}

[data-theme="dark"] .app-alert-danger,
[data-theme="dark"] .app-alert-error {
    border-color: rgba(248, 113, 113, 0.35);
}

[data-theme="dark"] .auth-proof-grid article {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .modal-content {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border);
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Bootstrap's .text-muted derives from the light body color and becomes nearly
   invisible on dark surfaces — use our readable muted token instead. */
[data-theme="dark"] .text-muted {
    color: var(--muted) !important;
}

[data-theme="dark"] .form-text {
    color: var(--muted);
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled {
    background-color: var(--surface-muted);
    color: var(--muted);
}
