:root {
  --paper: #f1f3f6;
  --card: #ffffff;
  --ink: #111c26;
  --muted: #586572;
  --line: #dde2e8;
  --taxi: #ffc400;
  --taxi-ink: #1d1600;
  --ok: #167a41;
  --ok-bg: #e3f4ea;
  --bad: #b3321f;
  --bad-bg: #fbe8e5;
  --warn-bg: #fff2c4;
  --warn-ink: #6b5300;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --checker: repeating-conic-gradient(var(--taxi) 0 25%, var(--ink) 0 50%) 0 0 / 20px 20px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 16px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -.01em; }

/* ---------- Yuqori panel: logotip + shashka lentasi ---------- */
.bar { background: #fff; position: relative; padding-bottom: 10px; box-shadow: 0 1px 0 var(--line); }
.bar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: var(--checker); }
.bar-in { max-width: 1040px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.bar.wide .bar-in { max-width: 1200px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-logo { display: block; height: 46px; width: auto; }
.brand-tag { font-size: .78rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: var(--ink); color: #fff; padding: 4px 10px; border-radius: 999px; }
.who { display: flex; align-items: center; gap: 14px; font-size: .95rem; font-weight: 600; }
.link { background: none; border: 0; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }
.link:hover { color: var(--muted); }
@media (max-width: 560px) {
  .brand-logo { height: 36px; }
  .who { gap: 8px; font-size: .85rem; }
  #whoName { display: none; }
}

main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 56px; }
main.wide { max-width: 1200px; }
.grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 1px 2px rgba(17, 28, 38, .04), 0 10px 28px rgba(17, 28, 38, .05); }

/* ---------- Kirish sahifasi ---------- */
body.is-login .bar { display: none; }
body.is-login::before { content: ""; display: block; height: 12px; background: var(--checker); }
.login { max-width: 420px; margin: 40px auto 0; }
.login-brand { text-align: center; margin: 4px 0 18px; }
.login-logo { height: 84px; width: auto; max-width: 100%; }
.login h2 { text-align: center; }

/* ---------- Maydonlar ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .9rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, #sum {
  width: 100%; font: inherit; font-size: 1.1rem; padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, #sum:focus { border-color: var(--ink); outline: 0; }
#sum { font-size: 1.7rem; font-weight: 800; }

/* Pozivnoy: mashina raqami shaklidagi maydon */
.plate {
  display: block; width: 100%; max-width: 300px; margin: 0 0 16px;
  background: var(--taxi); color: var(--taxi-ink);
  border: 3px solid var(--ink); border-radius: 12px; padding: 8px 16px 10px;
  box-shadow: inset 0 0 0 3px var(--taxi), inset 0 0 0 5px var(--ink);
}
.plate-cap { display: block; text-align: center; font-size: .85rem; font-weight: 700; margin: 4px 0 0; }
.plate input {
  display: block; width: 100%; background: transparent; border: 0; outline: 0;
  font: 800 3rem/1.1 var(--font); text-align: center; color: var(--taxi-ink); letter-spacing: .04em; padding: 4px 0;
}
.plate:focus-within { outline: 3px solid var(--ink); outline-offset: 3px; }

/* ---------- Tugmalar ---------- */
.btn {
  font: inherit; font-weight: 700; padding: 12px 20px; border-radius: 10px; cursor: pointer;
  border: 2px solid var(--ink); background: #fff; color: var(--ink); min-height: 48px;
  transition: transform .06s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: 0 2px 0 var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.accent { background: var(--taxi); color: var(--taxi-ink); }
.btn:disabled { opacity: .55; cursor: wait; box-shadow: none; }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible, .tab:focus-visible, .rowbtn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
form > .btn.primary, form > .btn.accent { width: 100%; }
@media (min-width: 520px) { #checkForm > .btn.primary { width: auto; } }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; border-radius: 8px; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Filial balansi (kassir) ---------- */
.balance-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 16px 18px; margin: 0 0 22px;
  border-left: 8px solid var(--taxi);
}
.bc-label { display: block; font-size: .9rem; font-weight: 600; color: #c4ced8; }
.bc-amount { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1.2; }
.bc-sub { font-size: .8rem; color: #9fabb7; }
.bonus-chip { background: var(--taxi); color: var(--taxi-ink); font-weight: 800; padding: 6px 12px; border-radius: 999px; font-size: .9rem; white-space: nowrap; }

/* ---------- Haydovchi ---------- */
.driver { margin: 20px 0 8px; padding: 14px 16px; border-left: 6px solid var(--taxi); background: #f6f8fa; border-radius: 0 10px 10px 0; }
.driver-name { margin: 0; font-size: 1.35rem; font-weight: 800; }
.driver-bal { margin: 2px 0 0; color: var(--muted); }
.driver-bal strong { color: var(--ink); }

.hint { color: var(--muted); font-size: .9rem; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip { font: inherit; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-weight: 700; }
.chip:hover { border-color: var(--ink); }

/* ---------- Xabarlar ---------- */
.notice { margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin: 0; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
#loginError { margin-bottom: 14px; }

/* ---------- To'lovdan keyingi ekran va chek ---------- */
.receipt-ok { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 1.3rem; font-weight: 800; color: var(--ok); }
.receipt-ok::before { content: "\2713"; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 1.05rem; }

.ticket {
  background: #fff; color: #000; width: 100%; max-width: 340px; margin: 0 auto; padding: 18px 18px 14px;
  font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(17, 28, 38, .10);
}
.ticket-logo { display: block; margin: 0 auto 8px; height: 46px; width: auto; }
.ticket-title { text-align: center; font-weight: 700; letter-spacing: .12em; margin: 6px 0; }
.ticket hr { border: 0; border-top: 1px dashed #000; margin: 10px 0; }
.ticket .tr { display: flex; justify-content: space-between; gap: 12px; }
.ticket .tr span:last-child { text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.ticket-sum { text-align: center; margin: 8px 0; }
.ticket-sum span { display: block; }
.ticket-sum strong { display: block; font-size: 1.7rem; line-height: 1.3; }
.ticket-foot { text-align: center; margin: 4px 0 0; }
.ticket-wrap { margin: 0 0 8px; }

.cashier-info { margin: 18px 0 10px; padding: 10px 14px; background: #f6f8fa; border-radius: 10px; }
.cashier-info > div:last-child { border-bottom: 0; }

dl { margin: 0 0 16px; }
dl > div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
dl dt { color: var(--muted); }
dl dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
dl > div.big dd { font-size: 1.3rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Bugungi ro'yxat ---------- */
.today-sum { margin: -6px 0 6px; font-weight: 700; }
.list { list-style: none; margin: 0; padding: 0; max-height: 540px; overflow-y: auto; }
.list li { border-bottom: 1px solid var(--line); }
.list .row { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 10px 6px; width: 100%; }
.list .rowbtn { background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
.list .rowbtn:hover { background: #f3f6f9; }
.list .t { color: var(--muted); }
.list .n { font-weight: 700; overflow-wrap: anywhere; }
.list .s { font-weight: 800; }
.list .a { grid-column: 2 / 4; color: var(--muted); font-size: .9rem; margin-top: -2px; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 16px 48px rgba(17, 28, 38, .4); }
dialog::backdrop { background: rgba(17, 28, 38, .55); }
dialog h2 { margin-bottom: 12px; }
dialog .field input, dialog .field select { font-size: 1rem; }
dialog:has(.tablewrap) { max-width: 760px; }
dialog form > .actions { margin-top: 16px; justify-content: flex-end; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; }

/* ---------- Admin ---------- */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #e4e8ed; padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tab { font: inherit; font-weight: 700; padding: 9px 18px; border-radius: 9px; cursor: pointer; border: 0; background: transparent; color: var(--muted); }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(17, 28, 38, .15); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: #f6f8fa; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat small { display: block; color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat strong { display: block; font-size: 1.35rem; line-height: 1.35; }
.stat.main { background: var(--ink); border-color: var(--ink); border-left: 8px solid var(--taxi); color: #fff; }
.stat.main small { color: #c4ced8; }
.stat.warn { background: var(--warn-bg); border-color: #ecd98a; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.toolbar h2 { margin: 0; }
.grow { flex: 1; margin: 0; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 12px; margin-bottom: 8px; }
.filters .field { margin-bottom: 8px; min-width: 150px; }
.filters .field input, .filters .field select { min-height: 52px; }
.filters > .btn { width: auto; align-self: flex-end; margin-bottom: 8px; }

.tablewrap { overflow-x: auto; }
.tablewrap.tall { max-height: 55vh; overflow-y: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.t th, table.t td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t th { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: #f6f8fa; }
table.t tbody tr:hover td { background: #fafbfc; }
table.t .num { text-align: right; white-space: nowrap; }
table.t .strong { font-weight: 800; }
table.t .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
table.t .pos { color: var(--ok); font-weight: 700; }
table.t .neg { color: var(--bad); font-weight: 700; }
table.t td.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; background: #e8ecef; color: var(--ink); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.tab .badge { margin-left: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; max-width: min(92vw, 560px);
  transition: opacity .2s, transform .2s; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Chop etish: faqat chek (kassa lentasi, taxminan 80 mm) ---------- */
#printArea { display: none; }
@media print {
  @page { margin: 3mm; }
  html, body { background: #fff; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  #printArea .ticket { border: 0; box-shadow: none; max-width: 72mm; width: 72mm; padding: 0; margin: 0; font-size: 12px; }
  #printArea .ticket-logo { height: 36px; }
}

/* Admin: Tizim va Jurnal */
.section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 800; }
.field.inline { margin: 0; }
.field.inline select { min-height: 44px; font-size: 1rem; padding: 8px 12px; }
.secret { font: 700 1.15rem/1.5 ui-monospace, Consolas, monospace; letter-spacing: .08em; background: #f6f8fa; padding: 12px 14px; border-radius: 10px; overflow-wrap: anywhere; user-select: all; margin: 8px 0 12px; }
code { font: .9em ui-monospace, Consolas, monospace; background: #eef1f4; padding: 1px 6px; border-radius: 6px; }
