:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #6b7485;
  --line: #dfe5ef;
  --primary: #246bfe;
  --success: #18a058;
  --warning: #d98900;
  --danger: #d43f3a;
  --radius: 8px;
}

[data-theme="dark"] {
  --bg: #101624;
  --panel: #171f30;
  --text: #eef3fb;
  --muted: #a9b4c6;
  --line: #2a3548;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; letter-spacing: 0; }
small, .muted { color: var(--muted); }
button, .button { border: 0; border-radius: var(--radius); background: var(--primary); color: #fff; padding: 11px 14px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 40px; }
.ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.full { width: 100%; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: var(--radius); padding: 11px 12px; font: inherit; min-height: 42px; }
textarea { min-height: 110px; resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--panel); border-right: 1px solid var(--line); padding: 22px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand span { width: 38px; height: 38px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 900; }
.brand.center { justify-content: center; margin-bottom: 18px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar a { padding: 11px 12px; border-radius: var(--radius); color: var(--muted); font-weight: 700; }
.sidebar a.active, .sidebar a:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

.app-shell { margin-left: 248px; padding: 24px 28px 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 26px; }
.panel, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat strong { display: block; font-size: 25px; margin-top: 8px; }
.section-title, .actions, .inline-form, .filters { display: flex; align-items: center; gap: 10px; }
.section-title { justify-content: space-between; margin-bottom: 16px; }
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.compact { margin-bottom: 16px; }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; align-items: center; flex-direction: row; gap: 10px; color: var(--text); }
.check input { width: auto; }

.table, .timeline { display: grid; gap: 9px; }
.row, .project-line, .task-line, .category-line { display: grid; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: color-mix(in srgb, var(--panel) 92%, var(--bg)); }
.row { grid-template-columns: 1fr auto; }
.project-line { grid-template-columns: 2fr auto auto auto auto; }
.task-line { grid-template-columns: 1.4fr 160px 170px 140px auto; }
.category-line { grid-template-columns: 1fr 70px auto; }
.danger { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); background: color-mix(in srgb, var(--danger) 9%, var(--panel)); }
.warning { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); background: color-mix(in srgb, var(--warning) 8%, var(--panel)); }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 5px 9px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 11%, transparent); color: var(--primary); font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.priority { background: color-mix(in srgb, var(--success) 13%, transparent); color: var(--success); }
.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--line); }
.alert.success { background: color-mix(in srgb, var(--success) 12%, var(--panel)); }
.alert.error { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }

.tabs { display: flex; gap: 8px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: transparent; color: var(--muted); border-radius: 0; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab { display: none; }
.tab.active { display: block; }
.details-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.details-grid p { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0; display: grid; gap: 5px; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.stack { display: grid; gap: 14px; }
.mobile-nav { display: none; }

@media (max-width: 980px) {
  .sidebar { display: none; }
  .app-shell { margin: 0; padding: 18px 14px 86px; }
  .stats, .two, .form-grid, .details-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .project-line, .task-line, .category-line, .inline-form { grid-template-columns: 1fr; display: grid; }
  .mobile-nav { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--line); z-index: 10; }
  .mobile-nav a { text-align: center; padding: 13px 4px; color: var(--muted); font-size: 12px; font-weight: 800; }
  .mobile-nav a.active { color: var(--primary); }
}
