:root {
  --bg: #0a0b0f;
  --bg-grad-1: rgba(99, 102, 241, 0.18);
  --bg-grad-2: rgba(16, 185, 129, 0.06);
  --surface: #14151b;
  --surface-2: #1b1d25;
  --surface-3: #232631;
  --border: #262936;
  --border-strong: #353a4a;
  --text: #ecedf2;
  --muted: #9097a8;
  --muted-strong: #b1b6c4;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.1);
  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  font-feature-settings: "ss01", "cv11";
  background: radial-gradient(1100px 700px at 12% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 600px at 95% 5%, var(--bg-grad-2), transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@supports (font-variation-settings: normal) {
  body {
    font-family: "Inter var", "Inter", ui-sans-serif, system-ui, sans-serif;
  }
}

a {
  color: var(--accent-2);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
  font-weight: 700;
}
h1 {
  font-size: 1.75rem;
}
h2 {
  font-size: 1.1rem;
}
h3 {
  font-size: 1rem;
}

p {
  margin: 0;
  line-height: 1.55;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 6px;
}
.muted-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ───────────────────────── topbar ───────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  font-size: 1.2rem;
}

.topbar-link {
  margin-left: auto;
  color: var(--muted-strong);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.topbar-link:hover {
  text-decoration: none;
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.topbar-actions ~ .topbar-link {
  margin-left: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.82rem;
  color: var(--muted-strong);
  font-weight: 500;
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.18);
}

/* ───────────────────────── layout ───────────────────────── */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.view.hidden {
  display: none;
}

.view-center {
  min-height: calc(100vh - 200px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding-top: 16px;
  padding-bottom: 24px;
}

.hero {
  text-align: center;
  max-width: 620px;
  animation: fade-up 0.5s ease both;
}
.hero-title {
  font-size: clamp(2rem, 4vw + 1rem, 3rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #ffffff 0%, #c9cdd9 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 12px;
}
.hero-title.small {
  font-size: clamp(1.5rem, 2vw + 0.75rem, 2rem);
}
.hero-sub {
  color: var(--muted-strong);
  font-size: 1.05rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ───────────────────────── card ───────────────────────── */

.card {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 24px;
  animation: fade-up 0.55s 0.05s ease both;
}
.auth-card.narrow {
  max-width: 420px;
}

.mono-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

/* ───────────────────────── tabs ───────────────────────── */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 120ms ease, background 120ms ease;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  background: color-mix(in oklab, var(--surface-3) 92%, white 4%);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-panel.hidden {
  display: none;
}

/* ───────────────────────── forms ───────────────────────── */

.form-stack {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}
.form-stack-item,
label {
  display: grid;
  gap: 6px;
}
label > span:first-child {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted-strong);
}
.hint {
  font-size: 0.78rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface-2) 65%, black 5%);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
input::placeholder {
  color: color-mix(in oklab, var(--muted) 70%, transparent);
}
input:hover,
select:hover {
  border-color: var(--border-strong);
}
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: color-mix(in oklab, var(--surface-2) 75%, black 0%);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}
.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #8e98ff, #6c70f7);
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted-strong);
}
.btn.ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn.danger {
  background: var(--danger-bg);
  border-color: color-mix(in oklab, var(--danger) 35%, var(--border));
  color: var(--danger);
}
.btn.danger:hover {
  background: color-mix(in oklab, var(--danger) 18%, transparent);
}

.btn.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted-strong);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms ease;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.gap-sm {
  gap: 6px;
}

/* ───────────────────────── dashboard ───────────────────────── */

.dash-hero {
  margin-bottom: 24px;
  animation: fade-up 0.4s ease both;
}
.dash-title {
  font-size: clamp(1.75rem, 2vw + 1rem, 2.25rem);
  letter-spacing: -0.025em;
  margin: 2px 0 6px;
}
.dash-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (min-width: 720px) {
  .stats {
    grid-template-columns: repeat(4, 1fr);
  }
}
.stat {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: grid;
  gap: 4px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.stat.is-bad .stat-value {
  color: var(--danger);
}
.stat.is-warn .stat-value {
  color: var(--warn);
}
.stat.is-ok .stat-value {
  color: var(--ok);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 920px) {
  .dash-grid {
    grid-template-columns: minmax(0, 1fr) 340px;
  }
}

.dash-side {
  display: grid;
  gap: 16px;
}

/* ───────────────────────── inline forms ───────────────────────── */

.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fade-up 0.25s ease both;
}
@media (min-width: 720px) {
  .inline-form {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }
  .inline-form .row {
    grid-column: span 2;
    justify-content: flex-end;
  }
  .inline-form #task-form-error {
    grid-column: 1 / -1;
  }
}

.period-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.period-input input {
  width: 80px;
}

.inline-form-tight {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

/* ───────────────────────── tasks ───────────────────────── */

.tasks {
  display: grid;
  gap: 10px;
}

.task {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: border-color 120ms ease, background 120ms ease;
  animation: fade-in 0.25s ease both;
}
.task:hover {
  border-color: var(--border-strong);
}

.task.overdue {
  border-color: color-mix(in oklab, var(--danger) 40%, var(--border));
  background: linear-gradient(180deg, var(--danger-bg), var(--surface-2));
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-main {
  flex: 1;
  min-width: 0;
}
.task-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.task-sub {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.task-sub .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.badge.bad {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in oklab, var(--danger) 40%, transparent);
}
.badge.warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in oklab, var(--warn) 40%, transparent);
}
.badge.ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: color-mix(in oklab, var(--ok) 40%, transparent);
}
.badge.muted {
  color: var(--muted);
  background: var(--surface-3);
  border-color: var(--border);
}

/* ───────────────────────── lists ───────────────────────── */

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.list li:hover {
  border-color: var(--border-strong);
}
.list .item-name {
  font-weight: 500;
  font-size: 0.92rem;
}
.list .item-sub {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", monospace;
}

.link-muted {
  color: var(--muted-strong);
}
.link-muted:hover {
  color: var(--text);
}

/* ───────────────────────── empty states ───────────────────────── */

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--surface-2) 50%, transparent);
}
.empty.empty-tight {
  padding: 14px;
  text-align: left;
}
.empty-emoji {
  font-size: 2rem;
  margin-bottom: 8px;
}
.empty h3 {
  margin-bottom: 4px;
  color: var(--text);
}

/* ───────────────────────── modal ───────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.18s ease both;
}
.modal.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative;
  width: min(440px, 100%);
  z-index: 51;
  box-shadow: var(--shadow-lg);
  animation: fade-up 0.22s ease both;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* ───────────────────────── toast ───────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: fade-up 0.2s ease both;
}

/* ───────────────────────── footer ───────────────────────── */

.footer {
  text-align: center;
  padding: 28px 24px;
  border-top: 1px solid var(--border);
  margin-top: 32px;
  background: color-mix(in oklab, var(--surface) 50%, transparent);
}

/* ───────────────────────── motion ───────────────────────── */

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ───────────────────────── focus ───────────────────────── */

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 8px;
}
