/* ============================================================
   Beachy Lila — EJS-side patches
   Augments /css/storytime.css with rules the React UI kit didn't need
   but the server-rendered admin panel does (auth shell, flash toasts,
   sidebar avatar fallback, generic form/table chrome).
   ============================================================ */

/* ---------- Card hover overrides ----------
   The base .card from storytime.css lifts (translateY) on hover and shifts its
   background. That's great for clickable tiles but visually noisy on container
   cards that wrap a whole filter+table or a long form. We disable the default
   hover here and add an opt-in `.card-interactive` for things that ARE actually
   clickable (dashboard quick-action tiles, list items, etc.).
   IMPORTANT: the resting-state background/border must match the values used by
   the layer-hierarchy block further down, otherwise hover flickers between the
   two. Keeping these in sync is the whole point of disabling the hover. */
.card { transform: none; }
.card:hover {
  background:
    linear-gradient(180deg, rgba(255,247,236,0.04) 0%, transparent 60px),
    rgba(45, 22, 80, 0.78);
  border-color: rgba(196,154,255,0.26);
  transform: none;
  box-shadow:
    0 12px 36px rgba(20, 8, 40, 0.55),
    inset 0 1px 0 rgba(255,247,236,0.08);
}
.card.card-interactive { cursor: pointer; }
.card.card-interactive:hover {
  background:
    linear-gradient(180deg, rgba(255,247,236,0.06) 0%, transparent 60px),
    rgba(55, 28, 95, 0.85);
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

/* Same hover-stability fix for .section-card so containers don't flicker. */
.section-card:hover {
  background:
    linear-gradient(180deg, rgba(255,247,236,0.04) 0%, transparent 60px),
    rgba(45, 22, 80, 0.78);
  border-color: rgba(196,154,255,0.26);
  transform: none;
}

/* Top-level page sections need breathing room between them. The body slot in
   layouts/main.ejs is wrapped in this class. */
.page-stack > * + * { margin-top: 24px; }

/* ============================================================
   LAYER HIERARCHY OVERRIDES
   The default storytime tokens read flat on dense admin views because every
   surface uses a similar deep-plum alpha. We bump contrast between four
   levels so the eye instantly tells page → card → section-body → input apart.

   Stack, from back to front:
     1. Page    : deep plum + a couple ambient orb gradients
     2. Card    : slightly brighter plum + warm rim-light
     3. Section : tinted top strip ("section-card-head") leading into a
                  marginally darker body
     4. Input   : recessed look (inset shadow + darker fill)
   ============================================================ */

/* 1 — Page: a deep plum with two ambient gradients for depth. */
body.has-shell {
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%,   rgba(169,114,244,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 90% 100%, rgba(110,224,210,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 50% at 10% 80%,  rgba(233,76,208,0.05)  0%, transparent 60%),
    var(--bg-page);
  background-attachment: fixed;
}

/* 2 — Card / section-card: a touch brighter and with a clearer rim-light.
   Card-hover from storytime.css is still neutralised by .card:hover below. */
.card,
.section-card {
  background:
    linear-gradient(180deg, rgba(255,247,236,0.04) 0%, transparent 60px),
    rgba(45, 22, 80, 0.78);
  border-color: rgba(196,154,255,0.26);
  box-shadow:
    0 12px 36px rgba(20, 8, 40, 0.55),
    inset 0 1px 0 rgba(255,247,236,0.08);
}

/* 3 — Section-card-head: tinted strip so the header reads as a separate band. */
.section-card-head {
  background:
    linear-gradient(180deg, rgba(169,114,244,0.10) 0%, rgba(169,114,244,0.02) 100%);
  border-bottom: 1px solid rgba(196,154,255,0.20);
}
/* Body sits a hair darker so the header pops. */
.section-card-body {
  background: rgba(20, 10, 40, 0.18);
}

/* 4 — Inputs: clearly recessed. Inset shadow + darker fill + thicker focus ring. */
.input {
  background: rgba(15, 7, 30, 0.70);
  border-color: rgba(196,154,255,0.22);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.28);
}
.input:focus {
  background: rgba(20, 10, 40, 0.85);
  border-color: rgba(220,193,255,0.65);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.25),
    0 0 0 3px rgba(169, 114, 244, 0.22),
    0 0 18px rgba(138, 79, 226, 0.30);
}
/* Same look for raw <input>/<select>/<textarea> picked up by the compat layer. */
input[type="text"], input[type="email"], input[type="url"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="password"],
input[type="search"], select, textarea {
  background: rgba(15, 7, 30, 0.70);
  border-color: rgba(196,154,255,0.22);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.28);
}
input:focus, select:focus, textarea:focus {
  background: rgba(20, 10, 40, 0.85);
  border-color: rgba(220,193,255,0.65);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.25),
    0 0 0 3px rgba(169, 114, 244, 0.22),
    0 0 18px rgba(138, 79, 226, 0.30);
}

/* Data-table chrome: same recessed inset trick on the wrap so the table
   reads as a panel within the card, not as the card itself. */
.data-table-wrap {
  background: rgba(15, 7, 30, 0.50);
  box-shadow: inset 0 1px 0 rgba(255,247,236,0.04);
}
.data-table thead th {
  background: rgba(169,114,244,0.08);
  border-bottom: 1px solid rgba(196,154,255,0.20);
}

/* form-section-panel: stronger background, more visible border. */
.form-section-panel {
  background: rgba(15, 7, 30, 0.55);
  border-color: rgba(196,154,255,0.18);
  box-shadow: inset 0 1px 0 rgba(255,247,236,0.04);
}

/* entry-card (weapon objects, upgrades, pet components): a step darker
   than its section-body so it reads as nested content. */
.entry-card {
  background: rgba(15, 7, 30, 0.62);
  border-color: rgba(196,154,255,0.22);
  box-shadow: inset 0 1px 0 rgba(255,247,236,0.04);
}

/* ============================================================
   Form-page wrapper — opt-in max-width so add/edit forms don't
   stretch across an ultra-wide monitor. Tables/stats keep using
   the full viewport without this class.
   ============================================================ */
.form-page {
  max-width: 1240px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.form-page > form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Two equal columns inside a form. Stacks vertically below 1100px so the
   form is still usable on a laptop. .section-card stretches to the row's
   tallest sibling for a clean rectangular grid. */
.form-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}
.form-2col > .section-card { display: flex; flex-direction: column; }
.form-2col > .section-card > .section-card-body { flex: 1; }
@media (max-width: 1100px) {
  .form-2col { grid-template-columns: 1fr; }
}

/* ============================================================
   Section-card pattern (used by add/edit Item, etc.)
   A full storytime card with an icon-led header + body.
   Keeps related fields visually grouped without the noisy hover
   the generic .card used to have.
   ============================================================ */
.section-card {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.section-card-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-hairline);
  background: linear-gradient(180deg, rgba(255,247,236,0.025) 0%, transparent 100%);
}
.section-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.section-card-titles { flex: 1; min-width: 0; }
.section-card-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  line-height: 1;
}
.section-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--fg-1);
  margin: 4px 0 0;
  line-height: 1.2;
}
.section-card-sub {
  font-size: 12px;
  color: var(--fg-3);
  margin: 4px 0 0;
}
.section-card-body { padding: 24px; }
.section-card-body > .form-grid { margin: 0; }
.section-card-divider {
  height: 1px;
  background: var(--border-hairline);
  margin: 24px -24px;
}

/* Item-type segmented bar — replaces the small Type <select> with a visual
   tile picker so admins can see at a glance which type they're configuring. */
.type-segment-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}
.type-segment {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  text-align: center;
}
.type-segment input[type="radio"] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
}
.type-segment:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
}
.type-segment-icon {
  font-size: 22px;
  color: var(--fg-3);
  transition: color var(--dur-fast);
}
.type-segment-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-2);
  transition: color var(--dur-fast);
}
.type-segment.is-active {
  background: rgba(169,114,244,0.18);
  border-color: var(--lila-400);
  box-shadow: var(--glow-lila);
}
.type-segment.is-active .type-segment-icon,
.type-segment.is-active .type-segment-label { color: var(--lila-200); }

/* Sub-card for repeated form entries (weapon-skin objects, upgrades,
   pet components). Visually distinct from the parent section-card. */
.entry-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px;
}
.entry-card + .entry-card { margin-top: 10px; }
.entry-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.entry-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.entry-card-title i { color: var(--lila-300); }
.entry-card-actions {
  display: flex; align-items: center; gap: 6px;
}
.entry-card-actions .icon-btn {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
}
.entry-card-grid {
  display: grid;
  gap: 10px;
}
.entry-card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.entry-card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.entry-card-grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .entry-card-grid-3, .entry-card-grid-5 { grid-template-columns: 1fr 1fr; }
}

/* Upgrade card has a stronger accent because each upgrade is a meaningful unit. */
.entry-card.upgrade-card {
  background: rgba(169,114,244,0.06);
  border-color: rgba(169,114,244,0.30);
}
.entry-card.upgrade-card .entry-card-title { color: var(--lila-200); }
.entry-card.upgrade-card .entry-card-title i { color: var(--lila-300); }
.upgrade-objects-inner {
  background: rgba(0,0,0,0.18);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-sm);
  padding: 10px;
  margin-top: 8px;
}
.upgrade-objects-inner h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0 0 8px;
}

/* Compact input variants — used inside entry-cards where space matters. */
.input.input-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

/* Drag & drop file zone — Beachy-Lila version of the import dropper. */
.dropzone {
  border: 2px dashed var(--border-medium);
  border-radius: var(--r-md);
  background: rgba(255,247,236,0.02);
  padding: 24px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.dropzone:hover, .dropzone.is-dragging {
  border-color: var(--lila-400);
  background: rgba(169,114,244,0.06);
}
.dropzone i { font-size: 28px; color: var(--lila-300); }
.dropzone-primary {
  color: var(--fg-1);
  font-size: 14px;
}
.dropzone-primary strong { color: var(--lila-200); }
.dropzone-secondary {
  color: var(--fg-3);
  font-size: 12px;
}

/* Image-preview frame (right side of the upload section). */
.image-preview-frame {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-input);
  height: 200px;
  /* Flex statt grid: erzwingt zuverlässig die max-height/-width-Begrenzung des
     Bildes. Bei grid place-items:center behält ein <img> sein min-height:auto
     (= Naturgröße) und wird nur vom Rahmen abgeschnitten statt skaliert. */
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: 8px;
  box-sizing: border-box;
}
.image-preview-frame img {
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  display: block;
}
.image-preview-frame .placeholder {
  text-align: center;
  color: var(--fg-3);
}
.image-preview-frame .placeholder i {
  font-size: 38px;
  color: var(--fg-4);
  margin-bottom: 10px;
  display: block;
}

/* Progress bar (image upload). */
.progress-track {
  background: var(--bg-input);
  border-radius: var(--r-pill);
  height: 6px;
  overflow: hidden;
}
.progress-fill {
  background: var(--grad-lila);
  height: 100%;
  width: 0%;
  transition: width 200ms var(--ease-out);
}

/* Weapon-type picker — search + category-pills + custom dropdown list. */
.weapon-cat-pills {
  display: flex; flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.weapon-cat-pill {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.weapon-cat-pill:hover { background: var(--bg-card-hover); color: var(--fg-1); }
.weapon-cat-pill.active {
  background: var(--lila-500);
  border-color: var(--lila-500);
  color: var(--foam);
}
.weapon-list {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-input);
  max-height: 260px;
  overflow-y: auto;
}
.weapon-group-head {
  position: sticky; top: 0;
  background: rgba(20,10,40,0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
  border-bottom: 1px solid var(--border-hairline);
  display: flex; align-items: center;
}
.weapon-group-head i { color: var(--lila-300); margin-right: 8px; }
.weapon-group-count { margin-left: auto; opacity: 0.6; }
.weapon-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px;
  color: var(--fg-2);
  border-bottom: 1px solid var(--border-hairline);
  transition: background var(--dur-fast);
}
.weapon-option:last-child { border-bottom: none; }
.weapon-option:hover { background: rgba(169,114,244,0.10); color: var(--fg-1); }
.weapon-option.is-selected {
  background: rgba(169,114,244,0.18);
  color: var(--lila-200);
}
.weapon-option code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  margin-left: 12px;
}
.weapon-selected-tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(169,114,244,0.18);
  color: var(--lila-200);
  border: 1px solid rgba(196,154,255,0.40);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  margin-top: 8px;
}
.weapon-selected-tag code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--lila-300);
}

/* ---------- Anchor styled as <button class="nav-item"> ---------- */
a.nav-item { text-decoration: none; }
a.nav-item:hover { color: var(--fg-1); }

/* ---------- Sidebar avatar (replaces the JS-only "server-dot" indicator) ---------- */
a.server-card { text-decoration: none; color: inherit; display: block; cursor: pointer; transition: background var(--dur-fast) var(--ease-out); border-radius: var(--r-md); }
a.server-card:hover { background: rgba(196,154,255,0.06); }
.server-card-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255,247,236,0.12);
}
.server-card-avatar-fallback {
  background: var(--grad-lila);
  color: var(--foam);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12px;
}

/* ---------- TopBar avatar fallback (logged-in pill) ---------- */
.user-avatar-fallback {
  background: var(--grad-lila);
  color: var(--foam);
}
.user-pill .user-avatar { background: var(--bg-input); }
.user-pill .user-avatar.user-avatar-fallback { background: var(--grad-lila); }

/* ---------- Auth shell (login / unauthorized / error pages) ---------- */
body.no-shell { min-height: 100vh; }
.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 140px;
  background: radial-gradient(ellipse at top, rgba(233,76,208,0.18), transparent 70%);
  pointer-events: none;
}
.auth-brand { position: relative; margin-bottom: 28px; }
.auth-brand-mark {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 6px 18px rgba(169,114,244,0.55));
}
.auth-wordmark {
  font-family: var(--font-display);
  font-size: 38px;
  background: var(--grad-sunset);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1;
}
.auth-sub {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-top: 8px;
}
.auth-title {
  font-family: var(--font-sans);
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 8px;
  color: var(--fg-1);
}
.auth-body { color: var(--fg-2); margin: 0 0 24px; font-size: 14px; line-height: 1.55; }
.auth-actions { display: flex; flex-direction: column; gap: 12px; }
.auth-foot { margin-top: 24px; font-size: 12px; color: var(--fg-3); }
.auth-foot a { color: var(--lila-300); }

/* Big Discord button used on the login page */
.discord-btn-block {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  background: #5865F2;
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 0 22px;
  height: 52px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 0 24px rgba(88,101,242,0.45);
  transition: filter var(--dur-fast) var(--ease-out), transform 80ms;
}
.discord-btn-block:hover { filter: brightness(1.08); color: #fff; }
.discord-btn-block:active { transform: scale(0.97); filter: brightness(0.92); }
.discord-btn-block i:first-child { font-size: 20px; }

/* ---------- Flash toasts (server-rendered, auto-dismiss) ---------- */
.flash-toast {
  animation: toast-in var(--dur-base) var(--ease-spring) both;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.flash-toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Page header (title row above content) ---------- */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header-text { display: flex; flex-direction: column; gap: 6px; }
.page-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title {
  font-family: var(--font-sans);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--fg-1);
  margin: 0;
}
.page-sub { color: var(--fg-3); font-size: 14px; margin: 0; }

/* ---------- Generic table chrome ---------- */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-hairline);
  background: rgba(255,247,236,0.02);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border-hairline);
  color: var(--fg-1);
  vertical-align: middle;
}
.data-table tbody tr:nth-child(even) td { background: rgba(255,247,236,0.025); }
.data-table tbody tr:hover td { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num, .data-table [data-numeric] { font-variant-numeric: tabular-nums; }
.data-table-wrap {
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.data-table-scroll { overflow-x: auto; }

/* ---------- Form patterns reused on every CRUD page ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 20px;
}
.form-grid .field-full { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .form-grid { grid-template-columns: 1fr; }
}
/* Subtle inset panel for grouping fields inside a card (replaces Tailwind's bg-gray-50). */
.form-section-panel {
  background: rgba(255, 247, 236, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: var(--r-md);
  padding: 20px;
}
.form-section-panel + .form-section-panel { margin-top: 20px; }

.form-section + .form-section { margin-top: 24px; }
.form-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-hairline);
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-hairline);
}

/* ---------- Empty state inside a card ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--fg-3);
}
.empty-state i { font-size: 38px; color: var(--fg-4); display: block; margin-bottom: 16px; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--fg-1); margin: 0 0 6px; }
.empty-state-body { font-size: 13px; margin: 0 0 18px; }

/* ---------- Inline list styles for permission rows etc ---------- */
.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 16px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.check-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast) var(--ease-out);
  font-size: 14px;
}
.check-list label:hover { background: rgba(196,154,255,0.06); }
.check-list input[type="checkbox"] { accent-color: var(--lila-500); width: 16px; height: 16px; }

/* ---------- Description list for stat / meta rows ---------- */
.meta-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 12px 24px;
  margin: 0;
  font-size: 14px;
}
.meta-list dt { color: var(--fg-3); font-weight: 500; }
.meta-list dd { margin: 0; color: var(--fg-1); }

/* ---------- Permission/permission-badge chips ---------- */
.perm-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-pill);
  background: rgba(169,114,244,0.16);
  color: var(--lila-200);
  border: 1px solid rgba(196,154,255,0.4);
}

/* ---------- Buttons as <a> ---------- */
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
a.btn:hover { text-decoration: none; }

/* ---------- Settings-style tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-hairline);
  margin-bottom: 24px;
}
.tab {
  background: transparent;
  border: none;
  color: var(--fg-3);
  padding: 12px 18px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  text-decoration: none;
}
.tab:hover { color: var(--fg-1); }
.tab.is-active { color: var(--lila-300); border-bottom-color: var(--lila-400); }

/* ---------- Spacing utilities used by the redesigned templates ---------- */
.stack-sm > * + * { margin-top: 8px; }
.stack-md > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 24px; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.flex-row-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.text-mono { font-family: var(--font-mono); font-size: 13px; }
.text-muted { color: var(--fg-3); }
.text-faint { color: var(--fg-4); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-num { font-variant-numeric: tabular-nums; }

/* ---------- Server-rendered modals (JS-toggled via .is-open) ---------- */
.modal-scrim.is-toggleable {
  display: none;
  animation: none;
}
.modal-scrim.is-toggleable.is-open {
  display: grid;
  animation: scrim-in var(--dur-base) var(--ease-out);
}

/* ---------- Sortable column headers (items list, etc.) ---------- */
.data-table thead th a.col-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-3);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.data-table thead th a.col-sort:hover { color: var(--lila-300); }
.data-table thead th a.col-sort i { font-size: 10px; opacity: 0.6; }
.data-table thead th a.col-sort.is-active { color: var(--lila-300); }
.data-table thead th a.col-sort.is-active i { opacity: 1; color: var(--lila-300); }

/* ---------- Inline checkbox in a table row ---------- */
.row-checkbox {
  width: 16px; height: 16px;
  accent-color: var(--lila-500);
  cursor: pointer;
}

/* ---------- Items list — coloured type-chip next to the item name.
   Same icon/colour vocabulary as the addItem type-picker. */
.type-chip {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: rgba(255,247,236,0.03);
  border: 1px solid var(--border-soft);
  font-size: 14px;
  flex-shrink: 0;
}

/* ---------- Items list — image thumbnail in row.
   Sized to fill nearly the whole row height so vehicle/skin previews are recognisable. */
.row-thumb {
  width: 64px; height: 64px;
  border-radius: var(--r-md);
  object-fit: cover;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  display: block;
}
.row-thumb:hover { transform: scale(1.04); border-color: var(--border-medium); }
.row-thumb-placeholder {
  width: 64px; height: 64px;
  border-radius: var(--r-md);
  background: rgba(255,247,236,0.03);
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  color: var(--fg-4);
  font-size: 20px;
}
/* Tighten vertical padding on the image cell so the bigger thumb doesn't stretch
   every other column. The image itself sets the row height. */
.data-table td:has(.row-thumb), .data-table td:has(.row-thumb-placeholder) {
  padding-top: 6px;
  padding-bottom: 6px;
}

/* ---------- Mass-action bar (sticky bottom, slides up when items selected) ---------- */
.mass-action-bar {
  position: fixed;
  left: 248px; /* width of the fixed sidebar */
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 14px 32px;
  background: rgba(25,12,50,0.92);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-medium);
  box-shadow: 0 -8px 24px rgba(20,8,40,0.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transform: translateY(110%);
  transition: transform var(--dur-base) var(--ease-spring);
}
.mass-action-bar.is-open { transform: translateY(0); }
.mass-action-bar .count-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--fg-2);
}
.mass-action-bar .count-pill strong {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--lila-300);
  font-size: 16px;
}
.mass-action-bar .link-quiet {
  background: none;
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mass-action-bar .link-quiet:hover { color: var(--fg-1); }
.mass-action-bar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 1100px) { .mass-action-bar { left: 0; } }

/* ---------- Mass-action confirmation modal: item-name list scroll area ---------- */
.mass-item-list {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-input);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--fg-2);
  margin-top: 12px;
  border: 1px solid var(--border-hairline);
}
.mass-item-row { padding: 2px 0; }

/* ---------- Advanced-filters popover dropdown ---------- */
.filter-popover-wrap { position: relative; }
.filter-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 280px;
  background: rgba(30,14,60,0.96);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 20;
  display: none;
  animation: modal-in var(--dur-fast) var(--ease-out);
}
.filter-popover.is-open { display: block; }
.filter-popover h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin: 0 0 12px;
}

/* ---------- Inline-count badge on filter button ---------- */
.btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--lila-500);
  color: var(--foam);
  font-size: 10px;
  font-weight: 700;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Items-list filter toolbar (search + dropdowns + actions) ---------- */
.items-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.items-toolbar .input-wrap { flex: 1; min-width: 240px; max-width: 360px; }
.items-toolbar .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ---------- Image preview lightbox ---------- */
.lightbox-scrim {
  position: fixed;
  inset: 0;
  background: rgba(7, 3, 18, 0.88);
  z-index: 95;
  display: none;
  place-items: center;
  padding: 32px;
  animation: scrim-in var(--dur-base) var(--ease-out);
}
.lightbox-scrim.is-open { display: grid; }
.lightbox-frame {
  position: relative;
  max-width: min(1200px, 90vw);
  max-height: 90vh;
}
.lightbox-frame img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.lightbox-close {
  position: absolute;
  top: -44px;
  right: 0;
  background: rgba(255,247,236,0.08);
  color: var(--foam);
  border: 1px solid var(--border-soft);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: filter var(--dur-fast);
}
.lightbox-close:hover { filter: brightness(1.2); }

/* ---------- Pagination bar ---------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-hairline);
}
.pagination-info { font-size: 13px; color: var(--fg-3); }
.pagination-info strong { font-weight: 700; color: var(--fg-1); font-variant-numeric: tabular-nums; }
.pagination-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-buttons { display: flex; gap: 4px; }
.page-btn-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
  background: var(--bg-input);
  color: var(--fg-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast);
}
.page-btn-link:hover { background: var(--bg-card-hover); border-color: var(--border-bright); color: var(--fg-1); }
.page-btn-link.is-current {
  background: rgba(169,114,244,0.22);
  border-color: var(--lila-400);
  color: var(--foam);
}
.page-btn-link.is-disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Import modal: file picker / summary ---------- */
.file-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.import-summary {
  display: none;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  background: rgba(95,216,166,0.12);
  border: 1px solid rgba(95,216,166,0.4);
  color: var(--success);
}
.import-summary.is-shown { display: block; }
.import-summary.tone-warning {
  background: rgba(255,194,103,0.14);
  border-color: rgba(255,194,103,0.4);
  color: var(--warning);
}
.import-summary.tone-danger {
  background: rgba(255,110,138,0.14);
  border-color: rgba(255,110,138,0.4);
  color: var(--danger);
}

/* ---------- Chart canvas wrap + empty-state ---------- */
.chart-canvas-wrap {
  width: 100%;
  padding: 8px;
  border-radius: var(--r-md);
  background: rgba(255,247,236,0.02);
  border: 1px solid var(--border-hairline);
}
.chart-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 200px;
  padding: 24px;
  border-radius: var(--r-md);
  background: rgba(255,247,236,0.02);
  border: 1px dashed var(--border-soft);
  text-align: center;
  color: var(--fg-3);
}
.chart-empty i { font-size: 32px; color: var(--fg-4); margin-bottom: 10px; }
.chart-empty p { margin: 0; font-size: 13px; }

/* ---------- Rank medals for leaderboard tables ---------- */
.rank-medal {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rank-gold {
  background: linear-gradient(135deg, rgba(255,210,122,0.35), rgba(255,180,138,0.25));
  color: var(--gold);
  box-shadow: var(--glow-gold);
}
.rank-silver {
  background: rgba(196,154,255,0.18);
  color: var(--lila-200);
}
.rank-bronze {
  background: rgba(255,180,138,0.22);
  color: var(--peach);
}
.rank-fire {
  background: rgba(255,126,139,0.22);
  color: var(--coral);
  box-shadow: var(--glow-coral);
}

/* ---------- KPI grid wraps anywhere stat cards land ---------- */
.kpi-grid-flex {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
