/* Health – веб-ресурс. Одна адаптивная версия (Р13): телефон – основной экран, десктоп – та же колонка шире. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #1c1f1d;
  --muted: #6b716c;
  --line: #dde1dc;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4d00;
  --err: #b3261e;
  --ok: #2f6f5e;
  --radius: 14px;
  --gap: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1f2224;
    --surface-2: #272b2d;
    --text: #eceeea;
    --muted: #9aa19b;
    --line: #33383a;
    --accent: #7cc5ad;
    --accent-ink: #0e1f19;
    --warn-bg: #3a3017;
    --warn-ink: #f2d38a;
    --err: #ff8a80;
    --ok: #7cc5ad;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) var(--gap) 8px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 12px; max-width: 720px; margin: 0 auto; }
.brand { font-weight: 700; letter-spacing: .02em; }
.owner-name { margin-left: auto; color: var(--muted); font-size: 14px; }
.owner-switch {
  margin-left: auto; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px;
}
.banner {
  max-width: 720px; margin: 8px auto 0; padding: 8px 12px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-ink); font-size: 14px;
}

.view { max-width: 720px; margin: 0 auto; padding: var(--gap); }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 20px 0 10px; }
.sub { color: var(--muted); font-size: 14px; margin: -10px 0 16px; }
h2.flat { margin-top: 0; }
.day-title { flex: 3 1 auto; text-align: center; margin: 0; font-size: 20px; }
.row > .ghost[aria-label] { flex: 0 0 48px; font-size: 20px; padding: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: var(--gap); margin-bottom: 12px;
}
.narrow { max-width: 420px; margin: 8vh auto 0; }

label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
input, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[readonly], input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.code-input { font-size: 28px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none;
}
button.wide { width: 100%; margin-top: 16px; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button.link { background: none; color: var(--accent); padding: 8px 0; font-weight: 500; }
button.danger { background: transparent; color: var(--err); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 auto; }

.msg { margin-top: 12px; font-size: 14px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* итоги дня */
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; text-align: center; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .u { font-size: 11px; color: var(--muted); }

.meal { padding: 0; overflow: hidden; }
.meal summary {
  list-style: none; cursor: pointer; padding: 14px var(--gap);
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
}
.meal summary::-webkit-details-marker { display: none; }
.meal .name { font-weight: 600; }
.meal .kcal { font-weight: 600; font-variant-numeric: tabular-nums; }
.meal .bju { grid-column: 1 / -1; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.entries { list-style: none; margin: 0; padding: 0 var(--gap) 12px; border-top: 1px solid var(--line); }
.entries li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.entries li:last-child { border-bottom: 0; }
.entries .d { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

.status-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 4px 0 12px; }

/* подключение TOTP */
.qr { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; }
.qr img { width: 220px; height: 220px; image-rendering: pixelated; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; word-spacing: .35em; text-align: center; margin: 12px 0 0; user-select: all; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; margin: 12px 0; }
.codes span { background: var(--surface-2); border-radius: 8px; padding: 8px; text-align: center; user-select: all; }
ol.steps { padding-left: 20px; margin: 0 0 8px; }
ol.steps li { margin: 4px 0; }

/* сессии */
.sess { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.sess:last-child { border-bottom: 0; }
.sess .ua { font-size: 14px; word-break: break-word; }
.sess .meta { grid-column: 1; color: var(--muted); font-size: 13px; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs a { flex: 1 1 0; max-width: 200px; text-align: center; padding: 10px 4px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs a.on { color: var(--accent); background: var(--surface-2); }

.foot { text-align: center; padding: 12px var(--gap) 20px; font-size: 12px; }
.foot a { color: var(--muted); }

@media (min-width: 760px) {
  .tabs { position: static; border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); padding: 6px; }
  body { padding-bottom: 0; }
  .view { padding-top: 24px; }
}
