@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Mono:wght@300;400;500&display=swap');

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

:root {
  --bg: #0E0E11;
  --bg2: #141417;
  --surface: #1C1C21;
  --surface2: #242429;
  --border: rgba(255,255,255,.07);
  --border2: rgba(255,255,255,.12);
  --text: #F0F0F5;
  --text2: #9090A0;
  --text3: #55555F;
  --accent: #7C6AF7;
  --accent2: #5B4ED4;
  --green: #34D399;
  --red: #F87171;
  --amber: #FBBF24;
  --blue: #60A5FA;
  --pink: #F472B6;
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --r: 12px;
  --r2: 16px;
}

html { font-size: 14px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Syne', sans-serif;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sb-logo {
  padding: 22px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sb-logo-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-logo-name span {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.sb-logo-date {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  font-family: 'DM Mono', monospace;
}

.sb-nav { padding: 12px 10px; flex: 1; }
.sb-section { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text3); padding: 10px 8px 6px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  margin-bottom: 2px;
  text-decoration: none;
}

.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ico { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.sb-bottom {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sb-clock {
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  padding: 8px 10px;
  letter-spacing: .05em;
}

/* ── Main ────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; flex: 1; max-width: 1100px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: 'Syne', sans-serif;
  transition: all .15s;
  letter-spacing: .01em;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-ghost { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.2); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 11px; border-radius: 7px; }
.btn-xs { padding: 3px 8px; font-size: 10px; border-radius: 6px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 18px;
}

.card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text3);
  margin-bottom: 14px;
}

/* ── Grid ────────────────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.g3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 14px; }
.g4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 14px; }
.mb { margin-bottom: 14px; }
.mb2 { margin-bottom: 24px; }

/* ── KPI ─────────────────────────────────────────────────── */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.kpi-indigo::before { background: var(--accent); }
.kpi-green::before { background: var(--green); }
.kpi-amber::before { background: var(--amber); }
.kpi-blue::before { background: var(--blue); }
.kpi-pink::before { background: var(--pink); }

.kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); margin-bottom: 6px; }
.kpi-val { font-size: 28px; font-weight: 800; font-family: 'DM Mono', monospace; line-height: 1; }
.kpi-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

/* ── Progress ────────────────────────────────────────────── */
.prog-wrap { background: var(--bg); border-radius: 20px; height: 6px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 20px; transition: width .5s ease; }

/* ── Chips ───────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px;
  letter-spacing: .02em;
}

.chip-alta { background: rgba(248,113,113,.15); color: var(--red); }
.chip-media { background: rgba(251,191,36,.15); color: var(--amber); }
.chip-baja { background: rgba(52,211,153,.15); color: var(--green); }
.chip-pendiente { background: rgba(124,106,247,.15); color: var(--accent); }
.chip-progreso { background: rgba(251,191,36,.15); color: var(--amber); }
.chip-completada { background: rgba(52,211,153,.15); color: var(--green); }
.chip-vencida { background: rgba(248,113,113,.15); color: var(--red); }
.chip-neutral { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 28px;
  width: 460px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  transform: translateY(16px);
  transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 22px; }

/* ── Form ────────────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.form-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text3); margin-bottom: 5px; }

.form-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 9px;
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border .15s;
}

.form-input:focus { border-color: var(--accent); }
.form-input option { background: var(--surface); }

.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }

/* ── Sections ────────────────────────────────────────────── */
.sec { display: none; }
.sec.active { display: block; }
.sec-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.sec-header h2 { font-size: 20px; font-weight: 800; letter-spacing: -.03em; }

/* ── Empty ───────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-ico { font-size: 36px; margin-bottom: 10px; }
.empty-txt { font-size: 13px; }

/* ── Toast ───────────────────────────────────────────────── */
#toast { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }

.toast {
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .25s ease;
  transition: opacity .3s, transform .3s;
}

.toast-hide { opacity: 0; transform: translateX(20px); }
.toast-error { border-color: rgba(248,113,113,.3); }

@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Loader ──────────────────────────────────────────────── */
#loader {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  transition: opacity .3s;
}

#loader.hide { opacity: 0; pointer-events: none; }
.loader-name { font-size: 18px; font-weight: 800; }
.loader-spin { width: 32px; height: 32px; border: 3px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; }

/* ── Habit specific ──────────────────────────────────────── */
.habit-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  margin-bottom: 8px;
  transition: all .15s;
  cursor: pointer;
  user-select: none;
}

.habit-row:hover { border-color: var(--accent); }
.habit-row.done { background: rgba(52,211,153,.06); border-color: rgba(52,211,153,.2); }

.habit-check {
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: all .15s;
}

.habit-row.done .habit-check { background: var(--green); border-color: var(--green); color: #fff; }
.habit-name { font-size: 13px; font-weight: 600; flex: 1; }
.habit-row.done .habit-name { color: var(--text3); text-decoration: line-through; }
.habit-streak { font-size: 11px; font-weight: 700; color: var(--amber); font-family: 'DM Mono', monospace; }

/* ── Task specific ───────────────────────────────────────── */
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface2);
  margin-bottom: 8px;
  transition: border-color .15s;
}

.task-item:hover { border-color: var(--border2); }
.task-item.done-task { opacity: .4; }

.task-check {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border2);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  color: transparent;
  transition: all .15s;
}

.task-check:hover { border-color: var(--green); color: var(--green); }
.task-item.done-task .task-check { background: var(--green); border-color: var(--green); color: #fff; }

.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.task-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.task-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* ── Note card ───────────────────────────────────────────── */
.note-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all .2s;
  break-inside: avoid;
  margin-bottom: 12px;
}

.note-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.note-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.note-content { font-size: 12px; color: var(--text2); line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.note-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.note-cat { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(124,106,247,.15); color: var(--accent); }

/* ── Meta card ───────────────────────────────────────────── */
.meta-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 10px;
  transition: border-color .15s;
}

.meta-card:hover { border-color: var(--border2); }
.meta-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.meta-desc { font-size: 12px; color: var(--text2); margin-bottom: 12px; line-height: 1.5; }
.meta-pct { font-size: 14px; font-weight: 800; font-family: 'DM Mono', monospace; color: var(--accent); }

/* ── Week bars ───────────────────────────────────────────── */
.week-bars { display: flex; gap: 5px; align-items: flex-end; height: 56px; }
.week-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.week-bar-bg { flex: 1; width: 100%; background: var(--bg); border-radius: 5px; display: flex; align-items: flex-end; overflow: hidden; }
.week-bar-fill { width: 100%; border-radius: 5px; transition: height .5s ease; }
.week-bar-day { font-size: 9px; color: var(--text3); font-weight: 700; font-family: 'DM Mono', monospace; }

/* ── Date nav ────────────────────────────────────────────── */
.date-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.date-nav-btn { background: var(--surface); border: 1px solid var(--border2); color: var(--text2); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.date-nav-btn:hover { background: var(--surface2); color: var(--text); }
.date-nav-label { font-size: 14px; font-weight: 700; flex: 1; }
.date-nav-today { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 7px; background: var(--accent); color: #fff; cursor: pointer; border: none; font-family: 'Syne', sans-serif; }
