/* ========== Central Command — Design System ========== */
:root {
  --bg: #0d1117;
  --bg-2: #131a23;
  --surface: #1a222e;
  --surface-2: #212b3a;
  --border: #2b3648;
  --text: #e6edf6;
  --text-dim: #93a4bb;
  --text-faint: #5d6d84;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #3fb970;
  --green-soft: rgba(63, 185, 112, 0.14);
  --red: #e5605e;
  --red-soft: rgba(229, 96, 94, 0.14);
  --amber: #e2a53d;
  --amber-soft: rgba(226, 165, 61, 0.14);
  --purple: #a77bff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 9px;
}
[data-theme="light"] {
  --bg: #f2f4f8;
  --bg-2: #e9edf3;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --border: #dbe1ea;
  --text: #1c2635;
  --text-dim: #5a6a80;
  --text-faint: #93a1b5;
  --accent-soft: rgba(79, 140, 255, 0.12);
  --shadow: 0 6px 18px rgba(30, 45, 70, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
::placeholder { color: var(--text-faint); }

.boot { display: grid; place-items: center; height: 100vh; color: var(--text-dim); }

/* ========== Layout ========== */
#app { height: 100vh; }
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 4px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 20px;
  font-weight: 700; font-size: 16px; letter-spacing: 0.2px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid; place-items: center; color: #fff; font-size: 15px;
  box-shadow: 0 4px 12px rgba(79, 140, 255, 0.4);
}
.brand small { display: block; font-weight: 500; font-size: 10.5px; color: var(--text-faint); letter-spacing: 1.2px; text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-weight: 500; font-size: 14px;
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-spacer { flex: 1; }
.nav-footer { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-footer .nav-item { font-size: 13px; }

.main { flex: 1; overflow-y: auto; padding: 28px 34px 60px; }
.main-inner { max-width: 1180px; margin: 0 auto; }

.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 26px; flex-wrap: wrap; gap: 8px; }
.topbar h1 { font-size: 24px; font-weight: 700; }
.topbar .date { color: var(--text-dim); font-size: 14px; }

/* ========== Components ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.card h3 {
  font-size: 13px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.card h3 a { color: var(--accent); text-decoration: none; font-size: 12px; letter-spacing: 0; text-transform: none; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 13px; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  display: inline-grid; place-items: center;
  color: var(--text-faint); transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }

.empty { color: var(--text-faint); font-size: 14px; padding: 14px 0; text-align: center; }

.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-form input[type="text"] { flex: 1; min-width: 160px; }

/* ========== Login ========== */
.login-wrap { display: grid; place-items: center; height: 100vh; background: radial-gradient(ellipse 900px 600px at 50% -10%, rgba(79,140,255,0.14), transparent), var(--bg); }
.login-card {
  width: 380px; max-width: calc(100vw - 40px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 38px 34px; box-shadow: var(--shadow);
  text-align: center;
}
.login-card .logo {
  width: 58px; height: 58px; border-radius: 17px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid; place-items: center; color: #fff; font-size: 27px;
  box-shadow: 0 8px 28px rgba(79, 140, 255, 0.45);
}
.login-card h1 { font-size: 21px; margin-bottom: 4px; }
.login-card p { color: var(--text-dim); font-size: 14px; margin-bottom: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { text-align: center; font-size: 16px; padding: 11px; }
.login-card input.otp { font-size: 26px; letter-spacing: 10px; font-variant-numeric: tabular-nums; }
.login-msg { font-size: 13px; color: var(--text-dim); min-height: 18px; }
.login-msg.error { color: var(--red); }

/* ========== Todos ========== */
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 6px; border-bottom: 1px solid var(--border);
}
.todo-item:last-child { border-bottom: none; }
.todo-check {
  width: 21px; height: 21px; border-radius: 7px; flex-shrink: 0;
  border: 2px solid var(--text-faint); display: grid; place-items: center;
  transition: all 0.15s; color: transparent; font-size: 13px;
}
.todo-check:hover { border-color: var(--accent); }
.todo-item.done .todo-check { background: var(--green); border-color: var(--green); color: #fff; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--text-faint); }
.todo-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.fav-btn { color: var(--text-faint); font-size: 16px; }
.fav-btn.on { color: var(--amber); }
.prio-dot { width: 8px; height: 8px; border-radius: 50%; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .chip { cursor: pointer; padding: 5px 13px; font-size: 13px; }
.chip.active { background: var(--accent); color: #fff; }

/* ========== Kanban ========== */
.kanban-wrap { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 20px; align-items: flex-start; }
.kanban-col {
  width: 280px; flex-shrink: 0;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
.kanban-col h4 {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  padding: 2px 6px 10px; display: flex; justify-content: space-between; align-items: center;
}
.kanban-cards { min-height: 30px; display: flex; flex-direction: column; gap: 8px; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  cursor: grab; font-size: 14px;
  border-left: 3px solid var(--border);
}
.kanban-card.dragging { opacity: 0.45; }
.kanban-card .body { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; white-space: pre-wrap; }
.kanban-cards.drag-over { outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }
.board-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }

/* ========== Projects ========== */
.project-card { border-top: 3px solid var(--accent); display: flex; flex-direction: column; gap: 8px; }
.project-card .name { font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: space-between; }
.project-card .desc { color: var(--text-dim); font-size: 13.5px; flex: 1; }
.project-stats { display: flex; gap: 8px; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.3s; }

/* ========== Finance ========== */
.stat-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 640px) { .stat-tiles { grid-template-columns: 1fr; } }
.stat-tile .label { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.7px; font-weight: 600; }
.stat-tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat-tile .value.green { color: var(--green); }
.stat-tile .value.red { color: var(--red); }
.tx-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tx-row:last-child { border-bottom: none; }
.tx-row .cat { min-width: 110px; }
.tx-row .note { flex: 1; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-row .amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.tx-row .amount.pos { color: var(--green); }
.tx-row .amount.neg { color: var(--red); }
.bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 10px; }
.bars .group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .bar { width: 22px; border-radius: 5px 5px 0 0; min-height: 2px; }
.bars .bar.income { background: var(--green); }
.bars .bar.expense { background: var(--red); }
.bars .label { font-size: 11.5px; color: var(--text-faint); }
.budget-row { margin-bottom: 12px; }
.budget-row .head { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }

/* ========== Reminders ========== */
.rem-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.rem-item:last-child { border-bottom: none; }
.rem-item .when { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rem-item.overdue .when { color: var(--red); font-weight: 600; }
.rem-item .title { flex: 1; }
.rem-item.done .title { text-decoration: line-through; color: var(--text-faint); }

/* ========== Notes ========== */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.note-card { display: flex; flex-direction: column; gap: 6px; min-height: 130px; }
.note-card .title-input { background: none; border: none; font-weight: 700; font-size: 15px; padding: 0; }
.note-card textarea { background: none; border: none; resize: none; flex: 1; padding: 0; font-size: 13.5px; color: var(--text-dim); min-height: 70px; }
.note-card .foot { display: flex; justify-content: space-between; align-items: center; color: var(--text-faint); font-size: 11.5px; }

/* ========== Habits ========== */
.habit-row { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--border); }
.habit-row:last-child { border-bottom: none; }
.habit-emoji { font-size: 22px; width: 34px; text-align: center; }
.habit-name { flex: 1; font-weight: 600; }
.habit-name small { display: block; font-weight: 400; color: var(--text-faint); font-size: 12px; }
.habit-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; max-width: 340px; }
.habit-dots span { width: 9px; height: 9px; border-radius: 3px; background: var(--surface-2); }
.habit-dots span.on { background: var(--green); }
.habit-toggle {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  border: 2px solid var(--border); display: grid; place-items: center; font-size: 17px;
  transition: all 0.15s; color: transparent;
}
.habit-toggle:hover { border-color: var(--green); }
.habit-toggle.on { background: var(--green); border-color: var(--green); color: #fff; }

/* ========== Dashboard extras ========== */
.hero-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .hero-tiles { grid-template-columns: 1fr 1fr; } }
.hero-tile { display: flex; flex-direction: column; gap: 2px; }
.hero-tile .num { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hero-tile .cap { font-size: 12.5px; color: var(--text-dim); }
.dash-habit { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; cursor: pointer; transition: all 0.15s; }
.dash-habit.on { background: var(--green-soft); border-color: var(--green); color: var(--green); }

/* ========== Modal & Toast ========== */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 10, 18, 0.6); display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 440px; max-width: calc(100vw - 32px); max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal .form { display: flex; flex-direction: column; gap: 11px; }
.modal label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: 12px; box-shadow: var(--shadow);
  font-size: 14px; z-index: 100; transition: transform 0.25s; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* Mobile */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .brand { padding: 0 8px; white-space: nowrap; }
  .brand small { display: none; }
  .nav-item span { display: none; }
  .nav-footer { border: none; padding: 0; flex-direction: row; }
  .main { padding: 18px 16px 40px; }
}
