/* Stage C: «Обзор» layout (period bar, collapsible sections), profile menu, «?» tooltips, phone shell
   (compact sticky header, bottom navigation, cards, 44 px targets). Loads last; tokens come from style.css. */

/* ---------- «?» hints ---------- */
span.hint { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 4px; border: 1px solid var(--line-strong); border-radius: 50%;
  font: 600 10px/1 var(--font); letter-spacing: 0; text-transform: none; color: var(--text-3); cursor: help; vertical-align: middle; transition: color .15s, border-color .15s; }
span.hint:hover, span.hint:focus-visible { color: var(--gold-text); border-color: var(--gold-mid); }
span.hint::after { content: ""; position: absolute; inset: -10px; }
#hint-tip { position: fixed; z-index: 70; max-width: min(300px, calc(100vw - 16px)); padding: 8px 11px; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow); font: 400 12.5px/1.45 var(--font); letter-spacing: 0; text-transform: none; pointer-events: none; text-wrap: pretty; }

/* ---------- header: refresh + profile menu ---------- */
.ico-refresh { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#refresh-btn .spinner:not([hidden]) + .ico-refresh { display: none; }
.top-right { flex-wrap: nowrap; }
.profile { position: relative; }
.profile-btn { gap: 8px; padding: 0 10px 0 6px; }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--gold-tint); color: var(--gold-text); font-weight: 600; font-size: 13px; border: 1px solid var(--line-strong); }
.profile-btn #whoami { padding: 0; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-btn .chev { width: 14px; height: 14px; stroke: var(--text-3); transition: transform .2s var(--ease); }
.profile-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu { position: absolute; z-index: 30; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 6px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-md); box-shadow: var(--shadow); }
.menu:not([hidden]) { animation: pop .18s var(--ease) both; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.menu-note { margin: 4px 10px 6px; font-size: 12px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; background: none; border: 0; border-radius: var(--r-sm); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background-color .12s; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item.danger { color: var(--bad); }
.menu-item.on { color: var(--gold-text); font-weight: 600; }
.menu-item.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.menu .badge { margin-left: auto; }

/* ---------- tab bar fade ---------- */
.tabs-wrap { position: sticky; top: 0; z-index: 5; background: var(--bg); }
.tabs-wrap .tabs { position: static; }
.tabs-wrap::before, .tabs-wrap::after { content: ""; position: absolute; top: 0; bottom: 1px; width: 28px; z-index: 2; pointer-events: none; opacity: 0; transition: opacity .2s; }
.tabs-wrap::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.tabs-wrap::after { right: 0; background: linear-gradient(to left, var(--bg), transparent); }
.tabs-wrap.fade-l::before, .tabs-wrap.fade-r::after { opacity: 1; }
.bottom-nav { display: none; }

/* ---------- «Обзор» ---------- */
.ov-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
#dash-range { font-size: 12.5px; }
.stack-gap > .sec-head { margin-bottom: 0; }
.sub-title { margin: 0 0 8px; }
.form-actions { display: flex; align-items: flex-end; }
.empty-act { display: grid; justify-items: start; gap: 8px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.empty-act p { margin: 0; color: var(--text-2); max-width: 56ch; }
.empty-act strong { font-size: 15px; }

/* collapsible sections */
details.fold { margin: 0; }
details.fold > summary { font: 600 12px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
.fold-note { margin-left: auto; font: 500 12px/1.2 var(--font); letter-spacing: 0; text-transform: none; color: var(--gold-text); }
.fold-note:empty { display: none; }
details.fold > summary::after { content: none; }
.fold-body .block { background: none; border: 0; box-shadow: none; padding: 0; }
.fold-body .block > h2 { margin-top: 0; }
.fold-body .section-title { margin-top: 0; }
.fold-body .grid + .grid { margin-top: 12px; }
.fold-body > .kpis:last-child, .fold-body > .cards:last-child { margin-bottom: 0; }
.fold-body .table-wrap + .btn { margin-top: 10px; }
.q-group + .q-group { margin-top: 16px; }
.q-group > h3 { margin: 0 0 8px; color: var(--text); }
.q-group > .btn { margin-top: 8px; }
.q-group .table-wrap { margin: 0; }

/* «Новое с прошлого обновления» */
.ch-counters { list-style: none; margin: 4px 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ch-counters li { display: grid; gap: 0; min-width: 84px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-3); }
.ch-counters li b { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ch-counters li span { font-size: 12px; }
.ch-counters li.has { border-color: color-mix(in srgb, var(--gold) 40%, var(--line)); background: var(--gold-tint); color: var(--text-2); }
.ch-counters li.has b { color: var(--gold-text); }
.ch-more { margin: 4px 0 8px; }
.ch-more > summary, .ch-hist > summary { cursor: pointer; color: var(--gold-text); min-height: 32px; display: flex; align-items: center; }
.ch-more .ch-list { margin-top: 6px; }
.dash-kpi .l { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }

/* ---------- touch targets ---------- */
@media (pointer: coarse), (max-width: 700px) {
  a.tap { display: inline-flex; align-items: center; min-height: 44px; }
  .tcard .mv .btn, .mv-btn { min-width: 44px; min-height: 44px; font-size: 18px; }
  .exp-toggle { width: 44px; height: 44px; }
  .menu-item { min-height: 44px; }
  .btn.small { min-height: 44px; }
  .chip { min-height: 44px; }
}

@media (max-width: 700px) {
  .table-wrap:has(> table.mcards) { overflow: visible; background: none; border: 0; max-height: none; }
  .data.mcards td.ttl { order: -1; font-weight: 600; }
  .data.mcards td.full { grid-column: 1 / -1; }
  .data.mcards td.actions .btn { width: 100%; }
  .data.mcards .row-actions { white-space: normal; }
  .data.mcards tr.src-row { box-shadow: inset 3px 0 0 var(--gold-mid); }
  .data.mcards tr.child-row { margin-left: 14px; background: none; }
  .data.mcards .child-label { padding-left: 0; }
  .fold-body { padding: 0 12px 14px; }
  details.block > summary { padding: 12px; }
  .ov-bar { flex-direction: column; align-items: stretch; }
}

/* ---------- phones ---------- */
@media (max-width: 600px) {
  .top { position: sticky; top: 0; z-index: 20; flex-wrap: nowrap; gap: 8px; min-height: 64px; padding: 8px 12px; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--surface) 92%, transparent); }
  .brand-logo { height: 22px; }
  .brand-tag { display: none; }
  .top-right { width: auto; gap: 6px; flex: none; }
  #status-line { display: none; }
  #refresh-btn { flex: none; order: 0; width: 44px; padding: 0; }
  #refresh-btn .label { display: none; }
  .profile-btn { width: 44px; padding: 0; }
  .profile-btn #whoami, .profile-btn .chev { display: none; }
  .avatar { width: 30px; height: 30px; }
  .menu { position: fixed; right: 12px; top: 68px; }
  .banner { padding: 8px 12px; }
  .tabs-wrap { display: none; }
  main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line-strong); }
  .nav-btn { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 52px; min-width: 0; padding: 4px 2px; background: none; border: 0; border-radius: var(--r-sm);
    color: var(--text-3); font: 500 11px/1.2 var(--font); cursor: pointer; transition: color .15s, background-color .15s; }
  .nav-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
  .nav-btn.on { color: var(--gold-text); background: var(--gold-tint); }
  .menu.sheet { position: absolute; right: 8px; left: auto; top: auto; bottom: calc(100% + 8px); min-width: 230px; }
  .dash-bar, .ov-bar { gap: 8px; }
  .seg button { min-height: 44px; }
  .data.mcards tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .acq-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid, .grid.eq { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { .menu:not([hidden]) { animation: none; } }

/* forms: labelled inline adders, secret rows */
.cat-add label, .filters label:not(.inline) { flex: 1 1 200px; }
.cat-add .btn, .filters > .btn.primary:last-child { align-self: flex-end; }
.secret-row { align-items: end; }
.secret-row .secret-del { min-width: 44px; min-height: 44px; }
.filters:has(> label) { align-items: flex-end; }

/* settings: events table */
.ev-table { width: 100%; border-collapse: collapse; }
.ev-table th, .ev-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
.ev-table thead th { color: var(--text-3); font: 600 12px/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.ev-table tbody th { font-weight: 400; color: var(--text); }
.ev-table td { width: 1%; text-align: center; white-space: nowrap; }
.ev-table tr.off th { color: var(--text-3); }
.ev-table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }

/* touch: chips, toggles, small links reach 44 px */
@media (pointer: coarse), (max-width: 700px) {
  .linklike, .badge.linklike { display: inline-flex; align-items: center; min-height: 44px; }
  .exp-toggle { min-height: 44px; }
  .cat-chip { padding: 2px 4px 2px 10px; }
  .cat-chip .btn.small, .cat-chip .btn.icon { min-height: 44px; min-width: 44px; }
  .cat-name { min-height: 44px; }
  .cat-dot { width: 28px; height: 28px; position: relative; }
  .cat-dot::after { content: ""; position: absolute; inset: -8px; }
  .inline { flex-wrap: wrap; }
  input[type=file] { max-width: 100%; }
  .data.mcards .trunc { white-space: normal; overflow-wrap: anywhere; }
}
@media (pointer: coarse), (max-width: 700px) {
  .exp-toggle { height: 44px; }
  .inline { max-width: 100%; }
  .inline input[type=file] { width: 100%; min-width: 0; }
}
@media (max-width: 700px) {
  .data.mcards .bind-select, .links-table .bind-select { min-width: 0; width: 100%; }
  .data.mcards td { min-width: 0; }
  .data.mcards td.full select { width: 100%; }
}
@media (pointer: coarse), (max-width: 700px) { .date-cal { min-width: 44px; min-height: 44px; } .date-wrap .date-in { width: 11ch; } }
