/* ========================================================================
   Центр управления объектом — v2.0
   Tumiza × АСК ТРАСТ | темно-светлая тема, сетка виджетов, командная палитра
   ======================================================================== */

/* ---- Design tokens ---- */
:root {
  /* geometry */
  --nav-w: 232px;
  --nav-w-collapsed: 64px;
  --top-h: 56px;
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(0,0,0,.08);
  --sh-2: 0 4px 14px rgba(0,0,0,.10);
  --sh-3: 0 18px 40px rgba(0,0,0,.14);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* brand */
  --brand: #ff6a00;
  --brand-2: #ff9142;
  --brand-soft: rgba(255,106,0,.14);

  /* Semantic accents (shared between themes) */
  --c-montazh: #3b82f6;
  --c-markir:  #eab308;
  --c-remont:  #ef4444;
  --c-lan:     #22c55e;
  --c-fluke:   #a855f7;
  --c-unplan:  #f97316;
}

/* Light theme (default) */
:root, [data-theme="light"] {
  --bg:         #f4f6fa;
  --bg-el:      #ffffff;
  --bg-el-2:    #f9fafc;
  --bg-sidebar: #0f172a;
  --bg-topbar:  #ffffff;
  --border:     #e5e9f2;
  --border-2:   #eef1f6;
  --text:       #111827;
  --text-2:     #374151;
  --muted:      #6b7280;
  --muted-2:    #9ca3af;

  --accent:     #2563eb;
  --accent-2:   #3b82f6;
  --accent-soft:#dbeafe;
  --ok:         #16a34a;
  --ok-soft:    #dcfce7;
  --warn:       #d97706;
  --warn-soft:  #fef3c7;
  --danger:     #dc2626;
  --danger-soft:#fee2e2;
  --info:       #0891b2;
  --info-soft:  #cffafe;

  --overlay:    rgba(15, 23, 42, .45);
}

/* Dark theme */
[data-theme="dark"] {
  --bg:         #0b1020;
  --bg-el:      #111831;
  --bg-el-2:    #0f162a;
  --bg-sidebar: #060a17;
  --bg-topbar:  #0e1429;
  --border:     #1f2a44;
  --border-2:   #182340;
  --text:       #e5e7eb;
  --text-2:     #c6cbdb;
  --muted:      #8b93a7;
  --muted-2:    #6b7389;

  --accent:     #6aa1ff;
  --accent-2:   #8bb7ff;
  --accent-soft:rgba(106,161,255,.12);
  --ok:         #4ade80;
  --ok-soft:    rgba(74,222,128,.12);
  --warn:       #fbbf24;
  --warn-soft:  rgba(251,191,36,.12);
  --danger:     #f87171;
  --danger-soft:rgba(248,113,113,.14);
  --info:       #38bdf8;
  --info-soft:  rgba(56,189,248,.12);

  --overlay:    rgba(0, 0, 0, .6);
  --sh-1: 0 1px 2px rgba(0,0,0,.5);
  --sh-2: 0 4px 14px rgba(0,0,0,.4);
  --sh-3: 0 18px 40px rgba(0,0,0,.5);
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--text); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
code, kbd { font-family: var(--font-mono); font-size: .82em; }
kbd {
  background: var(--bg-el-2); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: var(--r-xs);
  box-shadow: inset 0 -1px 0 var(--border);
  color: var(--text-2);
}
::selection { background: var(--brand-soft); color: var(--text); }

/* ---- Layout ---- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.app.collapsed { grid-template-columns: var(--nav-w-collapsed) 1fr; }

/* ---- Sidebar ---- */
.sidebar {
  grid-column: 1;
  background: var(--bg-sidebar);
  color: #cbd5e1;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  transition: width .2s;
}
.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
  white-space: nowrap; overflow: hidden;
}
.brand-badge {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .9rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(255,106,0,.35);
}
.brand-title { font-size: .95rem; font-weight: 700; color: #fff; line-height: 1.1; }
.brand-sub { font-size: .7rem; color: #7c8aa0; display: block; }
.collapsed .brand-title, .collapsed .brand-sub, .collapsed .nav-label, .collapsed .nav-section,
.collapsed .sidebar-footer { display: none; }

.sidebar-nav { flex: 1; padding: 8px 10px; }
.nav-section {
  font-size: .63rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #5a6782;
  padding: 12px 14px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 8px;
  color: #c0cadd; font-size: .88rem; font-weight: 500;
  transition: background .12s, color .12s;
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(255,106,0,.18), rgba(255,106,0,.06));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand);
}
.nav-icon { width: 18px; display: inline-flex; justify-content: center; font-size: 1rem; opacity: .85; }
.nav-item.active .nav-icon { opacity: 1; color: var(--brand-2); }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--brand); color: #fff;
  font-size: .68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 999px;
}

.sidebar-footer {
  padding: 12px 20px;
  font-size: .7rem; color: #5a6782;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 8px;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  box-shadow: var(--sh-1);
}
.topbar-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-r { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hamburger, .icon-btn {
  height: 34px; min-width: 34px; padding: 0 10px;
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--bg-el); color: var(--text-2);
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.hamburger:hover, .icon-btn:hover { background: var(--bg-el-2); color: var(--text); border-color: var(--text-2); }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; min-width: 0; }
.crumbs a { color: var(--text-2); font-weight: 500; }
.crumbs .sep { color: var(--muted-2); }
.crumbs .current { color: var(--text); font-weight: 600; }

/* Command palette trigger */
.cmd-trigger {
  height: 34px; padding: 0 10px 0 12px; min-width: 200px;
  background: var(--bg-el-2); border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: .82rem; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.cmd-trigger:hover { border-color: var(--accent); background: var(--bg-el); color: var(--text-2); }
.cmd-trigger .cmd-k { margin-left: auto; color: var(--muted-2); font-size: .75rem; }

/* ---- Page ---- */
.page {
  padding: 20px 24px 80px;
  max-width: 1560px;
  margin: 0 auto;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -.01em; }
.page-sub { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-md);
  font-size: .85rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, color .12s, transform .1s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; text-decoration: none; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-2); color: #fff; text-decoration: none; }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-ok:hover { filter: brightness(1.1); color: #fff; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-el-2); color: var(--text); border-color: var(--muted); text-decoration: none; }
.btn-sm { height: 28px; padding: 0 10px; font-size: .78rem; border-radius: var(--r-sm); }
.btn-xs { height: 24px; padding: 0 8px; font-size: .72rem; border-radius: var(--r-xs); }
.btn-block { width: 100%; justify-content: center; }

/* ---- Chips (filters) ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-el-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: .78rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: all .12s;
}
.chip:hover { border-color: var(--text-2); text-decoration: none; color: var(--text); }
.chip.active {
  background: var(--brand-soft); border-color: var(--brand);
  color: var(--brand);
}
.chip .chip-x { margin-left: 2px; color: var(--muted-2); }

/* ---- Cards / Widgets ---- */
.card {
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px;
  box-shadow: var(--sh-1);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-2);
}
.card-title {
  font-size: .95rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.card-title .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
}
.card-actions { display: flex; align-items: center; gap: 6px; }

/* Grid of cards */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto-lg { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-auto-md { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (max-width: 1100px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---- KPI ---- */
.kpi {
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 16px 14px;
  position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .12s;
}
.kpi::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--brand);
}
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }
.kpi.danger::before { background: var(--danger); }
.kpi.info::before { background: var(--info); }
.kpi:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.kpi-label {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.kpi-value {
  font-size: 1.8rem; font-weight: 700;
  color: var(--text); line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: .8rem; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi-sub {
  font-size: .75rem; color: var(--muted-2); margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}
.delta { font-weight: 600; font-size: .78rem; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); }

/* ---- Badges / pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .7rem; font-weight: 600; white-space: nowrap;
  background: var(--bg-el-2); color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.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-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* Work-type chips */
.wt {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--r-xs);
  font-size: .72rem; font-weight: 700;
}
.wt-montazh { background: rgba(59,130,246,.14); color: #3b82f6; }
.wt-markir  { background: rgba(234,179,8,.18); color: #a16207; }
.wt-remont  { background: rgba(239,68,68,.14); color: #dc2626; }
.wt-lan     { background: rgba(34,197,94,.14); color: #16a34a; }
.wt-fluke   { background: rgba(168,85,247,.16); color: #7c3aed; }
[data-theme="dark"] .wt-markir { color: #fbbf24; }
[data-theme="dark"] .wt-remont { color: #fca5a5; }
[data-theme="dark"] .wt-lan { color: #86efac; }
[data-theme="dark"] .wt-fluke { color: #c4b5fd; }

/* Task-kind pills */
.kind {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.kind-planned { background: var(--accent-soft); color: var(--accent); }
.kind-unplanned { background: rgba(249,115,22,.16); color: var(--c-unplan); }

/* Status pills */
.status { padding: 3px 10px; border-radius: 999px; font-size: .7rem; font-weight: 600; text-transform: lowercase; }
.status-in_progress { background: var(--accent-soft); color: var(--accent); }
.status-planned { background: var(--bg-el-2); color: var(--muted); border: 1px solid var(--border); }
.status-done { background: var(--ok-soft); color: var(--ok); }
.status-blocked { background: var(--danger-soft); color: var(--danger); }
.status-cancelled { background: var(--bg-el-2); color: var(--muted-2); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg-el); }
table.data {
  width: 100%; border-collapse: collapse;
  font-size: .85rem; color: var(--text-2);
}
table.data thead th {
  background: var(--bg-el-2); font-weight: 600;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--bg-el-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data code { background: var(--bg-el-2); padding: 1px 6px; border-radius: var(--r-xs); color: var(--text-2); }

/* ---- Progress bar ---- */
.progress {
  height: 8px; border-radius: 999px; background: var(--bg-el-2);
  overflow: hidden; position: relative;
}
.progress .bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .5s; }
.progress.ok .bar { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress.warn .bar { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress.danger .bar { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress-label { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-bottom: 4px; }

/* ---- Alerts strip ---- */
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-md);
  background: var(--bg-el); border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  font-size: .85rem;
}
.alert.info { border-left-color: var(--info); background: var(--info-soft); color: var(--text); }
.alert.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--text); }
.alert.danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--text); }
.alert .a-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-el); color: var(--text); font-weight: 700; font-size: .8rem;
}
.alert a.a-link { margin-left: auto; font-weight: 600; color: inherit; }

/* ---- Forms ---- */
label.fld { display: block; margin-bottom: 12px; }
label.fld > span { display: block; font-size: .75rem; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; height: 34px; padding: 0 10px;
  font-family: var(--font); font-size: .86rem;
  background: var(--bg-el); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 88px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-2); }

/* ---- Modal / Drawer ---- */
.modal-back {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-back.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-el); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); width: 92%; max-width: 560px;
  max-height: 90vh; overflow: auto;
  transform: translateY(8px) scale(.98); transition: transform .2s;
  border: 1px solid var(--border);
}
.modal-back.open .modal { transform: translateY(0) scale(1); }
.modal-head {
  padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1rem; }
.modal-close { background: var(--bg-el-2); border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 1.1rem; }
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 18px; }

/* ---- Command Palette ---- */
.palette-back {
  position: fixed; inset: 0; background: var(--overlay); z-index: 300;
  display: flex; justify-content: center; padding-top: 12vh;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.palette-back.open { opacity: 1; pointer-events: all; }
.palette {
  background: var(--bg-el); width: 92%; max-width: 640px;
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  transform: translateY(-8px); transition: transform .15s;
  border: 1px solid var(--border);
  max-height: 70vh; display: flex; flex-direction: column;
  overflow: hidden;
}
.palette-back.open .palette { transform: translateY(0); }
.palette input {
  border: none; border-bottom: 1px solid var(--border);
  height: 52px; padding: 0 18px; font-size: 1rem; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: var(--bg-el);
}
.palette input:focus { box-shadow: none; border-color: var(--brand); }
.palette-items { overflow-y: auto; padding: 6px; }
.palette-section { font-size: .65rem; font-weight: 700; color: var(--muted-2); padding: 10px 10px 4px; text-transform: uppercase; letter-spacing: .1em; }
.palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: var(--r-sm);
  cursor: pointer; font-size: .86rem; color: var(--text-2);
}
.palette-item:hover, .palette-item.active { background: var(--accent-soft); color: var(--accent); }
.palette-item .p-icon { width: 20px; text-align: center; color: var(--muted); }
.palette-item .p-sub { margin-left: auto; color: var(--muted-2); font-size: .75rem; }

/* ---- Sticky Quick Add ---- */
.quick-add {
  position: fixed; right: 24px; bottom: 24px; z-index: 90;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.quick-fab {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: none; cursor: pointer;
  font-size: 1.4rem; font-weight: 700;
  box-shadow: 0 10px 28px rgba(255,106,0,.45), 0 2px 6px rgba(0,0,0,.1);
  transition: transform .15s;
}
.quick-fab:hover { transform: scale(1.05); }
.quick-menu {
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--sh-3);
  padding: 6px; display: none; min-width: 220px;
}
.quick-menu.open { display: block; }
.quick-menu button {
  width: 100%; text-align: left; background: transparent; border: none;
  padding: 8px 12px; border-radius: var(--r-sm);
  display: flex; align-items: center; gap: 10px;
  color: var(--text-2); font-size: .85rem; font-weight: 500;
  cursor: pointer; height: auto;
}
.quick-menu button:hover { background: var(--bg-el-2); color: var(--text); }
.quick-menu .q-icon { width: 22px; text-align: center; color: var(--brand); }

/* ---- Toasts ---- */
.toasts { position: fixed; top: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-el); border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  padding: 10px 14px; border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  font-size: .85rem; color: var(--text); max-width: 380px;
  animation: toastIn .25s ease, toastOut .25s ease 3.6s forwards;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes toastOut { to { transform: translateX(40px); opacity: 0; } }

/* ---- Chart wrap ---- */
.chart { position: relative; height: 280px; margin-top: 8px; }
.chart.sm { height: 180px; }
.chart.lg { height: 360px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.chart-legend .lg-item { display: flex; align-items: center; gap: 6px; }
.chart-legend .lg-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ---- Party header card (ТУМИЗА / АСК ТРАСТ) ---- */
.parties {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px;
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 18px; margin-bottom: 18px;
  box-shadow: var(--sh-1);
}
.parties .p-side { min-width: 0; }
.parties .p-side small { display: block; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-2); font-weight: 700; }
.parties .p-side .p-name { font-size: .95rem; font-weight: 700; color: var(--text); }
.parties .p-side .p-meta { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.parties .p-mid {
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: var(--brand);
  letter-spacing: .3em;
}
.parties .p-right { text-align: right; }
@media (max-width: 780px) {
  .parties { grid-template-columns: 1fr; }
  .parties .p-right { text-align: left; }
  .parties .p-mid { justify-content: flex-start; letter-spacing: .15em; }
}

/* ---- Deployment grid (Расстановка) ---- */
.deploy-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.deploy-col {
  background: var(--bg-el-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.deploy-col-head {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.deploy-col-head .bd-color {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
}
.deploy-col-head .bd-name { font-weight: 600; font-size: .86rem; color: var(--text); }
.deploy-col-head .bd-count { margin-left: auto; font-size: .72rem; color: var(--muted); }
.deploy-person {
  padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--bg-el);
  border: 1px solid var(--border-2);
  font-size: .82rem;
}
.deploy-person .dp-head { display: flex; align-items: center; justify-content: space-between; }
.deploy-person .dp-name { font-weight: 600; color: var(--text); }
.deploy-person .dp-hrs { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.deploy-person .dp-where { font-size: .72rem; color: var(--muted); margin-top: 3px; }
.deploy-person .dp-wt { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.deploy-empty { padding: 12px; text-align: center; color: var(--muted-2); font-size: .78rem; }

/* ---- Efficiency card rows ---- */
.eff-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-2); font-size: .85rem; }
.eff-row:last-child { border-bottom: none; }
.eff-row .eff-name { flex: 1; color: var(--text-2); font-weight: 500; }
.eff-row .eff-val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.eff-row .eff-bar { width: 140px; height: 6px; border-radius: 999px; background: var(--bg-el-2); overflow: hidden; }
.eff-row .eff-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ---- Event feed ---- */
.feed { display: flex; flex-direction: column; gap: 0; max-height: 420px; overflow-y: auto; }
.feed-item {
  display: flex; gap: 10px; padding: 10px 4px;
  border-bottom: 1px solid var(--border-2);
}
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; background: var(--brand); }
.feed-body { flex: 1; font-size: .83rem; min-width: 0; }
.feed-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; flex-wrap: wrap; }
.feed-time { font-size: .72rem; color: var(--muted); }
.feed-body code { background: var(--bg-el-2); padding: 1px 6px; border-radius: var(--r-xs); font-size: .78em; }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); font-size: .85rem; }
.empty-icon { font-size: 2rem; opacity: .3; margin-bottom: 8px; }

/* ---- Mode toggle (shef / customer) ---- */
.seg {
  display: inline-flex; background: var(--bg-el-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 3px; gap: 2px;
}
.seg > button {
  height: 28px; padding: 0 12px; border: none; background: transparent;
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--muted); font-size: .78rem; font-weight: 600;
}
.seg > button.on { background: var(--bg-el); color: var(--text); box-shadow: var(--sh-1); }

/* ---- Responsive sidebar hide on mobile ---- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; width: var(--nav-w); z-index: 120; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--sh-3); }
  .app.collapsed { grid-template-columns: 1fr; }
}

/* ---- Utilities ---- */
.row { display: flex; align-items: center; gap: 8px; }
.row.gap-lg { gap: 16px; }
.row.wrap { flex-wrap: wrap; }
.space { flex: 1; }
.muted { color: var(--muted); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.hidden { display: none !important; }

/* ---- Scrollbar (subtle) ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* HTMX indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Legacy compat — старые имена классов из v1 шаблонов.
   Удалить после миграции всех страниц.
   ============================================================ */
.app-layout { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100vh; }
.main-content { grid-column: 2; }
.page-content { padding: 20px 24px 80px; max-width: 1560px; margin: 0 auto; }

.date-bar { background: var(--bg-el); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-bar label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.date-bar input[type="date"] { height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-el); color: var(--text); }
.date-bar .preset-btn, .date-bar .btn-outline { padding: 4px 10px; font-size: .78rem; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg-el-2); color: var(--text-2); cursor: pointer; }
.date-bar .preset-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.date-bar .preset-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.date-sep { color: var(--border); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 18px; }
.kpi-card {
  background: var(--bg-el); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 16px 14px;
  position: relative; overflow: hidden;
}
.kpi-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand); }
.kpi-card.success::before { background: var(--ok); }
.kpi-card.warning::before { background: var(--warn); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.info::before { background: var(--info); }
.kpi-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .75rem; color: var(--muted-2); margin-top: 6px; }

.section-card { background: var(--bg-el); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; margin-bottom: 16px; }
.section-card h3 { font-size: 1rem; color: var(--text); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; justify-content: space-between; }
.section-card h3 .card-actions { display: flex; gap: 6px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .two-col, .three-col { grid-template-columns: 1fr; } }

.alerts-strip { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r-md); background: var(--bg-el); border: 1px solid var(--border); border-left: 4px solid var(--muted); font-size: .85rem; }
.alert-danger { border-left-color: var(--danger); background: var(--danger-soft); }
.alert-warning { border-left-color: var(--warn); background: var(--warn-soft); }
.alert-info { border-left-color: var(--info); background: var(--info-soft); }
.alert-icon { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .78rem; color: #fff; background: var(--muted); }
.alert-danger .alert-icon { background: var(--danger); }
.alert-warning .alert-icon { background: var(--warn); }
.alert-info .alert-icon { background: var(--info); }
.alert-item a { margin-left: auto; font-weight: 600; font-size: .8rem; color: inherit; }

.event-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-2); }
.event-item:last-child { border-bottom: none; }
.event-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex-shrink: 0; }
.event-body { flex: 1; }
.event-text { font-size: .85rem; color: var(--text); }
.event-time { font-size: .72rem; color: var(--muted); }

.form-group { margin-bottom: 12px; }
.form-group > label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; }

.wt-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-xs); font-size: .72rem; font-weight: 700; }
.wt-chip.wt-montazh, .wt-montazh { background: rgba(59,130,246,.14); color: #3b82f6; }
.wt-chip.wt-markir, .wt-markir { background: rgba(234,179,8,.18); color: #a16207; }
.wt-chip.wt-remont, .wt-remont { background: rgba(239,68,68,.14); color: #dc2626; }
.wt-chip.wt-lan, .wt-lan { background: rgba(34,197,94,.14); color: #16a34a; }
.wt-chip.wt-fluke, .wt-fluke { background: rgba(168,85,247,.16); color: #7c3aed; }

.status-pill { padding: 3px 10px; border-radius: 999px; font-size: .7rem; font-weight: 600; text-transform: lowercase; }
.status-pill.status-in_progress { background: var(--accent-soft); color: var(--accent); }
.status-pill.status-planned { background: var(--bg-el-2); color: var(--muted); border: 1px solid var(--border); }
.status-pill.status-done { background: var(--ok-soft); color: var(--ok); }
.status-pill.status-blocked { background: var(--danger-soft); color: var(--danger); }

.btn-outline { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-el-2); color: var(--text); border-color: var(--muted); text-decoration: none; }

.chart-container { position: relative; height: 260px; margin: 12px 0; }
.chart-container.small { height: 180px; }

.progress-wrap { background: var(--bg-el-2); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #3b82f6, #2563eb); transition: width .5s; }
.progress-bar.blue { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.progress-bar.green { background: linear-gradient(90deg, #22c55e, #16a34a); }
.progress-bar.orange { background: linear-gradient(90deg, #f59e0b, #d97706); }
.progress-bar.red { background: linear-gradient(90deg, #ef4444, #dc2626); }

.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 200; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-backdrop.active { opacity: 1; pointer-events: all; }
.modal-box { background: var(--bg-el); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-3); width: 92%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal-header { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; }
.modal-close { background: var(--bg-el-2); border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--muted); font-size: 1.1rem; }
.modal-body { padding: 18px; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 400; display: flex; flex-direction: column; gap: 8px; }

.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); font-size: .85rem; }
.empty-state .empty-icon { font-size: 2rem; opacity: .3; margin-bottom: 8px; }

/* Blockers / reports legacy */
.blocker-item { padding: 14px 16px; border-radius: var(--r-md); margin-bottom: 10px; border-left: 4px solid; display: flex; gap: 12px; align-items: flex-start; background: var(--bg-el); border: 1px solid var(--border); border-left-width: 4px; }
.blocker-open { border-left-color: var(--danger); background: var(--danger-soft); }
.blocker-in_progress { border-left-color: var(--warn); background: var(--warn-soft); }
.blocker-resolved { border-left-color: var(--ok); background: var(--ok-soft); }
.blocker-dismissed { border-left-color: var(--muted); background: var(--bg-el-2); }
.blocker-body { flex: 1; }
.blocker-title { font-weight: 600; font-size: .9rem; }
.blocker-meta { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.blocker-actions { display: flex; gap: 6px; margin-top: 8px; }

.report-card { padding: 14px 16px; border-radius: var(--r-md); border: 1px solid var(--border); margin-bottom: 10px; background: var(--bg-el); }
.report-card.unprocessed { border-left: 3px solid var(--warn); }
.report-card.processed { border-left: 3px solid var(--ok); opacity: .75; }
.report-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.report-author { font-weight: 600; font-size: .85rem; color: var(--text); }
.report-time { font-size: .72rem; color: var(--muted); }
.report-text { font-size: .85rem; color: var(--text-2); line-height: 1.5; }
.report-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border-2); }

/* Tabel grid */
.tabel-grid { display: grid; gap: 1px; background: var(--border); border-radius: var(--r-md); overflow: hidden; }
.tabel-cell { background: var(--bg-el); padding: 8px 12px; font-size: .85rem; color: var(--text); }
.tabel-cell.header { background: var(--bg-el-2); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.tabel-cell input, .tabel-cell select { border: 1px solid transparent; background: transparent; padding: 4px 8px; border-radius: var(--r-xs); font-size: .82rem; width: 100%; color: var(--text); }
.tabel-cell input:focus, .tabel-cell select:focus { border-color: var(--accent); background: var(--bg-el); outline: none; }
.ts-present { color: var(--ok); }
.ts-absent { color: var(--danger); }
.ts-late { color: var(--warn); }
.ts-sick { color: var(--info); }

/* Filter bar (gpr etc.) */
.filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; padding: 10px 0; }
.filter-bar .form-group { margin-bottom: 0; }
.filter-bar select, .filter-bar input { padding: 0 10px; font-size: .82rem; border: 1px solid var(--border); border-radius: var(--r-sm); height: 30px; }

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 14px; }
.tab { padding: 8px 14px; font-size: .85rem; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; text-decoration: none; background: none; border-top: none; border-left: none; border-right: none; }
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.badge-gray { background: var(--bg-el-2); color: var(--muted); border-color: var(--border); }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--ok-soft); color: var(--ok); }
.badge-orange { background: var(--warn-soft); color: var(--warn); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-cyan { background: var(--info-soft); color: var(--info); }

/* Print-friendly */
@media print {
  .sidebar, .topbar, .quick-add, .toasts, .palette-back, .modal-back, .page-actions { display: none !important; }
  .app { grid-template-columns: 1fr !important; }
  .page { padding: 0; max-width: none; }
  .card { break-inside: avoid; box-shadow: none; border-color: #bbb; }
}
