:root {
  --bg: #02050e;
  --panel: #0b1424;
  --panel-2: #0f1c31;
  --line: #2a4a6a;
  --gold: #d8b46a;
  --gold-2: #f0d495;
  --text: #dfe8f3;
  --muted: #8ea3bb;
  --ok: #6fcf97;
  --bad: #ff7a6b;
  --warn: #f2c94c;
  --radius: 4px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg) radial-gradient(ellipse at 50% -20%, #0d2140 0%, transparent 60%) no-repeat;
  color: var(--text);
  font: 15px/1.45 "Exo 2", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2 { font-weight: 600; letter-spacing: .04em; color: var(--gold); margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 17px; text-transform: uppercase; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 16px; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: rgba(5, 10, 22, .96); border-bottom: 1px solid var(--line);
}
.brand { color: var(--gold); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 14px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab {
  padding: 8px 12px; color: var(--text); text-decoration: none; white-space: nowrap;
  border: 1px solid transparent; clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.tab:hover { background: var(--panel-2); }
.tab.active { background: var(--panel-2); border-color: var(--line); color: var(--gold-2); box-shadow: inset 0 -2px 0 var(--gold); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); min-width: 0; }
#who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

main { max-width: 1200px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); }

/* Panels */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; position: relative;
}
.panel::before {
  content: ""; position: absolute; left: -1px; top: -1px; width: 24px; height: 2px; background: var(--gold);
}
.panel.narrow { max-width: 420px; margin: 8vh auto 16px; }
.narrow-wide { max-width: 720px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.panel-head .input { flex: 1; min-width: 160px; max-width: 320px; margin-left: auto; }
.panel-head > .btn:last-child { margin-left: auto; }
.panel-head .input + .btn { margin-left: 0; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > p { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .input { flex: 1; min-width: 160px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field.grow { flex: 1 1 200px; }
.input {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: #060d1a; border: 1px solid var(--line); border-radius: var(--radius); min-height: 42px;
}
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(216, 180, 106, .25); }
.input.small { padding: 4px 8px; min-height: 32px; width: auto; font-size: 14px; }
textarea.input { resize: vertical; min-height: 80px; }
.code-input { font-size: 28px; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding-left: calc(12px + .5em); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
.invite { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.invite .btn { min-height: 42px; }
.form-msg { min-height: 1.4em; margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.form-msg.error { color: var(--bad); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; min-height: 40px; font: inherit; font-weight: 600; letter-spacing: .03em;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-2); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(#e2c27f, #b8913f); color: #1a1205; border-color: #e9cf91; }
.btn.primary:hover:not(:disabled) { color: #000; background: linear-gradient(#f0d495, #c9a14d); }
.btn.danger { background: #5a1a16; border-color: #a33a30; color: #ffd9d4; }
.btn.danger:hover:not(:disabled) { background: #7a221c; color: #fff; border-color: var(--bad); }
.btn.danger-outline { border-color: #7a3a33; color: #ffb4aa; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions.wrap { margin: 12px 0 8px; gap: 10px; }

/* Tables: on narrow screens each row becomes a card (labels from data-label). */
.list-box { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid rgba(42, 74, 106, .45); vertical-align: middle; }
.table tbody tr:hover { background: rgba(15, 28, 49, .7); }
.table tr.is-banned td { opacity: .75; }
.email { word-break: break-all; }
.note { font-style: italic; }
.details { font-size: 12px; color: var(--muted); word-break: break-all; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); white-space: nowrap; }
.badge.active { color: var(--ok); border-color: #2e6b4a; }
.badge.invited { color: var(--warn); border-color: #6b5a2e; }
.badge.banned { color: var(--bad); border-color: #7a3a33; }
.users .actions { max-width: 420px; }

@media (max-width: 860px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 10px; background: var(--panel-2); }
  .table td { border: 0; padding: 5px 0; display: flex; gap: 10px; align-items: baseline; }
  .table td::before { content: attr(data-label); flex: 0 0 120px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
  .table td[data-label=""]::before { display: none; }
  .table td > * { min-width: 0; }
  .users .actions { max-width: none; }
}

/* Save facts */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 8px 0; }
.fact { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.facts > p { grid-column: 1 / -1; margin: 0; }

/* Error feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { padding: 10px 0; border-bottom: 1px solid rgba(42, 74, 106, .45); }
.feed-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.feed-msg { color: var(--text); word-break: break-word; cursor: default; }
details > summary.feed-msg { cursor: pointer; }
details > summary.feed-msg::marker { color: var(--gold); }
pre.trace { margin: 8px 0 0; padding: 10px; max-height: 360px; overflow: auto; background: #050a14; border: 1px solid var(--line);
  border-radius: var(--radius); font: 12px/1.45 Consolas, "SFMono-Regular", Menlo, monospace; white-space: pre-wrap; word-break: break-all; color: #b9c8da; }

/* Login */
.login { text-align: left; }
.login h1 { text-align: center; }
.login > .muted { text-align: center; margin-top: -4px; }
.crest { width: 48px; height: 48px; margin: 18px auto 22px; border: 2px solid var(--gold); transform: rotate(45deg); position: relative; }
.crest::after { content: ""; position: absolute; inset: 9px; background: var(--gold); opacity: .8; }

/* Dialog */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(1, 3, 8, .78); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.dialog { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--gold);
  border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
.dialog-body { margin-bottom: 14px; }
.dialog-body p { margin: 0 0 10px; }
.dialog .field { margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.big-code { font: 700 44px/1.1 Consolas, "SFMono-Regular", Menlo, monospace; letter-spacing: .25em; text-align: center; color: var(--gold-2);
  padding: 14px 0 14px .25em; margin: 8px 0 12px; background: #050a14; border: 1px dashed var(--gold); border-radius: var(--radius); user-select: all; }

/* Toasts */
.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { max-width: 420px; padding: 10px 14px; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: var(--radius); box-shadow: 0 6px 24px rgba(0, 0, 0, .5); transition: opacity .5s, transform .5s; pointer-events: auto; }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }

@media (max-width: 600px) {
  .topbar { gap: 8px; }
  .brand { display: none; }
  .tabs { order: 2; flex-basis: 100%; }
  .who { margin-left: auto; }
  main { padding-top: 12px; }
  .panel { padding: 12px; }
  .table td::before { flex-basis: 96px; }
  .big-code { font-size: 36px; }
}

/* ---------- Polish pass: gradients, gold accents, icons ---------- */
body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(30, 70, 120, .35) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(216, 180, 106, .06) 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.small .ico { width: 15px; height: 15px; }
.h-ico { width: 20px; height: 20px; margin-right: 8px; vertical-align: -3px; color: var(--gold); opacity: .9; }
h2 { display: flex; align-items: center; }

.topbar {
  background: linear-gradient(180deg, rgba(12, 22, 40, .97), rgba(4, 9, 20, .97));
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, var(--gold) 20%, var(--line) 50%, var(--gold) 80%, transparent) 1;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; text-shadow: 0 0 14px rgba(216, 180, 106, .35); }
.brand-mark { width: 14px; height: 14px; border: 2px solid var(--gold); transform: rotate(45deg); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 3px; background: var(--gold); }
.tabs { gap: 2px; padding: 2px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; color: #b8c7d8;
  clip-path: none; border: 1px solid transparent; border-radius: 3px; position: relative; transition: color .15s, background .15s;
}
.tab .ico { opacity: .7; }
.tab:hover { background: rgba(42, 74, 106, .25); color: var(--text); }
.tab.active {
  color: var(--gold-2); background: linear-gradient(180deg, rgba(216, 180, 106, .16), rgba(216, 180, 106, .03));
  border-color: rgba(216, 180, 106, .45); box-shadow: inset 0 -2px 0 var(--gold), 0 0 16px rgba(216, 180, 106, .12);
}
.tab.active .ico { opacity: 1; }

.panel {
  background: linear-gradient(160deg, #0f1d33 0%, #0b1424 45%, #08101e 100%);
  border-color: #24415e; border-radius: 6px; padding: 18px 20px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
}
.panel::before { width: 40px; height: 2px; left: 14px; top: -1px; background: linear-gradient(90deg, var(--gold), transparent); }
.panel::after {
  content: ""; position: absolute; right: 10px; top: 10px; width: 8px; height: 8px;
  border-top: 1px solid rgba(216, 180, 106, .5); border-right: 1px solid rgba(216, 180, 106, .5);
}
.panel h2 { margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 0; }

.btn { border-radius: 4px; transition: border-color .15s, color .15s, background .15s, box-shadow .15s; }
.btn.primary { box-shadow: 0 0 14px rgba(216, 180, 106, .18); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 0 20px rgba(216, 180, 106, .35); }
.btn.gold-outline { border-color: rgba(216, 180, 106, .6); color: var(--gold-2); background: rgba(216, 180, 106, .07); }
.badge { padding: 2px 10px; }
.badge.removed { color: var(--muted); border-color: #3a4a5a; }
.table th { color: #9fb2c8; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: rgba(216, 180, 106, .04); }
.check.small { font-size: 13px; color: var(--muted); }
.check.small input { width: 16px; height: 16px; }
.toast { background: linear-gradient(160deg, #13233c, #0b1424); }
.dialog { background: linear-gradient(160deg, #12223a, #0a1322); border-radius: 6px; box-shadow: 0 0 0 1px rgba(216, 180, 106, .15), 0 16px 50px rgba(0, 0, 0, .7); }

/* Gifts («Бонусы») */
.gifts-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.gifts-layout > .panel { margin-bottom: 0; }
.gifts-layout + .panel { margin-top: 16px; }
.send-panel { position: sticky; top: 76px; }
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.pack {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: var(--text);
  padding: 14px 14px 12px; border-radius: 6px; cursor: pointer;
  background: linear-gradient(165deg, #132540 0%, #0c1729 60%, #0a1322 100%); border: 1px solid #24415e;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.pack:hover { border-color: rgba(216, 180, 106, .6); transform: translateY(-1px); }
.pack.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 22px rgba(216, 180, 106, .22);
  background: linear-gradient(165deg, #2a2512 0%, #131a26 55%, #0b1424 100%); }
.pack-head { display: flex; align-items: center; gap: 8px; padding-right: 26px; }
.pack-head strong { color: var(--gold-2); font-size: 15px; letter-spacing: .02em; }
.pack-ico { width: 22px; height: 22px; color: var(--gold); }
.pack-desc { color: var(--muted); font-size: 13px; }
.pack-check {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #3a5878; display: flex; align-items: center; justify-content: center; color: transparent;
}
.pack-check .ico { width: 14px; height: 14px; stroke-width: 2.6; }
.pack.on .pack-check { background: var(--gold); border-color: var(--gold); color: #1a1205; }
.items { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.items li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.items li b { color: var(--gold-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.items.small li { font-size: 13px; color: #c3d1e1; }
.items.inline { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; margin: 0; }
.items.inline li { gap: 6px; font-size: 13px; }
.preview { padding: 12px; border-radius: 6px; background: rgba(5, 10, 20, .6); border: 1px dashed rgba(216, 180, 106, .4); }
.preview .items { margin-top: 8px; }
.preview .items li { padding: 3px 0; border-bottom: 1px solid rgba(42, 74, 106, .35); }
.dialog .items { margin: 8px 0 12px; padding: 10px 12px; background: rgba(5, 10, 20, .6); border-radius: 4px; }
.send-panel .field select.input { margin-top: 6px; }

@media (max-width: 960px) {
  .gifts-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 760px) {
  .gifts-layout { grid-template-columns: 1fr; }
  .send-panel { position: static; }
  .pack-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
@media (max-width: 600px) {
  .panel { padding: 14px; }
  .tab { padding: 7px 10px; }
}
.h-email { text-transform: none; letter-spacing: 0; color: var(--text); margin-left: 8px; font-weight: 500; }
@media (max-height: 600px) { .send-panel { position: static; } .topbar { position: static; } }
@media (max-width: 1000px) {
  .brand-text { display: none; }
  #who-email { display: none; }
}
