/* MyCRM — dual-theme dashboard (light по умолчанию, dark переключаемый). */
:root, [data-theme="light"] {
  /* Main area — light (Zoho-like) */
  --bg:        #f5f7fb;
  --bg-2:      #ffffff;
  --bg-3:      #eef1f7;
  --line:      #dde2eb;
  --muted:     #6b7384;
  --text:      #1b2030;
  --text-2:    #3f4658;
  --accent:    #d97706;
  --accent-2:  #f59e0b;
  --green:     #16a34a;
  --red:       #dc2626;
  --blue:      #2563eb;
  /* Sidebar — всегда тёмный (как в референсе) */
  --side-bg:    #1a202c;
  --side-bg-2:  #2a3142;
  --side-bg-3:  #353d52;
  --side-text:  #e6e9ef;
  --side-text-2:#c5cad6;
  --side-muted: #8b94a8;
  --side-line:  #2a3142;
  --side-accent:#fbbf24;
  --radius:    10px;
  --mono:      ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans:      -apple-system, "SF Pro Text", system-ui, "Inter", "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg:        #0b0d10;
  --bg-2:      #11141a;
  --bg-3:      #161a22;
  --line:      #232834;
  --muted:     #8a93a6;
  --text:      #e6e9ef;
  --text-2:    #c5cad6;
  --accent:    #f59e0b;
  --accent-2:  #fbbf24;
  --green:     #4ade80;
  --red:       #f87171;
  --blue:      #60a5fa;
  --side-bg:    var(--bg-2);
  --side-bg-2:  var(--bg-3);
  --side-bg-3:  #1d222d;
  --side-text:  var(--text);
  --side-text-2:var(--text-2);
  --side-muted: var(--muted);
  --side-line:  var(--line);
  --side-accent:var(--accent);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text-2); text-decoration: none; }
a:hover { color: var(--text); }
code { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--bg-3); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--muted); font-size: 12.5px; }
.center { text-align: center; }
.dot { color: var(--line); margin: 0 .35em; }

.layout { display: grid; grid-template-columns: 240px 1fr; height: 100vh; max-width: 100vw; }

/* Sidebar */
.sidebar {
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  padding: 18px 16px;
  display: flex; flex-direction: column;
  position: relative;
  transition: width .18s, padding .18s;
  color: var(--side-text-2);
}
.sidebar-toggle {
  position: absolute; top: 12px; right: 8px;
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--side-bg-2); border: 1px solid var(--side-line);
  color: var(--side-muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.sidebar-toggle:hover { color: var(--side-text); border-color: var(--side-accent); }

/* Collapsed sidebar — only icons */
body.sidebar-collapsed .layout { grid-template-columns: 56px 1fr; }
body.sidebar-collapsed .sidebar { padding: 18px 8px; }
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .nav-item > span:not(.ico) { display: none; }
body.sidebar-collapsed .sidebar .brand-name { display: none; }
body.sidebar-collapsed .sidebar .brand-tag { display: none; }
body.sidebar-collapsed .sidebar .health-label { display: none; }
body.sidebar-collapsed .sidebar .env-tag { display: none; }
body.sidebar-collapsed .sidebar .brand { padding-bottom: 14px; margin-bottom: 10px; justify-content: center; }
body.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 8px 4px; }
body.sidebar-collapsed .sidebar-footer .health,
body.sidebar-collapsed .sidebar-footer .env-tag { font-size: 0; }
body.sidebar-collapsed .sidebar-footer .health-dot { width: 10px; height: 10px; }

/* Tooltip справа от иконки в свёрнутом состоянии */
body.sidebar-collapsed .sidebar .nav-item { position: relative; }
body.sidebar-collapsed .sidebar .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--side-bg-2);
  color: var(--side-text);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--side-line);
  white-space: nowrap;
  z-index: 100;
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
body.sidebar-collapsed .sidebar .nav-item[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--side-line);
  z-index: 100;
}
.brand {
  display: flex; align-items: baseline; gap: 8px;
  padding-bottom: 18px; margin-bottom: 14px;
  border-bottom: 1px solid var(--side-line);
}
.brand-mark { color: var(--side-accent); font-size: 20px; line-height: 1; }
.brand-name { font-weight: 600; letter-spacing: .03em; color: var(--side-text); }
.brand-tag  { font-family: var(--mono); font-size: 10.5px; color: var(--side-muted); margin-left: auto; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--side-text-2);
}
.nav-item .ico { width: 16px; text-align: center; color: var(--side-muted); }
.nav-item:hover { background: var(--side-bg-2); color: var(--side-text); }
.nav-item.active { background: var(--side-bg-2); color: var(--side-text); }
.nav-item.active .ico { color: var(--side-accent); }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--side-line); display: flex; flex-direction: column; gap: 8px; }
.health { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--side-text-2); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--side-muted); }
.health-dot.ok { background: var(--green); box-shadow: 0 0 6px rgba(74,222,128,.45); }
.health-dot.bad { background: var(--red); }
.health-dot.loading { background: var(--side-muted); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% {opacity: .35;} 50% {opacity: 1;} }
.env-tag { font-family: var(--mono); font-size: 10.5px; color: var(--side-muted); letter-spacing: .04em; }

/* Theme toggle button (sidebar footer) */
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  background: var(--side-bg-2); border: 1px solid var(--side-line);
  color: var(--side-text-2); cursor: pointer; font-size: 12.5px;
  font-family: inherit; line-height: 1;
  transition: all .15s;
}
.theme-toggle:hover { color: var(--side-text); border-color: var(--side-accent); }
.theme-toggle .tt-icon { font-size: 14px; }
body.sidebar-collapsed .sidebar .theme-toggle { justify-content: center; padding: 7px 4px; }
body.sidebar-collapsed .sidebar .theme-toggle .tt-label { display: none; }

/* Main */
.main {
  padding: 22px 28px 32px;
  min-width: 0;          /* чтоб overflow children не растягивал grid-родителя */
  overflow-y: auto;       /* вертикальный scroll внутри main */
  height: 100vh;
}
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.crumb { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
h1 { font-size: 22px; font-weight: 600; margin: 4px 0 0; }
h2 { font-size: 14.5px; font-weight: 600; margin: 0; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.ts { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  font: inherit; cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--bg-3); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #1a1306; border-color: var(--accent); font-weight: 500; }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { color: var(--muted); font-size: 12.5px; padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); }

/* Grid */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Card */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }

/* Stat */
.stat .stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .stat-value { font-size: 28px; font-weight: 600; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: 12px; color: var(--muted); }

/* Badges */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-3); color: var(--text-2);
  border: 1px solid var(--line); font-size: 12.5px;
}

/* Table */
.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
.t th { font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.t tbody tr:hover { background: var(--bg-3); }

/* Form */
.form { display: flex; flex-direction: column; gap: 12px; }
.form .row { display: flex; flex-direction: column; gap: 6px; }
.form .row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.input {
  appearance: none;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
select.input { padding-right: 34px; }

/* Filters bar */
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr 2fr; gap: 8px; margin-bottom: 12px; }
.filters-2 { grid-template-columns: 130px 130px 130px 1fr 1fr 1fr 2fr; }
@media (max-width: 1280px) { .filters-2 { grid-template-columns: 1fr 1fr 1fr; } }

/* TG preview */
.preview .tg-mock {
  background: #1a1d24;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  color: #d8dde7;
  white-space: pre-wrap;
  margin: 0;
  min-height: 200px;
}

/* Empty state */
.empty-state { padding: 22px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 8px; }

/* Footer */
.footer { color: var(--muted); font-size: 12px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; gap: 4px; align-items: center; }

/* Mini orders list (dashboard recent) */
.mini-orders { display: flex; flex-direction: column; gap: 6px; }
.mini-order { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-3); }
.mini-order:hover { background: var(--bg-3); border-color: var(--accent); }
.mini-order .mo-title { font-size: 13.5px; color: var(--text); }
.mini-order .mo-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.mini-order .mo-right { display: flex; gap: 6px; align-items: center; }

/* Order details list (dt/dd) */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.kv dd { margin: 0; font-size: 13.5px; color: var(--text); }

/* Status action buttons */
.status-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* Code-mono link */
.mono { font-family: var(--mono); font-size: 12px; }
.link { color: var(--accent); }
.link:hover { color: var(--accent-2); text-decoration: underline; }

/* Pill outline (used for type) */
.pill-outline { background: transparent; }

/* Order page two-column grid: main + sidebar */
.order-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
@media (max-width: 1280px) { .order-grid { grid-template-columns: 1fr; } }

.order-col-side .card { position: sticky; top: 12px; }

/* Events feed */
.events-feed { display: flex; flex-direction: column; gap: 10px; max-height: 600px; overflow-y: auto; padding-right: 4px; }
.events-feed::-webkit-scrollbar { width: 6px; }
.events-feed::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.event-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--line); }
.event-icon { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 6px; background: var(--bg); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 13px; }
.event-main { flex: 1; min-width: 0; }
.event-title { font-size: 13px; font-weight: 500; color: var(--text); }
.event-detail { font-size: 11.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.event-ts { font-size: 11px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }

/* Checkbox row */
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; }
.checkbox-row:hover { border-color: var(--accent); }
.checkbox-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.cb-label { font-size: 13.5px; }

/* Urgent flag — red left bar overrides status bar */
.t tr[data-urgent="1"] td:first-child { border-left-color: #ef4444 !important; border-left-width: 5px !important; }
.urgent-marker { display: inline-block; color: #ef4444; font-weight: 700; margin-right: 6px; }

/* TG-source row — лёгкая голубая подсветка чтобы видно: пришло из ТГ, надо проверить город */
.t tr[data-tg-source="1"] {
  box-shadow: inset 4px 0 0 #38bdf8;
}
.t tr[data-tg-source="1"][data-status="WAITING"] { background: rgba(56, 189, 248, 0.12); }

/* Просрочка / скоро — подсветка всей строки. Перебивает зелёный WAITING. */
.t tr.alert-soon, .t tr[data-status].alert-soon { background: rgba(239, 68, 68, 0.32) !important; }
.t tr.alert-overdue, .t tr[data-status].alert-overdue {
  background: rgba(239, 68, 68, 0.42) !important;
  animation: alertPulse 2.4s ease-in-out infinite;
}
@keyframes alertPulse {
  0%,100% { background: rgba(239, 68, 68, 0.38) !important; }
  50%     { background: rgba(239, 68, 68, 0.55) !important; }
}

/* TG-иконка перед № заказа */
.tg-mark {
  display: inline-block; margin-right: 4px;
  color: var(--blue); font-size: 12px;
}

/* === Orders table — single-row, draggable, full-color status === */
.orders-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.orders-scroll::-webkit-scrollbar { height: 10px; }
.orders-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
.orders-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.orders-table { width: 100%; min-width: 900px; }
#orders-table.orders-table { min-width: 1500px; }
.orders-table thead th {
  position: sticky; top: 0; background: var(--bg-2); z-index: 5;
  position: relative;            /* для resizer; sticky сохраняем через top: 0 */
}
/* Re-apply sticky после relative — chrome понимает оба, но для надёжности используем z-index слой */
.orders-table thead { position: sticky; top: 0; z-index: 5; background: var(--bg-2); }
.col-resizer {
  position: absolute;
  top: 0; right: 0;
  width: 6px; height: 100%;
  cursor: col-resize;
  user-select: none;
  background: transparent;
  transition: background .12s;
}
.col-resizer:hover { background: var(--accent); }
.orders-table th { padding-right: 14px; }   /* запас под resizer */
.orders-table th { cursor: grab; user-select: none; white-space: nowrap; }
.orders-table th.dragging { opacity: .4; }
.orders-table th.drop-target { background: var(--bg-3); border-bottom: 2px solid var(--accent); }
.orders-table td { white-space: nowrap; vertical-align: middle; }
.orders-table td.cell-truncate { overflow: hidden; text-overflow: ellipsis; }
.orders-table td.num-cell { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; }

/* Источник Авито без привязки — красная подсветка ячейки */
td.src-unmatched {
  background: rgba(239, 68, 68, 0.20) !important;
  color: #ef4444 !important;
  font-weight: 500;
}
td.src-unmatched::after { content: ' ⚠'; }

/* Pill для технического short_code — крупнее, видимее */
.pill-tech {
  background: var(--bg-3);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 6px;
  letter-spacing: .03em;
}

/* Кликабельный телефон → копирует */
.phone-cell { cursor: pointer; color: var(--text); border-bottom: 1px dotted var(--muted); }
.phone-cell:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* Status select — целиком цветной select с background = цвет статуса */
.status-select {
  border: none; padding: 6px 28px 6px 12px; border-radius: 8px;
  font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer;
  min-width: 130px; text-align: center;
  appearance: none; -webkit-appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 8"><path fill="%230b0d10" d="M6 8L0 0h12z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  transition: filter .12s;
}
.status-select:hover { filter: brightness(1.08); }
.status-select option { background: var(--bg-2); color: var(--text); font-weight: 500; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #0b0d10;
  padding: 10px 18px; border-radius: 8px; font-weight: 500; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .2s;
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Inline checkbox in filters */
.cb-inline { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.cb-inline input { accent-color: var(--accent); }

/* Address suggestions (Nominatim) */
#address-row { position: relative; }
.addr-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; max-height: 280px; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.4); margin-top: 4px;
}
.addr-suggest-item { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--line); }
.addr-suggest-item:hover { background: var(--bg-3); color: var(--accent); }
.addr-suggest-item:last-child { border-bottom: none; }

/* Inline master assignment cell */
.master-cell { display: flex; gap: 5px; align-items: center; }
.input-compact { padding: 5px 8px; font-size: 12.5px; min-width: 130px; }
.btn-apply {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--accent); color: #1a1306; border: none;
  font: inherit; font-weight: 700; line-height: 1; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-apply:disabled { background: #2a2f3a; color: #6b7280; cursor: default; }
.btn-apply:not(:disabled):hover { background: var(--accent-2); transform: scale(1.06); }
.btn-apply-ok { background: var(--green) !important; color: #052e16 !important; }
.btn-apply-err { background: var(--red) !important; color: #1f0606 !important; }
.master-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* Row actions (icons) */
.row-actions { display: flex; gap: 4px; align-items: center; justify-content: flex-end; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all .15s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--accent); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 14, 0.78);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 22px 24px; min-width: 460px; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h2 { font-size: 16px; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Compact form row inside modal */
.f-row { margin-bottom: 12px; }
.f-row > label { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.f-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.f-row.two > div > label { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.f-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Documents stub button */
.docs-stub {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px;
  background: var(--bg-3); color: var(--text-2);
  border: 1px dashed var(--line); cursor: pointer;
  font-size: 12.5px;
}
.docs-stub:hover { border-color: var(--accent); color: var(--text); }

/* Status inline select (active orders table) */
.status-cell { display: flex; gap: 5px; align-items: center; }
.status-cell select.input { font-weight: 500; }

/* Row tint by status — заявки видно «по фону» даже без фильтра */
.t tr[data-status] td:first-child {
  border-left: 3px solid transparent;
}
.t tr[data-status="WAITING"]      { background: rgba( 34,197, 94, 0.06); }
.t tr[data-status="WAITING"] td:first-child { border-left-color: #22c55e; border-left-width: 6px; box-shadow: inset 6px 0 0 #22c55e; }
.t tr[data-status="ASSIGNED"]     { background: rgba(167,139,250, 0.07); }
.t tr[data-status="ASSIGNED"] td:first-child { border-left-color: #a78bfa; }
.t tr[data-status="ACCEPTED"]     { background: rgba( 96,165,250, 0.07); }
.t tr[data-status="ACCEPTED"] td:first-child { border-left-color: #60a5fa; }
.t tr[data-status="EN_ROUTE"]     { background: rgba( 14,165,233, 0.10); }
.t tr[data-status="EN_ROUTE"] td:first-child { border-left-color: #0ea5e9; }
.t tr[data-status="IN_PROGRESS"]  { background: rgba(249,115, 22, 0.09); }
.t tr[data-status="IN_PROGRESS"] td:first-child { border-left-color: #f97316; }
.t tr[data-status="ON_HOLD"]      { background: rgba(234,179,  8, 0.08); }
.t tr[data-status="ON_HOLD"] td:first-child { border-left-color: #eab308; }
.t tr[data-status="OUT"]          { background: rgba(124, 58,237, 0.10); }
.t tr[data-status="OUT"] td:first-child { border-left-color: #7c3aed; }
.t tr[data-status="DONE"]         { background: rgba( 34,197, 94, 0.05); opacity: .82; }
.t tr[data-status="DONE"] td:first-child { border-left-color: #22c55e; }
.t tr[data-status="POSTPONED"]    { background: rgba(168, 85,247, 0.07); }
.t tr[data-status="POSTPONED"] td:first-child { border-left-color: #a855f7; }
.t tr[data-status="CANCELLED"]    { background: rgba(239, 68, 68, 0.07); opacity: .8; }
.t tr[data-status="CANCELLED"] td:first-child { border-left-color: #ef4444; }
.t tr[data-status="ANNULLED"]     { background: rgba(161, 98,  7, 0.10); opacity: .75; }
.t tr[data-status="ANNULLED"] td:first-child { border-left-color: #a16207; }
.t tr[data-status="NEEDS_REVIEW"] { background: rgba(250,204, 21, 0.10); }
.t tr[data-status="NEEDS_REVIEW"] td:first-child { border-left-color: #facc15; }

/* Date strip — горизонтальная лента дней (компактная) */
.date-strip {
  display: flex; gap: 3px; padding: 6px 0 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.date-strip::-webkit-scrollbar { height: 4px; }
.date-strip::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.date-day {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 42px; padding: 4px 6px; border-radius: 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--text-2); cursor: pointer;
  transition: all .12s;
  user-select: none;
  line-height: 1.1;
}
.date-day:hover { background: var(--bg-3); border-color: var(--accent); }
.date-day .dow { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.date-day .num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }
.date-day .mon { font-size: 9.5px; color: var(--muted); margin-top: 0; }
.date-day.weekend .dow,
.date-day.weekend .num { color: #ef4444; }
.date-day.today { border-color: var(--accent); }
.date-day.today .num { color: var(--accent); }
.date-day.active {
  background: var(--accent); border-color: var(--accent);
  color: #1a1306;
}
.date-day.active .dow,
.date-day.active .mon,
.date-day.active .num { color: #1a1306; }
.date-day.range-mode { font-style: italic; }
.date-day.picker { position: relative; cursor: pointer; }
.date-day.picker:hover { border-color: var(--accent); }

/* Page subtitle (dynamic context line) */
.page-context { font-size: 13px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ============================================================
   MOBILE / TABLET ADAPTATION
   ============================================================ */

/* Бургер-кнопка для мобильного — инжектится JS-ом в topbar */
.mobile-burger {
  display: none;
  width: 36px; height: 36px;
  background: var(--side-bg-2); border: 1px solid var(--side-line);
  color: var(--side-text); border-radius: 8px;
  cursor: pointer; font-size: 18px; line-height: 1;
  align-items: center; justify-content: center;
  margin-right: 8px;
}

/* Tablet (≤900): sidebar авто-схлопывается до иконок */
@media (max-width: 900px) {
  .layout { grid-template-columns: 56px 1fr; }
  .sidebar { padding: 18px 8px; }
  .sidebar .nav-label,
  .sidebar .nav-item > span:not(.ico),
  .sidebar .brand-name,
  .sidebar .brand-tag,
  .sidebar .health-label,
  .sidebar .env-tag,
  .sidebar .theme-toggle .tt-label { display: none; }
  .sidebar .brand { padding-bottom: 14px; margin-bottom: 10px; justify-content: center; }
  .sidebar .nav-item { justify-content: center; padding: 8px 4px; position: relative; }
  .sidebar .theme-toggle { justify-content: center; padding: 7px 4px; }
  .sidebar-toggle { display: none; }
  .main { padding: 16px 14px 24px; }
  .filters, .filters-2 { grid-template-columns: 1fr 1fr !important; }
}

/* Tablet/order-grid в 1 колонку при ≤900 (раньше срабатывало только при 1280) */
@media (max-width: 900px) {
  .order-grid { grid-template-columns: 1fr !important; }
  .order-col-side .card { position: static !important; }
}

/* Mobile (≤640): sidebar в drawer, layout в 1 колонку, touch targets */
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 240px; padding: 18px 16px;
    transform: translateX(-100%);
    transition: transform .22s ease-out;
    box-shadow: 6px 0 24px rgba(0,0,0,.5);
  }
  body.sidebar-mobile-open .sidebar { transform: translateX(0); }
  /* В drawer возвращаем все labels */
  body.sidebar-mobile-open .sidebar .nav-label,
  body.sidebar-mobile-open .sidebar .nav-item > span,
  body.sidebar-mobile-open .sidebar .brand-name,
  body.sidebar-mobile-open .sidebar .brand-tag,
  body.sidebar-mobile-open .sidebar .health-label,
  body.sidebar-mobile-open .sidebar .env-tag,
  body.sidebar-mobile-open .sidebar .theme-toggle .tt-label { display: inline; }
  body.sidebar-mobile-open .sidebar .nav-item { justify-content: flex-start; padding: 8px 10px; }
  body.sidebar-mobile-open .sidebar .brand { justify-content: flex-start; }
  body.sidebar-mobile-open .sidebar .theme-toggle { justify-content: flex-start; padding: 7px 10px; }

  /* Backdrop когда drawer открыт */
  body.sidebar-mobile-open::before {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 49;
  }

  .mobile-burger { display: inline-flex; }
  .main { padding: 12px 12px 24px; height: 100vh; }
  .topbar { gap: 8px; align-items: center; }
  h1 { font-size: 18px; }
  .crumb { font-size: 10px; letter-spacing: .04em; }
  .filters, .filters-2 { grid-template-columns: 1fr !important; gap: 8px; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }

  /* Touch-friendly targets */
  .input, select.input, .btn, .icon-btn, .status-select { min-height: 38px; }
  .btn-primary { min-height: 44px; }

  /* Карточка плотнее */
  .card { padding: 12px 14px; }
  .card-header { margin-bottom: 10px; }

  /* Modal на узком */
  .modal-card { min-width: 0; max-width: 95vw; padding: 16px; }
  .modal-actions { flex-direction: column; gap: 6px; }
  .modal-actions .btn { width: 100%; }

  /* Таблицы — компактнее, шрифт чуть меньше */
  .t th, .t td { padding: 6px 8px; font-size: 12.5px; }
  .orders-table { font-size: 12px; }

  /* Date strip — компактнее */
  .date-day { min-width: 36px; padding: 3px 4px; }
  .date-day .num { font-size: 12px; }

  /* Карточка заявки (/order.html) — все секции в столбец */
  .kv { grid-template-columns: 1fr; gap: 4px 0; }
  .kv dt { padding-top: 8px; padding-bottom: 0; font-size: 11px; }
  .kv dd { font-size: 14px; padding-bottom: 4px; }

  /* Form rows везде в 1 колонку */
  .form .row.two { grid-template-columns: 1fr !important; gap: 8px; }
  .f-row.two { grid-template-columns: 1fr !important; gap: 8px; }
  .f-row.two > div > label { margin-top: 6px; }

  /* Top-actions — кнопки справа в шапке могут переноситься */
  .top-actions { gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
  .top-actions .btn { padding: 8px 12px; font-size: 13px; }

  /* Card-header — название слева, badges/счётчики снизу */
  .card-header { flex-wrap: wrap; gap: 6px; }
  .card-header h2 { font-size: 14px; }

  /* Status-actions кнопки — компактнее */
  .status-actions { gap: 4px; }
  .status-actions .btn { padding: 6px 10px; font-size: 12px; min-height: 34px; }

  /* Действия — апплай-кнопка на всю ширину */
  #a-apply { width: 100%; }

  /* Финансы и подобные секции в /order.html — value стек */
  .finance-row, .cashbox-row { flex-direction: column; align-items: stretch; gap: 8px; }

  /* События — паддинги меньше */
  .event-item { padding: 6px 8px; }
  .event-title { font-size: 12.5px; }
  .event-detail { font-size: 11px; }
  .events-feed { max-height: 360px; }

  /* Mini-orders на дашборде — крупнее тапы */
  .mini-order { padding: 10px 12px; }

  /* Address-suggest — в полную ширину */
  .addr-suggest { max-height: 200px; }

  /* Recordings player — full width */
  audio { width: 100% !important; }
}
