:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eef4ff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #b45309;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }

.header {
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; z-index: 20;
}
.header-title { font-size: 19px; font-weight: 800; }
.header-sub { font-size: 12px; opacity: .9; margin-top: 4px; }
.icon-btn { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); color: #fff; font-size: 20px; border-radius: 12px; width: 44px; height: 44px; cursor: pointer; }

.screen { display: none; padding: 16px; }
.screen.active { display: block; }

.card { background: var(--card); border-radius: 18px; padding: 16px; margin-bottom: 14px; box-shadow: 0 2px 12px rgba(20,30,60,.06); }
.dark-card { background: linear-gradient(180deg, #071120, #020814); color: #fff; border-radius: 20px; padding: 16px; margin-bottom: 14px; }
.info-card { background: var(--blue-soft); border: 1px solid #dbeafe; color: #1e3a8a; border-radius: 16px; padding: 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.55; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.45; margin-bottom: 12px; }
.section-title { font-size: 16px; font-weight: 800; margin-bottom: 14px; }

.field { margin-bottom: 12px; min-width: 0; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid #d1d5db;
  font-size: 16px; background: #fff; color: var(--text); outline: none; font-family: inherit;
}
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.readonly { background: var(--blue-soft) !important; color: var(--blue) !important; font-weight: 800; }
.readonly.over { border: 2px solid var(--red) !important; }
.readonly.high { border: 2px solid #f59e0b !important; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 8px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #374151; font-weight: 700; }
.checks input { width: 18px; height: 18px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 4px 0 10px; }
.hint.light { color: rgba(255,255,255,.65); margin-top: 12px; }
.hint.center { text-align: center; }
.hint a, .consent a { color: var(--blue); }
.checks.consent label { align-items: flex-start; font-weight: 600; font-size: 12px; line-height: 1.45; margin: 4px 0 6px; }
.checks.consent input { flex: none; margin-top: 1px; }
.expense { border-top: 1px dashed var(--line); padding-top: 10px; margin-bottom: 14px; }
.photo-btn { display: inline-block; padding: 8px 12px; border-radius: 10px; background: var(--blue-soft); color: var(--blue-dark); font-size: 13px; font-weight: 800; border: 1px solid #dbeafe; cursor: pointer; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f3f4f6; }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; cursor: pointer; padding: 0; }

.btn-main, .btn-secondary, .btn-save, .btn-danger, .as-btn {
  display: block; width: 100%; border: none; border-radius: 14px; padding: 14px 16px;
  font-size: 15px; font-weight: 800; cursor: pointer; margin-bottom: 10px; text-align: center; text-decoration: none;
}
.btn-main { background: linear-gradient(90deg, var(--blue), var(--blue-dark)); color: #fff; }
.btn-secondary, .as-btn { background: #fff; border: 1px solid #dbe4ff; color: var(--blue); }
.btn-save { background: #0f766e; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-small { display: inline-block; width: auto; padding: 8px 12px; font-size: 13px; border-radius: 10px; margin: 0 6px 6px 0; }
.link-btn { background: none; border: none; color: var(--blue); font-weight: 800; cursor: pointer; padding: 0 4px; font-size: 14px; }

.result-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.12); font-size: 14px; }
.result-row:last-child { border-bottom: none; }
.result-row > div:last-child { text-align: right; white-space: nowrap; }
.muted { color: rgba(255,255,255,.8); }
.pos { color: #4ade80; font-weight: 800; }
.neg { color: #f87171; font-weight: 800; }
.warn { color: #fbbf24; font-weight: 800; }
.card .pos { color: var(--green); }
.card .neg { color: var(--red); }
.profit-title { text-align: center; margin-top: 16px; color: rgba(255,255,255,.85); font-size: 13px; font-weight: 700; }
.profit-amount { text-align: center; font-size: 30px; font-weight: 900; margin-top: 6px; }
.status { text-align: center; margin-top: 8px; font-size: 15px; font-weight: 800; }
.warning-box { margin-top: 10px; line-height: 1.5; font-size: 13px; color: #fbbf24; white-space: pre-line; }

.month-title { font-size: 17px; font-weight: 900; margin: 16px 0 10px; }
.trip-card { background: #fff; border-radius: 16px; padding: 14px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(20,30,60,.06); }
.trip-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; cursor: pointer; }
.trip-date { color: #9ca3af; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.trip-route { font-size: 16px; font-weight: 800; word-break: break-word; }
.trip-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.trip-profit { font-size: 15px; font-weight: 900; white-space: nowrap; }
.trip-details { margin-top: 12px; padding-top: 10px; border-top: 1px solid #eef2f7; }
.trip-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-size: 14px; }
.trip-line > div:first-child { color: var(--muted); }
.trip-line > div:last-child { text-align: right; word-break: break-word; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; margin-top: 6px; }
.chip-paid { background: #dcfce7; color: #166534; }
.chip-debt { background: #fee2e2; color: #991b1b; }
.chip-partial { background: #fef3c7; color: #92400e; }

.analytics-banner { background: #eefcf1; color: var(--green); border-radius: 16px; padding: 16px; text-align: center; font-size: 18px; font-weight: 900; margin-bottom: 14px; border: 1px solid #d7f8df; }
.analytics-banner.loss { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.toggle-row { display: flex; gap: 8px; margin-bottom: 8px; }
.toggle-row button { flex: 1; border: none; border-radius: 12px; padding: 12px; font-weight: 800; cursor: pointer; background: #e5e7eb; color: #374151; }
.toggle-row button.active { background: linear-gradient(90deg, var(--blue), var(--blue-dark)); color: #fff; }
.doc-box { background: #f9fafb; border: 1px solid var(--line); border-radius: 12px; padding: 12px; white-space: pre-line; font-size: 14px; line-height: 1.5; margin-bottom: 10px; }

.client-item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.client-item b { display: block; }
.client-item span { font-size: 12px; color: var(--muted); }

.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 480px;
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line); display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 30;
}
.nav-item { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #9ca3af; font-size: 11px; font-weight: 700; cursor: pointer; padding: 4px 0; }
.nav-item.active { color: var(--blue); }
.nav-icon { font-size: 22px; line-height: 1; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-card { background: #fff; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.modal-card img { width: 100%; border-radius: 12px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 700; z-index: 200; max-width: 90%; text-align: center; }

.sub-banner { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; line-height: 1.45; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.sub-banner.bad { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.sub-banner.ok { background: #eefcf1; border-color: #d7f8df; color: #166534; }
.sub-banner button { margin-top: 8px; }
.pay-box { background: var(--blue-soft); border: 1px solid #dbeafe; border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.6; margin-bottom: 12px; }
.pay-box b.big { font-size: 20px; }
.qr-img { display: block; width: 100%; max-width: 240px; margin: 10px auto; border-radius: 10px; background: #fff; }
.qr-preview img { display: block; max-width: 180px; border-radius: 10px; margin-bottom: 8px; }
.admin-item { background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(20,30,60,.06); font-size: 14px; }
.admin-item .claim { background: #fef3c7; color: #92400e; border-radius: 10px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }

/* ===== Документ для печати ===== */
.print-view { position: fixed; inset: 0; background: #e5e7eb; z-index: 150; overflow: auto; padding: 12px; }
.print-toolbar { display: flex; gap: 8px; max-width: 800px; margin: 0 auto 8px; }
.print-toolbar button { margin: 0; }
.print-doc { background: #fff; color: #000; max-width: 800px; margin: 0 auto; padding: 28px 24px; font-family: "Times New Roman", Times, serif; font-size: 13px; line-height: 1.4; }
.print-doc h1 { font-size: 17px; text-align: center; margin: 14px 0; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.print-doc td, .print-doc th { border: 1px solid #000; padding: 5px 6px; vertical-align: top; }
.print-doc th { background: #f3f4f6; font-weight: bold; }
.print-doc .noborder td { border: none; padding: 2px 4px; }
.print-doc .r { text-align: right; white-space: nowrap; }
.print-doc .c { text-align: center; }
.print-doc .sign { display: flex; justify-content: space-between; gap: 24px; margin-top: 36px; }
.print-doc .sign > div { flex: 1; }
.print-doc .sign-line { border-bottom: 1px solid #000; height: 28px; margin-bottom: 4px; }
.print-doc .small { font-size: 11px; }

@media screen and (max-width: 600px) {
  .print-doc { padding: 14px 8px; font-size: 11px; overflow-x: auto; }
  .print-doc h1 { font-size: 14px; }
  .print-doc td, .print-doc th { padding: 3px; word-break: break-word; }
}

@media print {
  body { background: #fff; }
  .app, .modal, .toast, .no-print { display: none !important; }
  .print-view { position: static; padding: 0; background: #fff; overflow: visible; }
  .print-doc { max-width: none; padding: 0; box-shadow: none; }
  @page { size: A4; margin: 14mm; }
}

/* ===== Автопарк, таблицы ===== */
.client-item.off { opacity: .55; }
.driver-pay { border-top: 1px dashed var(--line); padding-top: 10px; margin-bottom: 6px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; color: var(--muted); font-weight: 700; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mini-table td { padding: 7px 4px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.mini-table td:first-child { white-space: normal; font-weight: 700; }
.park-grid, .calc-grid { display: block; }

/* ===== Ноутбук и планшет: меню слева, широкие экраны ===== */
@media (min-width: 900px) {
  body { background: #eef2f8; }
  .app { max-width: none; margin: 0; padding: 0 0 40px 220px; }
  .header { position: fixed; top: 0; left: 0; bottom: 0; width: 220px; flex-direction: column; align-items: flex-start; justify-content: flex-start; padding: 22px 18px; gap: 14px; z-index: 40; }
  .header .icon-btn { width: 100%; height: auto; padding: 10px; font-size: 15px; text-align: left; }
  .header .icon-btn::after { content: ' Настройки'; font-weight: 700; }
  .bottom-nav { left: 0; top: 150px; bottom: auto; transform: none; width: 220px; max-width: none; flex-direction: column; background: transparent; border-top: none; padding: 0 10px; z-index: 41; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: 15px; color: rgba(255,255,255,.75); padding: 10px 12px; border-radius: 10px; margin-bottom: 4px; }
  .nav-item .nav-icon { font-size: 18px; }
  .nav-item.active { color: #fff; background: rgba(255,255,255,.18); }
  .nav-item:hover { background: rgba(255,255,255,.1); }
  .screen { padding: 28px 32px; max-width: 1240px; }
  .calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
  .calc-side { position: sticky; top: 20px; }
  .park-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
  #tripsList, #capexList, #adList { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
  #tripsList .month-title { grid-column: 1 / -1; }
  #tripsList .trip-card, #capexList .trip-card, #adList .admin-item { margin-bottom: 0; }
  #screen-analytics { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
  #screen-analytics > .section-title, #screen-analytics > .field, #screen-analytics > .toggle-row, #screen-analytics > .hint, #screen-analytics > .analytics-banner { grid-column: 1 / -1; }
  #screen-analytics > .field, #screen-analytics > .toggle-row { max-width: 420px; }
  #screen-settings, #screen-docs { columns: 2; column-gap: 18px; }
  #screen-settings > *, #screen-docs > * { break-inside: avoid; }
  #screen-settings > .section-title, #screen-docs > .section-title { column-span: all; }
  .modal { align-items: center; }
  .modal-card { border-radius: 18px; max-width: 520px; }
  .toast { bottom: 30px; }
  .btn-main, .btn-secondary, .btn-save, .btn-danger { cursor: pointer; }
}
@media (min-width: 1300px) {
  #screen-settings { columns: 3; }
}

/* ===== Водители ===== */
.nav-item { position: relative; }
.badge { position: absolute; top: 0; right: 18%; background: var(--red); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 800; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; }
.inbox-item { background: #fffbeb; border: 1px solid #fde68a; border-radius: 14px; padding: 12px; margin-bottom: 10px; font-size: 14px; }
.inbox-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; float: right; margin-left: 10px; cursor: zoom-in; }
.inbox-item::after { content: ''; display: block; clear: both; }
.code-box { font-family: Consolas, monospace; font-size: 28px; font-weight: 900; letter-spacing: 4px; text-align: center; background: var(--blue-soft); border: 1px dashed var(--blue); border-radius: 12px; padding: 12px; margin: 10px 0; }
.perm-box { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 6px; }
@media (min-width: 900px) { .badge { position: static; margin-left: auto; } #drvTrips { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; } }

/* Налоги (6.7.0) */
.tax-ev { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; cursor: pointer; }
.tax-ev input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.tax-ev.done { opacity: .55; }
.month-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 10px 0; }
.month-chip { display: flex; align-items: center; gap: 4px; justify-content: center; padding: 7px 2px; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.month-chip.done { background: #dcfce7; border-color: #86efac; color: #166534; }
.hint.light { color: rgba(255,255,255,.75); }
#taxPrintBtn { margin-bottom: 12px; }
@media (max-width: 480px) { .nav-item { font-size: 9.5px; min-width: 0; } .nav-icon { font-size: 20px; } }
.tax-past summary { cursor: pointer; padding: 6px 0; }
#taxPastDone { margin: 8px 0 4px; }
.an-note { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0 12px; font-size: 13px; }
.an-note summary { cursor: pointer; font-weight: 700; color: var(--blue); }
.an-note p { margin: 8px 0 0; }

/* Язык */
.header-btns { display: flex; gap: 8px; align-items: center; }
.lang-btn { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; padding: 7px 10px; font-weight: 800; font-size: 13px; cursor: pointer; }
