:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b91c1c;
  --warning-bg: #fff7ed;
  --warning-border: #fed7aa;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 260px);
}

button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: white;
  background: var(--accent);
  cursor: pointer;
  font-weight: 700;
}
button:hover { background: var(--accent-dark); }
button.secondary { background: #e8eefc; color: #1e3a8a; }
button.secondary:hover { background: #dbeafe; }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { background: #f3f4f6; }
button.danger { color: var(--danger); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: #374151;
  font-weight: 700;
}

main { width: min(1320px, calc(100% - 32px)); margin: 0 auto 3rem; }
.app-header {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 2rem 0 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-header h1 { margin: 0; font-size: clamp(2rem, 5vw, 4rem); letter-spacing: -0.06em; }
.eyebrow { margin: 0; text-transform: uppercase; color: var(--accent); font-weight: 800; letter-spacing: 0.12em; font-size: 0.75rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.panel, .card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(229,231,235,0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.panel { padding: 1.1rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }
code { background: #eef2ff; padding: 0.35rem 0.55rem; border-radius: 10px; font-weight: 800; color: #3730a3; }

.setup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.auth-tab { background: none; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 1rem; cursor: pointer; }
.auth-tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.auth-tab:hover:not(.active) { background: var(--bg); }
.form-error { color: var(--danger); font-size: 0.875rem; margin: 0; }
.invite-links { display: flex; flex-direction: column; gap: 0.4rem; }
.invite-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }
button.small { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.join-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; background: var(--warning-bg); border: 1px solid var(--warning-border); margin-bottom: 1rem; }
.join-banner p { margin: 0; }
.join-banner-actions { display: flex; gap: 0.5rem; }
.form-card { padding: 1rem; display: grid; gap: 0.9rem; }
.form-card h2 { margin: 0; }
.compact { box-shadow: none; border: 0; padding: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.household-bar {
  display: grid;
  grid-template-columns: 1fr auto minmax(180px, 260px);
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.household-bar h2 { margin: 0.2rem 0 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat span { display: block; font-size: 2rem; font-weight: 900; letter-spacing: -0.05em; }
.stat small { color: var(--muted); font-weight: 700; }
.content-grid { display: grid; grid-template-columns: 360px 1fr; gap: 1rem; align-items: start; }
.sidebar { display: grid; gap: 1.5rem; }
.toolbar { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(135px, 1fr)); gap: 0.65rem; margin-bottom: 1rem; }
.task-groups { display: grid; gap: 1rem; }
.group-title { margin: 1rem 0 0.5rem; font-size: 1rem; color: #111827; display: flex; gap: 0.5rem; align-items: center; }
.group-title:first-child { margin-top: 0; }
.count-badge { background: #eef2ff; color: #3730a3; padding: 0.18rem 0.45rem; border-radius: 999px; font-size: 0.76rem; }
.task-list { display: grid; gap: 0.7rem; }
.task-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 18px;
  padding: 0.9rem;
}
.task-card.overdue { background: var(--warning-bg); border-color: var(--warning-border); }
.task-main { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: start; }
.task-title-row { display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap; }
.task-card h3 { margin: 0; }
.priority-pill { border-radius: 999px; padding: 0.2rem 0.55rem; font-size: 0.74rem; font-weight: 900; text-transform: uppercase; }
.priority-high { background: #fee2e2; color: #991b1b; }
.priority-medium { background: #fef3c7; color: #92400e; }
.priority-low { background: #dcfce7; color: #166534; }
.task-meta { color: var(--muted); margin: 0.35rem 0 0; line-height: 1.5; }
.task-notes { margin: 0.45rem 0 0; color: #374151; }
.task-actions { display: flex; gap: 0.45rem; flex-wrap: wrap; justify-content: flex-end; }
.task-actions button { padding: 0.55rem 0.7rem; }
.empty { color: var(--muted); border: 1px dashed var(--border); border-radius: 18px; padding: 1rem; text-align: center; }
.history-panel { margin-top: 1rem; }
.history-panel h2 { margin-top: 0; }
.history-list { display: grid; gap: 0.5rem; }
.history-item { border-top: 1px solid var(--border); padding-top: 0.65rem; color: #374151; }

@media (max-width: 1000px) {
  .content-grid, .setup-grid, .household-bar, .stats-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .toolbar, .two-col { grid-template-columns: 1fr; }
  .task-main { grid-template-columns: 1fr; }
  .task-actions { justify-content: flex-start; }
}
