/* ==================================================================
   Service Manager — application stylesheet
   Mobile-first. Light background, dark content, blue accent.
   ================================================================== */

:root {
  --bg: #f2f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --text: #18202f;
  --muted: #67748e;
  --border: #e2e8f2;
  --accent: #4f46e5;
  --accent-600: #4338ca;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.1);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.07);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --header-h: 62px;
  --maxw: 1400px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
html { overflow-x: clip; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
.h1 { font-size: 1.55rem; }
.h2 { font-size: 1.05rem; margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.ta-r { text-align: right; }
.inline { display: inline; }
/* ---- container: desktop supports 1400px ---- */
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ==================================================================
   Header & navigation (sticky)
   ================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 1.05rem; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c9cff);
  color: #fff; flex: none;
}
.brand-mark svg { stroke: #fff; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; gap: 2px; }
.brand-name { white-space: nowrap; }
.brand-sub { font-size: .72rem; font-weight: 400; color: var(--muted); white-space: nowrap; }

/* Hamburger (mobile only) */
.nav-toggle {
  display: inline-flex; flex-direction: column; gap: 4px;
  width: 40px; height: 40px; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; margin-left: auto;
}
.nav-toggle-line { width: 18px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.main-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.main-nav.open { display: flex; }

.nav-list { list-style: none; margin: 0; padding: 8px 0; }
.nav-item { position: relative; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .85rem;
}
.nav-link:hover, .nav-item.active > .nav-link { background: var(--accent-soft); color: var(--accent); }
.has-sub::after {
  content: ""; width: 4px; height: 4px; margin-left: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .2s ease;
}
.dropdown.open .has-sub::after { transform: rotate(-135deg); }

.submenu {
  list-style: none; margin: 0; padding: 4px 8px 4px 30px;
  display: none;
}
.dropdown.open > .submenu { display: block; }
.submenu-link { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .92rem; }
.submenu-link:hover, .submenu-link.active { color: var(--accent); background: var(--accent-soft); }

.nav-actions {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 16px; border-top: 1px solid var(--border) !important;
}
.nav-user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 14px 4px 4px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text);
  font-weight: 600; font-size: .9rem; text-decoration: none;
  white-space: nowrap; margin-inline-end: auto; max-width: 100%;
  transition: background .16s ease, color .16s ease;
}
.nav-user-pill:hover, .nav-user-pill.active { background: var(--accent); color: #fff; }
.pill-avatar {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: .8rem; font-weight: 700;
  flex: none;
}
.nav-user-pill:hover .pill-avatar, .nav-user-pill.active .pill-avatar { background: rgba(255,255,255,.25); }
.pill-name { overflow: hidden; text-overflow: ellipsis; }

/* Desktop: show nav inline, submenus on hover/focus */
@media (min-width: 992px) {
  .nav-toggle { display: none; }
  .main-nav { display: flex !important; position: static; width: auto; border-top: 0; flex-direction: row; align-items: center; margin-left: auto; overflow: visible; max-height: none; box-shadow: none; }
  .nav-list { display: flex; gap: 4px; padding: 0; align-items: center; }
  .nav-item > .submenu {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 230px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    box-shadow: var(--shadow); padding: 6px;
    display: block; opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
  }
  .nav-item:hover > .submenu, .nav-item:focus-within > .submenu { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-actions { border-top: none !important; padding: 0 0 0 14px; }
  .nav-link { padding: 9px 12px; }
}

/* Update strip */
.update-strip {
  background: var(--warn-soft); color: #7c4a03;
  border-bottom: 1px solid rgba(217, 119, 6, 0.25);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px;
  font-size: .9rem; font-weight: 600;
}
.update-strip-warn { color: var(--danger); }

/* ==================================================================
   Page & layout
   ================================================================== */
.page { padding-top: 24px; padding-bottom: 56px; }

/* Fixed quick actions on phone-sized screens */
.mobile-bottom-nav { display: none; }
@media (max-width: 767px) {
  .app-body.has-mobile-bottom-nav { padding-bottom: calc(65px + env(safe-area-inset-bottom, 0px)); }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 70;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: .35rem .35rem calc(.4rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 -4px 18px rgba(16, 24, 40, .08);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }
  .mobile-bottom-item {
    display: flex;
    min-width: 0;
    min-height: 56px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    padding: .25rem .15rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .68rem;
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .mobile-bottom-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-bottom-item span { overflow: hidden; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bottom-item.is-active { color: var(--accent); background: var(--accent-soft); }
  .mobile-bottom-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin-bottom: 2px; }
.page-head .muted { margin-top: 0; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.hero h1 { margin-bottom: 2px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow-sm);
}
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { color: var(--muted); font-size: .88rem; }

/* Pills & badges */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-info { background: #e0f2fe; color: #0369a1; border-color: transparent; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-size: .92rem; font-weight: 600;
  font-family: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28); }
.btn-accent:hover { background: var(--accent-600); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--accent); background: var(--accent-soft); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 20px; font-size: 1rem; border-radius: 12px; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-icon { padding: 4px; width: 32px; height: 32px; flex: none; color: var(--muted); border-color: var(--border); background: var(--surface); }
.btn-icon:hover { color: var(--text); border-color: #cbd5e1; background: var(--surface-2); }
.btn-icon-danger { color: var(--danger); border-color: var(--border); background: var(--surface); }
.btn-icon-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 12px;
  font-size: .82rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.filter-chip-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  font-size: .7rem; font-weight: 700;
  color: var(--accent); text-decoration: none; line-height: 1;
  transition: background .15s ease;
}
.filter-chip-close:hover { background: var(--accent-soft); }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* Text link button */
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 6px;
  font-size: .92rem; font-weight: 600; text-decoration: none;
  color: var(--accent); transition: background .15s ease, text-decoration-color .15s ease;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; background: var(--accent-soft); }
.link-btn:active { transform: translateY(1px); }

/* Forms */
.form { max-width: 380px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: .88rem; }
.input, select.input {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: .95rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.field-error { color: var(--danger); font-size: .8rem; }
.hint { color: var(--muted); font-size: .8rem; }

.checkbox { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); cursor: pointer; user-select: none; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.grid-form { display: flex; flex-direction: column; gap: 20px; margin-left: auto; margin-right: auto; }

/* Toggle switches */
.toggles-row { display: flex; flex-direction: column; gap: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.switch-row-label { display: flex; flex-direction: column; gap: 2px; font-weight: 600; font-size: .92rem; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #cbd5e1; border-radius: 999px; transition: background .2s ease;
}
.slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch.disabled { opacity: .5; }
.switch.disabled .slider { cursor: not-allowed; }

/* Bigger variant for completion toggles (mobile-friendly) */
.switch-lg { width: 58px; height: 32px; }
.switch-lg .slider::before { height: 26px; width: 26px; left: 3px; top: 3px; }
.switch-lg input:checked + .slider::before { transform: translateX(26px); }

/* Working-hours schedule */
.week-schedule { display: flex; flex-direction: column; gap: 8px; }
.week-row {
  display: grid; grid-template-columns: 140px auto 1fr auto 1fr;
  align-items: center; gap: 8px;
}
.week-row .input { width: 150px; justify-self: start; }
.week-day { font-weight: 600; }
.week-dash { color: var(--muted); }
.week-value { color: var(--text); }
.week-error { grid-column: 3 / -1; color: var(--danger); font-size: .8rem; }
.week-row.is-invalid .input { border-color: var(--danger); }
@media (max-width: 720px) {
  .week-row { grid-template-columns: 1fr 1fr; }
  .week-day { grid-column: 1 / -1; }
  .week-dash { display: none; }
}

/* Date exceptions form */
.exc-form {
  display: grid; grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 1fr 1fr 1.4fr auto;
  gap: 12px; align-items: start;
  border-top: 1px solid var(--border);
  padding-top: 16px; margin-top: 16px;
}
@media (max-width: 820px) {
  .exc-form { grid-template-columns: 1fr 1fr; }
  .exc-form .switch-row { grid-column: 1 / -1; justify-self: start; }
}

/* Job status stage select */
.stage-select { min-width: 190px; }
@media (max-width: 720px) {
  .stage-select { min-width: 0; }
}

/* Copy rules */
.copy-rules-row { display: flex; gap: 8px; align-items: center; }
.copy-rules select { max-width: 260px; }

/* Rules toggles grid */
.rules-group { margin-bottom: 18px; }
.rules-group-title { font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
.rules-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.rule-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--surface-2); }
.rule-label { font-size: .9rem; font-weight: 600; }

/* Alerts */
.alert {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
  font-size: .92rem; font-weight: 600;
}
.alert-success { background: var(--ok-soft); color: var(--ok); border: 1px solid rgba(22,163,74,.25); }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(220,38,38,.25); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(217,119,6,.25); }
.alert-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(37,99,235,.25); }

/* Tables — card-style on mobile */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

.cell-user { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7c9cff); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem;
}
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.cell-sub { display: block; font-size: .78rem; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

/* Column width control — long client/company names would otherwise stretch the
   table and shove the actions column off screen. Fixed share on desktop,
   unrestricted on mobile where cells are stacked anyway. */
@media (min-width: 768px) {
  .table .col-name { width: 25%; max-width: 320px; }
  .table .col-name .cell-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.cell-user-link {
  color: var(--accent); font-weight: 600; text-decoration: none;
  overflow-wrap: anywhere;
}
.cell-user-link:hover { text-decoration: underline; }
.cell-user-name { font-weight: 600; }

.detail-link {
  font-family: inherit; font-size: inherit; font-weight: 600; text-align: left;
  color: var(--accent); background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; max-width: 100%; overflow-wrap: anywhere;
}
.detail-link:hover { text-decoration: underline; }

.table .col-planned { min-width: 130px; white-space: nowrap; }
.table .col-name { min-width: 220px; }
.table .col-vehicle { min-width: 200px; }
.table .col-client { min-width: 230px; }
.table .col-operator { min-width: 140px; }

.card-head-side { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.card.is-bypassed { opacity: .55; filter: grayscale(.35); }
.admin-rules-note { color: var(--danger); font-weight: 600; }

/* Client picker (searchable combobox) */
.client-picker { position: relative; }
.client-results[hidden] { display: none; }
.client-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.client-result {
  text-align: left; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; font-family: inherit; font-size: .92rem; cursor: pointer; color: var(--text);
}
.client-result:hover, .client-result:focus { background: var(--accent-soft); color: var(--accent); }
.client-results .muted { font-weight: 400; }
.client-empty { padding: 9px 12px; color: var(--muted); font-size: .92rem; }

.is-hidden { display: none !important; }

/* Fuel type picker (select + optional custom value) */
.fuel-wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.fuel-wrap select.input { flex: 1 1 auto; min-width: 0; }
.fuel-custom { flex: 1 1 140px; min-width: 0; }

/* Modal overlay */
.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px;
  animation: modalFadeIn .18s ease-out;
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 24, 40, .55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal-dialog {
  position: relative; width: 100%; max-width: 520px;
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.08);
  overflow: hidden;
  animation: modalDialogIn .2s ease-out;
}
@keyframes modalDialogIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.modal-head h3 { font-size: 1.1rem; margin: 0; line-height: 1.35; }
.modal-close {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 6px 10px; border-radius: 50%;
  transition: background .12s;
}
.modal-close:hover { color: var(--text); background: var(--border); }
.modal-body { padding: 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
body.modal-open { overflow: hidden; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.detail-sub { font-size: .82rem; display: block; margin-top: 2px; }

/* Contact links (tel, viber, mailto inside popups + tables) */
.contact-row { display: block; }
.contact-tel { color: var(--accent); text-decoration: none; font-weight: 600; }
.contact-tel:hover { text-decoration: underline; }
.contact-viber {
  display: inline-block; margin-top: 4px; padding: 3px 10px; font-size: .78rem; font-weight: 600;
  color: #fff; background: #7360F2; border-radius: 6px; text-decoration: none;
  transition: opacity .12s;
}
.contact-viber:hover { opacity: .85; color: #fff; text-decoration: none; }

.toolbar { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar-clients { flex-wrap: nowrap;}
.toolbar-clients select { width: auto; }
.toolbar-jobs { flex-wrap: nowrap; overflow-x: auto; }
.toolbar-jobs .search { flex: 0 1 340px; min-width: 170px; }
.toolbar-jobs .filter-select { min-width: 140px; }
.toolbar-jobs .filter-date { width: 150px; }
.search { max-width: 360px; width: 100%; }
.filter-select { width: auto; min-width: 140px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pagination-pages li { margin: 0; padding: 0; list-style: none; }
.pagination-page,
.pagination-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.pagination-page:hover,
.pagination-step:hover { border-color: var(--accent); color: var(--accent); }
.pagination-page:focus-visible,
.pagination-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pagination-page.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: default;
}
.pagination-step.is-disabled { opacity: .4; pointer-events: none; }
.pagination-gap { min-width: 20px; text-align: center; color: var(--muted); font-weight: 700; }

/* Mobile table → stacked cards */
@media (max-width: 767px) {
  .hide-sm { display: none; }
  .table, .table thead, .table tbody, .table tr, .table th, .table td { display: block; }
  .table thead { display: none; }
  .table tr { padding: 6px 0; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; border-bottom: 1px solid var(--surface-2); padding: 9px 14px; }
  .table td::before { content: attr(data-label); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
  .table td.ta-r { justify-content: space-between; }
  .row-actions { justify-content: flex-start; }
}
@media (min-width: 768px) {
  .hide-md { display: none; }
}

/* Tile links */
.tile-link { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; text-decoration: none; }
.tile-link:hover { text-decoration: underline; }

/* ==================================================================
   Service spots & tasks (settings)
   ================================================================== */

/* Duration picker on the task form (hours + minutes) */
.duration-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.duration-row > div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.duration-row .input { width: 90px; }
.duration-unit { font-size: .82rem; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* Operations editor on the task form */
.op-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.op-row + .op-row { margin-top: 8px; }
.op-row .op-title { flex: 1; min-width: 0; }
.op-row-actions { display: inline-flex; gap: 4px; flex: none; }
.op-remove { flex: none; font-size: 1.1rem; line-height: 1; }

/* ==================================================================
   Job statuses
   ================================================================== */
.status-chip {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: .78rem; font-weight: 700;
  white-space: nowrap; border: 1px solid rgba(0,0,0,.06);
}
.status-preview-wrap { display: flex; align-items: center; gap: 14px; }
.input-color { padding: 4px 6px; width: 64px; height: 40px; cursor: pointer; }

/* ==================================================================
   Status board (status page — sidebar + card list)
   ================================================================== */
.status-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.status-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sfl-list { display: flex; flex-direction: column; gap: 4px; }
.sfl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--text); font-weight: 600; font-size: .9rem; text-decoration: none;
}
.sfl-item:hover { background: var(--accent-soft); color: var(--accent); }
.sfl-item.active { background: var(--accent); color: #fff; }
.sfl-count { font-size: .78rem; font-weight: 700; opacity: .8; }

.status-jobs { display: flex; flex-direction: column; gap: 12px; }

.status-job-card {
  --sbg: var(--border);
  --stx: var(--text);
  display: block; text-decoration: none; color: var(--text);
  background: color-mix(in srgb, var(--sbg) 6%, var(--surface));
  border: 1px solid var(--border); border-left: 6px solid var(--sbg);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease;
}
.status-job-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.status-job-card:hover .sjob-name { color: var(--accent); }

.sjob-line1 {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.sjob-name { font-weight: 700; font-size: 1rem; }
.sjob-sub {
  display: flex; flex-wrap: wrap; gap: 4px 6px;
  color: var(--muted); font-size: .86rem; margin-top: 6px;
}
.sjob-dates { font-weight: 500; }
.sjob-sep { opacity: .55; }

.status-layout--no-sidebar { grid-template-columns: 1fr; }

@media (max-width: 860px) {
  .status-layout { grid-template-columns: 1fr; }
  .status-sidebar { position: static; }
}

/* ==================================================================
   Service jobs — list filters
   ================================================================== */
.card-body.flush { padding: 0; }
.inline-form { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Vehicle picker (searchable combobox, job form) */
.vehicle-picker { position: relative; }
.vehicle-results[hidden] { display: none; }
.vehicle-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
}
.vehicle-result {
  text-align: left; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
  background: none; font-family: inherit; font-size: .92rem; cursor: pointer; color: var(--text);
}
.vehicle-result:hover, .vehicle-result:focus { background: var(--accent-soft); color: var(--accent); }
.vehicle-empty { padding: 9px 12px; color: var(--muted); font-size: .92rem; }

/* Service task checkboxes (job form) */
.check-list { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: var(--surface-2); cursor: pointer;
}
.check-item:hover { border-color: var(--accent); }
.check-item input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.check-item-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 1; min-width: 0; }
.check-item-title { font-weight: 600; font-size: .92rem; }
.check-item-dur { color: var(--muted); font-size: .82rem; white-space: nowrap; }

/* Manual task rows (job form) */
.manual-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); margin-bottom: 8px;
}
.manual-row-actions { display: inline-flex; gap: 4px; flex: none; }
.manual-row .m-name { flex: 1 1 160px; min-width: 0; }
.manual-row .m-days { width: 72px; }
.manual-row .m-hours { width: 72px; }
.manual-row .m-min { width: 72px; }
.manual-row .m-readout { min-width: 90px; text-align: right; color: var(--muted); font-size: .82rem; }

/* Duration + ready readouts (job form) */
.duration-readout { font-weight: 800; font-size: 1.15rem; margin: 6px 0 0; }
.ready-readout { font-weight: 700; margin: 2px 0; }

/* Linked tasks + comments (job view) */
.job-linked-task {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-2); flex-wrap: wrap;
}
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.comment-row {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  background: var(--surface-2);
}
.comment-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: .88rem; }
.comment-body { white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.comment-form .field { width: 100%; }
.comment-form .textarea { width: 100%; resize: vertical; min-height: 96px; }

/* Quick-vehicle modal client panel */
.qv-client-panel { margin-top: 4px; }

/* Per-task completion meta (job form) */
.task-item { display: flex; flex-direction: column; }
.task-meta { padding: 6px 0 2px 30px; }
.task-meta[hidden] { display: none; }
.task-meta .task-done { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; cursor: pointer; color: var(--text); }

/* Overall completion pill (job form + job view) */
.card-head-right { display: inline-flex; align-items: center; gap: 10px; }
.job-progress { display: inline-flex; align-items: center; gap: 8px; }
.job-progress[hidden] { display: none; }
.job-progress-track { width: 64px; height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.job-progress-fill { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.job-progress-text { font-size: .78rem; font-weight: 700; white-space: nowrap; color: var(--text); }

/* Status quick-switch (job view) */
.status-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.status-btn {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; background: var(--surface-2); color: var(--muted);
  font: inherit; font-weight: 600; font-size: .82rem; cursor: pointer;
}
.status-btn:hover { border-color: var(--accent); color: var(--text); }
.status-btn.is-current { border-color: rgba(0,0,0,.08); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.status-btn.is-inactive { opacity: .72; }
.status-btn.is-static { cursor: default; }
.status-btn.is-static:hover { border-color: var(--border); color: var(--muted); }

/* Linked task rows on the job view */
.job-task-block {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-2);
}
.job-task-block .job-linked-task { border: 0; background: none; padding: 0; }
.task-ops-line {
  font-size: .82rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-track-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding-top: 2px; }
.task-track-controls .task-done { display: inline-flex; align-items: center; gap: 8px; font-size: .84rem; font-weight: 600; cursor: pointer; }
.task-track-state { font-size: .84rem; color: var(--muted); }
.task-track-state.is-done { color: var(--accent); font-weight: 700; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 18px 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }

/* ==================================================================
   Auth (login) page
   ================================================================== */
.auth-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(600px 400px at 85% -10%, rgba(37, 99, 235, 0.14), transparent 60%),
    radial-gradient(500px 320px at -10% 110%, rgba(124, 156, 255, 0.16), transparent 60%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow); padding: 30px 28px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-title { font-size: 1.15rem; margin: 0; }
.auth-hello { font-size: 1.3rem; font-weight: 800; margin: 0 0 2px; }
.auth-sub { color: var(--muted); margin: 0 0 20px; font-size: .92rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin: 0; }

/* ==================================================================
   Installer page
   ================================================================== */
.install-wrap { max-width: 720px; margin: 0 auto; padding: 32px 0; }
.install-banner {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 22px;
  display: flex; align-items: center; gap: 14px;
}
.install-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.install-card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-weight: 700; }
.install-card-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 > * { min-width: 0; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 700; }
.kv .kv-value { color: var(--muted); text-align: right; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* Update page */
.update-panel { max-width: 760px; }
.migration-list { list-style: none; margin: 0; padding: 0; }
.migration-list li { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--surface-2); font-size: .9rem; }
.migration-list .n { font-weight: 700; color: var(--accent); margin-right: 8px; }

@media (min-width: 640px) {
  .page { padding-top: 32px; }
}

/* Activity log — full-width page */
.page-full {
  max-width: 100%;
  padding-left: 0;
  padding-right: 0;
}
.page-full .card {
  max-width: 100%;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}
.page-full .card-head,
.page-full .card-body {
  padding-left: 24px;
  padding-right: 24px;
}

/* Activity log */
.log-filters { }
.log-filter-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.log-filter-row .field { flex: 1 1 140px; min-width: 140px; }
.log-filter-actions { flex: 2 1 300px; }
.log-filter-btns { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.log-detail { font-size: .85rem; }
.log-detail summary { cursor: pointer; color: var(--accent); font-size: .82rem; }
.log-detail summary:hover { text-decoration: underline; }
.log-detail-pre {
  margin: 6px 0 0; padding: 8px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem; line-height: 1.45; white-space: pre-wrap; overflow-x: auto;
  max-height: 260px; overflow-y: auto;
}
.log-clear-form { }
.log-clear-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.log-clear-input { display: flex; align-items: center; gap: 8px; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--accent-soft); color: var(--accent); }

@media (max-width: 600px) {
  .log-filter-row { flex-direction: column; }
  .log-filter-row .field { flex: 1 1 100%; }
  .log-filter-actions { flex: 1 1 100%; }
}

/* Mobile: all modals become bottom-sheets */
@media (max-width: 520px) {
  .modal { align-items: flex-end; padding: 0; }
  .modal-dialog { max-width: none; max-height: 88vh; border-radius: 18px 18px 0 0; animation: sheetIn .22s ease-out; }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
  .modal-head { padding: 14px 16px; border-radius: 18px 18px 0 0; }
  .modal-body { padding: 12px 16px 24px; }
  .modal-foot { padding: 12px 16px; border-radius: 0; }
}

/* Contact links in kv rows */
.kv .kv-value a.contact-tel { text-decoration: none; }
.kv .kv-value a.contact-tel:hover { text-decoration: underline; }
.kv .kv-value .contact-viber { margin-left: 6px; }

@media print {
  .site-header, .site-footer, .nav-toggle { display: none; }
}
