:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line2: #d1d5db;
  --primary: #2563eb;
  --primary-h: #1d4ed8;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --ok-soft: #ecfdf3;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .25);
  --sidebar: 232px;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.ok-text { color: var(--ok); } .danger-text { color: var(--danger); } .warn-text { color: var(--warn); }
.strike { text-decoration: line-through; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 360px; max-width: 100%; background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px; }
.login-card h1 { font-size: 22px; color: var(--primary); }
.login-card p { margin: 4px 0 22px; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar); background: var(--card); border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 30; }
.brand { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.brand .logo { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand .name { font-weight: 700; font-size: 14px; line-height: 1.2; word-break: break-word; }
.brand .sub { font-size: 11px; color: var(--muted); }
.nav { padding: 10px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #374151; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: #f3f4f6; text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav .sep { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 12px 6px; }
.main { margin-left: var(--sidebar); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 0; z-index: 20; }
.topbar .burger { display: none; }
.crumbs { color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }
.usermenu { position: relative; }
.usermenu .dropdown > button { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.usermenu .dropdown > button:hover { background: #f3f4f6; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #e0e7ff; color: #3730a3; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.content { padding: 22px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 4px; white-space: nowrap; }
.stat .value.ok { color: var(--ok); } .stat .value.danger { color: var(--danger); }
.stat .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line2); background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { padding: 2px 7px; font-size: 12px; border-radius: 6px; }
.icon-btn { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; border: 0; background: transparent; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }
.btn-group { display: inline-flex; border: 1px solid var(--line2); border-radius: 9px; overflow: hidden; background: #fff; }
.btn-group button { border: 0; background: transparent; padding: 7px 13px; cursor: pointer; font-weight: 500; }
.btn-group button + button { border-left: 1px solid var(--line2); }
.btn-group button.active { background: var(--primary-soft); color: var(--primary); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .hint { font-size: 11px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 8px 11px; border: 1px solid var(--line2); border-radius: 9px; background: #fff; outline: none; min-height: 36px; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input.sm { padding: 5px 8px; min-height: 30px; font-size: 13px; border-radius: 7px; }
.input.invalid { border-color: var(--danger); }
textarea.input { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: #d1d5db; position: relative; cursor: pointer; transition: background .15s; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 19px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { width: 340px; max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 20px; padding: 3px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfc; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 9px 10px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f8faff; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
table.data tr.sub td { background: #fafbfc; font-size: 13px; }
table.lines td { padding: 6px 6px; }
table.lines td .input.sm { min-width: 0; }
.empty { padding: 34px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.more { display: flex; justify-content: center; padding: 12px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #f3f4f6; color: #374151; }
.st-new { background: #f3f4f6; color: #374151; }
.st-booked { background: #e0f2fe; color: #0369a1; }
.st-waiting { background: #fef3c7; color: #92400e; }
.st-in_progress { background: #ede9fe; color: #5b21b6; }
.st-done { background: #dcfce7; color: #166534; }
.st-issued { background: #e5e7eb; color: #111827; }
.st-cancelled { background: #fee2e2; color: #991b1b; }
.pay-paid { background: var(--ok-soft); color: var(--ok); }
.pay-partial { background: var(--warn-soft); color: var(--warn); }
.pay-unpaid { background: var(--danger-soft); color: var(--danger); }
.ps-draft { background: #f3f4f6; color: #374151; } .ps-ordered { background: #fef3c7; color: #92400e; }
.ps-received { background: #e0f2fe; color: #0369a1; } .ps-installed { background: #dcfce7; color: #166534; } .ps-client { background: #fae8ff; color: #86198f; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 5px; background: #f3f4f6; color: #4b5563; font-weight: 600; }
.tag.upsell { background: #dcfce7; color: #166534; } .tag.custom { background: #fef3c7; color: #92400e; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg); width: 560px; max-width: 100%; animation: pop .14s; }
.modal.wide { width: 820px; } .modal.narrow { width: 420px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 700; flex: 1; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; top: calc(100% + 4px); right: 0; min-width: 210px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16,24,40,.16); padding: 6px; z-index: 60; }
.menu.left { left: 0; right: auto; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 7px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.menu button:hover, .menu a:hover { background: #f3f4f6; text-decoration: none; }
.menu button.danger { color: var(--danger); }
.menu .menu-title { font-size: 11px; color: var(--muted); text-transform: uppercase; padding: 8px 10px 4px; letter-spacing: .04em; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Combobox ---------- */
.combo { position: relative; }
.combo-list { position: absolute; top: calc(100% + 3px); left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16,24,40,.16); max-height: 300px; overflow-y: auto; z-index: 70; padding: 4px; min-width: 260px; }
.combo-item { padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.combo-item:hover, .combo-item.hl { background: var(--primary-soft); }
.combo-item .sub { font-size: 12px; color: var(--muted); }
.combo-item.create { color: var(--primary); font-weight: 500; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 13px; }
.combo-group { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 8px 10px 3px; letter-spacing: .03em; }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .15s; }
.toast.error { background: var(--danger); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Calendar ---------- */
.cal-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-scroll { overflow: auto; max-height: calc(100vh - 215px); position: relative; }
.cal-grid { display: grid; position: relative; min-width: 100%; }
.cal-head { position: sticky; top: 0; z-index: 6; background: #fafbfc; }
.cal-cell-h { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 6px 4px; text-align: center; font-size: 12px; font-weight: 600; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fafbfc; }
.cal-cell-h.day { font-size: 13px; }
.cal-cell-h.today { color: var(--primary); }
.cal-cell-h.weekend { color: var(--danger); }
.cal-time { position: sticky; left: 0; z-index: 5; background: #fff; border-right: 1px solid var(--line); font-size: 11px; color: var(--muted); text-align: right; padding: 0 6px; transform: translateY(-7px); }
.cal-time.corner { z-index: 7; background: #fafbfc; transform: none; }
.cal-slot { border-left: 1px solid var(--line); border-bottom: 1px solid #f1f2f4; cursor: pointer; }
.cal-slot.hour { border-bottom-color: #e5e7eb; }
.cal-slot:hover { background: #f5f8ff; }
.cal-slot.off { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f3f4f6 6px, #f3f4f6 12px); }
.cal-slot.drop { background: #dbeafe; }
.cal-slot.daystart { border-left: 2px solid #cbd5e1; }
.cal-event { position: absolute; border-radius: 7px; padding: 3px 6px; font-size: 11.5px; line-height: 1.3; overflow: hidden; cursor: pointer; border-left: 4px solid; box-shadow: 0 1px 2px rgba(0,0,0,.08); z-index: 3; user-select: none; }
.cal-event:hover { z-index: 4; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.cal-event.dragging { opacity: .5; }
.cal-event b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event .ln { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-new { background: #f3f4f6; border-color: #9ca3af; }
.ev-booked { background: #e0f2fe; border-color: #0284c7; }
.ev-waiting { background: #fef3c7; border-color: #d97706; }
.ev-in_progress { background: #ede9fe; border-color: #7c3aed; }
.ev-done { background: #dcfce7; border-color: #16a34a; }
.ev-issued { background: #e5e7eb; border-color: #4b5563; }
.ev-cancelled { background: #fee2e2; border-color: #dc2626; opacity: .7; }
.ev-noshow { opacity: .55; }
.now-line { position: absolute; height: 2px; background: var(--danger); z-index: 4; pointer-events: none; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-dow { padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: #fafbfc; }
.month-day { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px; cursor: pointer; }
.month-day:hover { background: #f8faff; }
.month-day.other { background: #fafafa; color: #9ca3af; }
.month-day .dn { font-weight: 600; font-size: 13px; margin-bottom: 3px; display: flex; justify-content: space-between; }
.month-day.today .dn span:first-child { background: var(--primary); color: #fff; border-radius: 12px; padding: 0 7px; }
.month-ev { font-size: 11px; padding: 2px 5px; border-radius: 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; border-left: 3px solid; }

/* ---------- Order card ---------- */
.order-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.order-head h1 { font-size: 22px; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.order-top { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 6px 10px; align-items: center; }
.kv > * { min-width: 0; }
.kv .row.nowrap > .input, .kv .row.nowrap > select { min-width: 0; flex: 1; }
.kv > .k { color: var(--muted); font-size: 13px; }
.fin-row { display: flex; justify-content: space-between; padding: 5px 0; }
.fin-row.total { font-size: 17px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.editable-text { border: 1px dashed transparent; border-radius: 8px; padding: 8px 10px; cursor: text; white-space: pre-wrap; min-height: 40px; }
.editable-text:hover { border-color: var(--line2); background: #fafbfc; }
.editable-text.empty-t { color: var(--muted); }
.lock-note { background: var(--warn-soft); color: #92400e; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.info-note { background: var(--primary-soft); color: #1e3a8a; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.cell-edit { border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; width: 100%; background: transparent; text-align: inherit; min-height: 28px; }
.cell-edit:hover { border-color: var(--line2); background: #fff; }
.cell-edit:focus { border-color: var(--primary); background: #fff; outline: none; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.cell-edit.num { text-align: right; }
.add-line { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.add-line .combo { flex: 1; min-width: 260px; }
.timeline { font-size: 12.5px; max-height: 260px; overflow-y: auto; }
.timeline div { padding: 5px 0; border-bottom: 1px solid #f3f4f6; }
.timeline .t { color: var(--muted); font-size: 11.5px; }

/* ---------- Misc ---------- */
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid #f3f4f6; display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain li > svg { width: 20px; height: 20px; flex: none; color: var(--muted); }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 10px 0 0; }
.bar-chart { justify-content: center; }
.bar-chart .bar { flex: 1; max-width: 46px; background: #93c5fd; border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover { background: var(--primary); }
.bar-labels { display: flex; gap: 4px; font-size: 10px; color: var(--muted); justify-content: center; }
.bar-labels span { flex: 1; max-width: 46px; text-align: center; overflow: hidden; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.spinner { width: 22px; height: 22px; border: 3px solid #e5e7eb; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.logo-preview { width: 120px; height: 60px; border: 1px dashed var(--line2); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #fafbfc; }
.logo-preview img { max-width: 100%; max-height: 100%; }
.weekday-picks { display: flex; gap: 6px; }
.weekday-picks label { width: 36px; height: 32px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line2); border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.weekday-picks input { display: none; }
.weekday-picks input:checked + span { color: #fff; }
.weekday-picks label:has(input:checked) { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .order-top { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .topbar .burger { display: inline-flex; }
  .content { padding: 14px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .toolbar .search { width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv > .k { margin-top: 8px; }
  .kv .row.nowrap { flex-wrap: wrap; }
  .order-head h1 { font-size: 19px; }
  .card { padding: 14px; }
}

/* ================= Мобильная версия ================= */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .input, select.input, textarea.input, .cell-edit { font-size: 16px; }
  .topbar { padding: 0 12px; height: 52px; }
  .usermenu .dropdown > button > div:last-child { display: none; }
  .crumbs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--card); border-top: 1px solid var(--line);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 10px rgba(16,24,40,.06); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none;
    color: var(--muted); font-size: 11px; font-weight: 500; border-radius: 10px; cursor: pointer; text-decoration: none; min-width: 0; }
  .bottom-nav a span, .bottom-nav button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--primary); }
  .sidebar { z-index: 60; }
  .sidebar-back { position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 55; }
  .page-head { gap: 8px; margin-bottom: 12px; }
  .page-head h1 { font-size: 20px; width: 100%; }
  .page-head .spacer { display: none; }
  .page-head .btn, .toolbar .btn { padding: 7px 11px; }
  .toolbar { gap: 8px; }
  .toolbar > select.input, .toolbar > input.input, .toolbar > .input { flex: 1 1 150px; width: auto !important; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 11px 12px; }
  .stat .value { font-size: 17px; white-space: normal; }
  .tabs button { padding: 10px 10px; }

  /* Таблицы превращаются в карточки */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tfoot, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td { border: 0; padding: 4px 0; display: flow-root; text-align: right; min-height: 24px; }
  table.data td::before { content: attr(data-label); float: left; color: var(--muted); font-size: 12px; text-align: left; max-width: 40%; font-weight: 500; padding: 2px 10px 0 0; }
  table.data td[data-label=""]::before, table.data td:not([data-label])::before { display: none; }
  table.data td[data-empty] { display: none; }
  table.data td > .row { justify-content: flex-end; }
  table.data td .cell-edit, table.data td select.input { display: inline-block; width: 58%; }
  table.data td.num { text-align: right; }
  table.data td:first-child { font-size: 15px; }
  table.data tr.clickable:hover td { background: transparent; }
  table.data tr.clickable:active { background: #f3f6ff; }
  table.data tr.sub { background: #fafbfc; }
  table.data tr.sub td { background: transparent; }
  table.data tfoot tr { background: #fafbfc; }
  .table-wrap { overflow: visible; }
  table.lines td { padding: 2px 0; }
  table.lines td:first-child .cell-edit { width: 100%; font-weight: 600; text-align: left; }
  table.lines td:first-child .row { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  table.lines td:first-child::before { display: none; }
  .card[style*="padding: 0"] > .table-wrap, .card[style*="padding:0"] > .table-wrap { padding: 0; }

  /* Окна на весь экран */
  .modal-back { padding: 0; align-items: stretch; }
  .modal, .modal.wide, .modal.narrow { width: 100%; min-height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-body { flex: 1; padding: 16px; }
  .modal-head { position: sticky; top: 0; background: var(--card); z-index: 2; padding: 12px 16px; }
  .modal-foot { position: sticky; bottom: 0; background: var(--card); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1; }
  .modal-foot .left { width: 100%; margin: 0; }
  .modal-foot .left .btn, .modal-foot .left .dropdown { flex: 1; }
  .combo-list { min-width: 0; }
  .menu { min-width: 230px; }
  .toasts { left: 12px; right: 12px; top: calc(8px + env(safe-area-inset-top)); bottom: auto; z-index: 300; }
  .toast { max-width: none; }

  /* Карточка заказа */
  .order-head { gap: 8px; }
  .order-head .spacer { display: none; }
  .order-actions .btn { flex: 1 1 auto; }
  .add-line .combo { min-width: 0; flex: 1 1 100%; }
  .part-add > input { flex: 1 1 42% !important; width: auto !important; min-width: 0 !important; }
  .part-add > input:nth-child(2) { flex: 1 1 100% !important; }
  .card-head .btn { padding: 6px 10px; }

  /* Календарь */
  .cal-scroll { max-height: calc(100vh - 290px); max-height: calc(100dvh - 290px); }
  .legend { display: none; }
  .month-day { min-height: 64px; padding: 3px; }
  .month-ev { font-size: 10px; padding: 1px 3px; }
  .month-day .dn { font-size: 12px; }
}
