/* ===========================================================================
   Personal Project Dashboard — design system + components
   Inter font, green accent, light/dark themes, mobile-first responsive.
   =========================================================================== */

/* --- Inter (self-hosted via system stack fallback; webfont optional) ------- */
:root {
    /* Brand */
    --green: #16A34A;
    --green-600: #15803D;
    --green-100: #DCFCE7;

    /* Light theme tokens (default) */
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --surface-2: #F1F5F9;
    --text: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --primary: #16A34A;
    --primary-contrast: #FFFFFF;

    /* Semantic */
    --blue: #3B82F6;
    --amber: #F59E0B;
    --red: #EF4444;
    --red-600: #DC2626;

    /* Effects */
    --radius: 12px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .10);
    --ring: 0 0 0 3px rgba(22, 163, 74, .25);

    --font: 'Inter', 'Segoe UI', Roboto, Arial, system-ui, sans-serif;
    --sidebar-w: 248px;
    --topbar-h: 60px;
}

[data-theme="dark"] {
    --green: #22C55E;
    --green-600: #16A34A;
    --green-100: #14532D;
    --bg: #0F172A;
    --surface: #1E293B;
    --surface-2: #334155;
    --text: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --primary: #22C55E;
    --primary-contrast: #052e16;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
    --ring: 0 0 0 3px rgba(34, 197, 94, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: no-preference) {
    * { transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .25rem; line-height: 1.25; }
h3 { font-size: 1rem; }
.muted { color: var(--text-muted); }
.muted.sm, .sm { font-size: .85rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-right { text-align: right; }
.mt { margin-top: 1rem; }

.skip-link {
    position: absolute; left: -999px; top: 0; z-index: 100;
    background: var(--green); color: #fff; padding: .5rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* --- Layout ---------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }
.layout-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.5rem; max-width: 1300px; width: 100%; margin: 0 auto; }

/* --- Sidebar --------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.brand-mark {
    background: var(--green); color: #fff; font-weight: 800; font-size: .8rem; letter-spacing: .5px;
    padding: .4rem .5rem; border-radius: 8px;
}
.brand-mark-lg { font-size: 1.1rem; padding: .6rem .8rem; }
.brand-name { font-weight: 700; font-size: .95rem; }
.sidebar-nav { padding: .75rem; display: flex; flex-direction: column; gap: .15rem; overflow-y: auto; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border-radius: var(--radius-sm);
    color: var(--text); font-weight: 500; text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.is-active { background: var(--green-100); color: var(--green-600); font-weight: 600; }
[data-theme="dark"] .nav-item.is-active { color: var(--green); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); }

/* --- Topbar ---------------------------------------------------------------- */
.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.menu-toggle { display: none; }

.icon-btn {
    background: none; border: none; color: var(--text); cursor: pointer; padding: .5rem;
    border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; position: relative;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.badge-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

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

.user-btn { display: flex; align-items: center; gap: .5rem; background: none; border: none; cursor: pointer; color: var(--text); padding: .3rem .5rem; border-radius: 8px; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.user-name { font-weight: 600; font-size: .9rem; }

/* --- Dropdown -------------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md);
    padding: .35rem; z-index: 50; display: none;
}
.dropdown.is-open .dropdown-menu { display: block; }
.dropdown-menu-wide { min-width: 320px; }
.dropdown-menu-right { right: 0; }
.dropdown-item { display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer; padding: .55rem .7rem; border-radius: 8px; color: var(--text); font: inherit; }
.dropdown-item:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-item-danger { color: var(--red); }
.dropdown-head { padding: .5rem .7rem; display: flex; justify-content: space-between; align-items: center; }
.dropdown-sep { height: 1px; background: var(--border); margin: .35rem 0; }

.notif-list { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.notif-list li { padding: .6rem .7rem; border-radius: 8px; }
.notif-list li.unread { background: var(--green-100); }
[data-theme="dark"] .notif-list li.unread { background: rgba(34,197,94,.12); }
.notif-list .notif-title { font-weight: 600; font-size: .9rem; }
.notif-list .notif-body { font-size: .82rem; color: var(--text-muted); white-space: pre-line; }
.notif-empty { color: var(--text-muted); }

/* --- Cards ----------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; gap: .5rem; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .75rem; }

/* --- Buttons --------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    padding: .55rem .9rem; border-radius: var(--radius-sm); font: inherit; font-weight: 600; min-height: 40px;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); border-color: transparent; }
.btn-primary:hover { background: var(--green-600); }
.btn-danger { background: var(--red); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--red-600); }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .65rem; min-height: 32px; font-size: .85rem; }
.link-btn { background: none; border: none; color: var(--green); cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); }

/* --- Forms ----------------------------------------------------------------- */
.form .field { margin-bottom: .9rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
input, select, textarea {
    width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit; min-height: 40px;
}
textarea { min-height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }
.hint { color: var(--text-muted); font-size: .78rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.check input { width: auto; min-height: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .field { margin-bottom: .9rem; }
.form-grid .col-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; margin-top: .5rem; }
.form-actions .spacer { flex: 1; }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.form-inline input, .form-inline select { width: auto; flex: 1; min-width: 120px; }
.inline { display: inline; }

/* --- Page head ------------------------------------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head-actions { display: flex; gap: .5rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1.25rem; }
.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 140px; }

/* --- Stat grid (overview) -------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .25rem; }
.stat-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.stat-label { color: var(--text-muted); font-size: .82rem; font-weight: 500; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--text); }

/* Rich icon stat cards */
.stat-grid-rich { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat-card-rich { flex-direction: row; align-items: center; gap: .9rem; }
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.stat-card-rich .stat-value { font-size: 1.6rem; line-height: 1.1; }
.stat-sub { color: var(--text-muted); font-size: .72rem; font-weight: 500; }

/* Overdue alert banner */
.alert-overdue { display: flex; align-items: center; gap: .6rem; background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25); color: #ef4444; border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1.25rem; font-size: .9rem; }
.alert-overdue svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-overdue span { flex: 1; min-width: 0; color: var(--text); }
.alert-overdue strong { color: #ef4444; }
.alert-overdue a { margin-left: auto; font-weight: 600; color: #ef4444; white-space: nowrap; }

/* KPI strip */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.kpi-label { color: var(--text-muted); font-size: .8rem; font-weight: 500; }
.kpi-val { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.kpi-bar { height: 7px; background: var(--border); border-radius: 99px; overflow: hidden; }
.kpi-bar > div { height: 100%; border-radius: 99px; transition: width .4s ease; }

/* Activity feed */
.activity-list { list-style: none; display: flex; flex-direction: column; }
.activity-row { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.activity-row:last-child { border-bottom: none; }
.act-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.act-text { flex: 1; min-width: 0; }
.act-time { white-space: nowrap; font-size: .78rem; }

/* --- Tasks page ------------------------------------------------------------ */
.task-list { display: flex; flex-direction: column; gap: .5rem; }
.task-row { display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; }
.task-row.is-done { opacity: .6; }
.task-check-form { display: flex; }
.task-check { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--border); background: transparent; cursor: pointer; flex-shrink: 0; display: grid; place-items: center; padding: 0; }
.task-check.is-checked { background: var(--green); border-color: var(--green); }
.task-check svg { width: 12px; height: 12px; }
.task-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; color: var(--text); }
.task-row.is-done .task-title { text-decoration: line-through; }
.task-desc { font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-proj { font-size: .75rem; color: var(--text-muted); background: var(--surface-2); padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.task-proj:hover { text-decoration: none; color: var(--text); }
.task-status { font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; }
.task-due { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.task-due svg { width: 13px; height: 13px; }
.task-due.is-overdue { color: var(--red); }
.task-actions { display: flex; gap: .1rem; }
.task-actions .icon-btn svg { width: 16px; height: 16px; }

/* Dashboard task board */
.task-board { margin-bottom: 1.25rem; }
.task-board-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.task-board-col { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1rem; border: 1px solid var(--border); border-left: 3px solid var(--tbc); border-radius: var(--radius-sm); background: var(--surface-2); }
.task-board-col:hover { text-decoration: none; box-shadow: var(--shadow); }
.tb-count { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.tb-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; }
.tb-due-head { font-size: .82rem; font-weight: 600; color: var(--text-muted); margin-bottom: .35rem; }
@media (max-width: 600px) { .task-board-cols { grid-template-columns: repeat(2, 1fr); } }

/* --- Sidebar collapse ------------------------------------------------------ */
.sidebar-collapse { margin-left: auto; }
.layout.is-collapsed .sidebar { width: 64px; }
.layout.is-collapsed .brand-name,
.layout.is-collapsed .nav-item span,
.layout.is-collapsed .sidebar-footer { display: none; }
.layout.is-collapsed .sidebar-brand { justify-content: center; padding: 1rem .5rem; }
.layout.is-collapsed .sidebar-collapse { margin-left: 0; }
.layout.is-collapsed .nav-item { justify-content: center; padding: .65rem; }
.layout.is-collapsed .sidebar-nav { padding: .75rem .4rem; }
.layout.is-collapsed .sidebar-collapse svg { transform: rotate(180deg); }
.sidebar-collapse svg { width: 16px; height: 16px; }
@media (max-width: 767px) { .sidebar-collapse { display: none; } }

.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.money-card h3 { margin-bottom: .75rem; }
.money-row { display: flex; justify-content: space-between; padding: .35rem 0; font-size: .95rem; }
.money-total { border-top: 1px solid var(--border); margin-top: .25rem; padding-top: .6rem; font-size: 1.05rem; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.chart-grid canvas { width: 100% !important; }

.recent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

/* --- Lists ----------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.empty-inline { padding: 1rem 0; }

/* --- Tables ---------------------------------------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; color: var(--text); }
.row-actions { display: flex; gap: .6rem; align-items: center; }

/* --- Badges ---------------------------------------------------------------- */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-100); color: var(--green-600); }
[data-theme="dark"] .badge-green { color: #bbf7d0; }
.badge-blue { background: rgba(59,130,246,.15); color: #2563eb; }
[data-theme="dark"] .badge-blue { color: #93c5fd; }
.badge-amber { background: rgba(245,158,11,.18); color: #b45309; }
[data-theme="dark"] .badge-amber { color: #fcd34d; }
.badge-red { background: rgba(239,68,68,.15); color: #dc2626; }
[data-theme="dark"] .badge-red { color: #fca5a5; }
.badge-gray { background: var(--surface-2); color: var(--text-muted); }

.tag-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag { background: var(--surface-2); color: var(--text-muted); padding: .15rem .5rem; border-radius: 6px; font-size: .75rem; }

/* --- Progress -------------------------------------------------------------- */
.progress { background: var(--surface-2); border-radius: 999px; height: 8px; width: 90px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.progress-lg { width: 100%; height: 10px; margin-top: .35rem; }

/* --- Cards grid (ideas/notes) ---------------------------------------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.idea-card-head { display: flex; gap: .4rem; margin-bottom: .5rem; }
.idea-desc, .note-preview { color: var(--text-muted); font-size: .9rem; margin: .4rem 0 0; }
.note-card { display: block; color: var(--text); }
.note-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }

/* --- Project detail -------------------------------------------------------- */
.project-header { margin-bottom: 1.25rem; }
.project-title-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .25rem; }
.project-desc { margin: .5rem 0; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin: 1rem 0; }
.meta-grid > div { display: flex; flex-direction: column; gap: .15rem; }
.meta-grid span.muted { font-size: .78rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.inline-form-wrap summary { cursor: pointer; display: inline-block; }
.inline-form-wrap[open] summary { margin-bottom: .5rem; }
.task-edit { background: var(--surface-2); padding: .8rem; border-radius: var(--radius-sm); margin-top: .5rem; }

/* --- Alerts ---------------------------------------------------------------- */
.alert { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--green-100); color: var(--green-600); border-color: rgba(22,163,74,.3); }
.alert-error { background: rgba(239,68,68,.12); color: var(--red-600); border-color: rgba(239,68,68,.3); }
.alert-info { background: rgba(59,130,246,.12); color: #2563eb; border-color: rgba(59,130,246,.3); }
[data-theme="dark"] .alert-success { color: #bbf7d0; }
.alert-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: inherit; line-height: 1; }

/* --- Empty state ----------------------------------------------------------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-illustration { font-size: 3rem; font-weight: 800; color: var(--text-muted); margin-bottom: .5rem; }

.danger-zone { margin-top: 1.25rem; display: flex; gap: .6rem; align-items: center; }

/* --- Auth ------------------------------------------------------------------ */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { font-size: 1.4rem; margin-top: .75rem; }
.auth-brand .brand-mark { display: inline-block; }
.auth-card { padding: 1.5rem; }
.auth-title { margin-bottom: 1rem; }
.auth-links { text-align: center; margin-top: 1rem; }

/* --- Offline banner -------------------------------------------------------- */
.offline-banner { background: var(--amber); color: #1f2937; padding: .6rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 600; }

/* --- Calendar -------------------------------------------------------------- */
.cal-controls { display: flex; align-items: center; gap: .5rem; }
.cal-title { font-size: 1.1rem; margin: 0 0 0 .5rem; }
.cal-views { display: flex; align-items: center; gap: .75rem; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { background: var(--surface); border: none; padding: .45rem .8rem; cursor: pointer; color: var(--text); font: inherit; font-weight: 600; }
.seg-btn.is-active { background: var(--green); color: #fff; }
.view-toggle .seg-btn { display: inline-flex; align-items: center; justify-content: center; padding: .4rem .6rem; }
.view-toggle .seg-btn svg { width: 16px; height: 16px; }

/* --- Card / Row view ------------------------------------------------------- */
/* Tasks: card layout reflows the same row markup */
.view-scope.is-card .task-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.view-scope.is-card .task-row { flex-wrap: wrap; align-items: center; padding: 1rem; }
.view-scope.is-card .task-main { order: 2; flex-basis: 100%; }
.view-scope.is-card .task-check-form,
.view-scope.is-card .task-dot { order: 1; }
.view-scope.is-card .task-actions { order: 1; margin-left: auto; }
.view-scope.is-card .task-proj,
.view-scope.is-card .task-status { order: 3; }
.view-scope.is-card .task-due { order: 3; margin-left: auto; }

/* Table sections (Cost, Projects): cards by default, table in row view */
.toolbar-row { display: flex; gap: .6rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-row .filter-bar { margin-bottom: 0; }
.entry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.entry-card { padding: 1rem; display: flex; flex-direction: column; gap: .4rem; }
.ec-top { display: flex; justify-content: space-between; align-items: center; }
.ec-title { font-weight: 600; color: var(--text); }
.ec-meta { font-size: .8rem; }
.ec-actions { display: flex; gap: .8rem; margin-top: .25rem; }
.view-scope .view-table { display: none; }
.view-scope.is-row .view-table { display: block; }
.view-scope.is-row .view-cards { display: none; }
.cal-card { padding: .5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.cal-dow { background: var(--surface-2); text-align: center; padding: .5rem; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.cal-cell { background: var(--surface); min-height: 92px; padding: .35rem; display: flex; flex-direction: column; gap: .2rem; }
.cal-cell.is-other { opacity: .4; }
.cal-cell.is-today .cal-daynum { background: var(--green); color: #fff; border-radius: 50%; }
.cal-daynum { font-size: .8rem; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; align-self: flex-end; }
.cal-event { font-size: .72rem; padding: .12rem .35rem; border-radius: 5px; color: #fff; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-list { list-style: none; margin: 0; padding: .5rem; }
.cal-list-item { display: flex; gap: .75rem; padding: .65rem .5rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.cal-list-time { font-weight: 700; color: var(--text-muted); min-width: 110px; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: .35rem; }

/* --- Modal ----------------------------------------------------------------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 80; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-card { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* --- Pagination ------------------------------------------------------------ */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.page-link { padding: .45rem .8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 600; }
.page-link.is-disabled { opacity: .4; pointer-events: none; }
.page-info { color: var(--text-muted); font-size: .9rem; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }

/* --- Scrim (mobile sidebar) ------------------------------------------------ */
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 35; }

/* --- Responsive ------------------------------------------------------------ */
@media (max-width: 980px) {
    .form-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }
    .sidebar.is-open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .content { padding: 1rem; }
    .user-name { display: none; }
    .topbar-title { font-size: 1rem; }
    .stat-value { font-size: 1.5rem; }
}
@media (min-width: 769px) {
    .scrim { display: none !important; }
}
