/* Панель Melea. Цвета заданы владельцем продукта: сливочный фон, белые плашки, пыльная роза для действий,
   капучино для второго ряда графиков. Подписи на розовом — тёмно-кофейные: белый на #E8A798 не читается.
   Шрифт панели — Commissioner (выбор владельца продукта). Заголовки и название компании — те же буквы,
   но с осями «вспышка» (FLAR) и «объём» (VOLM): штрихи расширяются к концам, как резьба. Файлы разделены
   по письменностям, браузер грузит только нужные. Планшет и пульт остаются на Ysabeau. */
@font-face { font-family: 'Commissioner'; font-weight: 100 900; font-display: swap; src: url(/panel-fonts/commissioner-cyrillic.woff2) format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Commissioner'; font-weight: 100 900; font-display: swap; src: url(/panel-fonts/commissioner-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #FDF8F5;
  --card: #FFFFFF;
  --ink: #4A3F3A;
  --muted: #766861;
  --line: #EFE4DE;
  --line-strong: #DCCBC3;
  --accent: #E8A798;          /* действие, выбор, первая серия графика */
  --accent-hover: #EEB8AB;
  --accent-soft: #F8E4DE;     /* фон выбранного, фокус, перетаскивание */
  --on-accent: #201816;       /* подпись на акценте */
  --strong: #201816;          /* самый контрастный текст: выбранная вкладка, коды, значки */
  --shell: #FFFFFF;           /* шапка */
  --on-shell: #4A3F3A;
  --on-shell-muted: #766861;
  --shell-line: #EFE4DE;
  --shell-accent: #E8A798;    /* черта под выбранной вкладкой */
  --dark: #201816;            /* полоса сохранения и всплывающие сообщения */
  --on-dark: #F6ECE8;
  --series-2: #BC8B60;
  --switch-off: #F1E9E5;
  --dot-idle: #CDBFB8;
  --frame: #2E2523;           /* рамка планшета в предпросмотре */
  --ok-ink: #2F5A3D;
  --stone: #8C7A72;
  --ok: #4F7D5E;
  --ok-soft: #E8F1EA;
  --danger: #9A3B28;
  --danger-soft: #FBE9E5;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(74, 63, 58, .05), 0 6px 18px rgba(74, 63, 58, .06);
  --drawer: 440px;
  --display: 'Commissioner', system-ui, sans-serif;
  --text: 'Commissioner', system-ui, sans-serif;
  --sculpt: 'FLAR' 100, 'VOLM' 100;      /* резьба заголовков */
  --sculpt-soft: 'FLAR' 70, 'VOLM' 50;  /* она же мягче — для заголовков карточек */
  color-scheme: light;
  scrollbar-color: var(--line-strong) transparent;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { min-height: 100vh; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--text); font-variant-numeric: lining-nums; font-synthesis: none; }
::selection { background: var(--accent-soft); color: var(--strong); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: 14px; text-wrap: pretty; }
.code { font-variant-numeric: tabular-nums; letter-spacing: .06em; color: var(--strong); }
.codes { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 16px; }
.code-chip { padding: 4px 12px; border-radius: 99px; background: var(--accent-soft); color: var(--strong); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* ---------- Шапка ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; height: 72px; display: flex; align-items: stretch; gap: 32px;
  padding: 0 40px; background: var(--shell); color: var(--on-shell); border-bottom: 1px solid var(--shell-line);
}
.company { align-self: center; font: 700 19px/1 var(--display); font-variation-settings: var(--sculpt); letter-spacing: .08em; text-transform: uppercase; text-decoration: none; white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: flex; align-items: center; padding: 0 14px; white-space: nowrap; text-decoration: none;
  font-weight: 500; color: var(--on-shell-muted); border-bottom: 3px solid transparent; transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--on-shell); }
.tab[aria-current] { color: var(--on-shell); border-bottom-color: var(--shell-accent); }
.tab-melea-mobile { display: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 18px; white-space: nowrap; }
.who .tab { height: 100%; }
.who-name { text-decoration: none; font-weight: 500; }
.bar .link { color: var(--on-shell); text-decoration-color: color-mix(in srgb, var(--on-shell) 40%, transparent); }
.who-name:hover, .who-name[aria-current] { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Страница ---------- */
.main { padding: 32px 40px 140px; max-width: 1240px; }
/* Выезд ящика анимируем только по нажатию: при загрузке страницы он сразу стоит на месте */
body.is-ready .main { transition: margin-right .22s ease-out; }
body.is-ready .preview { transition: transform .22s ease-out, visibility .22s; }
body.preview-open .main { margin-right: var(--drawer); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h1 { font: 700 32px/1.2 var(--display); font-variation-settings: var(--sculpt); letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 19px; font-weight: 650; line-height: 1.3; font-variation-settings: var(--sculpt-soft); }
h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.lead { color: var(--muted); margin-top: 6px; max-width: 60ch; text-wrap: pretty; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; }
.card > .hint { margin: 4px 0 14px; }
.narrow { max-width: 520px; }
.notice { background: var(--ok-soft); color: var(--ok-ink); border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 12px; padding: 10px 14px; margin: 8px 0 14px; }
.warn { color: var(--danger); }
.badge { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--strong); font-size: 12px; font-weight: 600; }
.empty { text-align: center; padding: 48px 24px; }
.empty .hint { max-width: 52ch; margin: 8px auto 0; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border-radius: 99px; font-size: 15px; font-weight: 600; white-space: nowrap; transition: background-color .15s, box-shadow .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { box-shadow: inset 0 2px 4px rgba(32, 24, 22, .12); }
.btn-outline { background: var(--card); color: var(--strong); box-shadow: inset 0 0 0 1px var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost-dark { color: var(--on-dark); }
.btn-ghost-dark:hover { background: color-mix(in srgb, var(--on-dark) 12%, transparent); }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; padding: 4px 0; }
.link:hover { text-decoration-color: currentColor; }
.link-light { color: var(--on-dark); text-decoration-color: color-mix(in srgb, var(--on-dark) 50%, transparent); }
.link-danger { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field .hint { font-weight: 400; }
input, select, textarea {
  min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card);
  font-size: 16px; font-weight: 400; color: var(--ink); caret-color: var(--strong); transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--stone); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
input[readonly] { background: var(--bg); }
textarea { width: 100%; padding: 12px 14px; font: 13px/1.5 ui-monospace, Menlo, monospace; resize: vertical; margin: 10px 0; }
.stack-form { display: grid; gap: 16px; margin-top: 12px; }
.stack-form .btn { justify-self: start; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.inline-form input { min-height: 36px; font-size: 15px; flex: 1 1 160px; }

/* Переключатель вкл/выкл */
.switch {
  appearance: none; flex: none; width: 44px; height: 26px; min-height: 0; padding: 0; border: 0; border-radius: 99px;
  background: var(--switch-off); box-shadow: inset 0 0 0 1.5px var(--stone); position: relative; cursor: pointer; transition: background-color .15s;
}
.switch::before {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 1px rgba(32, 24, 22, .28), 0 1px 2px rgba(32, 24, 22, .2); transition: transform .18s ease-out;
}
.switch:checked { background: var(--accent); box-shadow: none; }
.switch:checked::before { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; box-shadow: none; }

/* ---------- Меню планшета ---------- */
.lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; align-items: start; }
.list-card { margin: 0; }
.rows { list-style: none; }
.row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); background: var(--card); transition: opacity .15s; }
.row:first-child { border-top: 0; }
.row-text { display: flex; flex-direction: column; min-width: 0; }
.row-name { font-weight: 600; }
.row-desc { font-size: 14px; color: var(--muted); }
.row.is-off .row-text { opacity: .5; }
.row.is-dragging { opacity: .45; background: var(--accent-soft); border-radius: 10px; }
.grip { width: 28px; height: 36px; display: grid; place-items: center; color: var(--stone); cursor: grab; border-radius: 8px; }
.grip:hover { color: var(--ink); background: var(--bg); }
.grip:active { cursor: grabbing; }

/* Живой планшет: настоящая страница планшета, уменьшенная до ширины панели */
.preview {
  position: fixed; top: 72px; right: 0; bottom: 0; z-index: 10; width: var(--drawer); padding: 22px 24px; overflow-y: auto;
  background: var(--card); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(74, 63, 58, .06);
  transform: translateX(100%); visibility: hidden;
}
body.preview-open .preview { transform: none; visibility: visible; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.device { background: var(--frame); border-radius: 22px; padding: 12px; margin-bottom: 14px; }
.device-screen { position: relative; aspect-ratio: 1097 / 686; overflow: hidden; border-radius: 10px; background: #F5EFE9; }
/* 1097×686 — так страницу видит планшет; масштаб под ширину рамки ставит panel.js */
.device-screen iframe { position: absolute; top: 0; left: 0; width: 1097px; height: 686px; border: 0; transform: scale(.3355); transform-origin: 0 0; }

.savebar {
  position: fixed; left: 40px; right: 40px; bottom: 24px; z-index: 15; max-width: 1160px;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 22px; border-radius: 16px;
  background: var(--dark); color: var(--on-dark); box-shadow: 0 10px 30px rgba(32, 24, 22, .22);
  animation: rise .2s ease-out;
}
.savebar[hidden] { display: none; }
body.preview-open .savebar { right: calc(var(--drawer) + 24px); }
.savebar-text { flex: 1; }
@keyframes rise { from { transform: translateY(16px); opacity: 0; } }

/* ---------- Планшеты и пульт ---------- */
.salon { display: grid; grid-template-columns: 1fr 300px; gap: 36px; }
.salon h2 { margin-bottom: 10px; }
.salon .hint { margin-top: 10px; }
.staff { border-left: 1px solid var(--line); padding-left: 36px; }
.qr { width: 156px; height: 156px; margin: 4px 0 12px; }
.qr svg { width: 100%; height: 100%; }
.copy { display: grid; gap: 8px; justify-items: start; margin-top: 12px; }
.copy-input { width: 100%; min-height: 36px; font-size: 13px; }
.service-form, .pair-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.service-form .field, .pair-form .field { flex: 0 1 260px; }
.pair-form .field-short { flex-basis: 100px; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 0 16px 8px 0; }
.table td { padding: 12px 16px 12px 0; border-top: 1px solid var(--line); vertical-align: top; }
.table .seat { font-weight: 600; }
.table .actions { text-align: right; }
.table form { display: inline; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--dot-idle); vertical-align: 1px; }
.dot.is-on { background: var(--ok); }
.dot-warn { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- История ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.segmented { display: inline-flex; padding: 4px; gap: 2px; border-radius: 99px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong); }
.segmented a { padding: 8px 16px; border-radius: 99px; text-decoration: none; font-weight: 500; color: var(--muted); }
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current] { background: var(--accent); color: var(--on-accent); }
.field-inline select { min-height: 40px; }
.summary-text { font-size: 17px; max-width: 75ch; text-wrap: pretty; }
.summary-text b { font-weight: 600; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; margin: 22px 0 10px; padding-bottom: 22px; position: relative; }
.col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; position: relative; }
.stack { display: flex; flex-direction: column-reverse; min-height: 3px; border-radius: 6px 6px 2px 2px; overflow: hidden; }
.stack span { display: block; min-height: 3px; }
.stack-empty { height: 3px; background: var(--line); }
.col-n { margin-bottom: 4px; font-size: 12px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.col-label { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 12px; color: var(--muted); white-space: nowrap; }
.s-admin { background: var(--accent); }
.s-drink { background: var(--series-2); }
.s-color { background: var(--stone); }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 18px; font-size: 14px; color: var(--muted); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.table-card { padding-top: 14px; overflow-x: auto; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); display: grid; gap: 16px; padding: 32px; }
.login-brand { font: 700 14px/1 var(--display); font-variation-settings: var(--sculpt); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.login-card h1 { font-size: 24px; }
.login-card .hint { text-align: center; }

/* ---------- Все компании ---------- */
.company-card.is-current { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.company-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.company-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.plain { list-style: none; display: grid; gap: 6px; }
.user-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.user-row > span { flex: 1; }
.created { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.created p { font-size: 17px; margin-top: 6px; }
.created .hint { font-size: 14px; }
.raw { margin-top: 16px; }
.raw summary { cursor: pointer; font-size: 14px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 30; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: min(560px, calc(100vw - 32px)); padding: 13px 22px; border-radius: 16px; background: var(--dark); color: var(--on-dark);
  font-size: 15px; text-align: center; transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
body.preview-open .toast { left: calc((100% - var(--drawer)) / 2); }

/* ---------- Узкие экраны ---------- */
@media (max-width: 1100px) {
  body.preview-open .main { margin-right: 0; }
  body.preview-open .savebar { right: 40px; }
}
@media (max-width: 760px) {
  .bar { height: auto; flex-wrap: wrap; gap: 0 16px; padding: 12px 16px 0; }
  .company { flex: 1; }
  .tabs { order: 3; width: 100%; height: 48px; }
  .who .tab-melea { display: none; }
  .tab-melea-mobile { display: flex; }
  .tabs { padding-inline-end: 16px; }
  .main { padding: 24px 16px 140px; }
  .head { flex-direction: column; align-items: stretch; }
  .salon, .company-grid { grid-template-columns: 1fr; gap: 24px; }
  .staff { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 20px; }
  .preview { top: 0; z-index: 40; width: 100%; }
  .who-name { display: none; }
  .savebar, body.preview-open .savebar { left: 12px; right: 12px; flex-wrap: wrap; }
}
/* На широком экране планшет в предпросмотре крупнее */
@media (min-width: 1600px) {
  :root { --drawer: 560px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { transition: none !important; animation: none !important; }
}
