/* СДО: базовые стили оболочки. Mobile-first: телефон - нижняя панель, от 900px - тёмный сайдбар.
   Токены (переменные) можно использовать в стилях модулей: var(--accent), var(--line), var(--muted) и т. д. */
:root {
  --bg: #F4F5F1;
  --surface: #FFFFFF;
  --ink: #16201B;
  --muted: #55665E;
  --line: #DCE3DE;
  --line-strong: #C7D2CB;
  --accent: #0F6B5C;
  --accent-ink: #FFFFFF;
  --accent-hover: #0A4D42;
  --accent-soft: #E3F1ED;
  --side: #16201B;
  --side-ink: #C9D6CF;
  --side-hover: #22302A;
  --warm: #B8641A;
  --flame: #E07A1F;
  --flame-bg: #FFF1E3;
  --flame-ink: #8A4A12;
  --danger: #B3261E;
  --danger-soft: #FCE8E6;
  --ok: #1E7A3C;
  --ok-soft: #E3F4E8;
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
  --tabbar-h: 64px;
  --sidebar-w: 240px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 18px; }
p { margin: 0 0 .75em; }
img, svg { max-width: 100%; }
code, pre, kbd { font-family: var(--mono); font-size: .92em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ic { display: inline-flex; flex: none; }

/* ---------------------------------------------------------------- оболочка */
.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.main { padding: 20px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); min-width: 0; outline: none; }
.page { max-width: 1100px; margin: 0 auto; }
.page-body { display: flex; flex-direction: column; gap: 18px; }
.page-title { font-size: 26px; font-weight: 700; margin: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: #6A7973; text-decoration: none; background: none; border: 0; cursor: pointer; padding: 6px 2px;
}
.tab span:last-child { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab.on { color: var(--accent); font-weight: 600; }
body.fullscreen .tabbar { display: none; }
body.fullscreen .main { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; background: var(--side); padding: 24px 14px;
    position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  }
  .main { padding: 40px 48px 48px; }
  body.fullscreen .main { padding: 24px 32px; }
  .page-title { font-size: 34px; }
}
.brand { color: #FFFFFF; font-weight: 700; font-size: 20px; padding: 4px 12px 20px; text-decoration: none; }
.brand:hover { color: #FFFFFF; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--side-ink); text-decoration: none; font-size: 15px; min-height: 44px;
}
.nav:hover { background: var(--side-hover); color: #FFFFFF; }
.nav.on { background: var(--accent); color: #FFFFFF; }
.nav-btn { background: none; border: 0; width: 100%; cursor: pointer; text-align: left; }
.side-user { border-top: 1px solid #2B3A33; padding-top: 12px; margin-top: 12px; }
.side-user-name { color: #FFFFFF; padding: 4px 12px 6px; font-weight: 600; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- элементы */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
@media (min-width: 900px) { .card { padding: 24px 28px; } }
.card h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer; font-size: 15px; font-weight: 500; text-align: center;
}
.btn:hover { border-color: var(--accent); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn-lg { padding: 13px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; cursor: pointer; }
.icon-btn:hover { background: var(--bg); }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface);
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 13px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--flame-bg); color: var(--flame-ink); border-color: transparent; }

.progress { height: 8px; background: #E6ECE8; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.table td.center, .table th.center { text-align: center; }

.state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 16px; color: var(--muted); text-align: center; }
.state-error { color: var(--danger); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }

.toasts { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 900px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }
.toast { background: var(--ink); color: #FFFFFF; padding: 12px 16px; border-radius: 12px; max-width: 420px; transition: opacity .3s, transform .3s; pointer-events: auto; }
.toast-error { background: var(--danger); }
.toast-ok { background: var(--accent); }
.toast.out { opacity: 0; transform: translateY(8px); }

.dialog, .sheet { border: 0; border-radius: 16px; padding: 20px; max-width: min(440px, calc(100vw - 32px)); color: var(--ink); }
.dialog::backdrop, .sheet::backdrop { background: rgba(22, 32, 27, .45); }
.sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 18px 18px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .sheet { margin: auto; max-width: 420px; border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 8px; }
.sheet-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 16px; text-align: left; }
.sheet-item:hover { background: var(--bg); color: var(--ink); }

/* ---------------------------------------------------------------- вход */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--side); }
.login-card { width: 100%; max-width: 420px; background: var(--bg); border-radius: 18px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 26px; margin: 0; }
.login-brand { font-weight: 700; color: var(--accent); }
.dev-login { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }

/* ---------------------------------------------------------------- главная */
.home-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; }
.streak { display: flex; align-items: center; gap: 10px; background: var(--flame-bg); color: var(--flame); border-radius: 14px; padding: 10px 16px; }
.streak.off { background: #ECEFEC; color: #9AA59F; }
.streak-n { font-size: 18px; font-weight: 700; line-height: 1.15; color: var(--ink); }
.streak-sub { font-size: 13px; color: var(--flame-ink); }
.streak.off .streak-sub { color: var(--muted); }
.streak.risk { outline: 2px dashed var(--flame); outline-offset: -2px; }
.track-card { flex-direction: column; gap: 16px; }
.track-card-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.track-card-title { font-size: 20px; font-weight: 700; }
.track-card-actions { display: flex; flex-direction: column; gap: 10px; }
.track-card.hero { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.track-card.hero .eyebrow { color: #BFE3D9; }
.track-card.hero .muted { color: #D6EDE7; }
.track-card.hero .btn-primary { background: #FFFFFF; color: var(--accent); border-color: #FFFFFF; }
.track-card.hero .btn { background: transparent; color: #FFFFFF; border-color: rgba(255, 255, 255, .5); }
.track-card.hero .btn-primary { background: #FFFFFF; color: var(--accent); }
@media (min-width: 760px) {
  .track-card.hero { flex-direction: row; align-items: center; justify-content: space-between; }
  .track-card.hero .track-card-title { font-size: 26px; }
  .track-card.hero .track-card-actions { flex: none; min-width: 240px; }
}
.today-row { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); text-decoration: none; padding: 4px 0; }
.today-row.link:hover { color: var(--accent); }
.home-cards { display: flex; flex-direction: column; gap: 16px; }
.home-cards:empty { display: none; }
