:root {
    /* ---- Light theme (default) -- values pulled directly from the
       Tasko template's extracted CSS variables ---- */
    --bg: #f8f9f5;
    --bg-sidebar: #ffffff;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f1f3eb;
    --border: #e3e6de;
    --text: #202318;
    --muted: #707367;
    --accent: #008b46;
    --accent2: #005e30;
    --accent-soft: rgba(0, 139, 70, 0.12);
    --accent-contrast: #f3fbf5;
    --ring: rgba(0, 94, 48, 0.18);
    --pos: #008b46;
    --pos-soft: rgba(0, 139, 70, 0.12);
    --neg: #e40014;
    --neg-soft: rgba(228, 0, 20, 0.10);
    --warn: #b75000;
    --warn-soft: rgba(249, 156, 0, 0.14);
    --chart-1: #005e30;
    --chart-2: #008b46;
    --chart-3: #49a46e;
    --chart-4: #85bd98;
    --chart-5: #bad6c3;
    --shadow-sm: 0 1px 2px rgba(32, 35, 24, 0.04), 0 1px 1px rgba(32,35,24,0.03);
    --shadow-md: 0 10px 30px rgba(32, 35, 24, 0.07);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

html[data-theme="dark"] {
    --bg: #040705;
    --bg-sidebar: #080c09;
    --bg-panel: #080c09;
    --bg-card: #080c09;
    --bg-input: #0f1912;
    --bg-hover: #0f1912;
    --border: #1a251d;
    --text: #f6f9f7;
    --muted: #86938a;
    --accent: #008b46;
    --accent2: #008b46;
    --accent-soft: rgba(0, 139, 70, 0.18);
    --accent-contrast: #f3fbf5;
    --ring: rgba(0, 139, 70, 0.22);
    --pos: #49a46e;
    --pos-soft: rgba(73, 164, 110, 0.16);
    --neg: #bb061e;
    --neg-soft: rgba(187, 6, 30, 0.16);
    --warn: #f99c00;
    --warn-soft: rgba(249, 156, 0, 0.16);
    --chart-1: #005e30;
    --chart-2: #008b46;
    --chart-3: #49a46e;
    --chart-4: #85bd98;
    --chart-5: #bad6c3;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.2s ease, color 0.2s ease;
}

a { color: var(--accent2); text-decoration: none; }

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

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

.brand { font-size: 21px; font-weight: 800; margin-bottom: 28px; letter-spacing: -0.3px; display: flex; align-items: center; gap: 9px; }
.brand span { color: var(--accent2); }
.brand-dot { width: 11px; height: 11px; border-radius: 4px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: inline-block; flex-shrink: 0; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    color: var(--muted);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 13.5px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 11px;
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar nav a.active { background: var(--accent2); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }

.nav-group {
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--muted);
    margin: 16px 14px 4px;
    opacity: 0.7;
}

/* ---------- theme toggle ---------- */
.sidebar-footer { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.theme-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent2); }
.theme-toggle .nav-icon { width: 16px; height: 16px; }
html:not([data-theme="dark"]) .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html:not([data-theme="dark"]) .label-light { display: none; }
html[data-theme="dark"] .label-dark { display: none; }

.logout button {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.logout button:hover { color: var(--text); border-color: var(--accent2); }

.content { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1320px; }

h1 { font-size: 26px; margin-bottom: 24px; font-weight: 700; letter-spacing: -0.3px; }
h2 { font-size: 15px; margin-bottom: 16px; font-weight: 600; }

/* ---------- cards ---------- */
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
}
.card-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.card-value { font-size: 27px; font-weight: 700; margin: 10px 0 4px; letter-spacing: -0.4px; }
.card-sub { color: var(--muted); font-size: 12px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- panels ---------- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
table.data td { padding: 12px 10px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--bg-hover); }
table.data .r { text-align: right; }
table.data tfoot td { border-top: 2px solid var(--border); }
.row-review td { background: var(--warn-soft); }

.muted { color: var(--muted); font-size: 13px; }

/* ---------- chips / period bar ---------- */
.period-bar, .filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    background: var(--bg-card);
}
.chip.on { background: var(--accent2); color: #fff; border-color: var(--accent2); }

/* ---------- forms ---------- */
input, select, textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px var(--ring); }
.stack { display: flex; flex-direction: column; gap: 6px; max-width: 360px; }
.stack label { font-size: 12px; color: var(--muted); margin-top: 8px; }
.filter-bar input { min-width: 240px; }

.btn-primary {
    background: var(--accent2);
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    margin-top: 8px;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent); }

/* ---------- badges ---------- */
.badge { padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.b-ok { background: var(--pos-soft); color: var(--pos); }
.b-warn { background: var(--neg-soft); color: var(--neg); }

.btn-bare { background: none; border: none; padding: 0; margin: 0; font: inherit; cursor: pointer; display: inline; }
.inline-form { display: inline-block; }

/* ---------- inline categorize form (Transactions page) ---------- */
.btn-edit, .btn-cancel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}
.btn-edit:hover, .btn-cancel:hover { color: var(--text); border-color: var(--accent2); }
.edit-row td { background: var(--bg-hover); border-radius: var(--radius-md); padding: 18px; }
.cf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
.cf-grid label { font-size: 11px; color: var(--muted); display: block; margin-bottom: 4px; }
.cf-grid input, .cf-grid select { width: 100%; }
.cf-remember { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.checkbox-label input { width: auto; }
.rule-keyword { min-width: 220px; }
.categorize-form .btn-cancel { margin-left: 8px; }

/* ---------- calendar ---------- */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.cal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-panel { padding: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekday-row { color: var(--muted); font-size: 11px; text-transform: uppercase; text-align: center; margin-bottom: 6px; font-weight: 600; }
.cal-day {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-height: 90px;
    min-width: 0;
    overflow: hidden;
    padding: 6px;
    margin-bottom: 6px;
}
.cal-day-faded { opacity: 0.4; }
.cal-day-today { border: 1.5px solid var(--accent2); }
.cal-day-num { font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.cal-event {
    display: block;
    font-size: 11px;
    padding: 2px 5px;
    border-radius: 4px;
    margin-bottom: 3px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    background: var(--accent-soft);
}
.cal-event-time { color: var(--muted); margin-right: 4px; }

/* ---------- recipes ---------- */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.recipe-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    color: var(--text);
    display: block;
    box-shadow: var(--shadow-sm);
}
.recipe-card:hover { border-color: var(--accent2); }
.recipe-img { height: 120px; background-size: cover; background-position: center; background-color: var(--bg-panel); }
.recipe-img-placeholder { display: flex; align-items: center; justify-content: center; font-size: 36px; }
.recipe-card-body { padding: 12px 14px; }
.recipe-card-title { font-weight: 600; margin-bottom: 4px; }
.recipe-hero { width: 100%; max-height: 280px; object-fit: cover; border-radius: var(--radius-md); margin-bottom: 16px; }
.ingredient-list, .instruction-list { padding-left: 18px; }
.ingredient-list li, .instruction-list li { margin-bottom: 8px; font-size: 13px; }
.tag-row { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.ingredient-row { display: grid; grid-template-columns: 90px 90px 1fr 1fr 32px; gap: 8px; margin-bottom: 8px; }
.recipe-form textarea { background: var(--bg-input); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-sm); padding: 10px; }

/* ---------- meal plan ---------- */
.meal-plan-table th, .meal-plan-table td { text-align: center; }
.meal-cell { min-width: 110px; }
.meal-chip { display: inline-block; background: var(--accent-soft); color: var(--accent); padding: 4px 8px; border-radius: var(--radius-sm); font-size: 12px; }
.meal-remove { color: var(--neg); margin-left: 4px; font-size: 12px; }
.meal-select { width: 100%; font-size: 12px; }

/* ---------- shopping list ---------- */
.shopping-list { list-style: none; }
.shopping-list li { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.shopping-list input[type="checkbox"] { margin-right: 8px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 360px;
    box-shadow: var(--shadow-md);
}
.login-card .brand { text-align: center; justify-content: center; }
.login-sub { color: var(--muted); text-align: center; margin-bottom: 24px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 10px; }
.login-card .btn-primary { margin-top: 20px; }
.alert { background: var(--neg-soft); color: var(--neg); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }

/* ---------- dashboard layout ---------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.dash-main { display: flex; flex-direction: column; gap: 24px; }
.dash-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .dash-row2 { grid-template-columns: 1fr; } }

.dash-link-card { display: block; color: var(--text); }
.dash-link-card:hover { border-color: var(--accent2); }

/* ---------- expense tracker widget ---------- */
.exp-row { margin-bottom: 16px; }
.exp-row:last-child { margin-bottom: 0; }
.exp-row-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.exp-row-head .exp-name { font-weight: 600; }
.exp-bar-track { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.exp-bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.exp-bar-fill.over { background: var(--neg); }
.exp-row-foot { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ---------- agenda widget ---------- */
.dash-agenda { display: flex; flex-direction: column; }
.dash-agenda-list { overflow-y: auto; max-height: 640px; }
.agenda-day { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.agenda-day:last-child { border-bottom: none; }
.agenda-date { width: 44px; flex-shrink: 0; text-align: center; }
.agenda-date .dow { font-size: 10px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.agenda-date .num { font-size: 19px; font-weight: 700; line-height: 1.2; }
.agenda-date .mon { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.agenda-date.is-today .num { color: var(--accent2); }
.agenda-events { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.agenda-event { display: flex; align-items: baseline; gap: 7px; color: var(--text); }
.agenda-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.agenda-time { color: var(--muted); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.agenda-title { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- mobile ---------- */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
    .layout { flex-direction: column; }

    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: var(--bg-sidebar);
        border-bottom: 1px solid var(--border);
        padding: 14px 16px;
        position: sticky;
        top: 0;
        z-index: 60;
    }
    .mobile-topbar .brand { margin-bottom: 0; }
    .menu-btn {
        background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
        width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
        color: var(--text); cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        width: 260px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed; inset: 0;
        background: rgba(20, 24, 18, 0.4);
        z-index: 90;
    }

    .content { padding: 20px 16px; }
    h1 { font-size: 22px; }

    .card-row { grid-template-columns: 1fr 1fr; gap: 12px; }
    .grid-2, .dash-grid, .dash-row2 { grid-template-columns: 1fr; }
    .cf-grid { grid-template-columns: 1fr 1fr; }
    .ingredient-row { grid-template-columns: 1fr 1fr; }

    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table.data { min-width: 560px; }

    .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .meal-plan-table { min-width: 700px; }
}

@media (max-width: 480px) {
    .card-row, .cf-grid { grid-template-columns: 1fr; }
    .content { padding: 16px 12px; }
}