:root {
  color-scheme: light;
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --border: #e4e4e7;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --destructive: #dc2626;
  --destructive-foreground: #fafafa;
  --success: #16a34a;
  --success-foreground: #fafafa;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --radius: 0.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --background: #09090b;
    --foreground: #fafafa;
    --card: #18181b;
    --card-foreground: #fafafa;
    --border: #27272a;
    --primary: #fafafa;
    --primary-foreground: #18181b;
    --destructive: #7f1d1d;
    --destructive-foreground: #fafafa;
    --success: #166534;
    --success-foreground: #fafafa;
    --muted: #27272a;
    --muted-foreground: #a1a1aa;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
}

a {
  color: inherit;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.nav-links,
.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  min-height: 44px;
  padding: 0 0.75rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--muted);
  color: var(--foreground);
  outline: 2px solid var(--border);
  outline-offset: -2px;
}

.nav-logout {
  display: inline-flex;
}

.btn-link {
  background: none;
  border: none;
  padding: 0 0.75rem;
  min-height: 44px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-link:hover,
.btn-link:focus-visible {
  background: var(--muted);
  color: var(--foreground);
  outline: 2px solid var(--border);
  outline-offset: -2px;
}

.household-name {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
}

.household-name a {
  text-decoration: none;
  border-radius: var(--radius);
  padding: 0.125rem 0.375rem;
  margin: -0.125rem -0.375rem;
  transition: background-color 0.15s ease;
}

.household-name a:hover,
.household-name a:focus-visible {
  background: var(--muted);
  outline: 2px solid var(--border);
  outline-offset: -2px;
}

.household-actions {
  margin-bottom: 0.75rem;
}

.stats-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.stat-card {
  flex: 1;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.stat-label {
  color: var(--muted-foreground);
  font-size: 0.75rem;
  margin: 0.125rem 0 0;
}

.stats-bar {
  display: flex;
  height: 0.5rem;
  border-radius: 999px;
  overflow: hidden;
  background: var(--muted);
  margin-bottom: 1.5rem;
}

.stats-bar-segment {
  height: 100%;
}

.stats-bar-overdue {
  background: var(--destructive);
}

.stats-bar-due {
  background: var(--foreground);
  opacity: 0.6;
}

.card-link {
  display: block;
  text-decoration: none;
}

.card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.card-meta {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.op-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.op-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.op-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
}

.badge-overdue {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.badge-due {
  background: var(--muted);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

.badge-done {
  background: var(--success);
  color: var(--success-foreground);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.btn-sm {
  min-height: 44px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.field-group {
  margin-bottom: 1rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-bar .field-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 140px;
}

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.field-group input,
.field-group select,
.field-group textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-size: 1rem;
  font-family: inherit;
}

.field-group input[type="checkbox"] {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
}

.input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  font-size: 1rem;
  font-family: inherit;
}

.input-inline {
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  flex: 1;
}

.toast-container {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.15);
  font-size: 0.875rem;
}

.toast-success {
  border-color: var(--primary);
}

.toast-error {
  background: var(--destructive);
  color: var(--destructive-foreground);
  border-color: var(--destructive);
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  min-height: 24px;
  min-width: 24px;
  cursor: pointer;
  opacity: 0.7;
}

.errorlist {
  color: var(--destructive);
  font-size: 0.8125rem;
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table thead th {
  color: var(--muted-foreground);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

.data-table tbody tr:nth-child(even) {
  background: var(--muted);
}

.data-table tbody tr.overdue {
  background: color-mix(in srgb, var(--destructive) 12%, transparent);
}

.data-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.data-table th[data-sort]::after {
  content: "⇅";
  opacity: 0.4;
  margin-left: 0.25rem;
  font-size: 0.75rem;
}

.data-table th[data-sort].sorted-asc::after {
  content: "↑";
  opacity: 1;
}

.data-table th[data-sort].sorted-desc::after {
  content: "↓";
  opacity: 1;
}
