@font-face { font-family: "Prosto One"; src: url("./fonts/ProstoOne-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Mulish"; src: url("./fonts/Mulish.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: dark;
  --brand-green: #00FC00;
  --brand-warning: #FF8E00;
  --page-bg: #000000;
  --surface: #131212;
  --surface-raised: #232323;
  --surface-soft: #191919;
  --text: #FFFFFF;
  --text-muted: #C7C7C7;
  --border: #3D3D3D;
  --focus: #00FC00;
  --success-text: #00FC00;
  --warning-bg: #2B1A00;
  --warning-text: #FFB24D;
  --danger-bg: #2A0E0E;
  --danger-text: #FF8A80;
  --shadow: 0 14px 38px rgb(0 0 0 / 38%);
  --radius: 16px;
  --radius-small: 12px;
  --touch: 48px;
  --nav-height: 72px;
  --content-max: 760px;
  --fast: 180ms ease-out;
}
@media (prefers-color-scheme: light) and (min-width: 100000px) {
  :root {
    --page-bg: #F4F4F1;
    --surface: #FFFFFF;
    --surface-raised: #EAEAE6;
    --surface-soft: #F7F7F4;
    --text: #131212;
    --text-muted: #5C5C5C;
    --border: #CFCFCA;
    --success-text: #006B00;
    --warning-bg: #FFF1DE;
    --warning-text: #7A3A00;
    --danger-bg: #FDE7E5;
    --danger-text: #8A1C14;
    --shadow: 0 8px 24px rgb(0 0 0 / 8%);
  }
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page-bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; overflow-x: hidden; background: var(--page-bg); color: var(--text);
  font-family: "Mulish", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.45;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
}
h1, h2, h3, strong { font-family: "Prosto One", "Arial Black", system-ui, sans-serif; font-weight: 400; }
button { font: inherit; color: inherit; min-height: var(--touch); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--page-bg) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: block; height: 33px; width: auto; border-radius: 6px; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title strong { font-size: 18px; line-height: 1.2; }
.live-label { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-label.is-stale { color: var(--warning-text); }
.icon-btn { width: var(--touch); border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-small); font-size: 22px; }

.view { max-width: var(--content-max); margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kicker { margin: 0 0 4px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--success-text); }
.card h2 { margin: 0 0 12px; font-size: 18px; line-height: 1.25; }
.hero { position: relative; overflow: hidden; border-top: 3px solid var(--brand-green); }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: color-mix(in srgb, var(--brand-green) 10%, transparent); }
.big { font-family: "Prosto One", system-ui, sans-serif; font-size: 40px; line-height: 1.1; margin: 4px 0 6px; letter-spacing: -.01em; }
.big small { font-size: 18px; margin-left: 4px; color: var(--text-muted); }
.sub { font-size: 14px; color: var(--text-muted); margin: 2px 0; }
.sub b { color: var(--text); font-weight: 800; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.tile .t-title { font-size: 12px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.tile .t-value { font-family: "Prosto One", system-ui, sans-serif; font-size: 24px; line-height: 1.15; margin: 4px 0; overflow-wrap: anywhere; }
.tile .t-sub { font-size: 13px; color: var(--text-muted); }
.tile.is-muted .t-value { opacity: .6; }

.lines { margin: 0; padding: 0; }
.lines > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 48px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.lines > div:last-child { border-bottom: 0; }
.lines dt { margin: 0; color: var(--text-muted); min-width: 0; }
.lines dd { margin: 0; text-align: right; font-weight: 800; white-space: nowrap; }
.lines .hint { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; white-space: normal; }

.note { border-left: 3px solid var(--brand-warning); background: var(--warning-bg); color: var(--warning-text); border-radius: 0 var(--radius-small) var(--radius-small) 0; padding: 10px 12px; font-size: 13px; }
.note.is-danger { border-left-color: #E0564F; background: var(--danger-bg); color: var(--danger-text); }
.note.is-ok { border-left-color: var(--brand-green); background: color-mix(in srgb, var(--brand-green) 10%, var(--surface)); color: var(--text); }

.flag { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.flag:last-child { border-bottom: 0; }
.dot { flex: 0 0 12px; width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: var(--brand-warning); }
.dot.crit { background: #E0564F; }
.dot.ok { background: var(--brand-green); }
.flag .f-main { flex: 1; min-width: 0; }
.flag .f-amount { font-weight: 800; white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 0 16px; min-height: 44px; font-weight: 800; }
.chip.is-active { background: var(--brand-green); border-color: var(--brand-green); color: #000; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 8px; }
.bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: var(--brand-green); min-height: 2px; }
.bar.is-pre i { background: repeating-linear-gradient(45deg, var(--brand-warning) 0 4px, transparent 4px 8px); border: 1px solid var(--brand-warning); }
.bar span { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.row-btn { width: 100%; text-align: left; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.row-btn .r-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 800; }
.row-btn .r-sub { font-size: 13px; color: var(--text-muted); }
.row-detail { margin: -2px 0 10px; padding: 8px 12px; border-radius: 10px; background: var(--surface-soft); font-size: 14px; }
.row-detail div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; }

#fleet-map { height: 52vh; min-height: 300px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--surface-raised); }
.pill.go { background: color-mix(in srgb, var(--brand-green) 22%, var(--surface)); color: var(--success-text); }
.pill.idle { background: var(--warning-bg); color: var(--warning-text); }
.pill.off { opacity: .7; }

.link-card { display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: inherit; min-height: 56px; }
.link-card span { color: var(--success-text); font-size: 22px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--page-bg) 90%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border);
}
.nav-btn { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 800; color: var(--text-muted); }
.nav-btn .nav-ico { font-size: 20px; line-height: 1; }
.nav-btn.is-active { color: var(--success-text); }

.skeleton-card { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 25%, var(--surface-raised) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-card { animation: none; } }
@media (min-width: 900px) { .view { max-width: 980px; } .grid2.wide { grid-template-columns: repeat(4, 1fr); } }

/* Компьютер и широкие экраны: боковое меню слева со всеми разделами, карточки в две колонки */
@media (min-width: 1000px) {
  body { padding-bottom: 24px; padding-left: 248px; }
  .topbar { margin-left: 0; }
  .bottom-nav, .menu-backdrop { display: none !important; }
  .side-nav { transform: none !important; box-shadow: none; }
  .side-close { display: none; }
  .view { max-width: 1280px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; padding: 24px; gap: 20px; }
  .view > .hero, .view > .chips, .view > .note, .view > #fleet-map, .view > .grid2, .view > h2, .view > p, .view > .chip, .view > #orders-list { grid-column: 1 / -1; }
  .view > .grid2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #fleet-map { height: 62vh; }
  .big { font-size: 48px; }
  .orders-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: start; }
  .orders-list > p, .orders-list > .chip, .orders-list > .note { grid-column: 1 / -1; }
}
@media (min-width: 1000px) { .topbar { padding-left: 24px; } .brand { margin-left: 0; } }

button.bar { background: none; border: 0; padding: 0; min-height: 0; color: inherit; cursor: pointer; }
button.bar:active { opacity: .7; }

/* Боковое меню (на ПК закреплено, на телефоне выезжает по кнопке «Меню») */
.side-nav {
  position: fixed; top: 0; bottom: 0; left: 0; width: 248px; max-width: 86vw; z-index: 50; overflow-y: auto;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 20px; background: var(--surface); border-right: 1px solid var(--border);
  transform: translateX(-102%); transition: transform var(--fast); box-shadow: var(--shadow);
}
body.menu-open .side-nav { transform: translateX(0); }
.menu-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 55%); display: none; }
body.menu-open .menu-backdrop { display: block; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-head img { border-radius: 6px; }
.side-title { margin: 14px 8px 4px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.side-btn { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; margin: 2px 0; background: none; border: 0; border-radius: var(--radius-small);
  text-align: left; font-weight: 800; color: var(--text); text-decoration: none; cursor: pointer; }
.side-btn .nav-ico { width: 22px; text-align: center; color: var(--text-muted); }
.side-btn.is-active { background: var(--surface-raised); color: var(--success-text); }
.side-btn.is-active .nav-ico { color: var(--success-text); }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; }
.filters input, .filters select { width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--radius-small); border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); font: inherit; }
@media (min-width: 700px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.hint-line { display: flex; gap: 8px; align-items: flex-start; margin-top: 4px; }
.hint-line .dot { flex: 0 0 10px; width: 10px; height: 10px; margin-top: 5px; }

.wk-row { display: flex; gap: 8px; margin: 6px 0; }
.wk { flex: 1; min-width: 0; text-align: center; background: var(--surface-raised); border-radius: 10px; padding: 6px 2px; }
.wk b { display: block; font-size: 15px; }
.wk small { display: block; font-size: 10px; color: var(--text-muted); }

.bank-row { padding: 8px 0; border-bottom: 1px solid var(--border); }
.bank-row:last-child { border-bottom: 0; }
.bank-bar { height: 8px; border-radius: 99px; background: var(--surface-raised); margin: 6px 0 4px; overflow: hidden; }
.bank-bar i { display: block; height: 100%; border-radius: 99px; background: var(--brand-warning); }
.bank-bar i.inc { background: var(--brand-green); }
.bank-fold summary { cursor: pointer; font-weight: 800; min-height: 44px; display: flex; align-items: center; }
.bank-fold summary small { font-weight: 400; color: var(--text-muted); margin-left: 6px; }
.bank-row .r-head, .bank-fold .r-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 800; }
.bank-row .r-sub { font-size: 13px; color: var(--text-muted); }
@media (max-width: 480px) { .tile .t-value { font-size: 20px; white-space: nowrap; } }

/* tone accents for tiles and links (added 2026-10-19) */
.tile.is-good { border-left: 4px solid #2ee62e; }
.tile.is-warn { border-left: 4px solid #e0a21e; }
.tile.is-bad { border-left: 4px solid #e04a4a; }
a[data-deal] { text-decoration: underline; cursor: pointer; }
details summary { padding: 8px 0; }


.tile.span2 { grid-column: 1 / -1; }


/* revenue by payment method (added 2026-10-19) */
details.pay-part { border-top: 1px solid var(--border, rgba(127,127,127,.25)); }
details.pay-part > summary { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0; cursor: pointer; list-style: none; }
details.pay-part.is-warn > summary > span:first-child { color: #e0a21e; font-weight: 700; }


/* Контрагенты: доска счетов из бота Ардор 163 (ardor_invoices.js) в цветах кабинета */
.ardor-inv { --background: var(--page-bg); --card: var(--surface); --foreground: var(--text); --muted-foreground: var(--text-muted); --muted: var(--surface-soft); grid-column: 1 / -1; min-width: 0; }
.ardor-inv.ai { margin-top: 0; }

/* Касса: из бота Ардор 163 (ardor_cash.js) в цветах кабинета */
.ardor-cash { --background: var(--page-bg); --card: var(--surface); --foreground: var(--text); --muted-foreground: var(--text-muted); --muted: var(--surface-soft); grid-column: 1 / -1; min-width: 0; }
.ardor-cash .ac { margin-top: 0; }
