@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0b0d12;
  --bg-2: #0f1219;
  --panel: rgba(22, 26, 35, .85);
  --panel-solid: #161a23;
  --panel-2: #1c2130;
  --panel-hover: #212738;
  --fg: #e8ecf4;
  --fg-2: #c7cdd9;
  --muted: #6b7690;
  --line: rgba(255, 255, 255, .06);
  --line-2: rgba(255, 255, 255, .1);
  --accent: #6c9fff;
  --accent-soft: rgba(108, 159, 255, .12);
  --accent-glow: rgba(108, 159, 255, .08);
  --gradient: linear-gradient(135deg, #6c9fff, #a78bfa);
  --gradient-2: linear-gradient(135deg, #6c9fff, #34d399);
  --bad: #ff6b7a;
  --bad-soft: rgba(255, 107, 122, .1);
  --good: #5ee8a0;
  --good-soft: rgba(94, 232, 160, .1);
  --warn: #ffb347;
  --warn-soft: rgba(255, 179, 71, .1);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Header ─── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.bar h1 {
  margin: 0; font-size: 16px; font-weight: 700; letter-spacing: .3px;
}
.bar h1 .logo-text {
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); font-weight: 400; }

/* ─── Layout ─── */
main { max-width: 1280px; margin: 0 auto; padding: 24px 28px; }

/* ─── Buttons ─── */
button {
  font: 500 13px/1 'Inter', system-ui, sans-serif;
  border: 0; border-radius: var(--radius-sm); padding: 8px 16px;
  cursor: pointer; transition: all .18s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
button:active { transform: scale(.97); }

.primary {
  background: var(--gradient); color: #0a0f1a; font-weight: 600;
  box-shadow: 0 2px 12px rgba(108, 159, 255, .2);
}
.primary:hover { box-shadow: 0 4px 20px rgba(108, 159, 255, .35); transform: translateY(-1px); }

.ghost {
  background: var(--panel-2); color: var(--fg-2);
  border: 1px solid var(--line-2);
}
.ghost:hover { background: var(--panel-hover); border-color: rgba(255,255,255,.15); }

.danger {
  background: var(--bad-soft); color: var(--bad);
  border: 1px solid rgba(255, 107, 122, .2);
  padding: 6px 12px; font-size: 12px;
}
.danger:hover { background: rgba(255, 107, 122, .18); }

.btn-link {
  text-decoration: none; display: inline-flex; align-items: center;
  padding: 8px 16px; border-radius: var(--radius-sm);
}

.link-btn {
  background: var(--accent-soft); color: var(--accent); border: none;
  padding: 4px 10px; font-size: 12px; font-weight: 500;
  border-radius: 8px; text-decoration: none; display: inline-block;
  transition: all .15s;
}
.link-btn:hover { background: rgba(108, 159, 255, .2); }

/* ─── Tabs ─── */
.tabs {
  display: flex; gap: 2px;
  margin-bottom: 24px;
  background: var(--panel-solid); border-radius: var(--radius);
  padding: 4px; border: 1px solid var(--line);
}
.tab {
  flex: 1; text-align: center;
  background: transparent; color: var(--muted);
  border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; font-weight: 600; font-size: 13px;
  transition: all .2s;
}
.tab:hover { color: var(--fg-2); background: var(--panel-2); }
.tab.active {
  color: #fff; background: var(--gradient);
  box-shadow: 0 2px 12px rgba(108, 159, 255, .25);
}
.tab:active { transform: none; }

/* ─── Toolbar ─── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}

/* ─── Search & filter ─── */
.search-input {
  background: var(--panel-solid); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 14px; font: inherit; width: 280px;
  transition: all .2s;
}
.search-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-input::placeholder { color: var(--muted); }

.filter-select {
  background: var(--panel-solid); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 14px; font: inherit; cursor: pointer;
  transition: all .2s;
}
.filter-select:focus { outline: 0; border-color: var(--accent); }

/* ─── Tables ─── */
table.venues {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--panel-solid); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
table.venues th, table.venues td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle; font-size: 13px;
}
table.venues th {
  font-weight: 600; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
  background: var(--panel-2);
}
table.venues tr:last-child td { border-bottom: 0; }
table.venues tr.inactive { opacity: .5; }
table.venues tr.clickable { cursor: pointer; transition: background .15s; }
table.venues tr.clickable:hover { background: var(--panel-hover); }

code {
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 8px; border-radius: 6px;
  font-size: 12px; font-family: 'JetBrains Mono', ui-monospace, monospace; font-weight: 500;
}

/* ─── Badges ─── */
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 100px; white-space: nowrap;
  letter-spacing: .3px; text-transform: uppercase;
}
.badge.on { color: var(--good); background: var(--good-soft); }
.badge.off { color: var(--muted); background: rgba(107, 118, 144, .1); }
.badge.warn { color: var(--warn); background: var(--warn-soft); }
.badge.bad { color: var(--bad); background: var(--bad-soft); }

/* ─── Dialogs ─── */
dialog {
  background: var(--panel-solid); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: 18px;
  padding: 28px 32px; min-width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
  max-width: 580px; width: min(92vw, 580px);
  max-height: 85vh; overflow-y: auto;
}
dialog::backdrop { background: rgba(6, 8, 14, .75); backdrop-filter: blur(8px); }
dialog h2 { margin: 0 0 20px; font-size: 20px; font-weight: 700; }
dialog label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); font-weight: 500; }
dialog input[type="text"], dialog input[type="password"] {
  display: block; width: 100%; margin-top: 8px;
  padding: 10px 14px; background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; transition: all .2s;
}
dialog input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.row { display: flex; gap: 10px; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.err { color: var(--bad); margin: 10px 0 0; font-size: 13px; }

#guests-dlg, #guest-profile-dlg, #dupes-dlg { max-width: 940px; width: min(95vw, 940px); }
#delete-dlg { max-width: 480px; }

/* ─── Features ─── */
.section-title {
  font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px; margin: 20px 0 10px;
}
.feature-group { margin-bottom: 16px; }
.feature-group h4 {
  font-size: 12px; font-weight: 600; color: var(--muted);
  margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: .5px;
}
.feature-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm);
  margin: 2px 0; transition: background .12s;
}
.feature-row:hover { background: var(--panel-2); }
.feature-label { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.feature-icon { font-size: 16px; }

/* ─── Feature tiles (плиточный UI) ─── */
.features-groups { display: flex; flex-direction: column; gap: 18px; }
.feature-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.feature-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 14px 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
  user-select: none;
}
.feature-tile:hover { border-color: var(--line-2); }
.feature-tile:active { transform: scale(0.98); }
.feature-tile input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.feature-tile-icon { font-size: 28px; line-height: 1; margin-bottom: 6px; }
.feature-tile-label { font-size: 13px; font-weight: 600; color: var(--fg); line-height: 1.25; margin-bottom: 4px; }
.feature-tile-state {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
}
.feature-tile.on {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.feature-tile.on .feature-tile-state { color: var(--accent); }
.feature-tile.on::after {
  content: '✓'; position: absolute; top: 6px; right: 8px;
  font-size: 14px; font-weight: 700; color: var(--accent);
}

/* ─── Presets row ─── */
.presets-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-2);
}
.presets-label {
  font-size: 12px; color: var(--muted); font-weight: 600;
  margin-right: 4px;
}
.preset-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .08s;
}
.preset-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.preset-btn:active { transform: scale(0.97); }
.preset-icon { font-size: 16px; line-height: 1; }

/* ─── Toggle ─── */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 100px; transition: .2s;
}
.toggle .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .2s;
}
.toggle input:checked + .slider { background: var(--accent-soft); border-color: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }

/* ─── Sub titles ─── */
.sub-title {
  font-size: 14px; font-weight: 700; margin: 28px 0 12px;
  color: var(--fg); display: flex; align-items: center; gap: 8px;
}

/* ─── Cards ─── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 24px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 14px; font-size: 11px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .8px;
}
.card-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--line);
}
.card-row:last-child { border-bottom: 0; }
.card-row .label { color: var(--muted); }

/* ─── Log box ─── */
.log-box {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  font: 12px/1.7 'JetBrains Mono', ui-monospace, monospace;
  color: var(--muted); max-height: 300px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

/* ─── Money ─── */
.money { font-weight: 600; font-variant-numeric: tabular-nums; }
.money.good { color: var(--good); }

/* ─── Guests ─── */
.guests-venue {
  display: inline-block; background: var(--accent-soft);
  padding: 2px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: var(--accent);
  letter-spacing: .3px;
}
.no-data { text-align: center; padding: 48px; color: var(--muted); font-size: 14px; }

/* ─── Duplicates ─── */
.dupe-group {
  background: var(--panel-2); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 10px;
  border: 1px solid var(--line);
}
.dupe-group .dupe-phone { font-weight: 700; margin-bottom: 6px; color: var(--accent); font-size: 14px; }
.dupe-group .dupe-entry { font-size: 13px; color: var(--muted); padding: 3px 0; }

/* ─── Guest profile ─── */
.profile-grid {
  display: grid; grid-template-columns: 120px 1fr; gap: 6px 20px; margin-bottom: 18px;
}
.profile-grid .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.profile-grid .value { font-size: 14px; }

.stat-cards { display: flex; gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 20px;
  text-align: center; flex: 1;
}
.stat-card .stat-val {
  font-size: 28px; font-weight: 800;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-card .stat-label { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

/* ─── Login screen ─── */
.login-dlg { max-width: 400px; width: min(92vw, 400px); padding: 36px 34px 30px; }
.login-head { text-align: center; margin-bottom: 24px; }
.login-mark {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; border-radius: 16px;
  background: var(--accent-soft); border: 1px solid var(--line-2);
}
.login-logo {
  font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.login-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
.login-field { margin-bottom: 18px; }
.login-submit { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ─── Numeric alignment in tables ─── */
table.venues td { font-variant-numeric: tabular-nums; }

/* ─── Keyboard focus (a11y) ─── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible, .tab:focus-visible, .btn-link:focus-visible, .link-btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button:disabled { opacity: .5; cursor: not-allowed; }
button:disabled:active { transform: none; }

/* ─── Respect reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
main > section:not([hidden]) { animation: fadeIn .25s ease; }
dialog[open] { animation: fadeIn .2s ease; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  main { padding: 16px; }
  .bar { padding: 12px 16px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tab { font-size: 12px; padding: 8px 12px; flex: none; }
  .toolbar { gap: 8px; }
  .search-input { width: 100%; }
  .cards-grid { grid-template-columns: 1fr; }
  .stat-cards { flex-direction: column; }
  dialog { padding: 20px; min-width: auto; width: 95vw; border-radius: 14px; }
  table.venues th, table.venues td { padding: 8px 10px; font-size: 12px; }
}
