/* HouseList — dark theme, mobile-first */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #232838;
  --border: #2a2f40;
  --text: #e5e7eb;
  --muted: #8b91a5;
  --accent: #4ade80;
  --accent-dim: rgba(74, 222, 128, 0.12);
  --danger: #f87171;
  --slate: #64748b;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.accent { color: var(--accent); }

/* ---------- Shared controls ---------- */

.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px; /* 16px+ prevents iOS zoom-on-focus */
  outline: none;
}

.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b91a5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.btn {
  min-height: 44px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.btn:disabled { opacity: 0.55; cursor: default; }

a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #0c1a10;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ---------- Login page ---------- */

.login-body { display: flex; min-height: 100dvh; }

.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  display: flex;
  flex-direction: column;
}

.login-title {
  margin: 0;
  font-size: 28px;
  text-align: center;
}

.login-sub {
  margin: 4px 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 12px 0 6px;
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  margin: 12px 0 0;
  text-align: center;
}

.login-card .btn-primary { margin-top: 18px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-title { margin: 0; font-size: 20px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar .btn-ghost { min-height: 40px; padding: 6px 12px; font-size: 14px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ---------- Toolbar (search + filters) ---------- */

.toolbar {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 0;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.pill {
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.pill-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b91a5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

/* ---------- Sections & item cards ---------- */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px calc(32px + env(safe-area-inset-bottom));
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  margin: 20px 0 10px;
}

.count-badge {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 9px;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-msg {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 12px 0;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.item-card.pending { opacity: 0.55; }

.section-have .item-card { opacity: 0.75; }

.item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-name { font-weight: 700; font-size: 16px; word-break: break-word; }

.section-have .item-name {
  font-weight: 600;
  text-decoration: line-through;
  text-decoration-color: var(--slate);
}

.item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn.check { color: var(--accent); background: var(--accent-dim); border-color: transparent; }
.icon-btn.undo  { color: var(--slate); }
.icon-btn.del   { color: var(--danger); }

.item-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
}

.badge-amount { background: var(--surface-2); color: var(--text); }

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

.badge-for { background: var(--surface-2); color: var(--text); }

.badge-time { color: var(--muted); font-weight: 500; padding-left: 0; }

.item-notes {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.item-notes .notes-text {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-notes.expanded .notes-text { display: block; }

/* ---------- Add-item form ---------- */

.add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.add-form .input {
  background: var(--surface-2);
  border-color: transparent;
}
.add-form .input:focus { border-color: var(--accent); }

.add-row { display: flex; gap: 8px; }
.add-row > * { flex: 1; min-width: 0; }
.add-row .input-amount,
.add-row .input-unit { flex: 0 0 76px; }

/* ---------- Admin page ---------- */

.topbar-sub { color: var(--muted); font-weight: 500; }

.hint {
  color: var(--muted);
  font-size: 14px;
  margin: -2px 0 10px;
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.admin-row-main { flex: 1; min-width: 0; }

.admin-row-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  word-break: break-word;
}

.admin-row-you { color: var(--muted); font-weight: 500; font-size: 13px; }

.admin-row-date {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
}

.badge-admin {
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
}

.color-input {
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 5px; }
.color-input::-webkit-color-swatch { border: none; border-radius: 6px; }
.color-input::-moz-color-swatch { border: none; border-radius: 6px; }

.add-form .color-input { background: var(--surface); }

.color-field,
.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.check-field input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.ghost-swatch {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  z-index: 50;
  max-width: calc(100% - 32px);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%);
}

/* ---------- Wider screens ---------- */

@media (min-width: 700px) {
  .topbar { padding-left: 24px; padding-right: 24px; }
  .topbar-title { font-size: 22px; }
}
