:root {
  --bg: #f4f6f7; --panel: #ffffff; --ink: #172e34; --muted: #54677a;
  --accent: #096b61; --accent-dark: #105b53; --ok: #197347; --warn: #8b580a; --bad: #cf3d3d;
  --border: #d7e0df; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef3f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.layout { display: grid; grid-template-columns: 218px minmax(0, 1fr); min-height: 100vh; }
.layout:not(:has(.sidebar)) { grid-template-columns: 1fr; }
.sidebar { width: 100%; overflow-y: auto; background: #182b31; color: #cfe0ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.logo { padding: 20px 18px 14px; font-weight: 700; font-size: 16px; color: #fff; }
.logo-sub { font-weight: 400; font-size: 12px; color: #adc2c3; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 8px; flex: 1; }
.sidebar nav a { color: #cfe0ef; padding: 9px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: #2c4348; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.nav-caption { padding: 14px 12px 4px; font-size: 12px; font-weight: 700; color: #adc2c3; text-transform: uppercase; letter-spacing: .05em; }
.nav-caption.cap-active { color: #fff; }
.sub-link { padding: 6px 12px 6px 26px !important; font-size: 13px; }
.sidebar-footer { padding: 14px 18px; border-top: 1px solid #2c4348; font-size: 13px; }
.side-links { display: flex; gap: 14px; margin-bottom: 8px; }
.user { margin-bottom: 6px; }
.link-muted { color: #adc2c3; }

.content { min-width: 0; width: 100%; padding: clamp(18px, 1.65vw, 34px); }
h1 { margin: 0 0 16px; font-size: clamp(24px,1.7vw,34px); line-height: 1.2; letter-spacing: -.035em; }
h2 { margin: 4px 0 12px; font-size: 18px; letter-spacing: -.02em; }
h3 { margin: 18px 0 8px; font-size: 14px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-card.ok .stat-num { color: var(--ok); }
.stat-card.warn .stat-num { color: var(--warn); }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 9px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:hover td { background: #f7fafc; }
.td-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-scroll { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.b-ok { background: #e1f4ea; color: var(--ok); }
.b-info { background: #e4eff7; color: #315b77; }
.b-warn { background: #fbf1dc; color: var(--warn); }
.b-bad { background: #fbe3e3; color: var(--bad); }
.b-muted { background: #edf1f5; color: var(--muted); }

.btn { display: inline-block; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--ink); cursor: pointer; font-size: 13px; }
.btn:hover { background: #f0f5fa; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: white; }
.btn-danger { color: var(--bad); border-color: #eec3c3; }
.btn-danger:hover { background: #fbe9e9; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.inline { display: inline; }

label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd9f2; border-color: var(--accent); }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-ok { background: #e1f4ea; color: #14683c; }
.alert-bad { background: #fbe3e3; color: #8f2626; }
.alert-info { background: #e3eefb; color: #105b53; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-actions { display: flex; gap: 8px; align-items: center; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.rules-table input, .rules-table select { padding: 5px 6px; font-size: 12px; }
.w-pattern { min-width: 140px; }
.w-num { width: 64px; }
.row-off td { color: #9aa8b6; background: #fafbfc; }
.row-new td { background: #f4f9ff; }

.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 90vh; }
.login-card { width: 360px; }
.login-card h2 { margin-top: 0; }

.filter-bar { display: flex; gap: 10px; align-items: center; }
.filter-bar select, .filter-bar input { width: auto; }
.filter-bar input { flex: 1; }

.pager { margin: 12px 0; display: flex; gap: 8px; }
.pager a { padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; }

.ads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.ad-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ad-archived { opacity: .55; }
.ad-imgs { display: flex; gap: 4px; padding: 8px; background: #f7fafc; }
.ad-imgs img { width: 84px; height: 63px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.ad-body { padding: 12px; }
.ad-title { font-weight: 600; margin-bottom: 6px; }
.ad-price { color: var(--ok); font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.ad-cat, .ad-meta, .ad-desc { font-size: 12px; margin-bottom: 4px; }
.ad-desc { color: #465565; }

.log { background: #172b31; color: #cfe0ef; border-radius: 8px; padding: 12px; font-family: Consolas, monospace; font-size: 12px; max-height: 480px; overflow-y: auto; }
.log-err { color: #ff9c9c; }
.log-warn { color: #ffd280; }
.feed-url { display: block; padding: 8px; font-size: 12px; word-break: break-all; }

.bars { display: flex; flex-direction: column; gap: 3px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-date { width: 44px; flex: none; font-size: 11px; color: var(--muted); font-family: Consolas, monospace; }
.bar { height: 12px; background: linear-gradient(90deg, var(--accent), #4aa3e0); border-radius: 3px; min-width: 2px; }
.bar-num { font-size: 11px; color: var(--muted); }

.catalog-search { position: relative; }
.catalog-search input { width: 100%; }
.catalog-results { position: absolute; z-index: 30; left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(16,38,58,.14); max-height: 280px; overflow-y: auto; }
.cres { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.cres:last-child { border-bottom: none; }
.cres:hover { background: #eef5fc; }
.cres-price { margin-left: auto; font-weight: 700; color: var(--ok); }
.sto-works-hint { color: var(--muted); font-size: 12px; }

.page-head h1, .page-head h2 { margin: 0; }
.page-head { min-height: 40px; margin-bottom: 18px; }
.page-actions, .filter-bar { flex-wrap: wrap; }
.card, .form-row > *, .grid-2 > * { min-width: 0; }
.sidebar nav { overflow-y: auto; min-height: 0; }
.sidebar nav a:focus-visible, a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid #4697d5; outline-offset: 2px;
}
.logo { padding-bottom: 22px; border-bottom: 1px solid #384c50; }
.logo-sub { display: inline-block; padding-top: 4px; }
.pager { align-items: center; flex-wrap: wrap; }
.photo-import summary { cursor: pointer; color: var(--accent-dark); font-weight: 600; }
.photo-import input[type=file] { min-width: 200px; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-caption { grid-column: 1 / -1; }
  .sidebar-footer { display: flex; justify-content: space-between; }
  .card:has(>table) { overflow-x: auto; }
}

button.cres { width: 100%; background: white; color: inherit; border: 0; border-bottom: 1px solid var(--border); text-align: left; font: inherit; }

.line-fields { min-width: 0; padding: 0; margin: 0; border: 0; }
.line-fields:disabled .btn-danger { visibility: hidden; }

/* Рабочая область СТО */
body { line-height: 1.45; }
[hidden] { display: none !important; }
.logo { display: block; padding: 23px 20px 17px; font-size: 23px; line-height: 1.1; letter-spacing: -.04em; }
.logo:hover { text-decoration: none; color: white; }
.logo-sub { display: block; margin-top: 3px; letter-spacing: 0; }
.sidebar nav { padding: 11px; gap: 2px; }
.sidebar nav a { padding: 8px 12px; line-height: 1.25; font-weight: 500; }
.sidebar nav a.active { background: #284d4d; box-shadow: inset 3px 0 #66d5ba; }
.nav-caption { font-size: 10px; letter-spacing: .1em; padding: 17px 12px 5px; }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer a { color: #c8d9d8; }
.section-head, .section-foot, .form-footer { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.section-head { margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head a, .section-foot a { font-size: 13px; }
.desk-layout { display: grid; grid-template-columns: minmax(0,2.45fr) minmax(280px,1fr); align-items: start; gap: 20px; }
.desk-queue { padding: 0; overflow: hidden; }
.desk-queue .section-head { padding: 18px 20px 0; }
.stage-strip { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin: 0 20px 18px; gap: 8px; }
.stage { display: flex; align-items: center; justify-content: space-between; gap: 6px; border-radius: 6px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.stage strong { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stage-open { background: #eaf1f6; color: #345871; }
.stage-progress { background: #fcf0dc; color: #7e520e; }
.stage-ready { background: #e3f1ea; color: #236448; }
.queue-table th:first-child,.queue-table td:first-child { padding-left: 20px; }
th { background: #f5f8f7; border-bottom-width: 1px; padding: 9px; font-weight: 600; }
.queue-table td { padding-top: 11px; padding-bottom: 11px; vertical-align: middle; }
.queue-work span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.queue-work span + span { margin-top: 4px; }
.queue-work a { font-size: .875em; }
@media (max-width: 680px) {
  .queue-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .queue-table tbody > tr {
    display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center;
    grid-template-areas: "number stage" "car action" "work work" "master master";
    gap: 4px 12px; padding: 14px 18px; border-top: 1px solid var(--border);
  }
  .queue-table td, .queue-table td:first-child { padding: 0; border: 0; }
  .queue-id { grid-area: number; }
  .queue-car { grid-area: car; }
  .desk-stage { grid-area: stage; text-align: right; }
  .queue-action { grid-area: action; text-align: right; }
  .queue-work { grid-area: work; }
  .queue-master { grid-area: master; color: var(--muted); font-size: 12px; }
  .queue-master::before { content: "Мастер · "; }
}
.row-title { font-weight: 650; color: var(--ink); }
.order-number { font-weight: 600; white-space: nowrap; }
.queue-table small,.profile-brief small { display: block; color: var(--muted); margin-top: 2px; }
.section-foot { border-top: 1px solid var(--border); background: #f7f9f8; padding: 13px 20px; justify-content: flex-start; }
.section-foot a { margin-left: auto; }
.facts { margin: 0; }
.facts > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.facts dt { color: var(--muted); }.facts dd { margin: 0; font-weight: 650; }
.profile-brief { border-top: 1px solid var(--border); padding: 12px 0 0; margin-top: 5px; }
.brief-links { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 3px; }
.back-link { display: inline-block; font-size: 13px; margin-bottom: 7px; }
.subhead { margin: 6px 0 0; color: var(--muted); }
.empty { margin: 18px 20px; color: var(--muted); }
.status-tabs,.workspace-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 14px; border-bottom: 1px solid var(--border); }
.status-tabs a,.workspace-tabs a { padding: 9px 12px; background: transparent; border: 0; border-radius: 0; color: var(--muted); }
.status-tabs .btn-primary,.workspace-tabs [aria-current=page] { color: var(--accent-dark); box-shadow: inset 0 -3px var(--accent); font-weight: 650; }
.status-tabs a:hover,.workspace-tabs a:hover { background: #e7eeeb; color: var(--ink); text-decoration: none; }
.ticket-layout,.grid-2.list-editor { display: grid; grid-template-columns: minmax(0,2.2fr) minmax(300px,1fr); align-items: start; gap: 18px; }
.ticket-side,.ticket-lines,.desk-exchange { min-width: 0; }
.order-summary { display: flex; flex-wrap: wrap; background: white; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; padding: 12px 0; }
.order-summary > div { flex: 1 1 140px; padding: 0 20px; border-left: 1px solid var(--border); }
.order-summary > div:first-child { border-left: 0; }
.order-summary span { display: block; font-size: 12px; color: var(--muted); }
.order-summary strong { display: block; margin-top: 2px; font-size: 19px; }
.order-summary > div:last-child strong { color: var(--accent-dark); }
.order-stage, .order-stage-current { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.order-stage { justify-content: space-between; }
.order-stage h2, .warehouse-options h3 { margin: 0; }
.queue-stage { display: grid; justify-items: start; gap: 6px; }
.order-document-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.btn.document-shortcut { display: none; }
@media (max-width: 1190px) { .btn.document-shortcut { display: inline-flex; } }
.order-defect { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.order-defect small { display: block; margin-top: 3px; color: var(--muted); }
.warehouse-options { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,250px),1fr)); gap: 20px; }
.warehouse-options p { margin: 6px 0 12px; }
.category-choices { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,230px),1fr)); gap: 5px 16px; margin: 12px 0 18px; }
.category-choices label { display: flex; gap: 9px; align-items: center; min-height: 40px; margin: 0; cursor: pointer; }
.category-choices input[type=checkbox] { flex: none; width: 18px; height: 18px; margin: 0; }
.defect-actions { margin-top: 16px; }
@media (max-width: 760px) {
  .order-stage .action-menu > div { position: static; }
  .order-stage:has(.action-menu[open]) .page-actions { align-items: start; }
}
.inline-editor summary,.action-menu summary { cursor: pointer; font-weight: 600; }
.order-add .inline-editor { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
details[open].inline-editor > summary { margin-bottom: 12px; }
.action-menu { position: relative; }
.action-menu > div { position: absolute; z-index: 4; right: 0; top: 100%; min-width: 215px; background: white; padding: 10px; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px #182b311a; }
.action-menu a { display: block; padding: 6px 8px; }.action-menu button { margin-top: 10px; }
.action-menu summary::after { content: ' ▾'; }
.intake { max-width: 1100px; padding: 0; }
.intake-body { display: grid; grid-template-columns: minmax(250px,.8fr) minmax(0,1.2fr); }
.intake-body section { padding: 22px; }.intake-body section+section { border-left: 1px solid var(--border); }
.form-footer { justify-content: flex-end; border-top: 1px solid var(--border); padding: 12px 22px; }
.settings-panel { max-width: 1100px; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.catalog-results:empty { display: none; }
.card:has(>table) { overflow-x: auto; }
.menu-toggle { display: none; }
@media (max-width: 1190px) {
  .desk-layout,.ticket-layout,.grid-2.list-editor { grid-template-columns: 1fr; }
  .desk-exchange { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; align-items: start; }
}
@media (max-width: 760px) {
  .desk-exchange,.intake-body { grid-template-columns: 1fr; }
  .intake-body section+section { border-left: 0; border-top: 1px solid var(--border); }
  .sidebar { display: grid; grid-template-columns: 1fr auto; align-items: center; }
  .logo { border: 0; padding: 12px 16px; font-size: 18px; }
  .menu-toggle { display: block; background: transparent; color: white; border: 1px solid #819693; margin: 8px; border-radius: 5px; padding: 6px 12px; }
  .sidebar nav,.sidebar-footer { grid-column: 1/-1; }
  .sidebar:has(.menu-toggle[aria-expanded=false]) nav,.sidebar:has(.menu-toggle[aria-expanded=false]) .sidebar-footer { display: none; }
  .stage { flex-direction: column-reverse; align-items: flex-start; }
}

.login-card { width: min(100%, 390px); padding: 28px; }
.login-card .subhead { margin-bottom: 20px; }
.login-card button { margin-top: 18px; width: 100%; }

:root { --control-border: #637b78; --error-ink: #a5272a; }
body { font-variant-numeric: tabular-nums; }
input:not([type=checkbox]), select, textarea { border-color: var(--control-border); font-size: 14px; }
.btn, select, input:not([type=checkbox]):not([type=hidden]) { min-height: 40px; }
.btn { align-content: center; }
.b-bad { color: var(--error-ink); background: #fbe3e3; }
:is(button, a, summary, select, input, textarea):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: 0 0 0 2px white;
}
.filter-bar label { margin: 0; }
@media (max-width: 760px) {
  .btn, .menu-toggle, input:not([type=hidden]):not([type=checkbox]), select { min-height: 44px; }
  .layout, .desk-exchange, .stage-strip { min-width: 0; }
  .order-summary { flex-wrap: wrap; }
  .form-row > * { max-width: 100%; }
}
