:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e3e8ef;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff4ff;
    --danger: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --sidebar: #111827;
    --sidebar-text: #cbd5e1;
    --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 18px; color: #fff; padding: 0 10px; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #60a5fa; display: inline-block; }
.workspace-name { font-size: 12px; color: #94a3b8; padding: 2px 10px 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
    color: var(--sidebar-text); font-weight: 500;
}
.nav a:hover { background: #1f2937; text-decoration: none; color: #fff; }
.nav a.active { background: #1e3a8a; color: #fff; }
.nav .section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 16px 10px 6px; }
.sidebar-footer { margin-top: auto; padding: 10px; font-size: 13px; border-top: 1px solid #1f2937; }
.sidebar-footer a { color: var(--sidebar-text); }
.sidebar-footer button { background: none; border: 0; color: #94a3b8; padding: 0; cursor: pointer; font: inherit; }
.running-pill { display: block; margin: 0 0 12px; padding: 8px 10px; border-radius: 6px; background: #064e3b; color: #a7f3d0; font-size: 12px; }
.main { flex: 1; min-width: 0; padding: 24px 32px 48px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; padding: 12px; }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; }
    .nav .section { display: none; }
    .workspace-name { padding-bottom: 8px; }
    .sidebar-footer { margin-top: 8px; }
    .main { padding: 16px; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-stop { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-stop:hover { background: #b91c1c; }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-icon { padding: 4px 8px; border: 0; background: transparent; color: var(--muted); }
.btn-icon:hover { background: #f3f4f6; color: var(--text); }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: #374151; }
.field { margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
    font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; cursor: pointer; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-error ul { margin: 0; padding-left: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f3f4f6; color: #374151; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: #ecfdf5; color: var(--success); }
.badge-amber { background: #fffbeb; color: var(--warning); }
.badge-red { background: #fef2f2; color: var(--danger); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.project-tag { display: inline-flex; align-items: center; font-weight: 500; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

/* ---------- tracker ---------- */
.timer-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.timer-bar .desc { flex: 3; min-width: 200px; }
.timer-bar .proj { flex: 2; min-width: 160px; }
.timer-bar .task { flex: 2; min-width: 140px; }
.timer-bar .clock { font-size: 22px; font-weight: 600; min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.billable-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; font-weight: 700; color: #9ca3af; user-select: none; }
.billable-toggle input { display: none; }
.billable-toggle:has(input:checked) { color: var(--success); border-color: #6ee7b7; background: #ecfdf5; }

.day-head { display: flex; justify-content: space-between; padding: 10px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); font-weight: 600; }
.entry { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.entry:last-child { border-bottom: 0; }
.entry .what { flex: 1; min-width: 200px; }
.entry .what .d { font-weight: 500; }
.entry .when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.entry .dur { font-weight: 600; min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.entry-edit { padding: 12px 16px; background: #fafbfc; border-bottom: 1px solid var(--border); }

/* ---------- kanban / tasks ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: #eef1f5; border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kanban-col h3 { display: flex; justify-content: space-between; font-size: 13px; color: #374151; }
.task-card { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.task-card .t { font-weight: 500; margin-bottom: 6px; }
.task-card .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.task-card form { display: inline; }

.progress { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.over > span { background: var(--danger); }

/* ---------- reports ---------- */
.stat { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars .bar { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; position: relative; }
.bars .bar:hover { background: var(--primary-hover); }
.bars-labels { display: flex; gap: 3px; font-size: 10px; color: var(--muted); margin-top: 4px; }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; }
.auth-card.wide { max-width: 520px; }
.auth-card .brand { color: var(--text); padding: 0; margin-bottom: 18px; }
.auth-card .btn-primary { width: 100%; padding: 10px; margin-top: 6px; }
.auth-foot { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

.btn-google { width: 100%; padding: 10px; background: #fff; border-color: #dadce0; color: #3c4043; margin-bottom: 4px; }
.btn-google:hover { background: #f8f9fa; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
