@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@500;600;700&family=Urbanist:wght@400;500;600;700&display=swap');

:root {
  --color-bg: #151220;
  --color-surface: #1e1a2c;
  --color-surface-2: #262138;
  --color-text: #f2eefb;
  --color-accent: #8b5cf6;
  --color-accent-600: #7c3aed;
  --color-accent-700: #6d28d9;
  --color-accent-100: #efe9fe;
  --color-accent-300: #c4b5fd;
  --color-accent-800: #4c1d95;
  --color-accent-2: #fbbf24;
  --color-accent-2-100: #fef6df;
  --color-accent-2-800: #78350f;
  --color-divider: color-mix(in srgb, white 14%, transparent);
  --color-danger: #f87171;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --shadow-md: 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.55);
  --font-heading: 'Lexend', system-ui, sans-serif;
  --font-body: 'Urbanist', system-ui, sans-serif;
}

* , *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 600; margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
p { margin: 0 0 12px; }
a { color: var(--color-accent-300); text-decoration: none; }
a:hover { color: var(--color-accent); }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* — forms — */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; opacity: .85; }
.input, select.input {
  width: 100%; min-height: 42px; padding: 8px 12px; font: inherit; font-size: 15px;
  color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
}
.input::placeholder { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.input:focus-visible { border-color: var(--color-accent); }
.field-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; }
.form-error { font-size: 13px; color: var(--color-danger); margin: 4px 0 14px; }
.form-note { font-size: 12px; opacity: .6; margin-top: -4px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; cursor: pointer; }
.checkbox-row input { width: 17px; height: 17px; flex: none; margin-top: 1px; accent-color: var(--color-accent); }

/* — buttons — */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none; font-family: var(--font-heading); font-weight: 600;
  font-size: 14px; border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 10px 18px; background: transparent; color: var(--color-text);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-600); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: rgba(255,255,255,.06); }
.btn-danger { border-color: var(--color-danger); color: var(--color-danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--color-danger) 12%, transparent); }
.btn-ghost { color: var(--color-accent-300); padding-inline: 4px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* — cards — */
.card { background: var(--color-surface); border-radius: var(--radius-md); padding: 16px; }
.card-kicker { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--color-accent-300); margin-bottom: 4px; }
.card-title { font-family: var(--font-heading); font-weight: 600; font-size: 18px; }
.card-body { font-size: 13px; opacity: .7; }

/* — tags — */
.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.tag-accent { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-amber { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.tag-neutral { background: rgba(255,255,255,.1); color: var(--color-text); opacity: .75; }
.tag-danger { background: color-mix(in srgb, var(--color-danger) 18%, transparent); color: var(--color-danger); }

/* — auth layout (login/register/onboarding) — */
.auth-shell { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 56px 20px; }
.auth-box { width: 100%; max-width: 360px; }
.auth-logo { font-size: 28px; margin-bottom: 2px; }
.auth-sub { opacity: .65; font-size: 14px; margin-bottom: 28px; }
.auth-switch { text-align: center; font-size: 13px; margin-top: 4px; }

/* — onboarding cards — */
.ob-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 22px; }
.ob-card { cursor: pointer; border: 2px solid transparent; }
.ob-card.selected { border-color: var(--color-accent); }
.ob-card svg { color: var(--color-accent); margin-bottom: 6px; }

/* — app shell — */
.app-shell { min-height: 100vh; display: flex; }
.app-sidebar {
  width: 216px; flex: none; padding: 24px 14px; border-right: 1px solid var(--color-divider);
  display: flex; flex-direction: column;
}
.app-sidebar .brand { font-family: var(--font-heading); font-weight: 700; font-size: 19px; margin: 0 8px 24px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-md);
  color: var(--color-text); font-size: 14px; margin-bottom: 2px; text-decoration: none;
}
.nav-link svg { flex: none; opacity: .85; }
.nav-link.active { background: var(--color-accent); color: #fff; }
.nav-link.active svg { opacity: 1; }
.nav-link:hover:not(.active) { background: rgba(255,255,255,.06); }
.app-sidebar .spacer { flex: 1; }
.logout-link { opacity: .7; font-size: 13px; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: none; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--color-divider);
}
.app-content { flex: 1; padding: 24px 20px 90px; max-width: 720px; width: 100%; margin: 0 auto; }

.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: var(--color-surface); border-top: 1px solid var(--color-divider);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--color-text); opacity: .6; }
.bottom-nav a.active { color: var(--color-accent); opacity: 1; }

@media (max-width: 860px) {
  .app-sidebar { display: none; }
  .app-topbar { display: flex; }
  .bottom-nav { display: flex; }
  .app-content { padding-bottom: 96px; }
}

/* — history calendar — */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 5px; margin-bottom: 6px; }
.cal-wd { text-align: center; font-size: 11px; opacity: .55; }
.cal-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 12px; cursor: pointer; border: 1px solid transparent;
}
.cal-cell.status-done { background: var(--color-accent); color: #fff; }
.cal-cell.status-partial { background: var(--color-accent-100); color: var(--color-accent-800); }
.cal-cell.status-none { border-color: var(--color-divider); }
.cal-cell.status-future { color: color-mix(in srgb, var(--color-text) 30%, transparent); cursor: default; }
.cal-cell.status-empty { visibility: hidden; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; opacity: .7; margin-bottom: 20px; }
.legend-dot { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot span { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.history-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-surface);
  margin-bottom: 8px; text-decoration: none; color: var(--color-text);
}

/* — dialog (day edit) — */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(10,8,18,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.dialog { width: min(420px,100%); background: var(--color-surface); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-lg); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* — stats bars — */
.bars { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; align-items: end; height: 64px; margin-bottom: 4px; }
.bars .bar { background: var(--color-accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.bars-labels { display: grid; grid-template-columns: repeat(7,1fr); gap: 6px; text-align: center; margin-bottom: 18px; }
.bars-labels .d { font-size: 10px; opacity: .5; }
.bars-labels .v { font-size: 11px; }

/* — settings toggles — */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.seg { display: inline-flex; border: 1px solid var(--color-divider); border-radius: var(--radius-md); overflow: hidden; }
.seg a { padding: 6px 14px; font-size: 13px; color: var(--color-text); opacity: .7; }
.seg a.on { background: var(--color-accent); color: #fff; opacity: 1; }

/* — admin — */
.admin-header { display: flex; align-items: center; gap: 20px; padding: 14px 20px; border-bottom: 1px solid var(--color-divider); }
.admin-header .brand { font-family: var(--font-heading); font-weight: 700; }
.admin-header .brand .sub { color: var(--color-accent-300); font-weight: 500; }
.admin-header nav a { font-size: 14px; color: var(--color-text); opacity: .8; }
.admin-header .spacer { flex: 1; }
.admin-content { padding: 28px 20px 60px; max-width: 1080px; margin: 0 auto; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; opacity: .55; padding: 10px 12px; border-bottom: 1px solid var(--color-divider); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid color-mix(in srgb, white 8%, transparent); vertical-align: middle; }
.filters { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filters .input { max-width: 280px; }
.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--color-divider); }
.pagination a.current { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 10px; margin: 18px 0; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-md); }
.text-muted { opacity: .6; }
.mt-0 { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hr { height: 1px; background: var(--color-divider); border: 0; margin: 20px 0; }
.flash-ok { font-size: 13px; color: #86efac; margin-bottom: 14px; }
