/* "Автослужба" — minimal corporate UI, no build step. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #dde2ea;
  --text: #1c2430;
  --muted: #6a7686;
  --brand: #1f3a5f;
  --brand-2: #2b5c9b;
  --accent: #2b6fd6;
  --ok: #1e7b46;
  --warn: #9a6200;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; margin-bottom: 12px; }
h2 small { font-weight: 400; font-size: 13px; }
small { font-size: 12.5px; }
.muted { color: var(--muted); }
.ok { color: var(--ok); }
.error, .danger { color: var(--danger); }
.nowrap { white-space: nowrap; }
.right { float: right; margin-left: 8px; }
.req { color: var(--danger); }
[hidden] { display: none !important; }

/* --- controls --- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=date],
input[type=time], input[type=datetime-local], input:not([type]), select, textarea {
  width: 100%; min-height: 38px; padding: 7px 10px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0f5; border-color: var(--accent); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 3px; color: var(--text); font-size: 15px; }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: -4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f1f4f9; text-decoration: none; }
.btn-primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-primary:hover { background: var(--brand); }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fdecea; }
.btn-outline { border-color: var(--brand-2); color: var(--brand-2); }
.btn-active { background: #e4ecf8; border-color: #b9cdea; }
.btn-big { width: 100%; min-height: 56px; font-size: 17px; font-weight: 600; white-space: normal; }
.btn:disabled, button:disabled { opacity: .55; cursor: progress; }
.btn-group { display: inline-flex; gap: 4px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.link.danger { color: var(--danger); }
form.inline { display: inline; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.inline-form .check { flex: 0 0 auto; }

/* --- layout: manager --- */
body.manager { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex: 0 0 220px; background: var(--brand); color: #dbe5f3;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 20px; font-size: 18px; font-weight: 700; color: #fff; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sidebar nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: #dbe5f3; margin-bottom: 2px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 13px; }
.sidebar-foot .muted { color: #a9bbd3; }
.sidebar-foot .link { color: #fff; text-decoration: underline; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.burger, .nav-backdrop { display: none; }
.content { padding: 20px 24px 40px; max-width: 1500px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-danger { border-color: #efb8b3; background: #fff8f7; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.stack > :last-child { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; display: flex; flex-direction: column;
}
.stat b { font-size: 24px; font-weight: 650; }
.stat b small { font-size: 14px; color: var(--muted); font-weight: 400; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat-danger { border-color: #efb8b3; background: #fff5f4; }
.stat-danger b { color: var(--danger); }
.stat-warn { border-color: #ecd49a; background: #fffaf0; }
.stat-warn b { color: var(--warn); }

/* --- tables & lists --- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.table th { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.row-muted td { opacity: .6; }
.trip-list { list-style: none; margin: 0 0 8px; padding: 0; }
.trip-list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.trip-list li:last-child { border-bottom: 0; }
.trip-list small { display: block; color: var(--muted); }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.props dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.plate {
  display: inline-block; padding: 0 6px; border: 1px solid #b8c1cf; border-radius: 4px;
  font: 600 12.5px/1.5 Consolas, "Courier New", monospace; background: #fff; color: var(--text); white-space: nowrap;
}
.plate-primary { border-color: var(--brand-2); box-shadow: inset 0 0 0 1px var(--brand-2); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #e8ecf2; color: #46505f; white-space: nowrap;
}
.st-planned { background: #e8ecf2; color: #46505f; }
.st-assigned { background: #fdf0cf; color: #7a5200; }
.st-accepted { background: #dbe9fb; color: #1d4f91; }
.st-in_progress { background: #d9f2e3; color: #17643a; }
.st-completed { background: #e3efe6; color: #3b5e47; }
.st-cancelled { background: #eeeeee; color: #6d6d6d; }
.st-interrupted { background: #fbe0dd; color: #8f1f18; }
.badge-danger { background: var(--danger); color: #fff; }

.alert { display: block; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert-success { background: #e9f6ee; border-color: #b7dcc5; color: #17643a; }
.alert-error { background: #fdecea; border-color: #f0b9b4; color: #8f1f18; }
.alert-warning { background: #fff6e0; border-color: #ecd49a; color: #6e4b00; }
.alert-info { background: #e9f1fc; border-color: #bcd2f1; color: #1d4f91; }
.alert .btn { margin-top: 8px; }

/* --- forms --- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.field-wide { grid-column: 1 / -1; }
.field-check { align-self: end; padding-bottom: 8px; }
.field-check label, label.check { color: var(--text); font-size: 15px; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field small { display: block; margin-top: 2px; }
.field ul, .field > div[id] { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.field ul label, .field > div[id] label { color: var(--text); font-size: 15px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; margin-top: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { flex: 1 1 150px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs a { padding: 6px 14px; border-radius: 999px; color: var(--muted); }
.tabs a.active { background: #e4ecf8; color: var(--brand); font-weight: 600; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 14px; }

.fs-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.fs-row.is-deleted { opacity: .4; text-decoration: line-through; }
.fs-row > label { flex: 1 1 110px; }
.fs-row > label.grow-2 { flex-grow: 3; }
.fs-row > small.error { flex-basis: 100%; }
.fs-delete { flex: 0 0 auto !important; color: var(--danger); cursor: pointer; padding-top: 22px; }
.point-order { flex: 0 0 64px; }
.point-order input { text-align: center; }
.point-body { flex: 1 1 300px; min-width: 0; }
.point-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.point-grid .span-2 { grid-column: span 2; }

details.action { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
details.action > summary { padding: 10px 12px; cursor: pointer; font-weight: 600; }
details.action[open] > summary { border-bottom: 1px solid var(--border); }
details.action > form, details.action > p { padding: 12px; margin: 0; display: grid; gap: 10px; }

/* --- route & events --- */
.route { list-style: none; margin: 0; padding: 0; counter-reset: point; }
.route li { position: relative; padding: 0 0 14px 34px; counter-increment: point; }
.route li::before {
  content: counter(point); position: absolute; left: 0; top: 0; width: 24px; height: 24px;
  border-radius: 50%; background: #e8ecf2; color: #46505f; font-size: 12.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.route li::after { content: ""; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; background: #e1e6ee; }
.route li:last-child { padding-bottom: 0; }
.route li:last-child::after { display: none; }
.route li.done::before { background: var(--ok); color: #fff; }
.route li.next::before { background: var(--brand-2); color: #fff; }
.route small { display: block; }
.route small > * { margin-right: 8px; }
.events { list-style: none; margin: 12px 0 0; padding: 0; }
.events li { padding: 8px 0 8px 12px; border-left: 3px solid var(--border); margin-bottom: 6px; }
.events time { color: var(--muted); font-size: 12.5px; margin-right: 6px; }
.events .ev-correction { border-left-color: #e0a100; }
.events .ev-comment { border-left-color: var(--accent); }
.events .ev-status { border-left-color: var(--ok); }

/* --- calendar --- */
.cal-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px; min-height: 110px; }
.cal-week .cal-day { min-height: 320px; }
.cal-today { border-color: var(--brand-2); box-shadow: inset 0 0 0 1px var(--brand-2); }
.cal-other { background: #f7f8fa; opacity: .7; }
.cal-date { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cal-trip { display: block; padding: 4px 6px; border-radius: 6px; margin-bottom: 4px; font-size: 12.5px; line-height: 1.3; overflow: hidden; }
.cal-trip:hover { text-decoration: none; filter: brightness(.96); }
.cal-trip small { display: block; opacity: .85; }
.legend { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* --- login --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; color: var(--brand); }
.login-card form { display: grid; gap: 14px; margin-top: 16px; }

/* --- network & toasts --- */
.net-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 50; background: var(--danger); color: #fff; text-align: center; padding: 6px 12px; font-size: 13.5px; }
.toasts { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 60; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { max-width: 480px; padding: 10px 16px; border-radius: 10px; background: #2a2f38; color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.is-busy { opacity: .7; }
.htmx-request.btn, .htmx-request .btn-big { opacity: .6; }

/* --- layout: driver (mobile first) --- */
body.driver { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.d-top { background: var(--brand); color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 5; }
.d-top h1 { font-size: 18px; }
.d-content { padding: 12px; max-width: 640px; margin: 0 auto; }
.d-section { margin: 18px 4px 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.d-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.d-nav a { flex: 1; text-align: center; padding: 12px 2px; min-height: 56px; display: flex; align-items: center; justify-content: center; font-size: 12.5px; color: var(--muted); border-top: 3px solid transparent; }
.d-nav a.active { color: var(--brand-2); font-weight: 700; border-top-color: var(--brand-2); }
.d-nav a:hover { text-decoration: none; }
.trip-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.trip-card h2 { font-size: 18px; margin-bottom: 4px; }
.trip-card p { margin: 4px 0; }
.trip-time { font-weight: 600; }
.trip-card .route { margin: 12px 0; }
.trip-card form { display: grid; gap: 10px; margin-top: 10px; }
.trip-item { display: block; color: var(--text); }
.trip-item:hover { text-decoration: none; border-color: #b9cdea; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
body.driver .btn { min-height: 46px; }
body.driver input, body.driver textarea { min-height: 46px; font-size: 16px; }

/* --- responsive: manager on phones --- */
@media (max-width: 1200px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .4); }
  .burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 22px; color: var(--text); cursor: pointer; }
  .topbar { padding: 10px 12px; }
  .content { padding: 12px 12px 32px; }
  .calendar { grid-template-columns: minmax(0, 1fr); }
  .cal-day, .cal-week .cal-day { min-height: 0; }
  .cal-other { display: none; }
  .point-grid { grid-template-columns: minmax(0, 1fr); }
  .point-grid .span-2 { grid-column: auto; }
  .props { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .props dd { margin-bottom: 8px; }
  input, select, textarea { font-size: 16px; }
}
