/* Админка Wavely: те же цвета, шрифты и скелетон, что и в веб-приложении. Без inline-стилей (CSP). */
:root {
  --bg: #0d1218;
  --side-bg: #0f151c;
  --card: #151c25;
  --card-2: #1b2430;
  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.1);
  --text: #e6edf5;
  --muted: #8796a8;
  --accent: #6cb4ec;
  --on-accent: #0a1622;
  --ok: #5fd39a;
  --warn: #e9a23b;
  --danger: #ef6b6b;
  --sk: #212c3a;
  --sk-glint: rgba(255, 255, 255, 0.1);
  --r: 14px;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-num: "Unbounded", "Inter", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); }
body { color: var(--text); font: 400 15px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }

/* каркас: на телефоне — липкая шапка с чипами, на десктопе — боковое меню */
.shell { display: block; min-height: 100vh; }
.side { display: none; }
.main { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 5; padding: calc(12px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(13, 18, 24, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { font: 500 20px/1.2 var(--font-num); letter-spacing: -0.02em; }
.top-tools { display: flex; align-items: center; gap: 4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-link { flex: none; display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-weight: 500; font-size: 14px; }
.chip-link.is-active { background: rgba(108, 180, 236, 0.12); border-color: rgba(108, 180, 236, 0.35); color: var(--accent); }
.badge { min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.timer { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.timer.is-low { color: var(--warn); }
.view { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(64px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 250px 1fr; }
  .side { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; padding: 24px 14px; background: var(--side-bg); border-right: 1px solid var(--line); }
  .brand { font: 500 17px var(--font-num); padding: 0 10px; }
  .brand span { color: var(--muted); font: 400 13px var(--font-ui); margin-left: 4px; }
  .nav { display: flex; flex-direction: column; gap: 4px; }
  .nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); font-weight: 500; }
  .nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
  .nav a.is-active { background: rgba(108, 180, 236, 0.1); color: var(--accent); }
  .nav .badge { margin-left: auto; }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
  .chips, #timer-top, #logout-top { display: none; }
  .top { position: static; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border: 0; padding: 28px 32px 0; }
  .top h1 { font-size: 24px; }
  .view { padding: 18px 32px 64px; margin: 0; }
}

/* карточки, строки, статусы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px 16px; }
.card > h2 { font: 500 15px/1.3 var(--font-ui); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card > h2 .ic { color: var(--accent); }
.card-flat { padding: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.split { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 4px; }
button.stat:hover { border-color: var(--line-2); }
.stat .value { font: 500 22px/1.2 var(--font-num); letter-spacing: -0.01em; }
.stat.is-alert .value { color: var(--warn); }
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px; text-align: left; width: 100%; }
.li + .li { border-top: 1px solid var(--line); }
button.li:hover { background: rgba(255, 255, 255, 0.025); }
.li .select { width: auto; min-width: 0; max-width: 170px; min-height: 36px; padding-left: 10px; }
@media (max-width: 600px) {
  .li-wrap { flex-wrap: wrap; }
  .li-wrap > .grow { flex-basis: 100%; }
  .li-wrap .select { flex: 1; max-width: none; }
  .sortable .li-wrap > .grow { flex-basis: calc(100% - 96px); min-width: 0; }
}
.avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--card-2); color: var(--accent); font: 500 13px var(--font-num); text-transform: uppercase; }
.title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { text-align: right; overflow-wrap: anywhere; }
.kv dd.row-wrap { justify-content: flex-end; gap: 4px; }
.pill { display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; font-weight: 500; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: rgba(95, 211, 154, 0.12); color: var(--ok); }
.pill.warn { background: rgba(233, 162, 59, 0.12); color: var(--warn); }
.pill.danger { background: rgba(239, 107, 107, 0.12); color: var(--danger); }
.pill.accent { background: rgba(108, 180, 236, 0.12); color: var(--accent); }
.amount-plus { color: var(--ok); }
.amount-minus { color: var(--danger); }
.empty { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.note { padding: 10px 12px; border-radius: 10px; background: rgba(233, 162, 59, 0.1); color: var(--warn); font-size: 13px; }
.note.info { background: rgba(108, 180, 236, 0.08); color: var(--accent); }
.result { padding: 12px 14px; border-radius: 12px; background: var(--card-2); font-size: 14px; display: grid; gap: 4px; }
.result.ok { border-left: 3px solid var(--ok); }
.result.err { border-left: 3px solid var(--danger); }

/* кнопки и поля */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; font-weight: 500; font-size: 14px; transition: opacity .18s, transform .1s, background-color .18s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-secondary { background: var(--card-2); color: var(--accent); }
.btn-danger { background: rgba(239, 107, 107, 0.12); color: var(--danger); }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--on-accent); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-secondary.busy::after, .btn-danger.busy::after, .btn-ghost.busy::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); flex: none; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { color: var(--muted); font-size: 13px; }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 12px; background: var(--card-2); border: 1px solid transparent; outline: none; }
.textarea { padding: 10px 12px; min-height: 120px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); }
.input::placeholder, .textarea::placeholder { color: rgba(135, 150, 168, .6); }
.select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.hint { color: var(--muted); font-size: 12px; }
.inline-form { display: flex; gap: 8px; align-items: stretch; }
.inline-form .input { flex: 1; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 13px; background: var(--bg); }
.seg button { min-height: 36px; padding: 0 14px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 13px; }
.seg button.is-on { background: var(--card-2); color: var(--text); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: var(--card-2); transition: background-color .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: transform .2s, background-color .2s; }
.switch input:checked + i { background: rgba(108, 180, 236, 0.25); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.progress { height: 6px; border-radius: 3px; background: var(--card-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .3s ease-out; }
.thumb { max-width: 160px; max-height: 160px; border-radius: 12px; display: block; }

/* уведомления, окна */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 420px; padding: 11px 16px; border-radius: 12px; background: #202b38; border: 1px solid var(--line-2); font-size: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .45); animation: toast-in .25s cubic-bezier(.32, .72, 0, 1); }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.out { opacity: 0; transition: opacity .35s; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
dialog { color: var(--text); border: 0; background: var(--card); padding: 0; }
dialog::backdrop { background: rgba(4, 7, 11, .7); }
body:has(dialog[open]) { overflow: hidden; }
.modal { margin: auto; width: calc(100% - 32px); max-width: 440px; border-radius: 18px; }
.modal[open] { animation: pop-in .22s cubic-bezier(.32, .72, 0, 1); }
@keyframes pop-in { from { transform: scale(.96); opacity: 0; } }
.modal-body { padding: 20px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-body h3 { font: 500 17px/1.3 var(--font-ui); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.sheet { margin: auto auto 0; width: 100%; max-width: 640px; max-height: 94vh; border-radius: 22px 22px 0 0; }
.sheet[open] { animation: sheet-in .4s cubic-bezier(.32, .72, 0, 1); }
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 14px 12px 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.sheet-body { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet .card { background: var(--card-2); border-color: transparent; }
.sheet .card .input, .sheet .card .select, .sheet .card .textarea, .sheet .card .btn-secondary { background: var(--card); }
@media (min-width: 900px) {
  .sheet { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: 600px; max-width: 600px; border-radius: 22px 0 0 22px; }
  .sheet[open] { animation: drawer-in .35s cubic-bezier(.32, .72, 0, 1); }
  @keyframes drawer-in { from { transform: translateX(100%); } }
}
.ended { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; background: rgba(13, 18, 24, .96); }
.ended-card { max-width: 360px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ended-card .ic { width: 40px; height: 40px; color: var(--accent); }
.ended-card h2 { font: 500 20px var(--font-num); }

/* загрузка: серые формы с бликом */
.sk { border-radius: 10px; background: linear-gradient(100deg, transparent 40%, var(--sk-glint) 50%, transparent 60%) 100% 0 / 200% 100% no-repeat, var(--sk); animation: glint 1.5s linear infinite; }
@keyframes glint { to { background-position: -100% 0; } }
.sk-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; }
.sk-line { height: 14px; width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-line.w80 { width: 80%; }
.sk-block { height: 44px; border-radius: 12px; }
.sk-stat { height: 76px; border-radius: var(--r); }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* перетаскиваемый список инбаундов */
.sortable .li { position: relative; transition: transform .16s ease, opacity .2s; background: var(--card); }
.sortable .li.is-off .title, .sortable .li.is-off .pos { opacity: .55; }
.grip { flex: none; width: 36px; height: 40px; margin: -4px 0 -4px -8px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.grip:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.grip .ic { width: 20px; height: 20px; }
.pos { flex: none; min-width: 22px; text-align: center; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sortable .li.dragging { z-index: 5; transition: none; cursor: grabbing; background: var(--card-2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); outline: 1px solid rgba(108, 180, 236, 0.45); }
.sortable .li.dragging .grip { cursor: grabbing; color: var(--accent); }
body.is-dragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.hint { font-size: 13px; line-height: 1.4; }

/* страница входа (login.html) */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.login-brand { font: 500 15px var(--font-num); text-align: center; }
.login-brand span { color: var(--muted); font: 400 13px var(--font-ui); margin-left: 4px; }
.login-step { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.login-step h1 { font: 500 19px var(--font-num); line-height: 1.3; }
.login-step .btn { width: 100%; min-height: 50px; font-size: 15px; }
.login-ic { width: 44px; height: 44px; color: var(--accent); }
.login-ic.is-bad { color: var(--danger); }
.login-err { color: var(--danger); font-size: 13px; }
.login-left { font-size: 12px; font-variant-numeric: tabular-nums; }
.btn-tg { background: #2aabee; color: #fff; }
.btn-tg .ic { width: 20px; height: 20px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
