:root {
  --bg: #F3F4FA;
  --surface: #FFFFFF;
  --surface-2: #EEEFF7;
  --border: #E1E3EE;
  --text: #1F2333;
  --text-muted: #6B7086;
  --tasks: #5B5FEF;
  --tasks-soft: #ECEBFF;
  --wardrobe: #DB8A2E;
  --wardrobe-soft: #FDEDD8;
  --money: #1F9D63;
  --money-soft: #DEF5E9;
  --danger: #E0505A;
  --danger-soft: #FBE3E4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20,22,40,0.04), 0 4px 16px rgba(20,22,40,0.06);
}

[data-theme="dark"] {
  --bg: #12141F;
  --surface: #1B1E2C;
  --surface-2: #232739;
  --border: #2E3247;
  --text: #E9EAF3;
  --text-muted: #9095AC;
  --tasks-soft: #262A46;
  --wardrobe-soft: #3A2C17;
  --money-soft: #163A28;
  --danger-soft: #3A1F22;
  --shadow: 0 1px 2px rgba(0,0,0,0.2), 0 4px 20px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease;
}
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.85rem; }

/* Auth screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; font-weight: 800; }
.brand-mark { color: var(--tasks); }
.auth-tagline { color: var(--text-muted); margin: 8px 0 24px; font-size: 0.9rem; }
.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-weight: 600; }
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { font-size: 0.85rem; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.95rem;
}
.form-error { color: var(--danger); font-size: 0.85rem; min-height: 1em; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: -8px; }

button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-ghost {
  cursor: pointer; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 0.9rem; border: none;
}
.btn-primary { background: var(--tasks); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--money); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.icon-btn { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 1rem; }

/* App layout */
.app { min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.tab { border: none; background: transparent; padding: 8px 16px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; font-size: 0.9rem; }

.content { padding: 24px; max-width: 1100px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select, .filters input, #expense-month { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.inline-form {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--border); padding: 14px; border-radius: var(--radius);
}
.inline-form.vertical { flex-direction: column; }
.inline-form input, .inline-form select {
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 0.9rem;
}
.inline-form input[type="text"], .inline-form input[placeholder] { flex: 1; min-width: 120px; }

/* Todos */
.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--tasks);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.todo-item.completed { opacity: 0.55; }
.todo-item.priority-high { border-left-color: var(--danger); }
.todo-item.priority-low { border-left-color: var(--money); }
.todo-main { display: flex; align-items: flex-start; gap: 10px; }
.todo-main input[type="checkbox"] { margin-top: 4px; width: 18px; height: 18px; cursor: pointer; }
.todo-title-row { flex: 1; }
.todo-title { font-weight: 600; }
.todo-title.done { text-decoration: line-through; }
.todo-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.badge { font-size: 0.72rem; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.badge-category { background: var(--tasks-soft); color: var(--tasks); }
.badge-due { background: var(--surface-2); color: var(--text-muted); }
.badge-recurring { background: var(--money-soft); color: var(--money); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }
.todo-actions { display: flex; gap: 6px; }
.todo-actions button { background: transparent; border: none; cursor: pointer; color: var(--text-muted); font-size: 0.9rem; }
.subtasks { margin: 8px 0 0 28px; display: flex; flex-direction: column; gap: 4px; }
.subtask-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.subtask-row input[type="checkbox"] { width: 14px; height: 14px; }
.subtask-row.done span { text-decoration: line-through; color: var(--text-muted); }
.add-subtask { display: flex; gap: 6px; margin: 8px 0 0 28px; }
.add-subtask input { flex: 1; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 0.82rem; }
.add-subtask button { font-size: 0.8rem; padding: 6px 10px; }

/* Wardrobe */
.subtabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.subtab { border: none; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }
.subtab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.item-card {
  background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--wardrobe);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
}
.item-card h4 { margin: 0 0 4px; }
.item-card .worn-badge { font-size: 0.78rem; padding: 3px 8px; border-radius: 999px; background: var(--wardrobe-soft); color: var(--wardrobe); display: inline-block; margin: 6px 0; }
.item-card .worn-badge.stale { background: var(--money-soft); color: var(--money); }
.item-card .row-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.item-card .row-actions button { font-size: 0.78rem; padding: 6px 10px; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; max-height: 320px; overflow-y: auto; margin: 12px 0; }
.picker-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.picker-item.selected { border-color: var(--wardrobe); background: var(--wardrobe-soft); }

/* Expenses */
.stats-row { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 0.78rem; color: var(--text-muted); }
.stat-card .value { font-size: 1.4rem; font-weight: 700; }
.stat-card.income .value { color: var(--money); }
.stat-card.expense .value { color: var(--danger); }
.expense-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.expense-list { display: flex; flex-direction: column; gap: 6px; }
.expense-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow);
}
.expense-row .amount.income { color: var(--money); font-weight: 700; }
.expense-row .amount.expense { color: var(--danger); font-weight: 700; }
.budget-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.budget-item { margin-bottom: 10px; }
.budget-bar { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.budget-bar-fill { height: 100%; background: var(--money); }
.budget-bar-fill.over { background: var(--danger); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--surface); border-radius: 12px; padding: 20px; width: 90%; max-width: 480px; box-shadow: var(--shadow); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; font-size: 0.88rem; z-index: 100;
}

@media (max-width: 720px) {
  .expense-layout { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; }
}
