/* Домашний центр 2.0 — мобильный стиль */

:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6b7388;
  --border: #e6e9f0;
  --accent: #1f6feb;
  --accent-2: #e8f0ff;
  --success: #2ea44f;
  --danger: #d9363e;
  --warning: #b66a00;
  --warning-bg: #fff5e0;
  --shadow: 0 1px 2px rgba(20,30,50,.04), 0 4px 12px rgba(20,30,50,.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px; /* место под нижнюю навигацию */
}

/* ---------- Экраны ---------- */
.screen { display: block; }
.screen[hidden] { display: none; }

/* ---------- Auth-экран ---------- */
#authScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
}
#authScreen[hidden],
#appScreen[hidden] {
  display: none;
}
.auth-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-logo {
  font-size: 48px;
  text-align: center;
  line-height: 1;
}
.auth-title {
  font-size: 24px;
  margin: 0;
  font-weight: 700;
  text-align: center;
}
.auth-version {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: -8px;
}
.auth-status {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 14px;
  text-align: center;
}
.auth-status.error { background: #fdecee; color: var(--danger); }
.auth-status.ok { background: #e7f6ec; color: var(--success); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 13px;
  color: var(--muted);
}
.field input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}
.primary-btn {
  height: 46px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:active { transform: scale(.98); }
.primary-btn:disabled { opacity: .55; cursor: progress; }
.primary-btn.wide { width: 100%; }
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
}
.auth-toggle { text-align: center; }
.auth-help {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  margin-top: 4px;
}

/* Household panel */
.panel-title {
  font-size: 16px;
  margin: 0 0 6px;
  font-weight: 600;
}
.panel-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.household-block { display: flex; flex-direction: column; gap: 8px; }
.block-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.household-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  position: relative;
  margin: 4px 0;
}
.household-divider::before,
.household-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.household-divider::before { left: 0; }
.household-divider::after { right: 0; }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.header-left { min-width: 0; flex: 1 1 auto; }
.app-header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.user-line {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ---------- Cloud banner ---------- */
.cloud-banner {
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 13px;
  padding: 8px 16px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

main { padding: 12px 16px 24px; }

.page { animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(2px);} to { opacity:1; transform:none;} }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.date-line {
  font-size: 15px;
  color: var(--muted);
}
.counter-line {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 600;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: 8px;
}

.total-line {
  font-size: 17px;
}
.total-line strong { font-size: 22px; }

/* ---------- Формы ---------- */
.row-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.row-form input[type="text"],
.row-form input[type="number"],
.row-form select {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.row-form input:focus,
.row-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}
.row-form > button[type="submit"]:not(.wide) {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
}
.row-form button[type="submit"]:active { transform: scale(.97); }

/* Форма заметок — расширенная */
.note-form {
  flex-wrap: wrap;
}
.note-form input[type="text"],
.note-form textarea {
  flex: 1 1 100%;
  width: 100%;
}
.note-form textarea {
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: 16px/1.4 inherit;
  resize: vertical;
  outline: none;
}
.note-form textarea:focus,
.note-form input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-2);
}

/* ---------- Кнопки ---------- */
button, .ghost-btn {
  font-family: inherit;
}
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.ghost-btn:active { background: var(--accent-2); }

.danger-btn {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--danger);
  background: #fff;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.danger-btn:active { background: #fdecee; }

/* ---------- Списки ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.list li.done .item-title,
.list li.done .item-sub {
  color: var(--muted);
  text-decoration: line-through;
}
.item-check {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  border: 2px solid #c5cad6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
}
.list li.done .item-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.item-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.item-title {
  font-size: 16px;
  word-break: break-word;
}
.item-sub {
  font-size: 13px;
  color: var(--muted);
}
.item-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.item-del {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-size: 18px;
  cursor: pointer;
}
.item-del:active { background: #fdecee; }

.note-card {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.note-card .item-main { width: 100%; }
.note-card .note-text {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 4px;
}
.note-card .item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cat-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 15px;
  border-bottom: 1px dashed var(--border);
}
.cat-list li:last-child { border-bottom: 0; }

.empty-hint {
  text-align: center;
  color: var(--muted);
  margin: 24px 0;
  font-size: 14px;
}

/* ---------- Нижняя навигация ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid var(--border);
  max-width: 720px;
  margin: 0 auto;
}
.nav-btn {
  appearance: none;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 56px;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.nav-btn:active { background: var(--accent-2); }
.nav-btn.active {
  color: var(--accent);
  background: var(--accent-2);
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 96px;
  background: rgba(28,35,51,.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 50;
  max-width: 80vw;
  text-align: center;
}
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }

/* ---------- Модалка ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20,30,50,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}
.modal-text {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 12px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
.modal-actions .primary-btn,
.modal-actions .ghost-btn {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 16px;
  width: auto;
}
.modal-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}
.invite-code-box {
  background: var(--accent-2);
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 4px;
  text-align: center;
  padding: 14px;
  border-radius: 10px;
  margin: 10px 0 4px;
  user-select: all;
}
.migrate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--muted);
}
.migrate-list li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.migrate-list li:last-child { border-bottom: 0; }

/* ---------- Адаптив ---------- */
@media (max-width: 360px) {
  .row-form input[type="text"] { flex-basis: 100%; }
  .row-form { flex-wrap: wrap; }
  .auth-title { font-size: 22px; }
}
