:root {
  --bg: #ffffff; --soft: #f6f5f2; --line: #e9e6df; --text: #1c1b18; --muted: #77736a;
  --primary: #1f4436; --selected: #eef2ee; --red: #b3261e; --red-bg: #fbeeec; --amber: #8a5a00; --amber-bg: #fdf4e0; --green: #1f6b45;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1, h2 { margin: 0; font-size: 19px; }
a { color: inherit; }
.muted { color: var(--muted); } .small { font-size: 13px; } .spacer { flex: 1; }
.error { color: var(--red); margin: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.btn { font: inherit; font-size: 14px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; text-align: center; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; padding: 7px 22px; }
.btn.ghost { border-color: transparent; color: var(--muted); background: none; }
.btn.ghost:hover { color: var(--text); background: var(--soft); }
.btn.wide { display: block; width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.link:hover { color: var(--text); text-decoration: underline; }
label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
textarea { resize: none; display: block; }

.login { height: 100%; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.login-art { min-height: 0; overflow: hidden; position: relative; } .login-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.login-quote { position: absolute; left: 0; right: 0; bottom: 0; padding: 90px 40px 38px; color: #fff; background: linear-gradient(to top, rgba(20, 28, 22, .78), rgba(20, 28, 22, 0)); }
.login-quote h2 { font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; max-width: 480px; }
.login-quote p { margin: 10px 0 0; font-size: 16px; max-width: 460px; color: rgba(255, 255, 255, .92); }
.login form { align-self: center; justify-self: center; }
.login-card { padding: 28px; width: 340px; display: grid; gap: 12px; }
.login-card h1 { font-size: 26px; } .login-card p { margin: 0 0 6px; }
@media (max-width: 800px) { .login { grid-template-columns: 1fr; } .login-art { display: none; } }

.app { height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.brand { font-size: 16px; }
.mode { font-size: 12px; color: var(--amber); background: var(--amber-bg); padding: 1px 8px; border-radius: 5px; }
.sync { font-size: 13px; color: var(--red); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.columns { flex: 1; min-height: 0; display: grid; grid-template-columns: 290px minmax(0, 1fr) 300px; }
.queue { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 10px 10px 8px; flex: none; }
.tab { flex: 1; white-space: nowrap; font: inherit; font-size: 13px; padding: 6px 2px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.tab.on { color: var(--text); background: var(--soft); font-weight: 600; }
.tab b { font-weight: 600; }
.tab-note { margin: 0; padding: 0 14px 8px; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.search { margin: 0 10px 8px; width: calc(100% - 20px); flex: none; }
.case-list { overflow-y: auto; flex: 1; padding: 0 6px 6px; }
.case { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-radius: 8px; padding: 9px 10px; margin-bottom: 1px; cursor: pointer; }
.case:hover { background: var(--soft); }
.case.on { background: var(--selected); }
.case-row { display: flex; align-items: center; gap: 7px; }
.case-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
.age { font-size: 12.5px; color: var(--muted); flex: none; }
.case-why { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-preview { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; }
.case-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.case-viewer { font-size: 12px; color: var(--amber); }
.none { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.thread { min-height: 0; display: flex; flex-direction: column; }
.empty { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.welcome { max-width: 340px; text-align: center; }
.welcome img { width: 100%; height: 190px; object-fit: cover; border-radius: 12px; display: block; margin-bottom: 16px; }
.welcome p { margin: 4px 0 0; }
.thread-body { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 820px; margin: 0 auto; padding: 14px 20px 14px; }
.thread-scroll { flex: 1; min-height: 120px; overflow-y: auto; }
.case-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding-bottom: 10px; }
.btn-order, .side-close { display: none; }
.store-filter { display: flex; gap: 4px; }
.who { font-size: 13px; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; flex: none; }
.section-label span { font-weight: 400; text-transform: none; letter-spacing: 0; }
.situation { background: var(--selected); border-radius: 10px; padding: 10px 13px; font-size: 14px; flex: none; }
.situation.risk { background: var(--red-bg); }
.situation dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.situation dt { color: var(--muted); } .situation dd { margin: 0; }
.situation .todo-line { margin: 8px 0 0; }
.situation .notes { margin-top: 6px; font-size: 13px; color: var(--muted); }
.situation .notes summary { cursor: pointer; } .situation .notes p { margin: 4px 0 0; }
.msg.bot { background: #f0f3f6; }
.addr { margin: 0 0 12px; }
.overview { flex: 1; overflow-y: auto; padding: 26px 30px; max-width: 860px; }
.overview h2 { font-size: 24px; letter-spacing: -.01em; }
.overview > p { margin: 3px 0 16px; }
.overview h3 { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); margin: 24px 0 8px; }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ov-stat { background: var(--soft); border: 0; border-radius: 10px; padding: 13px 14px; text-align: left; font: inherit; color: inherit; display: block; }
.ov-stat b { display: block; font-size: 26px; line-height: 1.15; }
.ov-stat span { font-size: 13px; color: var(--muted); }
.ov-stat.click { cursor: pointer; background: var(--selected); } .ov-stat.click:hover { filter: brightness(.97); }
.ov-stat.risk { background: var(--red-bg); } .ov-stat.risk b { color: var(--red); }
.ov-next { margin-top: 14px; }
.ov-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.ov-flow div { background: var(--soft); border-radius: 10px; padding: 11px 13px; height: 100%; }
.ov-flow b { display: block; } .ov-flow span { font-size: 13px; color: var(--muted); }
.ov-flow i { color: var(--muted); font-style: normal; }
.others { font-size: 13px; color: var(--amber); margin-bottom: 10px; }
.card { background: var(--soft); border-radius: 9px; padding: 9px 12px; margin-bottom: 12px; font-size: 14px; }
.card p { margin: 0 0 2px; }
.msg { padding: 11px 13px; margin-bottom: 8px; border-radius: 10px; background: var(--soft); }
.msg.out { background: var(--selected); }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
.msg-head b { color: var(--text); font-weight: 600; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; }
.atts:not(:empty) { margin-top: 8px; }
.atts img { height: 130px; max-width: 200px; object-fit: cover; border-radius: 7px; display: block; }
.att-file { font-size: 13px; }

.composer { flex: none; border-top: 1px solid var(--line); margin-top: 6px; }
.todo-line { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.todo-line.risk { color: var(--red); }
.composer-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.composer-foot .link { margin-left: 8px; }
.findings { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.findings:empty { display: none; }
.findings li { font-size: 13px; padding: 4px 9px; border-radius: 6px; }
.findings .block { background: var(--red-bg); color: var(--red); }
.findings .warn { background: var(--amber-bg); color: var(--amber); }

.side { border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; min-height: 0; background: #fff; }
.order { margin-bottom: 18px; }
.item { display: flex; gap: 10px; margin-bottom: 10px; }
.item img { width: 56px; height: 70px; object-fit: cover; border-radius: 6px; flex: none; background: var(--soft); }
.item-title { font-size: 14px; font-weight: 500; text-decoration: none; }
a.item-title:hover { text-decoration: underline; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 12px; font-size: 13.5px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; overflow-wrap: anywhere; }
.dispute { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); margin-bottom: 14px; }
.dispute details { font-size: 14px; }
.dispute details[open] { display: grid; gap: 8px; }
.dispute summary, .find-order summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.dispute .hint { margin: 0; font-size: 13px; }
.dispute details > * { margin-bottom: 8px; }
.order-search { display: flex; gap: 6px; margin: 8px 0; }

.dialog { border: 0; border-radius: 14px; padding: 20px; width: 460px; max-width: 94vw; box-shadow: 0 16px 50px rgba(20, 18, 12, .2); }
.dialog::backdrop { background: rgba(25, 24, 20, .3); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 6px; }
.menu { width: 400px; } .menu h2 { margin-bottom: 10px; }
.menu-row { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-radius: 9px; padding: 9px 10px; cursor: pointer; color: inherit; }
.menu-row:hover { background: var(--soft); }
.menu-row span { display: block; font-size: 13px; color: var(--muted); }
#menu-foot { margin: 10px 10px 12px; }
.dialog.wide { width: 780px; height: 84vh; padding: 0; }
.dialog[open].wide { display: flex; flex-direction: column; }
.doc-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.doc-head h2 { white-space: nowrap; font-size: 17px; }
.doc-tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.chip { font: inherit; font-size: 12.5px; padding: 3px 10px; border: 0; border-radius: 99px; background: var(--soft); color: var(--muted); cursor: pointer; }
.chip.on { background: var(--text); color: #fff; }
.doc-body { padding: 16px 24px; overflow-y: auto; flex: 1; }
.doc-body h1 { font-size: 18px; margin: 14px 0 6px; } .doc-body h2 { font-size: 16px; margin: 16px 0 6px; } .doc-body h3 { font-size: 14px; margin: 10px 0 2px; }
.doc-body p { margin: 4px 0; } .doc-body ul { margin: 4px 0; padding-left: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--soft); border-radius: 9px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 8px 0; }
td, th { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }

.game { max-width: 680px; margin: 0 auto; }
.game section { margin-bottom: 26px; }
.doc-body .game h1 { font-size: 23px; line-height: 1.25; margin: 4px 0 8px; }
.game-hero { background: var(--selected); border-radius: 12px; padding: 16px 18px; }
.game-score { margin-top: 10px; font-weight: 600; color: var(--green); }
.flow { display: grid; gap: 6px; }
.flow-row { display: grid; grid-template-columns: 190px 1fr; gap: 10px; background: var(--soft); border-radius: 8px; padding: 9px 11px; }
.flow-if { font-weight: 600; font-size: 14px; }
.flow-row.danger { background: var(--red-bg); }
.steps { display: grid; gap: 9px; }
.step { display: flex; gap: 10px; }
.step-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 12.5px; display: flex; align-items: center; justify-content: center; }
.ladder { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.ladder span { padding: 2px 9px; border-radius: 6px; background: var(--soft); font-size: 13px; font-weight: 600; }
.ladder i { color: var(--muted); font-style: normal; font-size: 12px; }
.bars { display: grid; gap: 5px; margin: 8px 0; }
.bar { display: grid; grid-template-columns: 90px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; }
.bar i { display: block; height: 12px; background: var(--primary); border-radius: 3px; justify-self: start; }
.bar.lost i { background: var(--red); }
.moves { padding-left: 20px; margin: 0; } .moves li { margin-bottom: 5px; }
.fair { background: var(--amber-bg); color: var(--amber); padding: 7px 10px; border-radius: 7px; margin-top: 10px; }
.stats-title { font-size: 14px; margin: 14px 0 4px; }
.layers { display: grid; gap: 4px; margin: 8px 0 14px; }
.layer { display: grid; grid-template-columns: 22px 110px 1fr 70px; gap: 8px; align-items: center; padding: 7px 10px; background: var(--soft); border-radius: 8px; font-size: 14px; }
.layer.human { background: var(--selected); }
.layer .who { font-size: 12.5px; color: var(--muted); text-align: right; }
.layer.human .who { color: var(--primary); font-weight: 700; }
.tour { width: 460px; }
.tour img { width: 100%; height: 270px; object-fit: contain; display: block; border-radius: 10px; background: #f6f1e6; }
.tour h2 { font-size: 20px; margin: 2px 0 6px; }
.tour p { margin: 0 0 12px; }
.tour .tour-count { margin: 10px 0 0; font-size: 12.5px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 14px; z-index: 50; max-width: 80vw; }

@media (max-width: 1040px) {
  .who, #btn-home { display: none; }
}
@media (max-width: 1180px) {
  .columns { grid-template-columns: 240px minmax(0, 1fr); }
  .overview { padding: 20px; }
  
  .side { display: none; }
  .side.open { display: block; position: fixed; top: 0; right: 0; bottom: 0; width: 330px; max-width: 90vw; z-index: 20; box-shadow: -8px 0 24px rgba(30, 28, 22, .15); }
  .btn-order { display: inline-block; padding: 4px 12px; }
  .side-close { display: inline-block; margin-bottom: 12px; }
  .thread-body { padding: 0 14px 10px; }
}
@media (max-width: 700px) { .flow-row { grid-template-columns: 1fr; } .layer { grid-template-columns: 22px 1fr; } .layer .who { text-align: left; } }
.chip, .mode { white-space: nowrap; }
.top-right .btn { padding: 7px 9px; }
@media (max-width: 960px) { .store-filter .chip { padding: 3px 8px; font-size: 12px; } .brand { font-size: 15px; } }
@media (max-width: 960px) { .top { padding: 0 10px; gap: 7px; } .top-right { gap: 0; } .top-right .btn { padding: 6px 6px; font-size: 13px; } }
.need { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; vertical-align: middle; margin-left: 4px; white-space: nowrap; }
.need.first { background: var(--red-bg); color: var(--red); }
.need.yes { background: var(--selected); color: var(--primary); }
.need.no { background: var(--soft); color: var(--muted); }
.ov-grid.big { margin-top: 14px; } .ov-grid.big .ov-stat b { font-size: 34px; } .ov-grid.big .ov-stat span { font-size: 15px; font-weight: 600; color: var(--text); }
.store-select { width: auto; font-size: 13px; padding: 4px 8px; }
.ov-stat b { overflow-wrap: anywhere; }
.ov-money { background: var(--soft); border-radius: 10px; padding: 13px 14px; }
.ov-money b { display: block; font-size: 26px; line-height: 1.2; }
.ov-money span { font-size: 13.5px; color: var(--muted); }
@media (max-width: 860px) { .mode { display: none; } .tab { font-size: 12px; } }
.ov-intro { margin: 4px 0 0; color: var(--muted); }
.ov-stat small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 3px; line-height: 1.35; }
.bank-help { margin: 0; }
