:root {
  --bg: #eef4e8; --card: #ffffff; --text: #15231a; --muted: #6a786c; --line: #e4ebdd;
  --accent: #3f9a26; --accent-2: #8fd13f; --accent-soft: #e2f3d5; --on-accent: #fff;
  --grad: linear-gradient(135deg, #8fd13f 0%, #4fae2c 55%, #2f8f2a 100%);
  --shadow: 0 1px 2px rgba(30, 70, 20, .06), 0 8px 24px rgba(30, 70, 20, .08);
  --good: #2c8a1c; --bad: #c0392b; --promo: #b45309; --promo-soft: #fdefd3;
  --glass: rgba(255, 255, 255, .82);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c120d; --card: #172019; --text: #e9f2e6; --muted: #93a394; --line: #263226;
    --accent: #86d94e; --accent-2: #b4ec7a; --accent-soft: #1d3317; --on-accent: #0b1f06;
    --grad: linear-gradient(135deg, #5fb92f 0%, #2f8a25 55%, #1d6a22 100%);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --good: #86d94e; --bad: #ff8a7a; --promo: #fbbf24; --promo-soft: #3a2d10;
    --glass: rgba(23, 32, 25, .85);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Шапка: зелёный градиент со скруглённым низом */
#top {
  display: flex; align-items: center; gap: 4px; position: relative; z-index: 2;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 18px;
  background: var(--grad); color: #fff;
  border-radius: 0 0 26px 26px; box-shadow: 0 6px 22px rgba(47, 143, 42, .28);
}
#top h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#back { border: 0; background: rgba(255, 255, 255, .22); color: #fff; width: 36px; height: 36px; border-radius: 12px; font-size: 26px; line-height: 1; padding: 0 0 4px; margin-right: 8px; flex: none; }

#view { flex: 1; overflow-y: auto; padding: 18px 16px 110px; max-width: 720px; width: 100%; margin: 0 auto; }

/* Нижняя панель: парящая «таблетка» */
#tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px);
  max-width: 520px; margin: 0 auto; z-index: 5;
  display: flex; gap: 2px; padding: 6px;
  background: var(--glass); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
}
#tabs button {
  flex: 1; border: 0; background: none; padding: 7px 0 6px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; border-radius: 18px;
  transition: background .2s, color .2s;
}
#tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { background: var(--grad); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(63, 154, 38, .35); }

.card { background: var(--card); border-radius: 20px; margin-bottom: 14px; overflow: hidden; box-shadow: var(--shadow); }
.pad { padding: 16px; }
.hero { background: var(--grad); color: #fff; position: relative; }
.hero::after {
  content: ""; position: absolute; right: -40px; top: -60px; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0) 70%); pointer-events: none;
}
.hero .muted { color: rgba(255, 255, 255, .88); }
.hero .good { color: #fff; font-weight: 600; }
.hero .bad { color: #fff; font-weight: 600; background: rgba(160, 30, 20, .55); padding: 4px 8px; border-radius: 8px; display: inline-block; }
.hero .label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.hero .btns { margin: 14px 0 0; position: relative; z-index: 1; }
.hero .btn { background: #fff; color: #2f8f2a; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.hero .btn.ghost { background: rgba(255, 255, 255, .22); color: #fff; box-shadow: none; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%;
  border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
}
.row:last-child { border-bottom: 0; }
button.row:active { background: var(--accent-soft); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .r b { display: block; }
.row .r small { color: var(--muted); }
.wrap .t, .wrap .s { white-space: normal; }
.ava {
  width: 42px; height: 42px; border-radius: 14px; flex: none; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}

h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 6px 10px; }
h2:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.good { color: var(--good); } .bad { color: var(--bad); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--promo-soft); color: var(--promo); vertical-align: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 16px; padding: 14px 18px; font-weight: 700;
  background: var(--grad); color: #fff; width: 100%; box-shadow: 0 6px 16px rgba(63, 154, 38, .3);
  transition: transform .1s;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn.danger { background: none; color: var(--bad); border: 1.5px solid var(--line); box-shadow: none; }
.btn:disabled { opacity: .6; }
.btns { display: flex; gap: 10px; margin-bottom: 14px; }
.btns .btn.ghost { flex: 0 0 auto; width: auto; }

input[type=text], input[type=password], input[type=search], input[type=date], input[type=number], select {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.big { font-size: 36px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.bar { margin-bottom: 13px; }
.bar:last-child { margin-bottom: 0; }
.bar .lab { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 5px; }
.bar .lab span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.bar .track { height: 9px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.bar .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.fact { background: var(--card); border-radius: 18px; padding: 13px 15px; min-width: 0; box-shadow: var(--shadow); border-left: 4px solid var(--accent-2); }
.fact b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.fact span { color: var(--muted); font-size: 13px; }

.edit-item { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.edit-item:last-child { border-bottom: 0; }
.edit-item .line { display: grid; grid-template-columns: 1fr 1fr 46px; gap: 8px; margin-top: 8px; }
.edit-item .del { border: 1.5px solid var(--line); border-radius: 14px; background: none; color: var(--bad); font-size: 20px; }

.check { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.check .main { flex: 1; min-width: 0; }
.check.done .t { text-decoration: line-through; color: var(--muted); }
.check .x { border: 0; background: none; color: var(--muted); font-size: 22px; padding: 0 4px; }
.add { display: flex; gap: 8px; margin-bottom: 14px; }
.add .btn { width: auto; flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; background: var(--card); color: var(--accent); font-weight: 600; border-radius: 99px; padding: 8px 14px; font-size: 14px; box-shadow: var(--shadow); }

.photo { width: 100%; border-radius: 20px; display: block; box-shadow: var(--shadow); }
.login { max-width: 360px; margin: 9vh auto 0; text-align: center; }
.login img { width: 104px; height: 104px; border-radius: 26px; box-shadow: 0 14px 34px rgba(63, 154, 38, .4); }
.login h2 { text-transform: none; letter-spacing: -.01em; font-size: 28px; font-weight: 800; color: var(--text); margin: 18px 0 6px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login input { margin-bottom: 12px; text-align: center; }

.busy { position: fixed; inset: 0; background: rgba(12, 40, 10, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: #fff; z-index: 10; padding: 20px; text-align: center; }
.spin { width: 46px; height: 46px; border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 4s; } #tabs button, .btn { transition: none; } }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 96px);
  max-width: 480px; margin: 0 auto; background: #15231a; color: #fff; padding: 13px 16px;
  border-radius: 16px; z-index: 20; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
