@font-face { font-family: Manrope; src: url("/static/fonts/ManropeV5-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Manrope; src: url("/static/fonts/ManropeV5-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Manrope; src: url("/static/fonts/ManropeV5-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
:root {
  --background: 0 0% 100%; --foreground: 187 52% 9.8%;
  --primary: 183.4 77.2% 25.7%; --primary-foreground: 180 40% 98%;
  --secondary: 174 25% 92.2%; --muted-foreground: 186 14% 36%;
  --border: 178 18% 86%; --ring: 183.4 77.2% 30%;
  --success-text: 162.9 93.5% 24.3%; --warning-text: 26 90.5% 37.1%;
  --radius: .625rem; --b: hsl(var(--border)); --bg: hsl(var(--background));
}
    * { box-sizing: border-box; }
    body { margin: 0; font: 14px/1.5 Manrope, sans-serif; color: hsl(var(--foreground)); background: var(--bg); }
    header { background: #fff; border-bottom: 1px solid var(--b); padding: 14px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
    h1 { font-size: 22px; font-weight: 600; margin: 0; }
    .muted { color: hsl(var(--muted-foreground)); font-size: 13px; }
    .spacer { flex: 1; }
    .btn { display: inline-block; border: 1px solid var(--b); background: #fff; color: #1c1c1c; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; text-decoration: none; }
    .btn:hover { background: #f0f0f0; }
    .btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
    .btn-primary:hover { background: #1d4ed8; }
    main { padding: 16px 20px; }
    .toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
    input[type=text], input[type=search], input[type=email], input[type=password], select { padding: 7px 10px; border: 1px solid var(--b); border-radius: 6px; font-size: 16px; background: #fff; }
    #search { min-width: 240px; }
    .table-scroll { overflow-x: auto; }
    table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--b); border-radius: 8px; overflow: hidden; }
    th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }
    th { background: #fafafa; font-weight: 600; user-select: none; }
    th[data-col] { cursor: pointer; }
    th.group { text-align: center; background: #f0f3f8; }
    tbody tr.row-none, tbody tr.row-expired { background: #fdecec; }
    tbody tr.row-soon { background: #fff7e6; }
    tbody tr:hover { filter: brightness(0.975); }
    #grid td:nth-child(1) { width: 120px; }
    #grid td:nth-child(2), #grid th:nth-child(2) { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
    .reg { font-weight: 600; }
    .vin { font-size: 11px; color: #626871; font-weight: 400; letter-spacing: .3px; }
    .pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
    .ok { background: #e6f7ed; color: #137a3e; }
    .warn { background: #fff3e0; color: #b45309; }
    .bad { background: #fde8e8; color: #c81e1e; }
    .none { color: #626871; }
    .err { color: #c81e1e; font-size: 12px; }
    .flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
    .flash-ok { background: #e6f7ed; color: #137a3e; border: 1px solid #b7e3c6; }
    .flash-err { background: #fde8e8; color: #c81e1e; border: 1px solid #f3c2c2; }
    .toast { position: fixed; top: 16px; right: 16px; z-index: 1000; padding: 11px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.15); display: none; }
    dialog { border: 1px solid var(--b); border-radius: 10px; padding: 0; width: 380px; max-width: 92vw; }
    dialog form { padding: 18px; }
    dialog h2 { margin: 0 0 12px; font-size: 18px; }
    dialog label { display: block; margin: 8px 0 3px; font-size: 13px; color: #555; }
    dialog input, dialog textarea { width: 100%; }
    dialog textarea { height: 160px; font-family: ui-monospace, monospace; }
    .dlg-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }

:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 3px; }
::selection { background: hsl(var(--secondary)); color: hsl(var(--foreground)); }
input, textarea { caret-color: hsl(var(--primary)); }
.btn:disabled { opacity: .55; cursor: wait; }
[hidden] { display: none !important; }
.login { max-width: 420px; margin: 8vh auto; background: #fff; padding: 28px; border: 1px solid var(--b); border-radius: 8px; }
.login label { display: block; margin-top: 20px; margin-bottom: 6px; }
.login input { width: 100%; }
.login .btn { margin-top: 24px; width: 100%; }
#message, .form-error { min-height: 1.4em; overflow-wrap: anywhere; }
#message { margin-bottom: 14px; }
#grid td { max-width: 240px; white-space: normal; overflow-wrap: anywhere; }
#grid { font-variant-numeric: tabular-nums; }
#grid .registry-status { min-width: 260px; max-width: 340px; }
#grid .registry-status p { margin: 4px 0; }
.registry-refresh { margin-top: 8px; }
.registry-refresh .form-error:empty { display: none; }
#grid td:first-child { min-width: 130px; }
.empty { padding: 32px 12px; text-align: center; }
#filters label { display: flex; gap: 6px; align-items: center; }
#pager { margin: 16px 0; }
@media (max-width: 600px) { main, header { padding: 16px 12px; } .login { margin: 24px 12px; } #search { min-width: 0; width: 100%; } .toolbar { align-items: stretch; } }

dialog input[type=checkbox] { width: auto; }

/* поля, кнопки и светлая палитра TMS адаптированы к собственным шаблонам */
.brand { color: hsl(var(--foreground)); font-size: 20px; font-weight: 600; text-decoration: none; }
.btn { font-family: inherit; font-weight: 500; min-height: 36px; transition: background-color .15s ease; }
.btn:hover { background: hsl(var(--secondary)); }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.btn-primary:hover { background: hsl(var(--primary) / .9); }
input, select, textarea { font-family: inherit; color: hsl(var(--foreground)); }
input::placeholder, textarea::placeholder { color: hsl(var(--muted-foreground)); }
input:disabled, select:disabled, textarea:disabled { opacity: .65; cursor: not-allowed; }
a { color: hsl(var(--primary)); text-underline-offset: 3px; }
.documents-main { max-width: 1280px; margin: 0 auto; }
.documents-main h1 { margin: 12px 0 20px; font-size: 26px; }
.selected-owner { font-size: 20px; font-weight: 600; margin: 24px 0 12px; overflow-wrap: anywhere; }
header .muted { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.document-controls input::file-selector-button { border: 0; background: transparent; color: hsl(var(--primary)); font: 500 14px Manrope, sans-serif; margin-right: 12px; cursor: pointer; }
.document-nav { display: flex; gap: 24px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--b); }
.document-nav a { padding: 4px 0; text-decoration: none; color: hsl(var(--muted-foreground)); }
.document-nav a[aria-current] { color: hsl(var(--primary)); font-weight: 600; border-bottom: 2px solid hsl(var(--primary)); }
.documents-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 40px; margin-top: 24px; }
.document-controls { border-right: 1px solid var(--b); padding-right: 24px; }
.document-controls form { display: flex; flex-direction: column; gap: 12px; }
.document-controls h2, .document-content h2 { margin: 0 0 18px; font-size: 20px; }
.document-controls label, .document-review label { font-size: 14px; font-weight: 500; }
.document-controls input, .document-controls select, .document-review input, .document-review select, .document-review textarea { width: 100%; min-height: 36px; border: 1px solid var(--b); border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 16px; }
.document-controls .muted { margin: 0 0 8px; }
.document-controls .form-error:empty { display: none; }
.document-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.document-actions .btn { max-width: 100%; }
.document-item { border-top: 1px solid var(--b); padding: 24px 0; }
.document-item h3 { margin: 0 0 14px; font-size: 17px; font-weight: 600; }
.document-version { margin: 12px 0; }
.document-version-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.document-filename, .review-reason { overflow-wrap: anywhere; }
.document-version p { margin: 8px 0; }
.review-status { font-size: 13px; padding: 2px 8px; border-radius: 4px; background: hsl(var(--secondary)); }
.review-status.accepted { color: hsl(var(--success-text)); background: hsl(160 84% 39% / .08); }
.review-status.needs_replacement { color: hsl(var(--warning-text)); background: hsl(38 92% 50% / .1); }
summary { cursor: pointer; color: hsl(var(--primary)); padding: 8px 0; font-weight: 500; }
.owner-picker, .driver-create { margin-bottom: 24px; }
.owner-search { margin: 12px 0; }
#owner-list { list-style: none; padding: 0; margin: 12px 0; }
#owner-list a { display: block; padding: 10px 0; overflow-wrap: anywhere; }
.review-editor, .document-history { margin-top: 12px; }
.document-history .document-version { border-top: 1px solid var(--b); padding: 16px 0; }
.document-review { max-width: 420px; display: grid; gap: 10px; padding: 12px 0; }
.document-review textarea { min-height: 80px; resize: vertical; }
.document-review .btn { justify-self: start; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--b); border-radius: 8px; }
::-webkit-scrollbar-corner { background: transparent; }
@media (max-width: 760px) {
  .documents-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .document-controls { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--b); padding-bottom: 24px; }
  .document-nav { gap: 20px; }
  .btn, .document-nav a, summary { min-height: 44px; }
  .document-controls input, .document-controls select, .document-review input, .document-review select { min-height: 44px; }
  .documents-main h1 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }


/* очередь и длинный черновик наследуют поля и палитру документов */
.requests-main { max-width: 1280px; margin: 0 auto; }
.request-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 12px 0 20px; }
.request-heading h1 { font-size: 26px; }
#request-grid { font-variant-numeric: tabular-nums; }
#request-grid td { white-space: normal; max-width: 260px; overflow-wrap: anywhere; }
#request-grid td:first-child { min-width: 110px; }
#request-grid .request-vehicle-numbers { min-width: 150px; }
.request-vehicle-numbers span { display: block; white-space: nowrap; }
#request-editor { max-width: 900px; margin-top: 28px; }
#request-editor h2 { font-size: 20px; margin-bottom: 20px; }
.request-section { border: 0; border-top: 1px solid var(--b); margin: 24px 0; padding: 20px 0 0; min-width: 0; }
.request-section legend { padding: 0 16px 0 0; font-size: 18px; font-weight: 600; }
.request-section label, .route-point label { display: grid; gap: 6px; font-weight: 500; }
.request-section input, .request-section select, .request-section textarea { width: 100%; border: 1px solid var(--b); border-radius: 8px; padding: 8px 10px; font-size: 16px; min-height: 40px; background: #fff; }
.request-section textarea { resize: vertical; }
.request-section .toolbar { margin-top: 20px; }
.request-section .toolbar input { width: auto; flex: 1; min-width: 160px; }
.request-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin-top: 16px; }
.selected-vehicles { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.selected-vehicles li { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.vehicle-options { display: flex; flex-wrap: wrap; gap: 8px; max-height: 210px; overflow-y: auto; margin: 12px 0; }
#request-status-control { margin-top: 16px; }
#request-route { padding: 0 0 0 24px; }
.route-point { margin: 24px 0; padding-left: 8px; }
.request-readonly { max-width: 900px; }
.request-readonly p, .request-readonly li { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .request-fields { grid-template-columns: minmax(0, 1fr); }
  .request-heading { align-items: flex-start; flex-wrap: wrap; }
  .request-heading h1 { font-size: 24px; }
  .request-section input, .request-section select { min-height: 44px; }
  .requests-main .toolbar input { min-width: 0; width: 100%; }
  .request-section .toolbar input { flex-basis: 100%; }
}

/* этапы заявки используют поля и границы существующих документов */
.workflow-main { max-width: 1100px; }
#workflow-content { margin-top: 28px; max-width: 900px; }
#workflow-content p, #workflow-content li { overflow-wrap: anywhere; }
.workflow-form { border-top: 1px solid var(--b); padding: 24px 0; margin-top: 24px; }
.workflow-form h2 { margin: 0; font-size: 20px; }
.workflow-form label { display: grid; gap: 6px; margin: 12px 0; font-weight: 500; }
.workflow-form input, .workflow-form select, .workflow-form textarea { width: 100%; min-height: 40px; border: 1px solid var(--b); border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 16px; }
.workflow-form input[type=checkbox] { width: 20px; min-height: 20px; margin: 0; }
.workflow-form .workflow-choice { display: flex; align-items: flex-start; gap: 12px; font-weight: 400; overflow-wrap: anywhere; }
.workflow-form input[type=checkbox]:focus-visible { outline-offset: 2px; }
.workflow-form .request-section { padding-top: 12px; margin-top: 12px; }
#workflow-content .document-item > .btn { margin: 4px 8px 4px 0; }
@media (max-width: 760px) { .workflow-form input, .workflow-form select { min-height: 44px; } .workflow-form input[type=checkbox] { min-height: 20px; } }
