/* Стиль «Фабрики»: монохром, моноширинный шрифт, жёлтый акцент, жёсткие рамки. */
:root {
  --bg: #e9e8e4;
  --panel: #f5f4f1;
  --ink: #1b1b1b;
  --muted: #6b6a66;
  --line: #1b1b1b;
  --soft: #c7c6c1;
  --accent: #f2b705;
  --ok: #2f8f4e;
  --warn: #d9480f;
  --mono: ui-monospace, "JetBrains Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--mono); font-size: 14px; line-height: 1.4;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

/* Шапка */
.top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--ink); color: var(--bg);
}
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.mark {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  background: var(--accent); color: var(--ink); font-weight: 700;
}
.title { font-weight: 700; letter-spacing: .16em; font-size: 14px; white-space: nowrap; }
.sub { color: #a5a49f; font-size: 11px; letter-spacing: .06em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .right { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #a5a49f; }
.top .right form { margin: 0; }
.stripe { height: 6px; background: repeating-linear-gradient(-45deg, var(--accent) 0 12px, var(--ink) 12px 24px); }
.stripe.off { background: repeating-linear-gradient(-45deg, #8a8984 0 12px, var(--ink) 12px 24px); }

/* Вкладки */
.tabs { display: flex; border-bottom: 2px solid var(--line); padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; background: none; border: 0; border-right: 1px solid var(--soft);
  padding: 12px 14px; cursor: pointer; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
  text-decoration: none; position: relative;
}
.tab:first-child { border-left: 1px solid var(--soft); }
.tab.active { background: var(--ink); color: var(--accent); }
.tab .badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  background: var(--accent); color: var(--ink); font-size: 11px; text-align: center; font-weight: 700;
}
.tab .badge:empty { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 90px; }
.panel { display: none; }
.panel.active { display: block; }
h1, h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .16em;
  margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px dashed var(--muted);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; margin: 24px 0 10px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.right-text { text-align: right; }

/* Кнопки */
.btn {
  font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px;
  background: var(--accent); color: var(--ink);
  border: 2px solid var(--line); padding: 10px 14px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--line); text-decoration: none; display: inline-block;
  user-select: none;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--line); }
.btn.ghost { background: var(--panel); }
.btn.dark { background: var(--ink); color: var(--accent); }
.btn.danger { background: #fff; color: var(--warn); border-color: var(--warn); box-shadow: 3px 3px 0 var(--warn); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: 11px; box-shadow: 2px 2px 0 var(--line); }
.btn.sm:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .5; cursor: default; }

/* Карточки и таблицы */
.card { background: var(--panel); border: 2px solid var(--line); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 2px solid var(--line); padding: 12px 14px; }
.tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.tile .v { font-size: 24px; font-weight: 700; margin-top: 4px; word-break: break-all; }
.tile .v small { font-size: 12px; color: var(--muted); font-weight: 400; }
.tile.accent { background: var(--ink); color: var(--bg); }
.tile.accent .v { color: var(--accent); }

.table-wrap { overflow-x: auto; border: 2px solid var(--line); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--soft); vertical-align: top; white-space: nowrap; }
th { background: var(--ink); color: var(--bg); font-weight: 400; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; }
td.num, th.num { text-align: right; }
tr.link-row { cursor: pointer; }
tr.link-row:hover td { background: #ecebe6; }

.status {
  display: inline-block; padding: 2px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--line); background: #fff; white-space: nowrap;
}
.status.new { background: var(--accent); }
.status.in_progress { background: var(--ink); color: var(--accent); }
.status.in_progress_overdue { background: var(--warn); color: #fff; border-color: var(--warn); }
.status.paid { background: var(--ok); color: #fff; border-color: var(--ok); }
.status.cancelled_operator, .status.cancelled_system, .status.expired { background: #fff; color: var(--warn); border-color: var(--warn); }
.status.appeal_new, .status.appeal_in_progress { background: #fff3c4; border-color: var(--accent); }
.status.appeal_closed { background: #ddd; }
/* Журнал: пропуск и отказ оператора — свои метки */
.status.ev_skipped { background: #fff; color: #666; border-color: #999; border-style: dashed; }
.status.ev_refused { background: var(--warn); color: #fff; border-color: var(--warn); }

.dot { width: 10px; height: 10px; display: inline-block; background: #8a8984; vertical-align: middle; margin-right: 6px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--warn); }

/* Формы */
.form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
fieldset { border: 2px solid var(--line); background: var(--panel); margin: 0; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
legend { padding: 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .14em; background: var(--ink); color: var(--accent); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
input, select, textarea {
  font-size: 15px; color: var(--ink); background: #fff;
  border: 1px solid var(--line); padding: 10px 12px; border-radius: 0; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input[type=checkbox] { width: 20px; height: 20px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn { flex: none; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; align-items: start; }
.grid2 > * { min-width: 0; }
.tile .v small { white-space: nowrap; }
pre { white-space: pre-wrap; word-break: break-word; }
.notice { border-left: 6px solid var(--accent); background: var(--panel); padding: 10px 14px; margin-bottom: 16px; }
.notice.err { border-color: var(--warn); color: var(--warn); }
.notice.ok { border-color: var(--ok); }
.empty { border: 2px dashed var(--muted); padding: 40px 16px; text-align: center; color: var(--muted); letter-spacing: .2em; font-size: 12px; }
pre { background: var(--ink); color: var(--bg); padding: 12px; overflow-x: auto; font-size: 11px; }
code { background: #fff; padding: 1px 4px; border: 1px solid var(--soft); }

/* Вход */
.auth { max-width: 380px; margin: 60px auto; padding: 0 16px; }
.auth .card { padding: 20px; }

/* Переключатель онлайн/оффлайн (как у таксиста) */
.switch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg); padding: 12px 16px; margin: -20px -16px 20px;
}
.switch-bar .label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.switch-bar .state { font-weight: 700; font-size: 14px; }
.switch { position: relative; width: 92px; height: 44px; border: 2px solid var(--bg); background: #3a3a38; cursor: pointer; flex: none; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 34px; height: 34px; background: #8a8984; transition: left .15s, background .15s; }
.switch.on { background: var(--ok); }
.switch.on .knob { left: 51px; background: var(--accent); }
.switch .txt { position: absolute; top: 0; height: 100%; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .1em; width: 50px; }
.switch .txt.l { left: 0; } .switch .txt.r { right: 0; }
.switch.on .txt.l { opacity: 0; } .switch:not(.on) .txt.r { opacity: 0; }

/* Заявки оператора */
.orders { display: flex; flex-direction: column; gap: 12px; }
.order {
  background: var(--panel); border: 2px solid var(--line); padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
}
.order.offer { border-color: var(--accent); background: #fff8dc; }
.order.overdue { border-color: var(--warn); }
.order .id { font-size: 12px; color: var(--muted); word-break: break-all; }
.order .amt { font-size: 24px; font-weight: 700; }
.order .amt small { font-size: 12px; font-weight: 400; color: var(--muted); }
.order .timer { font-size: 22px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.order .timer.low { color: var(--warn); }
.order .timer.done { color: var(--warn); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.sla { grid-column: 1 / -1; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
.sla.low { color: var(--warn); }
.order .st { grid-column: 1 / -1; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.order .actions { grid-column: 1 / -1; display: flex; gap: 10px; }
.order .actions .btn { flex: 1; text-align: center; padding: 12px 10px; }
.order .reason { grid-column: 1 / -1; font-size: 13px; white-space: pre-wrap; }

/* Детали заявки (шторка) */
.sheet-bg { position: fixed; inset: 0; background: rgba(27,27,27,.55); display: none; z-index: 20; }
.sheet-bg.show { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-top: 4px solid var(--accent); z-index: 21;
  transform: translateY(100%); transition: transform .2s; padding: 16px 16px 24px;
}
.sheet.show { transform: translateY(0); }
.sheet .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet .head .t { font-size: 12px; text-transform: uppercase; letter-spacing: .14em; }
.sheet .close { background: var(--ink); color: var(--bg); border: 0; width: 40px; height: 40px; font-size: 18px; cursor: pointer; }
.fields { display: flex; flex-direction: column; gap: 10px; }
.field { background: var(--panel); border: 2px solid var(--line); display: grid; grid-template-columns: 1fr 48px; cursor: pointer; }
.field .body { padding: 10px 12px; min-width: 0; }
.field .k { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.field .v { font-size: 16px; font-weight: 600; word-break: break-all; white-space: pre-wrap; margin-top: 2px; }
.field .v.big { font-size: 26px; }
.field .copy { display: grid; place-items: center; border-left: 2px solid var(--line); background: #fff; }
.field .copy svg { width: 20px; height: 20px; }
.field.copied { border-color: var(--ok); }
.field.copied .copy { background: var(--ok); color: #fff; }
.sheet .actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet .actions .btn { flex: 1; text-align: center; padding: 14px 10px; }
.sheet .meta { font-size: 11px; color: var(--muted); margin-top: 12px; line-height: 1.6; }
.sheet .timer-big { text-align: center; font-size: 34px; font-weight: 700; margin: 4px 0 12px; font-variant-numeric: tabular-nums; }
.sheet .timer-big.low { color: var(--warn); }
.ask { display: none; flex-direction: column; gap: 10px; margin-top: 14px; padding: 12px; border: 2px dashed var(--warn); }
.ask.show { display: flex; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--panel); color: var(--ink); border: 2px solid var(--line);
  box-shadow: 2px 2px 0 var(--line); padding: 10px 12px; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.chip::before {
  content: attr(data-n); display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; background: var(--ink); color: var(--accent); font-size: 11px;
}
.chip:active { transform: translate(2px, 2px); box-shadow: none; }
.chip.active { background: var(--accent); }
.ask .k-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* История / статистика */
.hist { display: flex; flex-direction: column; gap: 8px; }
.hist .item { background: var(--panel); border: 1px solid var(--line); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; cursor: pointer; }
.hist .item .id { font-size: 12px; color: var(--muted); word-break: break-all; }
.hist .item .amt { font-weight: 700; text-align: right; }
.hist .item .when { font-size: 11px; color: var(--muted); }
.hist .item .rate { font-size: 11px; color: var(--muted); }
.hist .item .rate.usdt { text-align: right; color: var(--ink); font-weight: 600; }
.periods { display: flex; gap: 0; margin-bottom: 14px; border: 2px solid var(--line); }
.periods button { flex: 1; border: 0; background: var(--panel); padding: 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; }
.periods button.active { background: var(--ink); color: var(--accent); }

/* Тост */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-left: 6px solid var(--accent);
  padding: 12px 18px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: calc(100% - 32px); z-index: 30;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--warn); }

/* Квадрат статуса оператора в шапке */
.state-mark { font-size: 10px; letter-spacing: .06em; transition: background .15s; }
.state-mark.online { background: var(--ok); color: #fff; }
.state-mark.offline { background: var(--accent); color: var(--ink); }
.state-mark.blocked { background: var(--warn); color: #fff; }

/* Балансы в шапке */
.head-bal { text-align: right; font-size: 11px; line-height: 1.35; flex: none; }
.head-bal .k { color: #a5a49f; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
.head-bal b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.head-bal .free b { color: var(--accent); font-size: 15px; }
.head-bal .work b { color: var(--bg); font-size: 12px; font-weight: 400; }

.board-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--muted); }
.board-foot form { margin: 0; }

@media (max-width: 400px) {
  .top .title { font-size: 12px; letter-spacing: .1em; }
  .head-bal .free b { font-size: 13px; }
}

@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; width: 560px; transform: translate(-50%, 100%); }
  .sheet.show { transform: translate(-50%, 0); }
  .top { padding: 14px 24px; }
  .tabs { padding: 0 24px; }
  main { padding: 28px 24px 60px; }
  .switch-bar { margin: -28px -24px 24px; padding: 14px 24px; }
}
@media (max-width: 480px) {
  .top .right .hide-sm { display: none; }
}

/* Админка: шире, чтобы таблицы помещались без прокрутки */
body.admin main { max-width: 1600px; }
body.admin th, body.admin td { padding: 8px 8px; }
.tile-note { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Раздел «Баланс» оператора */
.hist .item .amt.plus { color: var(--ok); }
.hist .item .amt.minus { color: var(--warn); }
.hist .item .when { word-break: break-word; }
td b.plus { color: var(--ok); }
td b.minus { color: var(--warn); }

/* Табло оператора: блоки «Баланс» и «Заявки и курс» — светлые, без тёмных плашек */
.board-group { margin-bottom: 22px; }
.board-group .gt {
  padding: 0 0 8px; margin-bottom: 10px; border-bottom: 2px solid var(--line);
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--ink);
}
.board-group .tiles { gap: 10px; }
.board-group .tile.wide { grid-column: 1 / -1; }
.board-group .tile.wide .v { font-size: 30px; }
.board-group .tile.accent { background: #fff8dc; color: var(--ink); border-left: 8px solid var(--accent); }
.board-group .tile.accent .v { color: var(--ink); }
#stat-tiles .tile.accent { background: #fff8dc; color: var(--ink); border-left: 8px solid var(--accent); }
#stat-tiles .tile.accent .v { color: var(--ink); }
