/* BRAYT Хаб — токены и компоненты по экранам артефакта (ТЗ 5). Тёмной темы нет. */
:root {
  --bg: #FAF9F5; --text: #141413; --clay: #D97757; --muted: #5E5D59; --fill: #F0EEE6; --card: #FFFFFF;
  --line: rgba(31,30,29,0.15); --line2: rgba(31,30,29,0.3);
  --ok: #BCD1CA; --wait: #E3DACC; --bad: #EBCECE; --work: #CBCADB; --red: #B5432B;
  --serif: 'Anthropic Serif', Georgia, 'Times New Roman', serif;
  --sans: 'Anthropic Sans', system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--text); text-decoration: none; }
@media (hover: hover) { a:hover { color: var(--clay); } }
button, input, textarea, select { font: inherit; color: inherit; }
.serif { font-family: var(--serif); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.red { color: var(--red) !important; }
.b { font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 8px; }
.between { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* каркас */
.page { max-width: 1280px; margin: 0 auto; padding: 0 32px 48px; }
.topnav { display: flex; align-items: center; gap: 4px; height: 64px; border-bottom: 0.5px solid var(--line2); margin-bottom: 20px; }
.topnav .logo { font-family: var(--serif); font-size: 22px; margin-right: 18px; letter-spacing: .5px; }
.topnav a.nav { padding: 6px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.topnav a.nav.on { background: #EDEBE3; color: var(--text); font-weight: 600; }
.topnav .sep { width: 1px; height: 20px; background: var(--line2); margin: 0 10px; }
.h1 { font-family: var(--serif); font-size: 34px; font-weight: 500; line-height: 1.15; margin: 0; }
.h2 { font-family: var(--serif); font-size: 21px; font-weight: 500; margin: 0; }
.h3 { font-family: var(--serif); font-size: 19px; font-weight: 500; margin: 0; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 4px 0 18px; flex-wrap: wrap; }
.subtabs { display: flex; gap: 4px; }
.subtabs a { white-space: nowrap; padding: 6px 12px 8px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 15px; }
.subtabs a.on { color: var(--text); font-weight: 600; border-bottom-color: var(--clay); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.card { background: var(--card); border: 0.5px solid var(--line); border-radius: 16px; padding: 16px 20px; }
.card.fill { background: var(--fill); border-color: transparent; }
.card.flat { padding: 0; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 0.5px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-family: var(--serif); font-size: 26px; line-height: 1.25; }
.stat .s { font-size: 12px; color: var(--muted); }
.big { font-family: var(--serif); font-size: 30px; line-height: 1.2; }
.bar { height: 8px; background: var(--fill); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--clay); border-radius: 4px; }

/* кнопки */
.btn { height: 44px; padding: 0 16px; border-radius: 10px; border: 0.5px solid var(--line2); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn.dark { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.ghost { border-style: dashed; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; border: 0.5px solid var(--line2); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.seg { display: inline-flex; border: 0.5px solid var(--line2); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 34px; cursor: pointer; font-size: 13px; }
.seg button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { height: 32px; padding: 0 12px; border-radius: 16px; border: 0.5px solid var(--line2); background: var(--card); font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; }
.pill.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

/* чипы статусов */
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--fill); white-space: nowrap; }
.chip.ok { background: var(--ok); } .chip.wait { background: var(--wait); } .chip.bad { background: var(--bad); } .chip.work { background: var(--work); }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--clay); display: inline-block; flex: none; }

/* таблицы */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 10px 8px; border-bottom: 0.5px solid var(--line2); }
table.t td { padding: 11px 8px; border-bottom: 0.5px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #FBFAF7; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list > * + * { border-top: 0.5px solid var(--line); }
.li { padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }

/* формы */
.input, .textarea { width: 100%; border: 0.5px solid var(--line2); border-radius: 10px; background: var(--card); padding: 0 14px; height: 44px; font-size: 15px; }
.textarea { padding: 10px 14px; height: auto; min-height: 64px; resize: vertical; }
label.lbl { font-size: 13px; font-weight: 600; display: block; margin-bottom: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.err { background: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.okmsg { background: var(--ok); border-radius: 10px; padding: 10px 12px; font-size: 13px; }

/* входящие */
.item { background: var(--card); border: 0.5px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.item .meta { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.item .title { font-size: 15px; font-weight: 600; line-height: 1.35; }
.item .txt { font-size: 14px; color: var(--muted); }
.menu { position: absolute; right: 0; top: 48px; background: var(--card); border: 0.5px solid var(--line2); border-radius: 12px; padding: 6px; z-index: 20; min-width: 220px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--fill); }

/* лента/чат */
.bubble { border-radius: 14px; padding: 10px 14px; max-width: 80%; }
.bubble.me { background: var(--fill); align-self: flex-end; }
.bubble.them { background: var(--card); border: 0.5px solid var(--line2); align-self: flex-start; }

/* матрица «по дням» */
.matrix { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix table { border-collapse: collapse; min-width: 100%; }
.matrix th, .matrix td { padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; border-bottom: 0.5px solid var(--line); }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); z-index: 1; }
.matrix td.m { font-weight: 700; }
.matrix td.top { background: var(--fill); }

/* окно ключа */
.overlay { position: fixed; inset: 0; background: rgba(20,20,19,.35); z-index: 40; display: flex; justify-content: flex-end; }
.panel { width: min(700px, 100%); height: 100%; background: var(--bg); overflow-y: auto; padding: 28px; }

/* телефон */
.tabbar { display: none; }
.phonehead { display: none; }
@media (max-width: 760px) {
  .page { padding: 0 16px 96px; }
  .topnav { display: none; }
  .phonehead { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 0 10px; gap: 10px; }
  .h1 { font-size: 28px; }
  .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 14px 16px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 0.5px solid var(--line2); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
  .tabbar a.on { color: var(--text); font-weight: 600; }
  .hide-phone { display: none !important; }
  .panel { padding: 16px; }
  .subtabs { overflow-x: auto; width: 100%; }
  table.t.resp thead { display: none; }
  table.t.resp tr { display: block; padding: 10px 0; border-bottom: 0.5px solid var(--line); }
  table.t.resp td { display: block; border: 0; padding: 2px 0; }
  .stat .v { font-size: 22px; }
}
@media (min-width: 761px) { .hide-desk { display: none !important; } }
.sheet { position: fixed; inset: 0; background: rgba(20,20,19,.35); z-index: 50; display: flex; align-items: flex-end; }
.sheet > div { background: var(--bg); width: 100%; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet a { display: block; padding: 13px 4px; border-bottom: 0.5px solid var(--line); font-size: 16px; }
.banner { background: var(--bad); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.spinner { padding: 40px 0; text-align: center; color: var(--muted); }

/* приложение: офлайн, установка, первый вход и привязка Telegram */
.offbar { position: sticky; top: 0; z-index: 30; margin: 0 -32px; padding: 7px 16px; background: var(--wait); color: var(--text); font-size: 13px; text-align: center; }
.installhint { display: flex; align-items: center; gap: 12px; background: var(--fill); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }
.installhint .x { border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 6px; }
.gate { max-width: 380px; margin: 0 auto; padding-top: 16vh; gap: 14px; }
@media (max-width: 760px) { .offbar { margin: 0 -16px; } .gate { padding-top: 10vh; } }

/* ревью 29.10: тач-зоны ≥ 44 px, тост, «Хвосты», подписи ячеек на телефоне */
.pill { min-height: 44px; height: auto; padding: 0 14px; }
.seg button { min-height: 44px; height: auto; white-space: nowrap; }
.btn.sm { min-height: 44px; }
.subtabs a { min-height: 44px; display: inline-flex; align-items: center; }
.status-select { width: auto; min-height: 44px; height: 44px; font-size: 13px; background: var(--wait); border-color: transparent; font-weight: 600; }
.card .chip, .item .chip { min-height: 32px; display: inline-flex; align-items: center; gap: 4px; }
a.chip { min-height: 44px; padding: 0 12px; }
.chip .x { border: 0; background: none; cursor: pointer; font-size: 16px; padding: 0 2px; color: var(--muted); min-width: 28px; min-height: 28px; }
.topnav { overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.topnav::-webkit-scrollbar { display: none; }
.scrollx { overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.scrollx::-webkit-scrollbar { display: none; }
.card.returned { border-color: var(--red); border-width: 1px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60; display: flex; gap: 12px; align-items: center; background: var(--text); color: var(--bg); border-radius: 12px; padding: 10px 14px; min-width: 260px; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px; }
.toast .btn { background: transparent; color: var(--bg); border-color: rgba(250,249,245,.5); }
@media (min-width: 761px) { .toast { bottom: 24px; } }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px; }
  .stat .v { font-size: 20px; }
  table.t.resp td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: 12px; }
}

/* ---------- цех ---------- */
.fx-hud { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.fx-box { background: var(--card); border: 1.5px solid var(--text); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: 3px 3px 0 var(--text); text-align: left; font-size: 13px; line-height: 1.35; min-width: 180px; flex: 1 1 200px; }
button.fx-box { cursor: pointer; font: inherit; color: inherit; }
.fx-k { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.fx-brake { background: #EBCECE; }
button.fx-box.fx-mine, .fx-mine { background: #141413; color: #FAF9F5; box-shadow: 3px 3px 0 var(--clay); }
.fx-mine .fx-k { color: #E8E6DC; }
.fx-can { background: #FFF3D6; }
.fx-game { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #F4F2EA; }
.fx-game text { font-family: system-ui, sans-serif; }
@keyframes fxmv { from { transform: translateX(0) } to { transform: translateX(16px) } }
.fx-mv { animation: fxmv 1s linear infinite; }
@keyframes fxspin { to { transform: rotate(360deg) } }
.fx-spin { animation: fxspin 2.4s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fxblink { 50% { opacity: .2 } }
.fx-blink { animation: fxblink 1s steps(2) infinite; }
@keyframes fxbob { 50% { transform: translateY(-3px) } }
.fx-bob { animation: fxbob 1.6s ease-in-out infinite; }
@keyframes fxscan { 0%,100% { width: 2px } 50% { width: 16px } }
.fx-scan { animation: fxscan 1.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .fx-mv, .fx-spin, .fx-blink, .fx-bob, .fx-scan { animation: none; } }
.fx-m:hover rect { filter: brightness(.97); }
.fx-cells { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.fx-c { border: 0.5px solid var(--line2); border-radius: 8px; background: var(--card); min-height: 44px; padding: 3px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; cursor: pointer; overflow: hidden; }
.fx-sym { font-size: 13px; font-weight: 700; line-height: 1; }
.fx-nm { font-size: 9px; color: var(--muted); line-height: 1.1; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-d { background: #BCD1CA; } .fx-a { background: #FFFFFF; } .fx-r { background: #E3DACC; } .fx-w { background: #F0EEE6; opacity: .7; }
.fx-v { background: #C0392B; color: #fff; } .fx-v .fx-nm { color: #fff; } .fx-q { background: #FFF3D6; } .fx-b { background: #EBCECE; } .fx-o { opacity: .35; }
.fx-yc { box-shadow: inset 0 0 0 2px #E8B400; } .fx-rc { box-shadow: inset 0 0 0 2px #C0392B; }
.fx-sel { outline: 3px solid var(--clay); outline-offset: 1px; } .fx-hold { outline: 2px dashed var(--clay); outline-offset: 1px; }
.fx-panel-wrap { position: fixed; inset: 0; background: rgba(20,20,19,.25); z-index: 40; display: flex; justify-content: flex-end; }
.fx-panel { background: var(--bg); width: min(520px, 100%); height: 100%; overflow-y: auto; padding: 16px 20px 40px; border-left: 0.5px solid var(--line2); }
.fx-panel.phone { width: 100%; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }
.fx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
@media (max-width: 760px) { .fx-grid { grid-template-columns: 1fr; } .fx-box { flex-basis: 100%; } }
.fx-ol { margin: 4px 0 0; padding-left: 20px; } .fx-ol li { margin: 2px 0; }
.fx-hist { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.fx-h { border-left: 2px solid var(--line2); padding: 2px 0 2px 10px; font-size: 13px; }
.fx-h.off { opacity: .45; text-decoration: line-through; } .fx-h.lab { border-left-color: var(--red); }
.fx-acts { border-top: 0.5px solid var(--line); padding-top: 10px; }
