:root {
  color-scheme: dark;
  --bg: #1c1c1e;
  --sidebar-bg: #18181a;
  --panel-bg: #202022;
  --raised: #212123;
  --badge-bg: #272729;
  --line: #2a2a2c;
  --line-soft: #252527;
  --text: #f4f4f5;
  --muted: #8e8e96;
  --nav-text: #b4b4bb;
  --accent: #6756fa;
  --accent-strong: #5849ea;
  --accent-soft: #2d2850;
  --light: #edeef2;
  --light-text: #18181a;
  --sidebar-width: 250px;
  --topbar-height: 43px;
  --frame-bg: #38383c;
  --frame-gap: clamp(12px, 3.4vw, 56px);
  --frame-radius: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--frame-bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { background: none; border: 0; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { display: block; flex: none; }
[data-icon] { display: inline-flex; }

/* ---------- окно сайта: скруглённая карточка на сером фоне ---------- */
.app {
  position: fixed;
  inset: var(--frame-gap);
  max-width: 1480px;
  max-height: 980px;
  margin: auto;
  display: flex;
  overflow: hidden;
  background: var(--bg);
  border-radius: var(--frame-radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* ---------- sidebar ---------- */
.sidebar {
  position: relative;
  z-index: 30;
  flex: none;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 0 18px 16px;
  background: var(--sidebar-bg);
  border-right: 1px solid #202022;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 51px;
  flex: none;
  border-bottom: 1px solid var(--line-soft);
}
.brand-link { display: flex; align-items: center; gap: 4px; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid #3a3a3e;
  border-radius: 6px;
  color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: #55555b; }

.search-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  flex: none;
  margin-top: 13px;
  padding: 0 7px 0 11px;
  background: #1e1e20;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.search-label { flex: 1; text-align: left; }
kbd {
  min-width: 17px;
  padding: 1px 4px;
  border: 1px solid #333337;
  border-radius: 4px;
  background: var(--raised);
  font: 500 9.5px/13px Inter, system-ui, sans-serif;
  color: #a1a1a8;
  text-align: center;
}

.nav-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 10px -6px 8px 0; padding: 3px 6px 3px 0; scrollbar-width: thin; scrollbar-color: #3a3a3e transparent; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 33px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--nav-text);
  font-weight: 500;
}
.nav-icon { width: 20px; height: 20px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 6px; }
.nav-item:hover { color: var(--text); background: var(--raised); }
.nav-item.is-active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(90deg, rgba(88, 73, 234, 0.04) 0%, rgba(88, 73, 234, 0.45) 45%, var(--accent-strong) 100%);
  box-shadow: 0 0 14px rgba(103, 86, 250, 0.28);
}
.nav-item.is-active::after { content: ""; position: absolute; top: -1px; right: -1px; bottom: -1px; width: 3px; border-radius: 2px; background: #7a6bff; }
.nav-item.is-active .nav-icon { border-color: rgba(255, 255, 255, 0.35); }
.nav-divider { height: 1px; margin: 10px 0 12px; background: var(--line-soft); }
.nav-caption { margin: 0 0 7px; font-size: 11px; font-weight: 500; text-transform: uppercase; color: #6f6f77; }

.side-bottom { display: flex; flex-direction: column; gap: 10px; flex: none; }
.side-card { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.order-card { padding: 11px; }
.order-card-title { display: flex; align-items: center; gap: 7px; margin: 0 2px 10px; font-size: 13.5px; font-weight: 600; }
.order-card-title em { font-style: normal; color: var(--muted); }
.guest-card { position: relative; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 11px; }
.avatar { flex: none; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; background: #e4e4e7; color: #3f3f46; }
.guest-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.guest-arrows { flex: none; color: var(--muted); }

/* ---------- main ---------- */
.main {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 12px);
  scrollbar-width: thin;
  scrollbar-color: #3a3a3e transparent;
}
.topbar-brand { display: none; align-items: center; gap: 4px; margin-right: auto; font-size: 17px; font-weight: 700; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: var(--topbar-height);
  padding: 0 40px;
  background: rgba(29, 29, 29, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.menu-btn { display: none; margin-right: auto; width: 30px; height: 30px; }
.lang { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }
.lang button { min-width: 30px; height: 24px; border-radius: 6px; font-size: 10.5px; font-weight: 600; color: var(--muted); }
.lang button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.backdrop { position: absolute; inset: 0; z-index: 25; background: rgba(0, 0, 0, 0.6); }

/* ---------- свёрнутое меню ---------- */
@media (min-width: 861px) {
  body.is-collapsed { --sidebar-width: 68px; }
  body.is-collapsed .sidebar { padding-inline: 12px; }
  body.is-collapsed :is(.brand-link, .search-trigger kbd, .nav-caption, .order-card, .guest-arrows) { display: none; }
  /* подписи скрыты только визуально: экранные дикторы их читают */
  body.is-collapsed :is(.search-label, .nav-text, .guest-text) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  body.is-collapsed :is(.search-trigger, .nav-item, .guest-card) { gap: 0; }
  body.is-collapsed .brand { justify-content: center; }
  body.is-collapsed .search-trigger { justify-content: center; padding: 0; }
  body.is-collapsed .nav-item { justify-content: center; padding: 0; }
  body.is-collapsed .guest-card { justify-content: center; padding: 0; }
}

/* телефон: окно на весь экран, меню выезжает слева */
@media (max-width: 860px) {
  :root { --frame-gap: 0px; --frame-radius: 0px; --topbar-height: 54px; }
  .app { max-height: none; box-shadow: none; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: min(290px, 86vw);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-100%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
  }
  body.is-menu-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s ease; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5); }
  #collapse-btn { display: none; }
  .topbar { justify-content: flex-start; gap: 12px; padding: 0 14px; padding-top: env(safe-area-inset-top); }
  .menu-btn { display: inline-flex; margin-right: 0; width: 36px; height: 36px; border-radius: 10px; }
  .topbar-brand { display: inline-flex; }
  .lang button { min-width: 34px; height: 28px; font-size: 11px; }
  .nav-item { min-height: 40px; font-size: 14px; }
  .search-trigger { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  .main { scroll-behavior: auto; }
  * { transition: none !important; }
}
