/* ─── Design tokens ──────────────────────────────────────────────────────
   static/js/theme.js always sets html[data-theme] to "light" or "dark"
   (resolving the "system" choice), before first paint. frappe-gantt reads the
   --g-* variables and also keys its own dark styles off html[data-theme]. */
:root {
    color-scheme: light;
    --bg: #f3f4f7;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef0f4;
    --hover: #f1f3f7;
    --border: #e3e6eb;
    --border-strong: #cfd4dc;
    --text: #1d2330;
    --text-2: #4a5263;
    --text-3: #7a8294;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;
    --accent-text: #ffffff;
    --selected: #e4e8ff;
    --danger: #dc2626;
    --danger-soft: #fdecec;
    --warning: #d97706;
    --warning-soft: #fff4e0;
    --success: #059669;
    --success-soft: #e6f6f0;
    --late: #dc2626;
    --critical: #e11d48;
    --summary: #3b4252;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, .10);
    --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18);
    --radius: 8px;
    --focus: 0 0 0 3px rgba(79, 70, 229, .25);

    --status-todo: #94a3b8;
    --status-in_progress: #3b82f6;
    --status-blocked: #f59e0b;
    --status-done: #10b981;
    --priority-low: #94a3b8;
    --priority-medium: #3b82f6;
    --priority-high: #f97316;
    --priority-urgent: #ef4444;

    --g-arrow-color: #8a93a6;
    --g-bar-color: #e4e7ee;
    --g-bar-border: transparent;
    --g-tick-color: #eceef2;
    --g-tick-color-thick: #dde0e6;
    --g-actions-background: #f3f4f7;
    --g-border-color: #e3e6eb;
    --g-text-muted: #7a8294;
    --g-text-light: #ffffff;
    --g-text-dark: #1d2330;
    --g-progress-color: #c3c9d6;
    --g-handle-color: #4f46e5;
    --g-weekend-label-color: #cfd4dc;
    --g-expected-progress: #c4c4e9;
    --g-header-background: #ffffff;
    --g-row-color: #ffffff;
    --g-row-border-color: #eef0f4;
    --g-today-highlight: #4f46e5;
    --g-popup-actions: #f3f4f7;
    --g-weekend-highlight-color: #f6f7f9;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1c212b;
    --surface-3: #232935;
    --hover: #222835;
    --border: #2a3140;
    --border-strong: #3a4354;
    --text: #e6e9ef;
    --text-2: #b4bccb;
    --text-3: #838da0;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #252a4a;
    --accent-text: #0f1218;
    --selected: #2a3160;
    --danger: #f87171;
    --danger-soft: #3a1d22;
    --warning: #fbbf24;
    --warning-soft: #3a2e14;
    --success: #34d399;
    --success-soft: #133229;
    --late: #f87171;
    --critical: #fb7185;
    --summary: #c7cedb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    --focus: 0 0 0 3px rgba(129, 140, 248, .35);

    --g-arrow-color: #6b7489;
    --g-bar-color: #2a3140;
    --g-tick-color: #20252f;
    --g-tick-color-thick: #2a3140;
    --g-actions-background: #232935;
    --g-border-color: #2a3140;
    --g-text-muted: #838da0;
    --g-text-light: #ffffff;
    --g-text-dark: #e6e9ef;
    --g-progress-color: #4a5366;
    --g-handle-color: #818cf8;
    --g-weekend-label-color: #3a4354;
    --g-header-background: #171b23;
    --g-row-color: #171b23;
    --g-row-border-color: #20252f;
    --g-today-highlight: #818cf8;
    --g-popup-actions: #232935;
    --g-weekend-highlight-color: #1a1e27;
}

/* ─── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}
*:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
::selection { background: var(--accent-soft); }

/* ─── Form controls ────────────────────────────────────────────────────── */
.input, .select, .textarea {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 6px 9px;
    font-size: 13px;
    line-height: 1.4;
    transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--text-3); }
.label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.hint { color: var(--text-3); font-size: 12px; }

/* ─── Buttons ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid transparent;
    font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; user-select: none;
    background: transparent; color: var(--text-2);
    transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); color: #fff; }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-icon { width: 32px; padding: 0; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-sm.btn-icon { width: 26px; }
.btn.active { background: var(--accent-soft); color: var(--accent); }

/* ─── Login page ───────────────────────────────────────────────────────── */
.login-shell { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-md); padding: 28px;
}
.brand-mark {
    width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
    background: var(--accent); color: var(--accent-text); font-size: 16px;
}
.alert { border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent); }
