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

/* Login Gate */
#login-gate { position: fixed; inset: 0; background: var(--background, #f8fafc); display: flex; align-items: center; justify-content: center; z-index: 9999; }
#login-gate.hidden { display: none; }
.login-box { background: var(--card, #fff); border: 1px solid var(--border, #e2e8f0); border-radius: 1rem; padding: 2.5rem 2rem; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1rem; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.login-box h2 { font-size: 1.25rem; font-weight: 700; color: var(--foreground, #0f172a); }
.login-box p { font-size: 0.875rem; color: var(--muted-foreground, #64748b); }
#login-form { display: flex; flex-direction: column; gap: 0.75rem; }
#login-input { padding: 0.625rem 0.875rem; border: 1px solid var(--border, #e2e8f0); border-radius: 0.5rem; font-size: 0.9375rem; background: var(--background, #f8fafc); color: var(--foreground, #0f172a); outline: none; transition: border-color 0.15s; }
#login-input:focus { border-color: var(--violet, #8b5cf6); }
#login-form button { padding: 0.625rem; background: var(--violet, #8b5cf6); color: #fff; border: none; border-radius: 0.5rem; font-size: 0.9375rem; font-weight: 600; cursor: pointer; transition: opacity 0.15s; }
#login-form button:hover { opacity: 0.88; }
.login-error { font-size: 0.8125rem; color: #ef4444; min-height: 1rem; }

:root {
    --col-w: 100px;
    --label-w: 300px;
    --radius: 0.5rem;
    --transition: 0.25s ease;
    --violet: #8b5cf6;  --violet-muted: rgba(139,92,246,0.15);
    --blue: #3b82f6;    --blue-muted: rgba(59,130,246,0.15);
    --emerald: #10b981; --emerald-muted: rgba(16,185,129,0.15);
    --amber: #f59e0b;   --amber-muted: rgba(245,158,11,0.15);
    --rose: #f43f5e;    --rose-muted: rgba(244,63,94,0.15);
    --cyan: #06b6d4;    --cyan-muted: rgba(6,182,212,0.15);
    --orange: #f97316;  --orange-muted: rgba(249,115,22,0.15);
}

[data-theme="dark"] {
    --background: #09090b; --foreground: #fafafa; --card: #0a0a0c;
    --muted: #18181b; --muted-foreground: #a1a1aa; --border: #27272a;
    --tooltip-bg: #1c1c1e; --bar-text: rgba(255,255,255,0.85);
    --hover-ring: rgba(255,255,255,0.1); --tab-hover: #27272a;
}
[data-theme="light"] {
    --background: #fafafa; --foreground: #09090b; --card: #ffffff;
    --muted: #f4f4f5; --muted-foreground: #71717a; --border: #e4e4e7;
    --tooltip-bg: #ffffff; --bar-text: rgba(255,255,255,0.95);
    --hover-ring: rgba(0,0,0,0.08); --tab-hover: #f4f4f5;
}

body {
    font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--background); color: var(--foreground);
    line-height: 1.5; -webkit-font-smoothing: antialiased;
    padding: 2rem; min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

/* Header */
.page-header { max-width: 1400px; margin: 0 auto 1.5rem; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
.page-header .subtitle { color: var(--muted-foreground); font-size: 0.875rem; margin-top: 0.25rem; }

/* Theme toggle */
.theme-toggle { display: flex; align-items: center; background: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.25rem; flex-shrink: 0; margin-top: 0.25rem; transition: background var(--transition), border-color var(--transition); }
.theme-toggle button { all: unset; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-size: 0.875rem; cursor: pointer; transition: background var(--transition); }
.theme-toggle button.active { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.theme-toggle button:hover:not(.active) { background: var(--tab-hover); }

/* Tabs */
.tabs-container { max-width: 1400px; margin: 0 auto 1.5rem; }
.tabs { display: inline-flex; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; gap: 2px; transition: background var(--transition), border-color var(--transition); }
.tab { all: unset; padding: 0.5rem 1.25rem; font-size: 0.8125rem; font-weight: 500; border-radius: calc(var(--radius) - 2px); cursor: pointer; color: var(--muted-foreground); transition: all 0.15s; white-space: nowrap; }
.tab:hover { color: var(--foreground); background: var(--tab-hover); }
.tab:disabled { pointer-events: none; cursor: default; opacity: 0.4; }
.tab.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.tab .flag { margin-right: 0.375rem; }

/* Panels */
.campaign-panel { display: none; }
.campaign-panel.active { display: block; }

/* Stats */
.stats { display: flex; gap: 1rem; max-width: 1400px; margin: 0 auto 1.5rem; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 170px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; transition: background var(--transition), border-color var(--transition); }
.stat-card .label { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; letter-spacing: -0.025em; }
.stat-card .sub { font-size: 0.75rem; color: var(--muted-foreground); margin-top: 0.125rem; }
.stat-card .sub.up { color: var(--emerald); }

/* Legend */
.legend { display: flex; gap: 0; max-width: 1400px; margin: 0 auto 1rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; flex-wrap: wrap; transition: background var(--transition), border-color var(--transition); }
.legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8125rem; color: var(--muted-foreground); padding: 0.25rem 1rem 0.25rem 0; }
.legend-item:not(:last-child) { margin-right: 1rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Gantt */
.gantt-outer { max-width: 1400px; margin: 0 auto; }
.gantt-wrapper { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: scroll; overflow-y: visible; transition: background var(--transition), border-color var(--transition); scrollbar-width: none; }
.gantt-wrapper::-webkit-scrollbar { display: none; }
.gantt { display: grid; grid-template-columns: var(--label-w) repeat(12, var(--col-w)); min-width: calc(var(--label-w) + 12 * var(--col-w)); }

/* Custom scrollbar */
.gantt-scrollbar { height: 6px; margin-top: 6px; position: relative; border-radius: 999px; overflow: hidden; background: transparent; }
.gantt-scrollbar-thumb { position: absolute; top: 0; height: 100%; border-radius: 999px; background: var(--border); cursor: grab; transition: background 0.15s; }
.gantt-scrollbar-thumb:hover, .gantt-scrollbar-thumb.dragging { background: var(--muted-foreground); }
.gantt-scrollbar-thumb.dragging { cursor: grabbing; }

.gantt-header { display: contents; }
.gantt-header .cell { padding: 0.75rem 0.5rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted-foreground); border-bottom: 1px solid var(--border); text-align: center; position: sticky; top: 0; background: var(--card); z-index: 2; }
.gantt-header .cell:first-child { text-align: left; padding-left: 1.25rem; position: sticky; left: 0; z-index: 3; }
.gantt-header .cell.today { background: var(--violet-muted); color: var(--violet); }

.gantt-category { display: contents; }
.gantt-category .cell { padding: 0.625rem 0.5rem 0.625rem 1.25rem; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.075em; color: var(--muted-foreground); background: var(--muted); border-bottom: 1px solid var(--border); }

.gantt-row { display: contents; }
.gantt-row .cell { padding: 0; border-bottom: 1px solid var(--border); position: relative; height: 52px; }
.gantt-row:last-child .cell { border-bottom: none; }
.gantt-row .cell:not(:first-child)::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--border); opacity: 0.5; }

.gantt-row .cell:first-child { position: sticky; left: 0; z-index: 3; background: var(--card); }
.gantt-category .cell:first-child { position: sticky; left: 0; z-index: 4; }
.gantt-row .task-label { display: flex; align-items: center; gap: 0.75rem; padding: 0 1.25rem; height: 100%; background: var(--card); border-right: 1px solid var(--border); }
.task-label .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.task-label .info { min-width: 0; }
.task-label .name { font-size: 0.8125rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-label .meta { font-size: 0.6875rem; color: var(--muted-foreground); }

.bar-track { position: absolute; top: 50%; transform: translateY(-50%); height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: 0.6875rem; font-weight: 600; color: var(--bar-text); transition: opacity 0.2s; cursor: default; z-index: 1; opacity: 0.75; text-decoration: none; }
a.bar-track { cursor: pointer; }
.bar-track:hover { opacity: 0.9; box-shadow: 0 0 0 2px var(--hover-ring); }
.bar-track .pct { opacity: 0.9; }
.bar-progress { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; opacity: 0.45; }

.milestone { position: absolute; top: 50%; transform: translate(-50%, -50%) rotate(45deg); width: 12px; height: 12px; border-radius: 2px; z-index: 2; }

#gantt-tooltip { position: fixed; background: var(--tooltip-bg); color: var(--foreground); padding: 0.375rem 0.625rem; border-radius: 6px; font-size: 0.6875rem; font-weight: 400; white-space: nowrap; pointer-events: none; border: 1px solid var(--border); box-shadow: 0 4px 12px rgba(0,0,0,0.15); z-index: 9999; opacity: 0; transition: opacity 0.15s; }

.bg-violet { background: var(--violet); }  .bg-blue { background: var(--blue); }
.bg-emerald { background: var(--emerald); } .bg-amber { background: var(--amber); }
.bg-rose { background: var(--rose); }       .bg-cyan { background: var(--cyan); }
.bg-orange { background: var(--orange); }
.dot-violet { background: var(--violet); }  .dot-blue { background: var(--blue); }
.dot-emerald { background: var(--emerald); } .dot-amber { background: var(--amber); }
.dot-rose { background: var(--rose); }      .dot-cyan { background: var(--cyan); }
.dot-orange { background: var(--orange); }

.footer { max-width: 1400px; margin: 1.5rem auto 0; display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--muted-foreground); }
.badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.625rem; background: var(--muted); border: 1px solid var(--border); border-radius: 999px; font-size: 0.6875rem; font-weight: 500; transition: background var(--transition), border-color var(--transition); }
.badge .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--emerald); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.meta-in-progress { color: #ef4444; animation: flash-red 1s infinite; }
@keyframes flash-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Quarter tabs */
.quarter-tabs-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; max-width: 1400px; margin-left: auto; margin-right: auto; }
.quarter-tabs { display: inline-flex; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; gap: 2px; transition: background var(--transition), border-color var(--transition); }
.today-btn { all: unset; padding: 0.375rem 0.875rem; font-size: 0.75rem; font-weight: 600; border-radius: calc(var(--radius) - 2px); cursor: pointer; color: var(--emerald); background: var(--emerald-muted); border: 1px solid transparent; transition: all 0.15s; white-space: nowrap; }
.today-btn:hover { opacity: 0.8; }
.qtab { all: unset; padding: 0.375rem 1rem; font-size: 0.75rem; font-weight: 600; border-radius: calc(var(--radius) - 2px); cursor: pointer; color: var(--muted-foreground); transition: all 0.15s; white-space: nowrap; }
.qtab:hover { color: var(--foreground); background: var(--tab-hover); }
.qtab.active { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Quarter panels */
.quarter-panel { display: none; }
.quarter-panel.active { display: block; }

/* Quarter message */
.quarter-message { text-align: center; padding: 3rem 1.5rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted-foreground); font-size: 0.875rem; transition: background var(--transition), border-color var(--transition); }
.quarter-message .qm-title { font-size: 1.125rem; font-weight: 600; color: var(--foreground); margin-bottom: 0.375rem; }

@media (max-width: 768px) {
    body { padding: 1rem; }
    :root { --label-w: 200px; --col-w: 80px; }
    .page-header { flex-direction: column; }
    .page-header h1 { font-size: 1.25rem; }
    .stat-card { min-width: 140px; }
}
