/* ── Bootstrap Icons (CDN loaded in base.html) ───────────────────────── */
:root {
  --bg: #f5f7fa;
  --sidebar: #192233;
  --sidebar-w: 64px;
  --card: #ffffff;
  --text: #181c32;
  --muted: #6e7d8f;
  --blue: #3b7ddd;
  --blue-dark: #2c6fca;
  --blue-light: #e8f1fd;
  --line: #e4e7ef;
  --green: #0bb783;
  --orange: #ffa800;
  --red: #f64e60;
  --purple: #8950fc;
  --teal: #1bc5bd;
  --cyan: #17a2b8;
  --nav-icon: #8fa3b8;
  --nav-active: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--blue-dark); }

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  z-index: 200;
  box-shadow: 2px 0 8px rgba(0,0,0,.18);
}

.sidebar-logo {
  width: 40px; height: 40px;
  background: var(--blue);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 18px;
  margin-bottom: 16px;
  text-decoration: none;
}
.sidebar-logo:hover { text-decoration: none; background: var(--blue-dark); }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
}

.sidebar-link {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--nav-icon);
  font-size: 20px;
  transition: all .15s;
  text-decoration: none !important;
  position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,.08); color: var(--nav-active); }
.sidebar-link.active { background: var(--blue); color: #fff; }

.sidebar-link .tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%; transform: translateY(-50%);
  background: #1e2d40;
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 300;
}
.sidebar-link:hover .tooltip { opacity: 1; }

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
}

.sidebar-user {
  width: 36px; height: 36px;
  background: #2d4263;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #8fa3b8;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}
.sidebar-user form { margin: 0; }
.sidebar-user button {
  background: none; border: none; color: #8fa3b8;
  font-size: 15px; font-weight: 700; cursor: pointer; padding: 0;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-user button:hover { color: white; background: rgba(255,255,255,.1); filter: none; }
.sidebar-user .tooltip {
  position: absolute;
  left: calc(100% + 12px);
  top: 50%; transform: translateY(-50%);
  background: #1e2d40; color: #fff;
  padding: 5px 10px; border-radius: 6px;
  font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s; z-index: 300;
}
.sidebar-user:hover .tooltip { opacity: 1; }

/* ── MAIN ────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  height: 100vh;          /* фиксированная высота — скролл внутри .main */
  overflow-y: auto;       /* делает .main scroll-контейнером для position:sticky */
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ── FLASH MESSAGES ──────────────────────────────────────────────────── */
.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash {
  border-radius: 8px;
  border-left: 4px solid var(--line);
  background: var(--card);
  padding: 10px 14px;
  font-size: 13px;
}
.flash.success { border-color: var(--green); background: #f0fdf4; color: #166534; }
.flash.error   { border-color: var(--red);   background: #fff1f2; color: #9f1239; }
.flash.info    { border-color: var(--blue);  background: #eff6ff; color: #1e40af; }

/* ── PAGE HEADER ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.page-header-left { display: flex; flex-direction: column; gap: 2px; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--blue); }
h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--text); }
h2 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none !important;
  white-space: nowrap;
}
.btn-primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); color: white; }
.btn-secondary { background: white; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: #f8f9fb; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { background: #d93546; border-color: #d93546; color: white; }

button { cursor: pointer; }
input, select, textarea {
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  background: white;
  transition: border-color .15s;
  font-family: inherit;
  line-height: 1.4;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,125,221,.12);
}

/* ── FILTER PANEL ────────────────────────────────────────────────────── */
.filter-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 24px 16px;
  margin-bottom: 16px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 16px;
  margin-bottom: 14px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-group input,
.filter-group select { width: 100%; }
.filter-range { display: flex; gap: 6px; align-items: center; }
.filter-range input { flex: 1; min-width: 0; }
.filter-range span { color: var(--muted); font-size: 13px; }
.filter-actions { display: flex; gap: 10px; align-items: center; }

/* ── STATUS TABS ─────────────────────────────────────────────────────── */
.status-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}
.status-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
  transition: all .15s;
  display: flex; align-items: center; gap: 5px;
}
.status-tab:hover { background: var(--bg); color: var(--text); }
.status-tab.active { background: var(--blue); color: white; }
.status-tab .tab-count {
  background: rgba(0,0,0,.1);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
}
.status-tab.active .tab-count { background: rgba(255,255,255,.25); }

/* ── TABLE ───────────────────────────────────────────────────────────── */
.table-wrap {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  background: #fafbfc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }
td a { color: var(--blue); font-weight: 500; }

/* ── BADGES ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}
/* Status group colors */
.badge-new      { background: #e8f1fd; color: #2469de; }
.badge-agree    { background: #fff3cd; color: #856404; }
.badge-assembly { background: #f3e8ff; color: #7c3aed; }
.badge-delivery { background: #d1fae5; color: #065f46; }
.badge-done     { background: #d1fae5; color: #065f46; }
.badge-cancel   { background: #fee2e2; color: #991b1b; }
.badge-waiting  { background: #fef3c7; color: #92400e; }
.badge-payment  { background: #cffafe; color: #164e63; }
.badge-default  { background: #f1f3f5; color: #495057; }

/* Payment status icons */
.pay-ok   { color: var(--green); }
.pay-wait { color: var(--muted); }
.pay-err  { color: var(--red); }

/* ── CUSTOMER AVATAR ─────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.av-A,.av-B { background: #ffe5d0; color: #c05600; }
.av-В,.av-Г { background: #d0f0fd; color: #0077a8; }
.av-Д,.av-Е,.av-Ж { background: #d7f5e4; color: #1a7a4a; }
.av-З,.av-И { background: #fde8fa; color: #891d84; }
.av-К,.av-Л { background: #fff3d0; color: #8b6914; }
.av-М,.av-Н { background: #e8edff; color: #3451b2; }
.av-О,.av-П { background: #ffe0e0; color: #c0392b; }
.av-Р,.av-С { background: #e0f7e9; color: #217a4f; }
.av-Т,.av-У { background: #fef9c3; color: #92400e; }
.av-Ф,.av-Х { background: #e8f8ff; color: #0369a1; }
.av-Ц,.av-Ч { background: #f0e8ff; color: #6d28d9; }
.av-Ш,.av-Щ,.av-Ъ,.av-Ы,.av-Ь,.av-Э,.av-Ю,.av-Я { background: #ffe8f5; color: #be185d; }
.av-default  { background: #e5e7eb; color: #6b7280; }

.customer-cell { display: flex; align-items: center; gap: 10px; }
.customer-name { display: flex; flex-direction: column; }
.customer-name strong { color: var(--blue); font-weight: 500; }
.vip-tag { font-size: 10px; font-weight: 700; color: #c05600; background: #ffe5d0; padding: 1px 5px; border-radius: 4px; display: inline-block; }

/* ── CARDS ───────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 20px;
}
.kpi-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--text); }
.kpi-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── ORDER DETAIL ────────────────────────────────────────────────────── */
.order-header {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 24px;
  margin-bottom: 0;
}
.order-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}
.order-title-block { display: flex; flex-direction: column; gap: 4px; }
.order-title { font-size: 22px; font-weight: 700; }
.order-meta { display: flex; gap: 24px; font-size: 13px; color: var(--muted); }
.order-meta strong { color: var(--text); }
.order-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.order-status-select { min-width: 220px; }

/* ── TABS ────────────────────────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
  background: white;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 0 16px;
}
.tab-btn {
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--blue); background: none; filter: none; }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-body {
  background: white;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 24px;
}

/* ── FORM GRID ───────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-group input,
.form-group select,
.form-group textarea { width: 100%; }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-full { grid-column: 1 / -1; }

/* ── SECTION HEADER ──────────────────────────────────────────────────── */
.section-header {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

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

/* ── TASKS LIST ──────────────────────────────────────────────────────── */
.task-date-group { margin-bottom: 0; }
.task-date-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: #f8f9fb;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
}
.task-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  gap: 14px;
  background: white;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: #f8f9fb; }
.task-check-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid #ced4da;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: transparent;
}
.task-check-btn:hover { border-color: var(--green); color: var(--green); filter: none; }
.task-done .task-check-btn { background: var(--green); border-color: var(--green); color: white; }
.task-time { font-size: 12px; color: var(--muted); white-space: nowrap; min-width: 110px; }
.task-title { flex: 1; font-weight: 500; }
.task-order-link { font-size: 13px; color: var(--blue); min-width: 80px; }
.task-assignee { font-size: 13px; color: var(--muted); min-width: 90px; }

/* ── BULK BAR ────────────────────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fb;
  border-top: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
}
.bulk-bar select { min-width: 180px; }

/* ── PAGER ───────────────────────────────────────────────────────────── */
.pager { display: flex; gap: 6px; margin-top: 16px; align-items: center; }
.pager a, .pager span {
  display: inline-block;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  color: var(--blue);
}
.pager span { color: var(--muted); }
.pager a:hover { background: var(--blue-light); text-decoration: none; }
.pager-count { font-size: 13px; color: var(--muted); margin-left: 6px; }

/* ── COMPOSITION LIST ────────────────────────────────────────────────── */
.composition-list { margin: 0; padding: 0 0 0 14px; font-size: 13px; }
.composition-list li { margin-bottom: 2px; color: var(--text); }

/* ── INLINE FORM ─────────────────────────────────────────────────────── */
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── AUDIT LOG ───────────────────────────────────────────────────────── */
.audit-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  align-items: flex-start;
}
.audit-row:last-child { border-bottom: none; }
.audit-time { color: var(--muted); white-space: nowrap; min-width: 140px; }
.audit-action { font-weight: 600; color: var(--text); }
.audit-actor { color: var(--muted); }
.audit-payload { color: var(--muted); font-size: 12px; }

/* ── CONVERSATIONS ───────────────────────────────────────────────────── */
.conv-row {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px; align-items: center;
}
.conv-row:last-child { border-bottom: none; }
.conv-channel { background: var(--blue-light); color: var(--blue); padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }

/* ── STATUS PANEL (left accordion) ──────────────────────────────────── */
.orders-layout {
  display: flex;
  gap: 0;
  align-items: flex-start;
}

.status-panel {
  width: 220px;
  min-width: 220px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-right: 12px;
  flex-shrink: 0;
  overflow: hidden;
}

.status-panel-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.status-panel-collapse {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-panel-collapse:hover { color: var(--blue); }

.status-panel-stub {
  width: 36px;
  min-width: 36px;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
  margin-right: 8px;
}
.status-panel-expand {
  width: 32px;
  height: 32px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.status-panel-expand:hover { color: var(--blue); }

.status-panel-body { padding: 6px 0; }

.status-panel-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none !important;
  margin: 2px 8px;
  border-radius: 6px;
}
.status-panel-all:hover { background: var(--bg); }
.status-panel-all.active { background: var(--blue); color: white; }
.status-panel-all.active .sp-count { background: rgba(255,255,255,.25); color: white; }

/* Group */
.sp-group { margin-bottom: 2px; }

.sp-group-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.sp-group-header:hover { background: var(--bg); }

.sp-group-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
/* Icon colors matching badge groups */
.sp-group-icon.badge-new      { color: var(--blue); }
.sp-group-icon.badge-agree    { color: var(--orange); }
.sp-group-icon.badge-assembly { color: var(--purple); }
.sp-group-icon.badge-delivery { color: var(--green); }
.sp-group-icon.badge-done     { color: var(--green); }
.sp-group-icon.badge-cancel   { color: var(--red); }
.sp-group-icon.badge-waiting  { color: var(--orange); }
.sp-group-icon.badge-payment  { color: var(--teal); }

.sp-group-name { flex: 1; }

.sp-chevron {
  font-size: 11px;
  color: var(--muted);
  transition: transform .2s;
}
.sp-group.open .sp-chevron { transform: rotate(180deg); }

/* Group items (collapsed by default) */
.sp-group-items { display: none; }
.sp-group.open .sp-group-items { display: block; }

.sp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 6px 20px;
  font-size: 12px;
  color: var(--text);
  text-decoration: none !important;
  border-radius: 0;
}
.sp-item:hover { background: var(--bg); color: var(--blue); }
.sp-item.active { color: var(--blue); font-weight: 600; background: var(--blue-light); }
.sp-sub-item { padding-left: 28px; color: var(--muted); }
.sp-sub-item:hover { color: var(--blue); }
.sp-sub-item.active { color: var(--blue); font-weight: 600; background: var(--blue-light); }

.sp-count {
  font-size: 11px;
  background: #f1f3f5;
  color: var(--muted);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.orders-table-area { flex: 1; min-width: 0; }

/* ── ORDERS TABLE ────────────────────────────────────────────────────── */
.orders-table-wrap { overflow-x: auto; }
.orders-table { min-width: 1400px; }

/* СТАТУСЫ narrow column */
.statuses-col {
  width: 22px;
  padding: 0 !important;
  background: #f5f7fa;
  border-right: 1px solid var(--line);
}
.statuses-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--muted);
  text-transform: uppercase;
  display: block;
  text-align: center;
  padding: 8px 0;
}
/* Status right-edge bar column */
.status-bar-col {
  width: 8px;
  min-width: 8px;
  max-width: 8px;
  padding: 0 !important;
  background: #e9ecef;
  border-radius: 0 4px 4px 0;
}
/* Row colors by group */
tr[data-group="Новый"] .status-bar-col         { background: var(--blue); }
tr[data-group="Лист ожидания"] .status-bar-col { background: var(--orange); }
tr[data-group="Оплата"] .status-bar-col        { background: var(--teal); }
tr[data-group="Комплектация"] .status-bar-col  { background: var(--purple); }
tr[data-group="Доставка"] .status-bar-col      { background: var(--green); }
tr[data-group="Выполнен"] .status-bar-col      { background: var(--green); }
tr[data-group="Отменен"] .status-bar-col       { background: var(--red); }

/* Column widths */
.col-date      { min-width: 95px; }
.col-num       { min-width: 80px; }
.col-composition { max-width: 220px; }
.col-comment   { max-width: 180px; }
.col-address   { max-width: 220px; }

/* Sort icon */
.sortable { cursor: pointer; white-space: nowrap; }
.sort-icon { font-size: 10px; color: #ced4da; margin-left: 3px; }
/* Table cell helpers */
.td-muted { color: var(--muted); }
.td-amount { font-weight: 600; white-space: nowrap; }

/* Filter toggle button */
.filter-toggle-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 0 2px 12px;
  vertical-align: middle;
}
.filter-toggle-btn:hover { text-decoration: underline; }

/* ── ORDER DETAIL ────────────────────────────────────────────────────── */

/* Page header */
.od-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.od-head-left { min-width: 0; flex: 1; overflow: hidden; }
.od-head-title-row { display: flex; align-items: flex-end; gap: 24px; margin-top: 4px; flex-wrap: nowrap; }
.od-title { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.2; flex-shrink: 0; }
.od-meta-block { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.od-meta-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.od-meta-val { font-size: 16px; font-weight: 600; color: var(--text); white-space: nowrap; }
.od-head-right { flex-shrink: 0; }

/* Subsection header inside section card */
.ocs-sub-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: #f8f9fb; border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line); margin: 0;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.ocs-sub-hdr:first-child { border-top: none; }
.ocs-sub-action { font-size: 12px; color: var(--blue); cursor: pointer; background: none; border: none; font-weight: 500; }
.ocs-sub-action:hover { text-decoration: underline; }

/* Address structured fields */
.od-addr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.od-addr-grid .ocs-field:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
.od-addr-grid .ocs-field:last-child { border-bottom: none; }
.od-addr-full { grid-column: 1 / -1; }

/* Communication tabs */
.od-comm-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.od-comm-tab {
  padding: 7px 14px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; margin-bottom: -1px;
}
.od-comm-tab:hover { color: var(--blue); }
.od-comm-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.od-comm-body { font-size: 12px; color: var(--muted); padding: 6px 0 8px; }
.od-comm-new-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  background: var(--blue-light); color: var(--blue); border: none; border-radius: 5px; cursor: pointer; margin-top: 6px;
}
.od-comm-new-btn:hover { background: #d4e6fb; }

/* Expense block */
.od-expense-list { min-height: 32px; }
.od-expense-empty { font-size: 12px; color: var(--muted); padding: 6px 0; }
.od-add-expense-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  background: none; color: var(--blue); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; margin-top: 6px;
}
.od-add-expense-btn:hover { background: var(--blue-light); }

/* Right delivery sidebar */
.od-delivery-side-section { margin-bottom: 16px; }
.od-delivery-side-section:last-child { margin-bottom: 0; }

/* Progress bar + status button */
.od-progress {
  list-style: none; margin: 0 0 0 0; padding: 0;
  display: flex; gap: 3px;
  width: 246px;
}
.od-progress li {
  flex: 1; height: 6px; border-radius: 2px 2px 0 0;
  background: #e9ecef; cursor: default;
  transition: height .15s;
}
.od-progress li.past    { opacity: .35; }
.od-progress li.active  { height: 10px; }
/* segment colors per group */
.od-progress li[data-grp="badge-new"].active,
.od-progress li[data-grp="badge-new"].past   { background: #ffa800; }
.od-progress li[data-grp="badge-agree"].active,
.od-progress li[data-grp="badge-agree"].past  { background: #ffa800; }
.od-progress li[data-grp="badge-assembly"].active,
.od-progress li[data-grp="badge-assembly"].past { background: #8950fc; }
.od-progress li[data-grp="badge-delivery"].active,
.od-progress li[data-grp="badge-delivery"].past { background: #3b7ddd; }
.od-progress li[data-grp="badge-done"].active,
.od-progress li[data-grp="badge-done"].past   { background: #0bb783; }
.od-progress li[data-grp="badge-waiting"].active,
.od-progress li[data-grp="badge-waiting"].past { background: #ffa800; }
.od-progress li[data-grp="badge-cancel"].active,
.od-progress li[data-grp="badge-cancel"].past  { background: #f64e60; }

.od-status-wrap { position: relative; }
.od-status-btn-wrap { display: flex; }
.od-status-btn {
  flex: 1;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-size: 13px; font-weight: 700;
  border: none; border-radius: 6px 0 0 6px;
  cursor: pointer; white-space: nowrap; min-width: 160px;
  color: white;
}
.od-status-arr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; border: none; border-radius: 0 6px 6px 0;
  cursor: pointer; color: white; opacity: .8;
  border-left: 1px solid rgba(255,255,255,.25);
}
/* status colors */
.od-status-btn.badge-new,    .od-status-arr.badge-new    { background: #ffa800; }
.od-status-btn.badge-agree,  .od-status-arr.badge-agree  { background: #ffa800; }
.od-status-btn.badge-assembly,.od-status-arr.badge-assembly{ background: #8950fc; }
.od-status-btn.badge-delivery,.od-status-arr.badge-delivery{ background: #3b7ddd; }
.od-status-btn.badge-done,   .od-status-arr.badge-done   { background: #0bb783; }
.od-status-btn.badge-cancel, .od-status-arr.badge-cancel { background: #f64e60; }
.od-status-btn.badge-waiting,.od-status-arr.badge-waiting { background: #ffa800; }
.od-status-btn.badge-payment,.od-status-arr.badge-payment { background: #1bc5bd; }
.od-status-btn.badge-default,.od-status-arr.badge-default { background: #6e7d8f; }
.od-status-btn:hover,.od-status-arr:hover { filter: brightness(.92); }
.od-status-icon { font-size: 12px; opacity: .8; flex-shrink: 0; }
.od-status-list {
  display: none; position: absolute; right: 0; top: calc(100% + 4px);
  background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  min-width: 240px; max-height: 340px; overflow-y: auto; z-index: 300;
}
.od-status-list.open { display: block; }
.od-status-item { padding: 9px 16px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.od-status-item:last-child { border-bottom: none; }
.od-status-item:hover { background: #f8f9fb; }
.od-status-item.active { font-weight: 600; color: var(--blue); background: var(--blue-light); }

/* Sticky nav bar */
.od-sticky-nav {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 100;
  background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); margin-bottom: 16px;
}
.od-action-bar {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.od-flag {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; border: none; cursor: pointer; background: none; color: var(--muted);
  font-size: 12px;
}
.od-flag.vip:hover { color: #b8860b; background: #fef3c7; }
.od-flag.bad:hover { color: var(--red); background: #fee2e2; }
.od-bar-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; flex-shrink: 0; }
.od-bar-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; font-size: 12px; color: var(--text);
  background: none; border: none; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.od-bar-btn:hover { background: #f1f3f5; }
.od-bar-btn i { font-size: 12px; color: var(--muted); }
.od-arr { font-size: 9px !important; }
.od-bar-drop {
  display: none; position: absolute; top: calc(100% + 2px); left: 0; z-index: 200;
  background: white; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); min-width: 210px; padding: 4px 0;
}
.od-bar-drop.open { display: block; }
.od-bar-drop-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 12px; color: var(--text); cursor: pointer;
}
.od-bar-drop-item:hover { background: #f8f9fb; }
.od-bar-drop-item i { font-size: 13px; color: var(--muted); }
.od-plus-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; background: var(--blue); color: white;
  border-radius: 50%; font-size: 12px; font-weight: 700; margin-left: 2px;
}

/* Anchor nav links */
.od-section-nav { display: flex; padding: 0 14px; gap: 0; }
.od-nav-link {
  padding: 10px 14px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
  white-space: nowrap;
}
.od-nav-link:hover { color: var(--blue); text-decoration: none; }
.od-nav-link.active { color: var(--blue); border-bottom-color: var(--blue); }

/* Content area */
.od-content { }
.od-section { margin-bottom: 4px; }

/* Collapsible section cards */
.ocs {
  background: white; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 10px; overflow: hidden;
}
.ocs-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; transition: background .12s;
}
.ocs-hdr:hover { background: #f8f9fb; }
.ocs-arr { font-size: 12px; color: var(--muted); transition: transform .2s; flex-shrink: 0; margin-left: 8px; }
.ocs-bdy { padding: 16px 20px; }
.ocs.ocs-closed .ocs-bdy { display: none; }
.ocs.ocs-closed .ocs-arr { transform: rotate(-180deg); }
.ocs.ocs-closed .ocs-hdr { border-bottom: none; }
.ocs-counter {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue); color: white; border-radius: 10px;
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 4px;
}
.ocs-sub-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin-bottom: 6px;
}

/* 2-col field grid inside sections */
.ocs-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px;
}
.ocs-field {
  display: flex; align-items: flex-start; padding: 11px 0;
  border-bottom: 1px solid var(--line); gap: 14px; min-width: 0;
}
.ocs-field:nth-last-child(-n+2) { border-bottom: none; }
.ocs-field label {
  min-width: 130px; max-width: 130px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); flex-shrink: 0; padding-top: 2px;
}
.ocs-val { font-size: 11px; flex: 1; min-width: 0; color: var(--text); }
.ocs-val input[disabled] {
  border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px; font-size: 11px; width: 100%; background: #fafbfc; color: var(--text);
}
.ocs-val textarea { width: 100%; resize: vertical; font-size: 11px; }
.ocs-val.od-amount { font-size: 14px; font-weight: 700; }

/* Client section */
.ocs-client-row {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px;
  flex-wrap: wrap;
}
.ocs-client-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--blue-light); color: var(--blue);
  border-radius: 20px; padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.ocs-client-pill:hover { text-decoration: none; background: #d4e6fb; }
.ocs-client-meta { font-size: 12px; color: var(--muted); }
.ocs-refill-link { font-size: 12px; color: var(--blue); }
.od-tel-btn {
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue-light); color: var(--blue); border-radius: 4px; font-size: 12px;
}
.od-tel-btn:hover { background: #d4e6fb; text-decoration: none; }

/* Composition table */
.od-comp-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.od-comp-table thead th {
  padding: 8px 14px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: #f8f9fb;
  border-bottom: 1px solid var(--line); text-align: left;
}
.od-comp-table tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.od-comp-table tbody tr:last-child td { border-bottom: none; }
.od-comp-table tbody tr:hover { background: #f8f9fb; }
.od-comp-totals { border-top: 2px solid var(--line); padding: 12px 20px; }
.od-comp-total-row {
  display: flex; justify-content: space-between;
  padding: 4px 0; font-size: 11px;
}
.od-comp-total-row span:first-child { color: var(--muted); }
.od-comp-total-main { font-weight: 700; font-size: 13px; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }

/* Delivery 2-col layout */
.od-delivery-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; }
.od-delivery-main { min-width: 0; }
.od-delivery-side { min-width: 0; }

/* Save bar */
.od-save-bar {
  position: -webkit-sticky; position: sticky; bottom: 0; z-index: 100;
  display: flex; align-items: center; gap: 8px;
  background: white; border-top: 1px solid var(--line);
  padding: 10px 0; margin: 16px -32px -28px -32px; padding-left: 24px; padding-right: 24px;
}
.od-save-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 20px; background: var(--blue); color: white;
  border: none; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.od-save-btn:hover { background: var(--blue-dark); }
.od-save-exit-btn {
  padding: 8px 16px; background: white; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; font-size: 13px; cursor: pointer;
}
.od-save-exit-btn:hover { background: #f8f9fb; }
.od-cancel-link { font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 8px; }
.od-cancel-link:hover { color: var(--text); }
.od-delete-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); cursor: pointer; font-size: 14px;
}
.od-delete-btn:hover { background: #fee2e2; border-color: var(--red); color: var(--red); }

/* legacy aliases kept for other pages */
.oph { margin-bottom: 16px; }
.oph-right { flex-shrink: 0; }

/* Status button (large, colored) */
.oph-status-wrap { position: relative; }
.oph-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  min-width: 180px;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.oph-status-btn:hover { filter: brightness(.93); }
/* inherit badge colors via badge-btn + badge class combination */
.badge-btn.badge-new     { background: #3b7ddd; color: white; }
.badge-btn.badge-agree   { background: #ffa800; color: white; }
.badge-btn.badge-assembly{ background: #8950fc; color: white; }
.badge-btn.badge-delivery{ background: #0bb783; color: white; }
.badge-btn.badge-done    { background: #0bb783; color: white; }
.badge-btn.badge-cancel  { background: #f64e60; color: white; }
.badge-btn.badge-waiting { background: #ffa800; color: white; }
.badge-btn.badge-payment { background: #1bc5bd; color: white; }
.badge-btn.badge-default { background: #6e7d8f; color: white; }
.oph-status-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
  min-width: 240px;
  max-height: 340px;
  overflow-y: auto;
  z-index: 300;
}
.oph-status-list.open { display: block; }
.oph-status-item {
  padding: 11px 18px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.oph-status-item:last-child { border-bottom: none; }
.oph-status-item:hover { background: #f8f9fb; }
.oph-status-item.active { font-weight: 600; color: var(--blue); background: var(--blue-light); }

/* Sticky bar: action + tabs */
.order-sticky-bar {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  margin: 0 0 0 0;
}

/* Action bar inside sticky */
.oab {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.oab-flag {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  border: 1.5px solid;
  cursor: pointer;
  letter-spacing: .05em;
  background: none;
  line-height: 1.4;
}
.oab-flag.vip { color: #b8860b; border-color: #b8860b; }
.oab-flag.vip:hover { background: #fef3c7; }
.oab-flag.bad { color: var(--red); border-color: var(--red); }
.oab-flag.bad:hover { background: #fee2e2; }
.oab-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; flex-shrink: 0; }
.oab-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.oab-btn:hover { background: #f1f3f5; }
.oab-btn i { font-size: 13px; color: var(--muted); }
.oab-arr { font-size: 10px !important; color: var(--muted) !important; }
.oab-plus-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  margin-left: 2px;
}

/* Tabs inside sticky bar */
.order-tabs {
  display: flex;
  padding: 0 16px;
  gap: 0;
}
.otab {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.otab:hover { color: var(--blue); }
.otab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* (old tab/ocf classes removed — replaced by od-* and ocs-* above) */

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .container { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
}

/* ── ПАНЕЛЬ ПРОДАЖИ (FLYOUT) ─────────────────────────────────────────── */
.sf-panel {
  position: fixed;
  left: var(--sidebar-w);
  top: 0;
  height: 100vh;
  width: 236px;
  background: #f5f7fa;
  border-right: 1px solid var(--line);
  z-index: 190;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - 4px));
  transition: transform .22s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sf-panel.open {
  transform: translateX(0);
  box-shadow: 4px 0 20px rgba(0,0,0,.1);
}
/* Сдвиг основного контента когда панель открыта */
.main.sf-open {
  margin-left: calc(var(--sidebar-w) + 236px);
  transition: margin-left .22s ease;
}
.main {
  transition: margin-left .22s ease;
}

.sf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.sf-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.sf-close-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}
.sf-close-btn:hover { background: var(--line); color: var(--text); }

.sf-body { padding: 6px 0; flex: 1; }

/* Прямые ссылки */
.sf-item {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none !important;
  transition: background .1s;
  border-left: 3px solid transparent;
}
.sf-item:hover { background: rgba(0,0,0,.04); color: var(--blue); text-decoration: none !important; }
.sf-item.sf-active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
  border-left-color: var(--blue);
}

/* Группы с раскрытием */
.sf-group { }
.sf-group-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
}
.sf-group-btn:hover { background: rgba(0,0,0,.04); }
.sf-arr { font-size: 11px; color: var(--muted); transition: transform .18s; flex-shrink: 0; }
.sf-group.open .sf-arr { transform: rotate(180deg); }
.sf-group-items { display: none; background: rgba(0,0,0,.02); }
.sf-group.open .sf-group-items { display: block; }
.sf-sub-item {
  display: block;
  padding: 7px 16px 7px 26px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none !important;
  transition: background .1s;
}
.sf-sub-item:hover { background: rgba(0,0,0,.04); color: var(--blue); text-decoration: none !important; }
.sf-sub-item.sf-active { color: var(--blue); font-weight: 600; }

.sf-divider { height: 1px; background: var(--line); margin: 8px 0; }
.sf-add-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--blue);
  text-decoration: none !important;
}
.sf-add-link:hover { text-decoration: underline !important; }

/* Sidebar кнопки (не только ссылки) */
.sidebar-link[type="button"] {
  background: none;
  border: none;
  cursor: pointer;
}

/* ── ПАНЕЛЬ НАСТРОЕК (FLYOUT) ─────────────────────────────────────────── */
.stg-panel {
  position: fixed;
  left: var(--sidebar-w);
  top: 0;
  height: 100vh;
  width: 236px;
  background: #f5f7fa;
  border-right: 1px solid var(--line);
  z-index: 190;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - 4px));
  transition: transform .22s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.stg-panel.open {
  transform: translateX(0);
  box-shadow: 4px 0 20px rgba(0,0,0,.1);
}
.stg-back-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  padding: 2px 6px 2px 0;
}
.stg-back-link:hover { color: var(--accent); }
.main.stg-open {
  margin-left: calc(var(--sidebar-w) + 236px);
  transition: margin-left .22s ease;
}

/* ── SETTINGS FORM ────────────────────────────────────────────────────── */
.settings-form { max-width: 640px; }
.settings-form .form-group { margin-bottom: 20px; }
.settings-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.settings-form label .req { color: var(--red); margin-left: 2px; }
.settings-form input[type="text"],
.settings-form input[type="email"],
.settings-form select,
.settings-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,125,221,.12);
}
.settings-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}
.settings-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.settings-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 24px 28px;
  margin-bottom: 20px;
}
.settings-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stg-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.stg-badge-green { background: #e6f9f3; color: var(--green); }
.stg-badge-red   { background: #fff0f2; color: var(--red); }
.stg-badge-blue  { background: var(--blue-light); color: var(--blue); }
.stg-badge-gray  { background: #f0f1f3; color: var(--muted); }
