/* AutoBui OS — мобильный учёт автопарка. Цвета статусов: красный — просрочено, янтарный — скоро, зелёный — в порядке. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #17202b;
  --muted: #5f6b78;
  --line: #e1e5ea;
  --brand: #1b2430;
  --accent: #e8a317;
  --accent-text: #1b2430;
  --primary: #1f5fbf;
  --primary-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #c9d1db;
  --focus: #9ec0f5;
  --hover: #eef1f5;
  --ok: #157f3b; --ok-bg: #dcf5e4; --ok-fg: #0f5f2c;
  --soon: #b26a00; --soon-bg: #fff1cc; --soon-fg: #7a4800;
  --bad: #c62828; --bad-bg: #fde3e3; --bad-fg: #9b1c1c;
  --info-bg: #e3eefc; --info-fg: #163f7a;
  --none-bg: #eceff3; --none-fg: #5f6b78;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #182029; --text: #e7ecf2; --muted: #9aa6b2; --line: #2b3541;
  --brand: #0b1016; --accent: #f0b232; --accent-text: #11161c; --primary: #4b8fee; --primary-text: #0b1016;
  --input-bg: #10161d; --input-border: #3a4653; --focus: #2c5a9c; --hover: #202a35;
  --ok: #3fbf6a; --ok-bg: #13301e; --ok-fg: #8be0a8;
  --soon: #f0b232; --soon-bg: #3a2c0b; --soon-fg: #f6cf74;
  --bad: #ff6b6b; --bad-bg: #3d1618; --bad-fg: #ffa3a3;
  --info-bg: #13294a; --info-fg: #a8c8f5; --none-bg: #222b35; --none-fg: #9aa6b2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #182029; --text: #e7ecf2; --muted: #9aa6b2; --line: #2b3541;
    --brand: #0b1016; --accent: #f0b232; --accent-text: #11161c; --primary: #4b8fee; --primary-text: #0b1016;
    --input-bg: #10161d; --input-border: #3a4653; --focus: #2c5a9c; --hover: #202a35;
    --ok: #3fbf6a; --ok-bg: #13301e; --ok-fg: #8be0a8;
    --soon: #f0b232; --soon-bg: #3a2c0b; --soon-fg: #f6cf74;
    --bad: #ff6b6b; --bad-bg: #3d1618; --bad-fg: #ffa3a3;
    --info-bg: #13294a; --info-fg: #a8c8f5; --none-bg: #222b35; --none-fg: #9aa6b2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .4rem 0 .8rem; line-height: 1.25; }
h2 { font-size: 1.12rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
code { background: var(--hover); padding: 0 .3em; border-radius: 4px; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.warn-text { color: var(--soon); font-weight: 600; }
.req { color: var(--bad); }
[hidden] { display: none !important; }

.container { max-width: 860px; margin: 0 auto; padding: 12px 16px 24px; }

/* шапка */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  background: var(--brand); color: #fff; padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 7px; }
.topsearch { flex: 1; max-width: 320px; }
.topsearch input { width: 100%; padding: 7px 12px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: .95rem; }
.topsearch input::placeholder { color: rgba(255, 255, 255, .65); }
.mainnav { display: none; gap: 4px; margin-left: auto; }
.mainnav a { color: rgba(255, 255, 255, .8); padding: 6px 10px; border-radius: 8px; }
.mainnav a.active, .mainnav a:hover { color: #fff; background: rgba(255, 255, 255, .12); text-decoration: none; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px 8px; color: var(--muted); font-size: .72rem; }
.bottomnav a:hover { text-decoration: none; }
.bottomnav .ico { font-size: 1.25rem; line-height: 1.2; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }
.bottomnav a.add .ico { background: var(--accent); color: var(--accent-text); border-radius: 50%; width: 34px; height: 34px; display: grid; place-items: center; font-weight: 700; margin-top: -3px; }

@media (min-width: 900px) {
  .mainnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 0; }
}

/* блоки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 0 0 14px; }
.card.empty { text-align: center; padding: 24px 16px; }
.ok-card { border-left: 4px solid var(--ok); }
section > h2 { margin-top: 1.1rem; }
.pagehead, .between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.between > a { flex: 1; }
.right { text-align: right; }
.label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.big-link { font-size: 1.15rem; font-weight: 700; }
.count { display: inline-block; background: var(--bad); color: #fff; border-radius: 999px; font-size: .8rem; padding: 0 8px; vertical-align: middle; }

/* кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--input-border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: .9rem; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 4px; }
.link.danger { color: var(--bad); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.actions form { margin: 0; }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 14px; }
.qbtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); font-size: .82rem; font-weight: 600; text-align: center;
}
.qbtn span { font-size: 1.4rem; }
.qbtn:hover { text-decoration: none; background: var(--hover); }

/* формы */
form { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); flex: none; }
label.checkbox, label.radio { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
label.checkbox.big { font-weight: 600; padding: 10px 12px; border: 1px dashed var(--input-border); border-radius: 10px; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 700; padding: 0 6px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.inline input, .inline select { flex: 1; min-width: 140px; width: auto; }
.upload input[type="file"] { padding: 8px; }
details summary { cursor: pointer; padding: 6px 0; color: var(--primary); font-weight: 600; }
details[open] summary { margin-bottom: 8px; }

/* сообщения */
.flash { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; background: var(--ok-bg); color: var(--ok-fg); }
.flash.error { background: var(--bad-bg); color: var(--bad-fg); }
.flash.warn { background: var(--soon-bg); color: var(--soon-fg); }
.flash.info { background: var(--info-bg); color: var(--info-fg); }

/* статусы */
.chip { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .8rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.lvl-overdue.chip, .chip.lvl-today { background: var(--bad-bg); color: var(--bad-fg); }
.chip.lvl-soon { background: var(--soon-bg); color: var(--soon-fg); }
.chip.lvl-ok { background: var(--ok-bg); color: var(--ok-fg); }
.chip.lvl-none { background: var(--none-bg); color: var(--none-fg); }
.badge { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: .78rem; font-weight: 700; white-space: nowrap; vertical-align: middle; }
.badge.st-line { background: var(--ok-bg); color: var(--ok-fg); }
.badge.st-repair { background: var(--bad-bg); color: var(--bad-fg); }
.badge.st-search { background: var(--soon-bg); color: var(--soon-fg); }
.badge.st-idle { background: var(--none-bg); color: var(--none-fg); }
.statline { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.dot::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; background: var(--none-fg); vertical-align: 0; }
.dot.lvl-ok::before { background: var(--ok); }
.dot.lvl-soon::before { background: var(--soon); }
.dot.lvl-today::before, .dot.lvl-overdue::before { background: var(--bad); }

.plate {
  font-family: "Roboto Mono", ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .02em;
  border: 2px solid var(--text); border-radius: 6px; padding: 0 6px; background: var(--surface); color: var(--text); white-space: nowrap;
}
a.plate:hover { text-decoration: none; background: var(--hover); }
.plate.big { font-size: 1.6rem; display: inline-block; padding: 2px 10px; margin: 0; }

/* главная: что требует внимания */
.alerts { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 8px; }
.alert a {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--none-fg); border-radius: 10px; color: var(--text);
}
.alert a:hover { text-decoration: none; background: var(--hover); }
.alert .text { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }
.alert.lvl-overdue a, .alert.lvl-today a { border-left-color: var(--bad); }
.alert.lvl-soon a { border-left-color: var(--soon); }

.carlist { display: flex; flex-direction: column; gap: 8px; }
.carrow { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); box-shadow: var(--shadow); }
a.carrow:hover, .carrow a.carrow-top:hover { text-decoration: none; }
a.carrow:hover { background: var(--hover); }
.carrow-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text); }
.carrow-sub { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: .88rem; color: var(--muted); }
.row-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* карточка машины */
.carhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin: 6px 0 12px; flex-wrap: wrap; }
.statusform select { width: auto; font-weight: 600; }
.terms { list-style: none; padding: 0; margin: 0; }
.terms > li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.terms > li:first-child { border-top: 0; }
.terms > li.sub { border-top: 0; padding-top: 0; }
.term-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.recs { list-style: none; padding: 0; margin: 0 0 8px; }
.recs li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.recs li:first-child { border-top: 0; }
.recs li.done span { text-decoration: line-through; color: var(--muted); }
.check { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--input-border); background: var(--surface); color: #fff; font-weight: 700; cursor: pointer; flex: none; }
.check.on { background: var(--ok); border-color: var(--ok); }

.list { list-style: none; padding: 0; margin: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li > a, .list li > div { display: block; padding: 10px 2px; color: var(--text); }
.list li > a:hover { text-decoration: none; background: var(--hover); }
.list.card { padding-top: 4px; padding-bottom: 4px; }
.menu { list-style: none; padding: 4px 16px; }
.menu li { border-top: 1px solid var(--line); }
.menu li:first-child { border-top: 0; }
.menu a { display: block; padding: 14px 0; color: var(--text); font-weight: 600; }
.plain { margin: 4px 0; padding-left: 18px; }

.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.tbl { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .93rem; }
.tbl th, .tbl td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; border-top: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl tfoot td { font-weight: 600; }
.tbl tr.sum td { font-size: 1.05rem; border-top: 2px solid var(--text); }
.total { text-align: right; font-size: 1.05rem; margin: 6px 0 0; }

/* заказ-наряд: строки */
.line { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 0; border-top: 1px dashed var(--line); }
.line:first-child { border-top: 0; }
.line select { grid-column: 1 / 2; }
.line input[name="line_name"] { grid-column: 1 / -1; }
.line .qty { width: 80px; }
.line .price { width: auto; }
.line [data-remove-line] { grid-row: 1; grid-column: 2; }
@media (min-width: 640px) {
  .line { grid-template-columns: 120px 1fr 70px 120px 36px; align-items: center; }
  .line select, .line input[name="line_name"] { grid-column: auto; }
  .line .qty { width: 100%; }
  .line [data-remove-line] { grid-row: auto; grid-column: auto; }
}

/* фото */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 8px 0; }
.thumb { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; background: var(--hover); }
.thumb .pdf { display: grid; place-items: center; aspect-ratio: 1; border-radius: 8px; background: var(--info-bg); color: var(--info-fg); font-weight: 700; text-align: center; padding: 6px; overflow: hidden; }
.thumb figcaption { font-size: .78rem; color: var(--muted); line-height: 1.25; }
.day { color: var(--muted); font-size: .9rem; margin: 12px 0 0; }

/* аренда */
.paylist { display: flex; flex-direction: column; }
.card.pay.debtor { border-left: 5px solid var(--bad); }
.card.pay > a { color: var(--text); }
.card.pay > a:hover { text-decoration: none; }
.who { padding: 8px 0; border-top: 1px solid var(--line); }
.who:first-child { border-top: 0; }

/* вход */
body.auth { padding-bottom: 0; background: var(--brand); min-height: 100vh; }
body.auth .container { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.auth-card { background: var(--surface); border-radius: 16px; padding: 24px 20px; max-width: 380px; width: 100%; margin: 0 auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.auth-card h1 { margin-bottom: 0; }
.auth-logo { border-radius: 16px; display: block; margin-bottom: 8px; }

/* договор */
.btn.wide { display: block; width: 100%; text-align: center; margin: 16px 0 8px; padding: 14px; font-size: 1.05rem; }
