:root { color-scheme: light; --page: #f1f5f9; --surface: #fff; --text: #1e293b; --border: #e2e8f0; --surface-soft: #f8fafc; --text-secondary: #475569; --muted: #64748b; --label: #334155; --input-border: #cbd5e1; }
html[data-theme="dark"] {
  color-scheme: dark;
  --page: #111821; --surface: #1b2531; --surface-soft: #222f3e;
  --text: #e5edf5; --text-secondary: #bdcad8; --muted: #a2b2c4;
  --label: #d0dce8; --border: #344253; --input-border: #4b6075;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--page);
  color: var(--text);
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: #1f2937;
  color: #d1d5db;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  transition: margin-left .2s;
  z-index: 30;
}
.sidebar.collapsed { margin-left: -230px; }
.brand {
  padding: 18px 20px;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  border-bottom: 1px solid #374151;
  letter-spacing: .5px;
}
.sidebar nav { padding: 10px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #111827; color: #fff; }
.sidebar nav a.active { background: #111827; color: #fff; border-left-color: #22c55e; }
.sidebar .sect { padding: 16px 20px 6px; font-size: 11px; text-transform: uppercase; color: #6b7280; }

.main-area { flex: 1; margin-left: 230px; transition: margin-left .2s; }
.main-area.expanded { margin-left: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.hamburger {
  background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary);
}
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }
.crumbs .sep { margin: 0 6px; }
.topbar .spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 12px; font-size: 13px;
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: #22c55e; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.user-chip .role { color: var(--muted); font-size: 11px; }
.btn-out-sm {
  background: var(--border); color: var(--label); border: none; padding: 5px 10px;
  border-radius: 6px; cursor: pointer; font-size: 12px;
}

main { padding: 22px; max-width: 1400px; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .spacer { flex: 1; }

h1 { margin-bottom: 16px; font-size: 22px; }
h2 { font-size: 16px; margin-bottom: 12px; }
h3 { font-size: 14px; margin-bottom: 8px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-title { font-weight: 600; margin-bottom: 12px; font-size: 15px; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { text-align: center; padding: 12px; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.green b { color: #16a34a; }
.stat.red b { color: #dc2626; }
.stat.blue b { color: #2563eb; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
thead th { color: var(--text-secondary); font-weight: 600; background: var(--surface-soft); cursor: pointer; white-space: nowrap; }
thead th.sorted-asc::after { content: ' ▲'; font-size: 9px; }
thead th.sorted-desc::after { content: ' ▼'; font-size: 9px; }
thead tr.search-row th { padding: 4px 6px; background: var(--surface); cursor: default; }
thead tr.search-row input, thead tr.search-row select {
  width: 100%; padding: 5px 7px; font-size: 12px; border: 1px solid var(--border); border-radius: 4px;
  margin: 0;
}
.suggest-box {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  max-height: 260px;
  overflow-y: auto;
  min-width: 140px;
}
.suggest-item {
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.suggest-item:hover { background: #eff6ff; color: #1d4ed8; }
tbody tr:hover { background: var(--surface-soft); }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }

/* Действия в таблице актов: компактный ряд без «разъезжания» */
.acts-actions { display: inline-flex; align-items: center; gap: 4px; }
.acts-actions .status-select {
  width: auto; min-width: 140px; margin: 0; padding: 5px 8px;
  font-size: 12px; border-radius: 6px;
}
.acts-actions .icon-btn {
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px;
  background: var(--surface); line-height: 1;
}
.acts-actions .icon-btn:hover { background: var(--surface-soft); }
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 15px; padding: 2px 4px;
  color: var(--text-secondary); vertical-align: middle;
}
.icon-btn:hover { color: #111; }
.icon-btn.danger:hover { color: #dc2626; }
.text-right { text-align: right; }
.muted { color: var(--muted); font-size: 12px; }
.empty { text-align: center; color: #94a3b8; padding: 26px; font-size: 14px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.yellow { background: #fef9c3; color: #854d0e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.gray { background: var(--page); color: var(--text-secondary); }
.badge.orange { background: #ffedd5; color: #9a3412; }

.overdue { color: #dc2626; font-weight: 700; }
.soon { color: #ea580c; font-weight: 700; }

.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 12px; font-size: 13px; }
.pagination select { width: auto; padding: 4px 6px; }
.pagination button { border: 1px solid var(--border); background: var(--surface); border-radius: 5px; padding: 4px 9px; cursor: pointer; }
.pagination button.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.pagination button:disabled { opacity: .4; cursor: default; }

/* ---------- Формы ---------- */
label { display: block; margin-bottom: 9px; font-size: 13px; color: var(--label); }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--input-border); border-radius: 6px;
  font-size: 13px; margin-top: 3px; background: var(--surface);
}
textarea { min-height: 66px; resize: vertical; }
input[type=checkbox] { width: auto; margin-top: 0; }
.check { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 13px; }
.check input { margin: 0; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 150px; }
.form-row .check { flex: 0 0 auto; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 14px; }
/* Форма добавления клиента: поля идут в столбик (подпись : окошко) */
#clientModal .field-grid { grid-template-columns: 1fr; gap: 6px; }
#clientModal .modal { max-width: 480px; }
/* Договор аренды: поля условий — в столбик (подпись : окошко) */
.contract-layout .field-grid { grid-template-columns: 1fr; gap: 6px; }
/* Форма добавления техники: поля идут в столбик (подпись : окошко) */
#scooterForm .field-grid { grid-template-columns: 1fr; gap: 6px; }
#scooterForm form { max-width: 480px; }
/* Универсальный «столбик»: подпись сверху, окошко снизу — одна колонка */
.field-grid.col { grid-template-columns: 1fr; gap: 6px; }

.btn {
  display: inline-block; background: #2563eb; color: #fff; border: none;
  padding: 9px 16px; border-radius: 6px; font-size: 14px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #1d4ed8; }
.btn.green { background: #22c55e; }
.btn.green:hover { background: #16a34a; }
.btn.gray { background: #64748b; }
.btn.gray:hover { background: #475569; }
.btn.orange { background: #f59e0b; }
.btn.orange:hover { background: #d97706; }
.btn.red { background: #dc2626; }
.btn.red:hover { background: #b91c1c; }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.danger { background: #dc2626; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-danger { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef9c3; color: #854d0e; }
.flash-info { background: #dbeafe; color: #1e40af; }

/* ---------- Вкладки ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 16px; font-size: 14px; color: var(--text-secondary); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

/* ---------- Login ---------- */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #1f2937; }
.login-card { width: 400px; max-width: 92%; background: var(--surface); border-radius: 12px; padding: 30px; }
.login-card h1 { font-size: 22px; text-align: center; }
.login-card .muted { text-align: center; margin-bottom: 18px; }
.login-card .btn { width: 100%; margin-top: 8px; }

/* ---------- Договор ---------- */
.contract-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rent-block { border: 1px dashed var(--input-border); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.rent-block table { margin-bottom: 8px; }
.info-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.info-line b { font-weight: 600; }
.total-box { background: #dcfce7; padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; }

/* ---------- Карта ---------- */
.map-grid { position: relative; background: var(--border); border-radius: 10px; min-height: 420px; overflow: hidden; }
.map-marker {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  background: #2563eb; color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; cursor: pointer; border: 2px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.map-marker.rented { background: #f59e0b; }
.map-marker.overdue { background: #dc2626; }
.map-marker.offmap { background: #94a3b8; }
.map-side { position: absolute; right: 10px; top: 10px; width: 260px; background: var(--surface); border-radius: 8px; padding: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* ---------- Группы аксессуаров ---------- */
.group-head { background: var(--page); font-weight: 700; }
.group-total { background: var(--surface-soft); font-weight: 600; }
.grand-total { text-align: right; font-weight: 700; font-size: 15px; padding: 10px 0; }

/* ---------- Модальное окно ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 12px; width: 100%; max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 20px 22px;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.modal-close {
  background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.modal-close:hover { background: var(--page); color: #0f172a; }

@media (max-width: 960px) {
  .contract-layout, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .sidebar { margin-left: -230px; }
  .sidebar.open { margin-left: 0; }
  .main-area { margin-left: 0; }
}

/* ---------- �������������� ������ ������ ---------- */
.group-toggle {
  background: var(--border); border: none; border-radius: 6px;
  width: 22px; height: 22px; line-height: 1; cursor: pointer;
  font-size: 12px; color: var(--label); margin-right: 6px; vertical-align: middle;
}
.group-toggle:hover { background: var(--input-border); }
.part-details { padding: 4px 0; }
.sub-parts { width: 100%; border-collapse: collapse; }
.sub-parts th, .sub-parts td {
  border: 1px solid var(--border); padding: 6px 8px; text-align: left;
  font-size: 13px;
}
.sub-parts th { background: var(--surface-soft); }
.sub-parts .muted, td .muted { color: var(--muted); font-size: 12px; }

/* VETROLET branding */
.brand { display:flex; align-items:center; gap:10px; }
.brand-logo { width:34px; height:34px; object-fit:contain; flex:0 0 34px; }
.login-brand { display:flex; align-items:center; justify-content:center; gap:12px; }
.login-brand-logo { width:48px; height:48px; object-fit:contain; }

/* Все значения и элементы в столбцах выровнены по центру. */
table th, table td, table .text-right, .sub-parts th, .sub-parts td { text-align: center; }
table input, table select, table textarea { text-align: center; }

/* Keep wide warehouse details inside their card on laptop screens. */
.main-area { min-width: 0; }
.warehouse-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.warehouse-layout > .card { min-width: 0; }
.warehouse-layout .sub-parts td.actions { white-space: normal; }
.warehouse-layout .sub-parts td.actions form { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 3px; }
@media (max-width: 1366px) {
  .warehouse-layout { grid-template-columns: minmax(0, 1fr); }
}

.theme-toggle { white-space: nowrap; min-height: 32px; }
.login-theme { position: absolute; right: 22px; top: 20px; z-index: 1; }
input, select, textarea { color: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 2px solid #60a5fa; outline-offset: 3px; }
html[data-theme="dark"] a:where(:not(.btn):not(.btn-out-sm)) { color: #93c5fd; }
html[data-theme="dark"] .sidebar nav a { color: #cbd5e1; }
html[data-theme="dark"] .sidebar nav a.active { color: #fff; }
html[data-theme="dark"] .tabs a.active { color: #93c5fd; }
html[data-theme="dark"] .login-wrap { background: var(--page); }
html[data-theme="dark"] .badge.green, html[data-theme="dark"] .flash-success,
html[data-theme="dark"] .total-box { background: #163d30; color: #a7f3d0; }
html[data-theme="dark"] .badge.red, html[data-theme="dark"] .flash-danger { background: #4c252d; color: #fecaca; }
html[data-theme="dark"] .badge.blue, html[data-theme="dark"] .flash-info { background: #203b60; color: #bfdbfe; }
html[data-theme="dark"] .badge.yellow, html[data-theme="dark"] .flash-warning { background: #493b1c; color: #fef08a; }
html[data-theme="dark"] .badge.orange { background: #4b321f; color: #fed7aa; }
html[data-theme="dark"] .badge.gray { background: var(--surface-soft); color: var(--text-secondary); }
html[data-theme="dark"] .stat.green b { color: #86efac; }
html[data-theme="dark"] .stat.red b, html[data-theme="dark"] .overdue { color: #fca5a5; }
html[data-theme="dark"] .stat.blue b { color: #93c5fd; }
html[data-theme="dark"] .soon { color: #fdba74; }
html[data-theme="dark"] .icon-btn:hover, html[data-theme="dark"] .modal-close:hover { color: #fff; }
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .leaflet-control a { background: var(--surface); color: var(--text); }
#serialBox { margin: 10px 0; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); }
@media (max-width: 760px) {
 .topbar { flex-wrap: wrap; gap: 10px; }
 .topbar .user-chip { display: none; }
}
@media print {
 html[data-theme="dark"] { color-scheme: light; --page: #fff; --surface: #fff; --surface-soft: #f8fafc; --text: #1e293b; --text-secondary: #475569; --muted: #64748b; --label: #334155; --border: #e2e8f0; --input-border: #cbd5e1; }
 .theme-toggle { display: none; }
}

/* Акты приёма-передачи */
.handover-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin: 8px 0; }
.handover-photos img { width: 100%; height: 84px; object-fit: cover; border-radius: 6px; border: 1px solid var(--input-border); display: block; }
.handover-kit { border: 1px solid var(--input-border); border-radius: 8px; padding: 8px 12px; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.handover-kit legend { padding: 0 4px; font-size: 13px; }
#handover textarea { width: 100%; box-sizing: border-box; font: inherit; }
