/* Байк Центр CRM. Светлая тема по умолчанию, тёмная — в цветах логотипа.
   Тема — атрибут data-theme на <html> (переключатель в меню, выбор хранится в браузере). */

:root {
  --font-head: "Unbounded", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 16px;
  --radius-sm: 12px;

  --bg: #f4f2ec;
  --panel: #ffffff;
  --panel-2: #f8f7f2;
  --line: #e7e3d8;
  --line-strong: #d6d1c3;
  --text: #15170f;
  --muted: #6b6e62;
  --accent: #6cbf2e;
  --accent-hover: #5eae22;
  --accent-ink: #10190a;
  --accent-soft: #ebf6de;
  --accent-text: #3f8a12;
  --shadow: 0 1px 2px rgba(20, 22, 12, .04), 0 8px 24px rgba(20, 22, 12, .05);

  --green-bg: #e3f4d3;  --green-fg: #2f7a0e;
  --blue-bg: #e2ecfd;   --blue-fg: #2258c4;
  --violet-bg: #ece6fe; --violet-fg: #5b3fd1;
  --amber-bg: #fcefd2;  --amber-fg: #9a6400;
  --red-bg: #fde3e0;    --red-fg: #c0392f;
  --gray-bg: #ecebe5;   --gray-fg: #5e6055;
  --green: #3f9b1c; --blue: #2f6fdb; --amber: #d99a12; --red: #d6453d; --violet: #7b5cf0;

  --flash-ok-bg: #e9f6dc; --flash-ok-line: #bfe39e; --flash-ok-fg: #2d6b0c;
  --flash-err-bg: #fde8e5; --flash-err-line: #f3b9b2; --flash-err-fg: #a5281f;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0b0c09;
  --panel: #141610;
  --panel-2: #1a1d15;
  --line: #272b20;
  --line-strong: #363b2c;
  --text: #eef2e6;
  --muted: #9aa18b;
  --accent: #a6e22e;
  --accent-hover: #b8f040;
  --accent-ink: #0b0c09;
  --accent-soft: #1e2a10;
  --accent-text: #b8ee52;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);

  --green-bg: #1c2d10;  --green-fg: #a6e22e;
  --blue-bg: #14223a;   --blue-fg: #7fb0ff;
  --violet-bg: #231b3d; --violet-fg: #b5a0ff;
  --amber-bg: #2e2410;  --amber-fg: #f2c14e;
  --red-bg: #361714;    --red-fg: #ff8a7f;
  --gray-bg: #22251d;   --gray-fg: #a4a996;
  --green: #a6e22e; --blue: #7fb0ff; --amber: #f2c14e; --red: #ff7b6f; --violet: #b5a0ff;

  --flash-ok-bg: #18260c; --flash-ok-line: #35501b; --flash-ok-fg: #b8ee52;
  --flash-err-bg: #2c1210; --flash-err-line: #5a2621; --flash-err-fg: #ffb0a7;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
h1 { font: 700 24px/1.2 var(--font-head); letter-spacing: -.01em; margin: 0 0 18px; }
h2 { font: 700 13px/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .08em;
  margin: 28px 0 12px; color: var(--muted); }
b, strong { font-weight: 700; }

/* ---------- Каркас ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 236px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.brand .name { font: 700 15px/1.1 var(--font-head); }
.brand .tag { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 800 10px/1.6 var(--font-body); letter-spacing: .06em; }
.nav { flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text); margin-bottom: 2px; font-weight: 600; }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--accent); color: var(--accent-ink); }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .me { border-top: 1px solid var(--line); padding: 12px 8px 0; color: var(--muted); font-size: 13px; }
.side .me .who { color: var(--text); font-weight: 700; }
.side .me a { color: var(--muted); font-weight: 600; }
.me-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.main { flex: 1; padding: 26px 32px 64px; min-width: 0; }

.theme-toggle { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0; flex-shrink: 0; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
html[data-theme="dark"] .theme-toggle .sun { display: block; }
html[data-theme="dark"] .theme-toggle .moon { display: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .side { width: auto; height: auto; position: static; padding: 12px; }
  .brand { padding-bottom: 10px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { padding: 7px 10px; margin: 0; }
  .nav .sep { display: none; }
  .side .me { margin-top: 10px; }
  .main { padding: 18px 14px 48px; }
  h1 { font-size: 20px; }
}

/* ---------- Сообщения ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; font-weight: 600; }
.flash.ok { background: var(--flash-ok-bg); border-color: var(--flash-ok-line); color: var(--flash-ok-fg); }
.flash.error { background: var(--flash-err-bg); border-color: var(--flash-err-line); color: var(--flash-err-fg); }

/* ---------- Панель инструментов и плашки ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar form.search { flex: 1; min-width: 240px; display: flex; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--text); font-size: 13px; font-weight: 600; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { background: var(--panel-2); color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.chip.on .n { background: rgba(0, 0, 0, .12); color: var(--accent-ink); }
.chips .gap { width: 8px; }

/* ---------- Кнопки и поля ---------- */
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--panel); color: var(--text);
  font: 700 14px/1.2 var(--font-body); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover, button:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 6px 16px rgba(108, 191, 46, .25); }
.btn.primary:hover, button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger, button.danger { color: var(--red-fg); border-color: var(--red-bg); background: var(--panel); }
.btn.danger:hover, button.danger:hover { border-color: var(--red); }
.btn.small, button.small { padding: 5px 10px; font-size: 12px; border-radius: 10px; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
input, select, textarea { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 9px 12px; font: 500 14px/1.4 var(--font-body); width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--panel-2); color: var(--muted); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: 7px; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 5px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; font-weight: 600; margin: 0; }
.form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  max-width: 900px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.inline { display: inline; }
.inline-form { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline-form > div { min-width: 150px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
  padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 800; background: var(--panel-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
td:first-child, th:first-child { padding-left: 16px; white-space: nowrap; }
td:last-child, th:last-child { padding-right: 16px; }
td a { color: var(--text); }
td a:hover { color: var(--accent-text); }
td:first-child a { color: var(--accent-text); }
td .badge + .badge { margin-top: 3px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.card table th { background: transparent; }
.card table td { padding: 9px 4px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.count { color: var(--muted); font-size: 13px; margin: -4px 0 10px; font-weight: 600; }

/* ---------- Метки статусов ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  white-space: nowrap; background: var(--gray-bg); color: var(--gray-fg); }
.b-green { background: var(--green-bg); color: var(--green-fg); }
.b-blue { background: var(--blue-bg); color: var(--blue-fg); }
.b-violet { background: var(--violet-bg); color: var(--violet-fg); }
.b-amber { background: var(--amber-bg); color: var(--amber-fg); }
.b-red { background: var(--red-bg); color: var(--red-fg); }
.b-gray { background: var(--gray-bg); color: var(--gray-fg); }
.b-outline { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }

/* ---------- Карточки ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h3 .badge { text-transform: none; letter-spacing: 0; }
.kpi { font: 700 28px/1.15 var(--font-head) !important; letter-spacing: -.02em; margin: 2px 0 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head h1 { margin: 0; }
.head .spacer { flex: 1; }

/* ---------- Вход ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; padding: 0 0 26px; box-shadow: var(--shadow); overflow: hidden; }
.login .banner { background: #0b0c09; padding: 22px 26px; display: flex; justify-content: center; }
.login .banner img { width: 100%; max-width: 280px; height: auto; display: block; }
.login .body { padding: 22px 26px 0; }
.login h1 { font-size: 18px; text-align: center; margin-bottom: 16px; }
.login .field { margin-bottom: 12px; }
.login button.primary { width: 100%; margin-top: 6px; padding: 12px; }
.auth .theme-toggle { position: fixed; top: 16px; right: 16px; }
.muted { color: var(--muted); }
.warn { color: var(--amber-fg); font-weight: 600; }

/* ---------- Оформление договора, документы ---------- */
h2.sec { margin: 26px 0 12px; color: var(--accent-strong, var(--text)); }
.flash.warn { background: var(--amber-bg); border-color: var(--amber); color: var(--amber-fg); display: flex; flex-direction: column; gap: 8px; }
.flash.warn label.inline { font-weight: 500; color: var(--text); }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.seg-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; margin: 0; }
.seg-item:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.seg-item span { display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.seg-item small { color: var(--muted); font-weight: 500; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 18px; }
.battery-list { grid-template-columns: 1fr; gap: 6px; margin-bottom: 10px; }
.bat { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.bat .seal { font-weight: 500; color: var(--muted); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.progress { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--accent); }
button.link { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; font-size: 12px; cursor: pointer; box-shadow: none; }
button.link.danger-link { color: var(--red); }
.seg-item input { width: auto; margin: 3px 0 0; flex-shrink: 0; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.flash.info { background: var(--blue-bg); border-color: var(--blue); color: var(--blue-fg); }
.dropzone { position: relative; border: 2px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-2);
  min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 18px; }
.dropzone.has { border-color: var(--accent); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone .dz-text { display: flex; flex-direction: column; gap: 4px; font-size: 16px; color: var(--text); pointer-events: none; }
.dropzone .dz-text span { font-size: 13px; color: var(--muted); }
.dropzone .dz-count { font-weight: 700; color: var(--accent); pointer-events: none; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis .card { padding: 14px 18px; text-align: center; }
.kpis .card h3 { margin: 4px 0 0; }
.meter { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter > div { height: 100%; border-radius: 999px; }
.meter .pos { background: var(--green); }
.meter .neg { background: var(--red); }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font: 500 11px var(--font-body); }
svg.chart .muted-axis { opacity: .75; }
svg.chart .val { fill: var(--text); font: 700 11px var(--font-body); }
svg.chart .bar rect:first-child { fill: var(--accent); }
svg.chart .bar .hit { fill: transparent; }
svg.chart .bar:hover rect:first-child { opacity: .8; }
