/* Shared admin components. Page styles own application-specific layouts. */
:root {
  --adm-accent: #E6256F;
  --adm-accent-hover: #c21959;
  /* Filled buttons and badges with white text: >= 4.5:1 contrast (WCAG AA). */
  --adm-fill: #ba1551;
  --adm-fill-hover: #9d174b;
  --adm-text: #1A1118;
  --adm-muted: #685d64;
  --adm-subtle: #8A7F86;
  --adm-line: #e5dfe2;
  --adm-bg: #FBFAF8;
  --adm-panel: #fff;
  --adm-tint: #f6f0f3;
  --adm-danger: #b00020;
  --adm-success: #16633d;
  --adm-space-1: 4px;
  --adm-space-2: 8px;
  --adm-space-3: 12px;
  --adm-space-4: 16px;
  --adm-space-6: 24px;
  --adm-space-8: 32px;
  --adm-radius-sm: 8px;
  --adm-radius: 12px;
  --adm-radius-lg: 16px;
  --adm-shadow: 0 2px 8px #1a111806;
  --adm-shadow-raised: 0 12px 36px #1a111812;
  --adm-font: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --adm-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --adm-text-xs: 13px;
  --adm-text-sm: 14px;
  --adm-text-base: 16px;
  --adm-text-lg: 20px;
  --adm-text-xl: 28px;
  /* Compatibility tokens used by moderation markup. */
  --fuchsia: var(--adm-accent);
  --dark: var(--adm-bg);
  --surface: var(--adm-panel);
  --light-pink: var(--adm-text);
  --muted: var(--adm-muted);
  --border: var(--adm-line);
  --border-soft: var(--adm-line);
  color-scheme: light;
  font-family: var(--adm-font);
  color: var(--adm-text);
  background: var(--adm-bg);
}
:where(*) { box-sizing: border-box; }
:where(html) { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--adm-bg); color: var(--adm-text); font: var(--adm-text-base)/1.6 var(--adm-font); -webkit-font-smoothing: antialiased; }
:where(main) { max-width: 1080px; min-width: 0; margin: auto; padding: var(--adm-space-6) max(16px, env(safe-area-inset-right)) var(--adm-space-8) max(16px, env(safe-area-inset-left)); }
body :where(h1, h2, h3, h4) { font-family: var(--adm-font); font-weight: 800; line-height: 1.3; letter-spacing: -.025em; overflow-wrap: anywhere; }
:where(h1) { font-size: var(--adm-text-xl); margin: 16px 0; }
:where(h2) { font-size: var(--adm-text-lg); }
:where(h3) { font-size: 17px; }
:where(p) { line-height: 1.6; }
body :where(a) { color: #9d174b; text-underline-offset: 3px; }
/* Filled link-buttons («Пополнить …», a.button): the link colour above is #9d174b — nearly the
   fill itself, so the label vanished. Same weight, declared later: white wins; .secondary still darker. */
body :where(a.button, a.topup) { color: #fff; text-decoration: none; }
:where(nav) { display: flex; flex-wrap: wrap; gap: var(--adm-space-4); }
:where(nav a) { padding: 8px 0; }
:where(nav a[aria-current=page]) { font-weight: 800; }
:where(.card, fieldset, .admin-panel) { min-width: 0; padding: var(--adm-space-6); margin: 20px 0; border: 1px solid var(--adm-line); border-radius: var(--adm-radius-lg); background: var(--adm-panel); box-shadow: var(--adm-shadow); }
:where(.card h2, .card h3) { margin-top: 0; }
:where(legend) { font-weight: 700; padding: 0 8px; }
:where(button, .button, .topup) { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 10px 16px; border: 1px solid transparent; border-radius: var(--adm-radius-sm); background: var(--adm-fill); color: #fff; font: 700 var(--adm-text-sm)/1.4 var(--adm-font); text-decoration: none; cursor: pointer; white-space: normal; transition: background-color .15s, border-color .15s, box-shadow .15s; }
:where(button:hover:not(:disabled):not([aria-busy=true]), .button:hover:not(:disabled):not([aria-busy=true]), .topup:hover:not(:disabled):not([aria-busy=true])) { background: var(--adm-fill-hover); }
body :where(button, .button).secondary { background: var(--adm-panel); color: var(--adm-text); border-color: var(--adm-line); }
body :where(button, .button).secondary:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-tint); border-color: var(--adm-accent); color: #9d174b; }
body :where(button, .button).danger { background: #fff5f6; color: var(--adm-danger); border-color: #e5b5bd; }
body :where(button, .button).danger:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-danger); color: #fff; }
/* A button that reads as a text link (a name that opens a card) and a compact row button. */
body :where(button.link-button) { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--adm-text); font: 700 var(--adm-text-base)/1.4 var(--adm-font); text-align: left; text-decoration: underline; text-decoration-color: var(--adm-line); text-underline-offset: 4px; }
body :where(button.link-button:hover:not(:disabled):not([aria-busy=true])) { background: none; color: #9d174b; text-decoration-color: currentColor; }
body :where(button, .button).compact { min-height: 36px; padding: 6px 12px; font-size: var(--adm-text-sm); }
body :where(button, .button):disabled, body :where(button, .button)[aria-busy=true] { opacity: .5; cursor: default; box-shadow: none; }
body :where(label) { display: block; margin: 12px 0 6px; color: var(--adm-muted); font-size: var(--adm-text-sm); font-weight: 600; }
body :where(input, select, textarea) { max-width: 100%; font: inherit; font-size: var(--adm-text-base); color: var(--adm-text); accent-color: var(--adm-accent); }
body :where(input:not([type=checkbox]):not([type=radio]), select, textarea) { width: 100%; min-height: 44px; margin: 4px 0 12px; padding: 10px 12px; border: 1px solid #b5a8af; border-radius: var(--adm-radius-sm); background: var(--adm-panel); }
body :where(textarea) { resize: vertical; min-height: 96px; }
body :where(input, select, textarea):disabled { background: var(--adm-tint); color: var(--adm-muted); cursor: default; }
body :where(input, select, textarea)[aria-invalid=true] { border-color: var(--adm-danger); background: #fff5f6; }
body :where(.field-error, [role=alert]) { color: var(--adm-danger); overflow-wrap: anywhere; }
body :where(small, .hint, .muted) { color: var(--adm-muted); }
body :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid #9d174b; outline-offset: 3px; }
:where(.table-wrap, .table-scroll) { max-width: 100%; overflow: auto; border: 1px solid var(--adm-line); border-radius: var(--adm-radius); background: var(--adm-panel); }
:where(table) { width: 100%; border-collapse: collapse; font-size: var(--adm-text-sm); font-variant-numeric: tabular-nums; }
:where(th, td) { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--adm-line); }
body :where(thead th) { top: 0; z-index: 3; background: var(--adm-tint); color: var(--adm-muted); font-weight: 700; }
/* --adm-row-bg lets opaque cell content (payment part rows) match the row tint. */
@media (min-width: 721px) {
  :where(tbody tr:nth-child(even)) { --adm-row-bg: #fcfafb; background: var(--adm-row-bg); }
  :where(tbody tr:hover) { --adm-row-bg: #faf3f6; background: var(--adm-row-bg); }
}
body .num { text-align: right; font-variant-numeric: tabular-nums; }
:where(code, pre, .banned-item) { font-family: var(--adm-mono); }
:where(.empty-state) { padding: 24px; text-align: center; color: var(--adm-muted); border: 1px dashed var(--adm-line); border-radius: var(--adm-radius); background: var(--adm-bg); }
:where(.skeleton, .is-loading) { color: var(--adm-muted); background: linear-gradient(100deg, var(--adm-tint), var(--adm-panel), var(--adm-tint)); border-radius: var(--adm-radius); }
:where(.skeleton) { min-height: 80px; }
:where(.icon) { display: inline-block; width: 18px; height: 18px; vertical-align: -.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* Decorative icons must not intercept delegated button clicks. */
body :where(.icon, .icon *) { pointer-events: none; }
:where(.hidden, [hidden]) { display: none !important; }
/* Desktop headers stick to the window; mobile wrappers retain horizontal scrolling. */
@media (min-width: 768px) {
  :where(.table-wrap, .table-scroll) { overflow: visible; }
  body :where(thead th) { position:sticky; }
}
@media (max-width: 720px) {
  :where(main) { padding: 12px max(12px, env(safe-area-inset-right)) 24px max(12px, env(safe-area-inset-left)); }
  :where(.card, fieldset, .admin-panel) { padding: 16px; }
  body :is(button, .button, .topup) { font-size: 16px; }
  body :where(input, select, textarea) { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  body :where(*, *::before, *::after) { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Navigation shared by every admin page (admin-nav.js). One topbar, one row of
   sections with the current one filled, one segmented sub-navigation. Links and
   buttons inside these rows look the same, so a link never renders as plain text. */
.adm-topbar { display: flex; justify-content: space-between; align-items: center; gap: var(--adm-space-4); flex-wrap: wrap; margin: 0 0 var(--adm-space-4); }
.adm-topbar h1 { margin: 0; font-size: 24px; color: var(--adm-text); text-transform: none; }
.adm-topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.adm-topbar-actions > a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--adm-line); border-radius: var(--adm-radius-sm); background: var(--adm-panel); color: var(--adm-text); font: 700 var(--adm-text-sm)/1.4 var(--adm-font); text-decoration: none; }
.adm-topbar-actions > a:hover:not([aria-busy=true]) { border-color: var(--adm-accent); color: #9d174b; }
.adm-sections { display: flex; flex-wrap: nowrap; gap: 4px; padding: 4px; margin: 0 0 18px; background: var(--adm-panel); border: 1px solid var(--adm-line); border-radius: 13px; overflow-x: auto; scrollbar-width: none; scroll-padding-inline: 8px; }
/* Sticky only on /admin: events and costs tables keep their own sticky headers at top: 0. */
.adm-sections[data-admin-page=moderation] { position: sticky; top: 0; z-index: 50; }
.adm-sections::-webkit-scrollbar { display: none; }
.adm-sections > a, .adm-sections > button { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin: 0; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: #544a50; font: 700 var(--adm-text-sm)/1.2 var(--adm-font); text-decoration: none; white-space: nowrap; box-shadow: none; }
.adm-sections > a:hover { background: var(--adm-tint); color: var(--adm-text); }
.adm-sections > button:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-tint); color: var(--adm-text); }
.adm-sections > .on, .adm-sections > a.on:hover { background: var(--adm-text); color: #fff; }
.adm-sections > button.on:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-text); color: #fff; }
.adm-sections > [data-badge]::after { content: attr(data-badge); margin-left: 6px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--adm-fill); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.adm-sections > .on[data-badge]::after { background: #fff; color: var(--adm-text); }
.adm-subnav { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 0 var(--adm-space-4); border: 1px solid var(--adm-line); border-radius: var(--adm-radius); background: var(--adm-tint); }
.adm-subnav > a, .adm-subnav > button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; margin: 0; padding: 0 16px; border: 0; border-radius: var(--adm-radius-sm); background: transparent; color: #544a50; font: 700 var(--adm-text-sm)/1.2 var(--adm-font); text-decoration: none; box-shadow: none; }
.adm-subnav > a:hover { background: var(--adm-panel); color: var(--adm-text); }
.adm-subnav > button:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-panel); color: var(--adm-text); }
.adm-subnav > [aria-current=page], .adm-subnav > [aria-current=page]:hover:not(:disabled):not([aria-busy=true]) { background: var(--adm-panel); color: #9d174b; box-shadow: 0 1px 3px #1a111814; }
@media (max-width: 720px) {
  .adm-topbar { gap: 8px; min-height: 48px; margin-bottom: 8px; }
  .adm-topbar h1 { flex: 1 0 auto; font-size: 18px; white-space: nowrap; }
  .adm-topbar-actions { flex: 0 1 auto; gap: 8px; min-width: 0; }
  .adm-topbar-actions > a, .adm-topbar-actions > button { min-height: 36px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
  .adm-sections { margin-bottom: 12px; scroll-snap-type: x proximity; }
  .adm-sections > a, .adm-sections > button { flex: none; min-height: 36px; padding: 0 10px; scroll-snap-align: center; }
}
