:root {
  --bg: #f8fafc;
  --bg-gradient-top: #f8fafc;
  --bg-gradient-bottom: #eef2ff;
  --panel: #ffffff;
  --panel-dark: #0f172a;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: rgba(226, 232, 240, 0.8);
  --primary: #0f172a;
  --primary-contrast: #ffffff;
  --secondary-bg: #eef2ff;
  --secondary-text: #1e293b;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --radius: 24px;
}


* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bottom) 100%);
  color: var(--text);
  min-height: 100vh;
  transition: background 180ms ease, color 180ms ease;
}

body,
.card,
.card-inline,
.item-card,
input,
textarea,
select,
.btn,
.tab-btn {
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

a { color: inherit; }

.card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-inline {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.dark-panel {
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 35%), var(--panel-dark);
  color: #fff;
}

.auth-shell,
.app-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: center;
  padding: 32px 0;
}

.hero-panel,
.auth-panel,
.section-card,
.stat-card { padding: 28px; }

.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.badge { background: rgba(255,255,255,0.14); color: #fff; }
.pill { background: var(--secondary-bg); color: var(--secondary-text); }
.pill-accent { background: #fef3c7; color: #92400e; }
.pill-success { background: var(--success-soft); color: var(--success); }

.hero-panel h1,
.dashboard-header h1 {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1.02;
  margin: 18px 0 14px;
}

.hero-panel p,
.muted { color: var(--muted); }
.dark-panel p { color: rgba(255,255,255,0.75); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 26px;
}

.mini-card {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  font-weight: 600;
}

.tab-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  background: var(--line);
  border-radius: 18px;
  margin-bottom: 22px;
}

.tab-btn,
.btn {
  border: 0;
  border-radius: 16px;
  font: inherit;
  cursor: pointer;
}

.tab-btn {
  padding: 12px 14px;
  background: transparent;
  font-weight: 700;
  color: var(--muted);
}

.tab-btn.active { background: var(--panel); color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-stack,
.inline-edit-grid {
  display: grid;
  gap: 16px;
}

label span,
.sr-only {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  background: var(--panel);
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.15);
  border-color: #93c5fd;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  text-decoration: none;
  font-weight: 700;
}

.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-secondary { background: var(--secondary-bg); color: var(--secondary-text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 14px; }

.flash {
  position: sticky;
  top: 14px;
  z-index: 30;
  width: min(900px, calc(100% - 32px));
  margin: 14px auto 0;
  padding: 14px 18px;
  border-radius: 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
}
.flash-success { background: var(--success-soft); color: var(--success); }
.flash-error { background: var(--danger-soft); color: #991b1b; }

.app-shell { padding: 24px 0 48px; }
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow { color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.header-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.search-form { display: flex; gap: 12px; align-items: center; }
.search-form input { min-width: 300px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.stat-card strong { font-size: 2rem; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}

.column-stack,
.item-list { display: grid; gap: 18px; }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin: 0 0 8px; }

.item-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--panel);
}

.item-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.item-meta-row h3 { margin: 0; font-size: 1.1rem; }
.item-main p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
.item-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.item-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: start; justify-content: end; }
.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 22px;
  color: var(--muted);
  text-align: center;
}
.completed,
.completed-copy {
  text-decoration: line-through;
  color: #94a3b8 !important;
}

.inline-edit-form {
  grid-column: 1 / -1;
  display: none;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.inline-edit-form.is-open {
  display: block;
}

.inline-edit-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-edit-full {
  grid-column: 1 / -1;
}

.inline-edit-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .auth-shell,
  .dashboard-grid,
  .stats-grid,
  .feature-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-header,
  .header-actions,
  .search-form,
  .item-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .search-form input { min-width: 0; }
  .inline-edit-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .auth-shell,
  .app-shell { width: min(100% - 20px, 1200px); }
  .hero-panel,
  .auth-panel,
  .section-card,
  .stat-card { padding: 20px; }
  .btn { width: 100%; }
  .inline-edit-actions { flex-direction: column; }
}
