:root {
  --bg: #1b1a17; --panel: #2a2721; --panel2: #332f28; --line: #46403a; --text: #ece4d6; --dim: #a59c8c; --mute: #7d7569;
  --acc: #e8a33d; --inc: #3fa66b; --exp: #d9534f; --info: #4d8fd6;
  --r: 8px; --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--font); overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; }
#view { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

/* Верхняя полоса */
#top { position: absolute; left: 0; right: 0; top: 0; height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: linear-gradient(#1b1a17f2, #1b1a17d0); border-bottom: 1px solid #00000060; z-index: 5; }
.brand { font-weight: 700; letter-spacing: .02em; color: var(--acc); }
.stat { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat.big { font-size: 18px; font-weight: 600; min-width: 52px; }
.stat.dim { color: var(--dim); }
#tCash.neg { color: var(--exp); }
#locSel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; max-width: 220px; }
.speed { display: flex; gap: 2px; margin-left: auto; }
.speed button { background: var(--panel); border: 1px solid var(--line); padding: 4px 9px; border-radius: 6px; font-size: 12px; min-width: 34px; }
.speed button.on { background: var(--acc); color: #1b1a17; border-color: var(--acc); }
button.icon { background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; font-size: 16px; }
button.icon:hover { border-color: var(--line); background: var(--panel); }
button.icon.sm { font-size: 12px; padding: 0 6px; }

/* Вкладки слева */
#tabs { position: absolute; left: 0; top: 48px; bottom: 0; width: 72px; display: flex; flex-direction: column; gap: 2px; padding: 8px 6px;
  background: #1b1a17d8; border-right: 1px solid #00000060; z-index: 5; overflow-y: auto; }
#tabs button { background: transparent; border: 1px solid transparent; border-radius: var(--r); padding: 6px 2px; font-size: 10.5px; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 2px; }
#tabs button span { font-size: 20px; line-height: 1; filter: saturate(.8); }
#tabs button:hover { background: var(--panel); color: var(--text); }
#tabs button.on { background: var(--panel2); border-color: var(--acc); color: var(--text); }
#tabs button.alert::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--exp); position: relative; top: -38px; left: 20px; margin-bottom: -7px; }

/* Панель */
#panel { position: absolute; left: 72px; top: 48px; bottom: 0; width: min(500px, calc(100vw - 72px)); background: var(--panel); border-right: 1px solid #00000080;
  z-index: 4; display: flex; flex-direction: column; box-shadow: 6px 0 24px #0006; }
.phead { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.phead h2 { margin: 0; font-size: 16px; flex: 1; }
#pbody { overflow-y: auto; padding: 12px 14px 40px; flex: 1; }
#pbody h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); margin: 18px 0 8px; font-weight: 600; }
#pbody h3:first-child { margin-top: 0; }
.note { color: var(--dim); font-size: 12.5px; margin: 6px 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.sp { justify-content: space-between; }
.grow { flex: 1; }
.card { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 8px; }
.card.sel { border-color: var(--acc); }
.card h4 { margin: 0 0 4px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #00000030; border: 1px solid var(--line); color: var(--dim); }
.chip.good { color: #9bd8b1; border-color: #3fa66b80; }
.chip.bad { color: #f0a29f; border-color: #d9534f80; }
.chip.warn { color: #f1c78a; border-color: #e8a33d80; }
.btn { background: #3b362e; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--acc); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.pri { background: var(--acc); color: #1b1a17; border-color: var(--acc); font-weight: 600; }
.btn.red { color: #f0a29f; }
.btn.sm { padding: 2px 7px; font-size: 12px; }
input[type=number], input[type=text], select.in { background: #1f1d19; border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; width: 76px; }
input[type=text].wide { width: 100%; }
input[type=range] { accent-color: var(--acc); }
input[type=checkbox] { accent-color: var(--acc); width: 15px; height: 15px; }
select.in { width: auto; }
.inc { color: var(--inc); } .exp { color: var(--exp); } .acc { color: var(--acc); } .dim { color: var(--dim); } .infoc { color: var(--info); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: left; color: var(--mute); font-weight: 500; font-size: 11.5px; padding: 4px 4px; border-bottom: 1px solid var(--line); }
table.t td { padding: 4px 4px; border-bottom: 1px solid #ffffff0d; vertical-align: middle; }
table.t tr.off td { opacity: .5; }
table.t tr.sum td { font-weight: 600; border-top: 1px solid var(--line); }
table.t input[type=number] { width: 62px; }
.bar { height: 6px; background: #00000040; border-radius: 3px; overflow: hidden; min-width: 50px; }
.bar i { display: block; height: 100%; background: var(--acc); border-radius: 3px; }
.bar.g i { background: var(--inc); } .bar.r i { background: var(--exp); } .bar.b i { background: var(--info); }
.skills { display: grid; grid-template-columns: 70px 1fr 18px; gap: 2px 6px; align-items: center; font-size: 11.5px; color: var(--dim); margin-top: 6px; }
.tabs2 { display: flex; gap: 4px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs2 button { background: transparent; border: 1px solid var(--line); border-radius: 14px; padding: 3px 11px; font-size: 12.5px; color: var(--dim); }
.tabs2 button.on { background: var(--acc); color: #1b1a17; border-color: var(--acc); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.item { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px; text-align: left; }
.item:hover:not(:disabled) { border-color: var(--acc); }
.item.on { border-color: var(--acc); background: #e8a33d22; }
.item b { display: block; font-size: 13px; }
.item small { color: var(--dim); font-size: 11.5px; }
.tc { background: #00000026; border-radius: 6px; padding: 6px 8px; margin: 4px 0 6px; font-size: 12px; }
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.kpi div { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 8px; }
.kpi small { display: block; color: var(--mute); font-size: 11px; }
.kpi b { font-size: 15px; font-variant-numeric: tabular-nums; }
canvas.chart { width: 100%; height: 130px; display: block; background: #00000022; border-radius: 6px; }
.msg { padding: 6px 8px; border-radius: 6px; background: #00000030; border-left: 3px solid var(--info); margin: 6px 0; font-size: 12.5px; }
.msg.good { border-color: var(--inc); } .msg.bad { border-color: var(--exp); }

/* Лента */
#feed { position: absolute; right: 10px; top: 58px; width: 320px; max-height: 42vh; display: flex; flex-direction: column; background: #1b1a17d8;
  border: 1px solid #00000060; border-radius: var(--r); z-index: 3; backdrop-filter: blur(3px); }
#feed.min #feedList { display: none; }
.fhead { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; font-size: 12px; color: var(--dim); border-bottom: 1px solid #ffffff10; }
#feedList { overflow-y: auto; padding: 4px 0; }
.fi { padding: 3px 10px; font-size: 12.5px; border-left: 3px solid transparent; }
.fi time { color: var(--mute); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.fi.good { border-color: var(--inc); } .fi.warn { border-color: var(--acc); } .fi.bad { border-color: var(--exp); } .fi.info { border-color: #ffffff14; }

/* Карточка выбора */
#info { position: absolute; right: 10px; bottom: 10px; width: 320px; background: #2a2721f0; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; z-index: 3; box-shadow: 0 6px 24px #0007; }
#info h4 { margin: 0 0 2px; font-size: 15px; }
#info .x { position: absolute; right: 6px; top: 4px; }
#hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: #1b1a17e8; border: 1px solid var(--line); border-radius: 20px; padding: 6px 16px; font-size: 13px; z-index: 3; white-space: nowrap; }
#hint.bad { border-color: var(--exp); color: #f0a29f; }
#toasts { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 8; pointer-events: none; align-items: center; }
.toast { background: #2a2721f2; border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: 6px; padding: 7px 14px; font-size: 13px; box-shadow: 0 4px 16px #0008; animation: tin .25s ease-out; max-width: 520px; }
.toast.good { border-left-color: var(--inc); } .toast.bad { border-left-color: var(--exp); } .toast.warn { border-left-color: var(--acc); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }

/* Модальные окна */
#modal { position: absolute; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.mbox { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 20px 22px; box-shadow: 0 20px 60px #000a; }
.mbox.wide { width: min(980px, 100%); }
.mbox h2 { margin: 0 0 6px; font-size: 20px; }
.mbox p { white-space: pre-line; }
.mbox .opts { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.mbox .opts .btn { text-align: left; padding: 9px 12px; font-size: 14px; }
.scen { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.scen button { text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.scen button:hover { border-color: var(--acc); }
.scen .ic { font-size: 28px; }
.scen b { display: block; margin: 4px 0; font-size: 15px; }
.scen small { color: var(--dim); font-size: 12.5px; display: block; }
.diff { color: var(--acc); font-size: 12px; letter-spacing: 2px; }
.rep { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#loading { position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 20; transition: opacity .4s; }
#loading .ld { font-size: 28px; font-weight: 700; color: var(--acc); text-align: center; }
#loading small { display: block; font-size: 13px; color: var(--dim); font-weight: 400; margin-top: 6px; }
#loading.out { opacity: 0; pointer-events: none; }

@media (max-width: 760px) {
  #top { gap: 8px; height: auto; min-height: 48px; flex-wrap: wrap; padding: 4px 8px; }
  .brand, #tLive, #tRating { display: none; }
  #tabs { top: auto; bottom: 0; left: 0; right: 0; width: auto; height: 58px; flex-direction: row; padding: 4px; overflow-x: auto; }
  #tabs button { min-width: 58px; }
  #panel { left: 0; top: 48px; bottom: 58px; width: 100%; }
  #feed { display: none; }
  #info { left: 8px; right: 8px; width: auto; bottom: 66px; }
  .rep { grid-template-columns: 1fr; }
}
