:root {
  --bg: #151c2e;
  --bg-soft: #1a2236;
  --panel: #212b42;
  --panel-alt: #283450;
  --panel-raised: #313f60;
  --border: #3a4767;
  --border-light: #46557a;
  --text: #eef2f9;
  --muted: #a3aec4;
  --muted-dim: #75829e;
  --accent: #4f93f8;
  --accent-hover: #3b82f6;
  --accent-soft: rgba(79, 147, 248, 0.18);
  --success: #2dd46a;
  --success-hover: #22c55e;
  --danger: #f15a5a;
  --danger-hover: #ef4444;
  --danger-soft: rgba(241, 90, 90, 0.16);
  --warning: #f5a623;
  --radius: 20px;
  --radius-sm: 11px;
  --radius-pill: 999px;
  --grad-1: #22d3ee;
  --grad-2: #6366f1;
  --grad-3: #ec4899;
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 24px 48px -28px rgba(0, 0, 0, 0.65), 0 2px 10px -2px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --bg: #f6f7fa;
  --bg-soft: #f6f7fa;
  --panel: #ffffff;
  --panel-alt: #eff1f5;
  --panel-raised: #e6e8ee;
  --border: #e2e4eb;
  --border-light: #cdd1db;
  --text: #0e1015;
  --muted: #5d6270;
  --muted-dim: #8b8f9c;
  --accent: #5b45e0;
  --accent-hover: #4c37c9;
  --accent-soft: rgba(91, 69, 224, 0.1);
  --success: #0e8a4b;
  --success-hover: #0b7040;
  --danger: #e0393f;
  --danger-hover: #c22f34;
  --danger-soft: rgba(224, 57, 63, 0.1);
  --warning: #b6720c;
  --card-shadow: 0 1px 2px rgba(15, 17, 21, 0.06), 0 4px 12px rgba(15, 17, 21, 0.05);
}
:root[data-theme="light"] .auth-card,
:root[data-theme="light"] .card { box-shadow: var(--card-shadow); }
:root[data-theme="light"] .navbar { box-shadow: 0 1px 3px rgba(30, 41, 59, 0.06); }
:root[data-theme="light"] .success { color: #fff; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top, var(--bg-soft) 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.navbar { flex-shrink: 0; }

a { color: var(--accent); }

/* ---------- Nav ---------- */
.navbar {
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.navbar::after {
  content: "";
  display: block;
  height: 2px;
  background: linear-gradient(90deg, #22d3ee, #6366f1, #a855f7, #ec4899, #6366f1, #22d3ee);
  background-size: 200% 100%;
  animation: navGlow 8s linear infinite;
  opacity: 0.85;
}
@keyframes navGlow {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .navbar::after { animation: none; }
}
.navbar-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.65rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 0.65rem; text-decoration: none; flex-shrink: 0; }
.brand-mark {
  width: 36px; height: 36px;
  object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.45));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-weight: 800; font-size: 1.05rem; letter-spacing: 0.01em;
  background: linear-gradient(90deg, #22d3ee, #6366f1 45%, #a855f7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tagline { font-size: 0.72rem; color: var(--muted-dim); }

.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.9rem; flex-shrink: 0; }
.nav-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; gap: 0.15rem; }
.nav-user-email { font-size: 0.85rem; color: var(--text); }
.nav-user-role {
  font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px;
  background: linear-gradient(90deg, rgba(168, 85, 247, 0.16), rgba(236, 72, 153, 0.16));
  border: 1px solid rgba(168, 85, 247, 0.4); color: #d8b4fe;
}
:root[data-theme="light"] .nav-user-role { color: #9333ea; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--panel-alt); border: 1px solid var(--border);
  color: var(--muted); display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none; font-size: 0.95rem; padding: 0; flex-shrink: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--panel-raised); color: var(--text); border-color: #6366f1; box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35), 0 0 12px -2px rgba(99, 102, 241, 0.5); }
.logout-form { display: flex; }
#mobile-nav-toggle { display: none; }
.navbar-mobile-panel { display: none; }

.navbar-tabs {
  display: flex; gap: 0.25rem;
  overflow-x: auto;
}
.navbar-tabs a {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.85rem; font-size: 0.88rem; font-weight: 500;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.navbar-tabs a:hover { color: var(--text); background: var(--panel-alt); }
.navbar-tabs a.active {
  color: #fff;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  box-shadow: 0 2px 10px -2px rgba(139, 92, 246, 0.6);
}

/* ---------- Layout ---------- */
.container { max-width: 1600px; margin: 0 auto; padding: 1.75rem 2rem 3rem; flex: 1 1 auto; display: flex; flex-direction: column; width: 100%; }
.container > .discord-topup-banner { margin-top: auto; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.page-subtitle { color: var(--muted); font-size: 0.9rem; margin: 0; }
.header-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: var(--danger-soft); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: rgba(45, 212, 106, 0.14); border: 1px solid var(--success); color: var(--success); }

/* ---------- Cards ---------- */
.auth-card, .card {
  background: linear-gradient(180deg, var(--panel), var(--panel-alt));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
}
.auth-card {
  max-width: 420px; margin: 4.5rem auto; padding: 2.1rem 2rem 2rem;
  position: relative; overflow: hidden; border-radius: var(--radius);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.12);
}
.auth-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #22d3ee, #6366f1, #a855f7, #ec4899);
}
.auth-card::after {
  content: ""; position: absolute; top: -60%; left: 50%; transform: translateX(-50%);
  width: 140%; height: 220px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(99, 102, 241, 0.22), transparent 70%);
  z-index: 0;
}
.auth-card > * { position: relative; z-index: 1; }
.auth-card .brand { justify-content: center; margin-bottom: 1.5rem; }
.auth-card .brand-mark { width: 44px; height: 44px; }
.auth-card .brand-title { font-size: 1.2rem; }
.auth-card h1 {
  font-size: 1.4rem; font-weight: 800; text-align: center; margin: 0 0 0.3rem;
}
.auth-card-subtitle { text-align: center; color: var(--muted); font-size: 0.85rem; margin: 0 0 1.6rem; }
.auth-card .primary {
  background: linear-gradient(90deg, #6366f1, #a855f7); border: none;
  box-shadow: 0 10px 24px -10px rgba(139, 92, 246, 0.65);
  font-weight: 700; padding: 0.68rem 1.05rem; transition: filter 0.15s ease, transform 0.15s ease;
}
.auth-card .primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.auth-card label { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 1.1rem; }
.auth-card input {
  padding: 0.65rem 0.8rem; border-radius: 10px; border-color: var(--border-light);
  background: var(--bg-soft); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-card input:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18); }

.section-card { margin-bottom: 1.25rem; position: relative; overflow: hidden; }
.section-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--grad-1), var(--grad-2), var(--grad-3)); opacity: 0.8;
}
.section-card-head { margin-bottom: 1.1rem; }
.section-card-head h2 { font-size: 1.05rem; margin: 0 0 0.2rem; display: flex; align-items: center; gap: 0.5rem; }
.section-card-head p { color: var(--muted); font-size: 0.85rem; margin: 0; }

.badge-strip {
  display: block; border-radius: 0.65rem; background: var(--bg-soft);
  border: 1px solid var(--border-light); padding: 0.5rem 0.85rem;
  font-size: 0.8rem; line-height: 1.45; color: var(--muted); width: auto;
}
.badge-strip strong { color: var(--text); font-weight: 700; }

/* Mini stat cards (attacks-today, loot totals, current target, points, ...)
   shown under a module's settings header - same visual language as the
   dashboard's .stat-tile (accent top bar + gradient-text value) but compact
   enough to sit several to a row. */
.mini-stat-row { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 0.85rem; }
.mini-stat {
  position: relative; overflow: hidden; flex: 0 1 auto; min-width: 148px;
  background: var(--panel-alt); border: 1px solid var(--border-light);
  border-radius: 0.85rem; padding: 0.6rem 1rem 0.65rem;
}
.mini-stat::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #22d3ee, #6366f1);
}
.mini-stat-gold::before { background: linear-gradient(90deg, #f59e0b, #eab308); }
.mini-stat-ruby::before { background: linear-gradient(90deg, #ef4444, #ec4899); }
.mini-stat-green::before { background: linear-gradient(90deg, #22c55e, #06b6d4); }
.mini-stat-label {
  display: flex; align-items: center; gap: 0.35rem; color: var(--muted);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap;
}
.mini-stat-value {
  font-size: 1.3rem; font-weight: 800; margin-top: 0.15rem;
  background: linear-gradient(90deg, #22d3ee, #6366f1);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.mini-stat-value-gold { background: linear-gradient(90deg, #f59e0b, #eab308); -webkit-background-clip: text; background-clip: text; }
.mini-stat-value-ruby { background: linear-gradient(90deg, #ef4444, #ec4899); -webkit-background-clip: text; background-clip: text; }
.mini-stat-value-green { background: linear-gradient(90deg, #22c55e, #06b6d4); -webkit-background-clip: text; background-clip: text; }
.mini-stat-hint { font-size: 0.68rem; color: var(--muted-dim); margin-top: 0.1rem; }

.subcard {
  background: var(--panel-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.subcard:last-child { margin-bottom: 0; }
.subcard-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; font-weight: 600; font-size: 0.95rem; }
.subcard-head .muted { font-weight: 400; }

.section-divider {
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.8rem 0 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.section-divider::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); flex-shrink: 0;
  box-shadow: 0 0 8px -1px var(--grad-2);
}
.section-divider::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--border-light), transparent);
}
.section-divider:first-of-type { margin-top: 0; }

.field-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 1.25rem; }
.field-grid-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0.5rem 1.25rem; }

/* Kahn Bot's Wall Tool Layout (Left/Front/Right, each holding its own
   nested field-grid) - Front has 3 sub-columns (Wall/Gate/Wall) vs 2 for
   Left/Right, so it needs more of the row's width or its selects clip
   badly against the native dropdown arrow. */
.wall-tool-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); }
.wall-tool-layout label { margin-bottom: 0.6rem; min-width: 0; }

/* Kahn Bot's Wall/Gate/Moat tool pickers - reuse the attack-template wave
   builder's .slot-pick-btn trigger + the shared .modal-* picker classes
   instead of plain <select> elements (which clipped tool names badly and
   don't match the in-game "search & pick" experience the user wanted). */
.wall-tool-layout .slot-pick-btn,
.field-grid-2 .slot-pick-btn {
  display: block; width: 100%; margin-top: 0.3rem;
  font-size: 0.78rem; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}

/* Kahn Bot's Wall Troop Split - three colour-coded sliders (matches the
   in-game Left/Middle/Right panel) plus a live running total and a stacked
   bar preview built from the same three colours. */
.wall-troop-split-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
}
.wall-troop-split-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.wall-troop-split-title { font-weight: 600; font-size: 0.9rem; color: var(--text); }
.wall-troop-split-total {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem; font-weight: 600;
  color: #34d399; background: color-mix(in srgb, #34d399 15%, transparent);
  border: 1px solid color-mix(in srgb, #34d399 35%, transparent);
  border-radius: var(--radius-sm); padding: 0.2rem 0.55rem;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.wall-troop-split-total.wall-troop-split-total-bad {
  color: #f87171; background: color-mix(in srgb, #f87171 15%, transparent);
  border-color: color-mix(in srgb, #f87171 35%, transparent);
}
.wall-troop-split-row { margin-bottom: 1.1rem; }
.wall-troop-split-row:last-of-type { margin-bottom: 0.9rem; }
.wall-troop-split-row-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 0.45rem;
}
.wall-troop-split-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.wall-troop-split-value { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.wall-troop-split-left::before,
.wall-troop-split-middle::before,
.wall-troop-split-right::before {
  content: ""; display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 0.4rem; vertical-align: middle;
}
.wall-troop-split-left::before { background: #3b82f6; }
.wall-troop-split-middle::before { background: #34d399; }
.wall-troop-split-right::before { background: #a855f7; }

.wall-troop-split-lock {
  background: none; border: none; padding: 0; margin-left: 0.3rem;
  font-size: 0.75rem; line-height: 1; cursor: pointer; opacity: 0.55;
  vertical-align: middle; transition: opacity 0.15s ease;
}
.wall-troop-split-lock:hover { opacity: 0.9; }
.wall-troop-split-lock.wall-troop-split-locked { opacity: 1; }

.wall-troop-split-slider {
  width: 100%; margin: 0; padding: 0; height: 6px; border-radius: 999px;
  background: var(--border); appearance: none; -webkit-appearance: none;
  cursor: pointer;
}
.wall-troop-split-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid #3b82f6;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4); cursor: pointer;
}
.wall-troop-split-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid #3b82f6;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4); cursor: pointer;
}
.wall-troop-split-slider-middle::-webkit-slider-thumb { border-color: #34d399; }
.wall-troop-split-slider-middle::-moz-range-thumb { border-color: #34d399; }
.wall-troop-split-slider-right::-webkit-slider-thumb { border-color: #a855f7; }
.wall-troop-split-slider-right::-moz-range-thumb { border-color: #a855f7; }

.wall-troop-split-bar {
  display: flex; height: 8px; border-radius: 999px; overflow: hidden;
  margin-top: 0.4rem; background: var(--border);
}
.wall-troop-split-bar-seg { flex-grow: 1; transition: flex-grow 0.15s ease; }
.wall-troop-split-bar-left { background: #3b82f6; }
.wall-troop-split-bar-middle { background: #34d399; }
.wall-troop-split-bar-right { background: #a855f7; }

/* Pill-style toggle group - a nicer stand-in for a bare radio/checkbox row
   (e.g. Target Mode, Skip Mode, Allowed Skip Types). The native input is
   visually hidden but stays focusable/keyboard-operable; the pill is the
   sibling <span> it's paired with. */
.pill-group {
  display: inline-flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 0.4rem;
}
.pill-group.pill-group-checkbox .pill-toolbar { margin-bottom: 0.4rem; }
.pill-toolbar { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.3rem; }
.pill-toolbar-count { font-size: 0.78rem; color: var(--muted); }
.pill-select-all {
  padding: 0.3rem 0.7rem; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.pill-select-all:hover { border-color: var(--accent); }
/* Every pill (selected or not) keeps its own same-size border box - so an
   unselected pill doesn't look smaller/uneven next to a filled one, and
   the group doesn't need a bulky outer frame around it. */
.pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.5rem 1.05rem; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; user-select: none;
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}
.pill:hover { color: var(--text); border-color: var(--border-light); transform: translateY(-1px); }
.pill input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.pill:has(input:checked) {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -6px var(--grad-2);
}
.pill:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.pill-checkbox:has(input:checked) { background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); border-color: transparent; color: #fff; }
.pill-checkbox-mark { display: none; }
.pill-checkbox:has(input:checked) .pill-checkbox-mark { display: inline; }

.field-hint { display: block; margin-top: 0.3rem; font-size: 0.78rem; color: var(--muted); font-weight: 400; }

.required { color: var(--danger); margin-left: 0.15rem; }

/* ---------- Forms ---------- */
form label { display: block; margin-bottom: 0.9rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  margin-top: 0.3rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--border-light); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
textarea { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.82rem; }

/* Plain radio/checkbox inputs (e.g. Target Mode, Allowed Skip Types) inherit
   the generic input{width:100%} rule above, which stretches the native
   control across the whole row and shoves its label text onto the line
   below, far from the dot/box. Give them a fixed native size and lay the
   label out as an inline row instead of the block stacking used for
   text/number/select fields. */
input[type="checkbox"], input[type="radio"] {
  width: 16px;
  height: 16px;
  margin-top: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
form label:has(> input[type="checkbox"]),
form label:has(> input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* Browser autofill (e.g. saved login) otherwise forces a stark white
   background regardless of theme - repaint it to match the dark inputs. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-soft) inset;
  box-shadow: 0 0 0 1000px var(--bg-soft) inset;
  transition: background-color 9999s ease-in-out 0s;
}

/* ---------- Buttons ---------- */
button, .primary, .danger, .secondary, .success, .link-button {
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background: var(--panel-raised);
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.2;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
button:hover:not(.primary):not(.success), .secondary:hover { background: var(--panel-alt); transform: translateY(-1px); }
.primary {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); color: #fff; border-color: transparent;
  box-shadow: 0 8px 20px -9px var(--grad-2);
}
.primary:hover {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  filter: brightness(1.08); transform: translateY(-1px);
}
.success {
  background: linear-gradient(135deg, #22c55e, #16a34a); color: #06210f; border-color: transparent; font-weight: 700;
  box-shadow: 0 8px 20px -9px rgba(34, 197, 94, 0.55);
}
.success:hover {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  filter: brightness(1.06); transform: translateY(-1px);
}
.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.danger:hover { background: var(--danger-soft); transform: translateY(-1px); }
.link-button { background: none; border: none; text-decoration: underline; padding: 0; color: var(--accent); border-radius: 0; }
.link-button:hover { transform: none; background: none; }

/* ---------- Bot dashboard cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card-grid.recruit-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
/* Caps at 3 per row regardless of container width, instead of auto-fit
   packing in more columns on very wide screens - falls back to fewer
   columns (not more) when there's less than 3x280px of space. */
.card-grid.card-grid-max3 { grid-template-columns: repeat(auto-fit, minmax(280px, calc((100% - 2rem) / 3))); }
.recruit-card label { display: flex; flex-direction: column; gap: 0.4rem; }

/* ---------- Reusable card accent / hover ---------- */
.card-accent { position: relative; overflow: hidden; }
.card-accent::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, #22d3ee, #6366f1); }
.card-accent-purple::before { background: linear-gradient(90deg, #a855f7, #ec4899); }
.card-accent-green::before { background: linear-gradient(90deg, #22c55e, #06b6d4); }
.card-accent-amber::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.card-hover { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.55); }
.stat-tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.stat-tile { padding: 1rem 1.1rem; }
.stat-tile-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile-value { font-size: 1.7rem; font-weight: 800; margin-top: 0.2rem; background: linear-gradient(90deg, #22d3ee, #6366f1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-tile-value-purple { background: linear-gradient(90deg, #a855f7, #ec4899); -webkit-background-clip: text; background-clip: text; }

.bot-card { display: flex; flex-direction: column; gap: 0.85rem; }
.bot-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; }
.bot-card-name { font-weight: 600; font-size: 1.02rem; }
.bot-card-meta { color: var(--muted-dim); font-size: 0.78rem; margin-top: 0.15rem; }
.bot-card-info { display: flex; flex-direction: column; gap: 0.15rem; }
.bot-card-info-row { color: var(--muted); font-size: 0.8rem; }
.bot-card-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
/* Full-width of its own row (flex-basis 100% leaves no room for anything
   else on that line) so the primary Start/Stop action reads as clearly
   more prominent than Configure/Live Ops/Delete, instead of getting
   squeezed down to a sliver next to them. */
.bot-card-actions .bot-card-main-action { display: flex; flex: 1 1 100%; }
.bot-card-actions .bot-card-main-action button { width: 100%; justify-content: center; padding: 0.85rem 1rem; font-size: 1.05rem; }
.bot-card-actions > a.secondary { white-space: nowrap; flex-shrink: 0; }
.bot-card-actions > form:last-child { display: inline-flex; flex-shrink: 0; }
.bot-card-extend { display: flex; flex-direction: column; gap: 0.3rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.bot-card-extend .admin-credit-form { justify-content: space-between; }
.bot-card-extend .extend-days-input { flex: 1 1 auto; }
.extend-cost-hint { margin: 0; }

/* ---------- Status badges ---------- */
.status { font-size: 0.7rem; padding: 0.2rem 0.6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.02em; font-weight: 600; }
.status-running { background: rgba(34, 197, 94, 0.16); color: var(--success); }
.status-stopped { background: rgba(139, 150, 171, 0.16); color: var(--muted); }
.status-error { background: var(--danger-soft); color: var(--danger); }
.badge { font-size: 0.68rem; color: var(--muted); border: 1px solid var(--border-light); border-radius: 999px; padding: 0.15rem 0.55rem; }

/* ---------- Tabs (bot detail) ---------- */
.tabs { display: flex; gap: 0.35rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab { color: var(--muted); text-decoration: none; padding: 0.6rem 0.95rem; border-bottom: 2px solid transparent; font-size: 0.9rem; font-weight: 500; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.tab:hover { color: var(--text); background: var(--panel-alt); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar form { display: inline-flex; }
.toolbar-spacer { flex: 1; }
#toolbar-save:disabled {
  opacity: 1; cursor: not-allowed;
  background: var(--panel-raised); color: var(--muted-dim); border-color: var(--border);
}

/* ---------- Top stats bar (rubies/coins/attacks) ---------- */
.top-stats-bar {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  margin-bottom: 1.25rem; padding: 0.7rem 1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.top-stat strong { font-weight: 700; }
.top-stat-rubies strong { color: var(--danger); }
.top-stat-coins strong { color: var(--accent); }
.top-stat-attacks strong { color: var(--text); }

/* ---------- Function toggle switches ---------- */
.function-group { margin-bottom: 1.3rem; }
.function-group:last-child { margin-bottom: 0; }
.function-group-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.03em;
  padding-bottom: 0.5rem; margin-bottom: 0.8rem;
  border-bottom: 1px solid var(--border-light);
}
.function-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem 1.5rem; }
.function-row {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.55rem 0.6rem; margin: 0 -0.6rem;
  border-radius: var(--radius-sm); transition: background 0.15s ease;
}
.function-row:hover { background: var(--bg-soft); }
.function-row-locked { opacity: 0.55; }
.function-row-text { display: flex; flex-direction: column; gap: 0.1rem; }
.function-row-label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; font-weight: 500; }
.function-row-desc { color: var(--muted-dim); font-size: 0.78rem; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex-shrink: 0; margin-top: 0.1rem; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute; inset: 0; background: var(--border-light);
  border-radius: 999px; transition: background 0.15s ease; cursor: pointer;
}
.switch-track::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.switch input:checked + .switch-track { background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); box-shadow: 0 2px 8px -2px var(--grad-2); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }
.switch input:disabled + .switch-track { opacity: 0.4; cursor: not-allowed; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Accordions ---------- */
.accordion {
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  margin-bottom: 0.75rem; background: var(--panel);
  overflow: hidden;
}
.accordion + .accordion { margin-top: 0.75rem; }
.accordion > summary {
  list-style: none; cursor: pointer; padding: 0.85rem 1rem;
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 600; font-size: 0.95rem;
  transition: background 0.15s ease;
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::before {
  content: "▸"; display: inline-block; color: var(--muted-dim);
  transition: transform 0.15s ease; flex-shrink: 0; font-size: 0.8em;
}
.accordion[open] > summary::before { transform: rotate(90deg); }
.accordion > summary .accordion-icon { flex-shrink: 0; }
.accordion > summary .accordion-title-rule {
  flex: 1; height: 1px; background: var(--border-light); margin-left: 0.4rem; opacity: 0.6;
}
.accordion > summary:hover { background: var(--bg-soft); }
.accordion[open] > summary { border-bottom: 1px solid var(--border-light); }
.accordion-desc { color: var(--muted-dim); font-size: 0.78rem; padding: 0.7rem 1rem 0 2.35rem; }
.accordion-body { padding: 1rem; }
.accordion-nested { margin: 0; border-radius: calc(var(--radius-sm) - 2px); background: var(--panel-alt); }
.accordion-nested > summary { font-size: 0.88rem; padding: 0.65rem 0.85rem; }
.accordion-nested .accordion-desc { padding: 0.6rem 0.85rem 0 2.1rem; }
.accordion-nested .accordion-body { padding: 0.85rem; }
.accordion-group-body { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.85rem 1rem 1rem; }

/* ---------- Recruit cards ---------- */
.recruit-card label { margin-bottom: 0.7rem; }

/* ---------- Logs ---------- */
.log-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.log-card-title { display: flex; align-items: center; gap: 0.55rem; font-weight: 600; }
.log-card-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.log-card-actions button { padding: 0.35rem 0.65rem; font-size: 0.78rem; }
.log-card-footer { display: flex; justify-content: flex-end; margin-top: 0.6rem; }
.log-autoscroll-toggle { display: flex; align-items: center; gap: 0.4rem; background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 0.78rem; }
.autoscroll-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--success); display: inline-block; flex-shrink: 0; }
.badge-active { color: var(--success); border-color: var(--success); }
.log-box {
  background: #0c1322;
  color: #8fd9fc;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  height: 650px;
  overflow-y: auto;
  white-space: pre-wrap;
}
.log-box p { color: var(--muted-dim); }

.resource-box { display: flex; flex-direction: column; gap: 0.6rem; }
.resource-box p { color: var(--muted-dim); }
.resource-castle-card {
  background: var(--panel); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem;
}
.resource-castle-name { font-weight: 600; margin-bottom: 0.4rem; }
.resource-stats { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.resource-troops { font-size: 0.82rem; color: var(--muted-dim); }

/* ---------- Bot detail: sidebar layout ---------- */
.bot-layout { display: flex; gap: 2rem; align-items: flex-start; }
.config-sidebar {
  flex: 0 0 250px;
  display: flex; flex-direction: column; gap: 0.15rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem;
  position: sticky; top: 5.5rem;
}
.config-sidebar-title {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted-dim); padding: 0.4rem 0.6rem 0.6rem;
}
.config-link {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.6rem 0.65rem; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: 0.88rem; font-weight: 500;
}
.config-link:hover { background: var(--panel-alt); color: var(--text); }
.config-link.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent); color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 600;
}
.config-content { flex: 1; min-width: 0; }

/* ---------- Live Ops ---------- */
.live-ops-layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.live-ops-sidebar {
  flex: 0 0 200px;
  display: flex; flex-direction: column; gap: 0.15rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem;
}
.live-ops-link-disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
@media (max-width: 880px) {
  .live-ops-layout { flex-direction: column; }
  .live-ops-sidebar { flex: 1 1 auto; width: 100%; flex-direction: row; overflow-x: auto; gap: 0.3rem; }
}

/* ---------- Alerts ---------- */
.alert-warning {
  background: rgba(245, 158, 11, 0.12); border: 1px solid var(--warning); color: var(--warning);
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 1rem;
}

/* ---------- Server picker ---------- */
.server-picker-row { display: flex; gap: 0.5rem; }
.server-picker-row input { flex: 1; }
.server-picker-row button { flex-shrink: 0; }
.server-code {
  font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.78rem;
  color: var(--accent); min-width: 64px; flex-shrink: 0;
}

/* ---------- Modals ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(5, 8, 16, 0.7);
  align-items: center; justify-content: center; z-index: 100; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; width: 100%; max-width: 420px; max-height: 85vh;
  display: flex; flex-direction: column; gap: 0.85rem;
}
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-search { margin: 0; }
.modal-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.modal-list { overflow-y: auto; display: flex; flex-direction: column; gap: 0.2rem; }
.modal-list-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.88rem;
}
.modal-list-item:hover { background: var(--panel-alt); }
.modal-subtitle { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.82rem; }

/* ---------- Commander Assignment Editor ---------- */
.commander-editor-modal { max-width: 780px; max-height: 84vh; overflow: hidden; }
.editor-section { border-top: 1px solid var(--border); padding-top: 0.9rem; display: flex; flex-direction: column; gap: 0.55rem; flex-shrink: 0; }
.editor-section:first-of-type { border-top: none; padding-top: 0; }
.editor-section-scroll { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.editor-section-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.editor-section-label { font-size: 0.78rem; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }
.editor-hint { margin: 0; color: var(--muted); font-size: 0.82rem; }
.commander-summary { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.summary-pill {
  font-size: 0.76rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent);
}
.summary-pill.summary-pill-skip { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.commander-card-list { gap: 0.65rem; flex: 1; min-height: 0; overflow-y: auto; padding-right: 0.25rem; }
.commander-card {
  background: var(--panel-raised); border: 1px solid var(--border-light); border-radius: var(--radius);
  padding: 0.75rem 0.85rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.commander-card-head { display: flex; align-items: center; gap: 0.5rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.commander-card-name { font-size: 0.92rem; font-weight: 700; }
.chip-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 0.4rem; }
.chip {
  font-size: 0.78rem; font-weight: 500; padding: 0.45rem 0.5rem; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--panel); border: 1px solid var(--border-light); color: var(--muted);
  text-align: center; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.chip:hover { border-color: var(--accent); color: var(--text); background: var(--panel-alt); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 0 0 1px var(--accent); }
.chip-skip { grid-column: 1 / -1; border-color: var(--danger-soft); color: var(--danger); margin-top: 0.15rem; }
.chip-skip:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.chip-skip.active { background: var(--danger); border-color: var(--danger); color: #fff; box-shadow: 0 0 0 1px var(--danger); }
.modal-footer { border-top: 1px solid var(--border); padding-top: 0.9rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; flex-shrink: 0; }
.modal-footer-hint { margin: 0; color: var(--muted-dim); font-size: 0.76rem; max-width: 360px; }
.modal-footer-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ---------- Attack template wave builder ---------- */
.wave-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.wave-toolbar h3 { margin: 0; font-size: 0.95rem; }
.wave-builder { display: flex; flex-direction: column; gap: 0.85rem; margin-bottom: 0.5rem; }
.wave-card { background: var(--panel-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 0.9rem; display: flex; flex-direction: column; gap: 0.75rem; }
.wave-card-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.wave-card-head h3 { margin: 0; font-size: 0.9rem; }
.wave-controls { display: flex; gap: 0.3rem; }
.wave-controls button { padding: 0.3rem 0.55rem; font-size: 0.78rem; }

.priority-list { display: flex; flex-direction: column; gap: 0.5rem; }
.priority-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--panel-alt); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 0.6rem 0.8rem;
  cursor: grab;
}
.priority-row.dragging { opacity: 0.4; }
.priority-row-handle { font-size: 1rem; color: var(--muted); line-height: 1; user-select: none; }
.priority-row-label { flex: 1; font-size: 0.88rem; }
.wing-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.65rem; }
.wing-col { background: var(--panel); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem; }
.wing-col-title { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.slot-group-label { font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.slot-row { display: flex; gap: 0.35rem; align-items: center; }
.slot-pick-btn {
  flex: 1; text-align: left; font-size: 0.76rem; padding: 0.4rem 0.55rem; background: var(--panel-alt);
  border: 1px dashed var(--border-light); border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-pick-btn.filled { border-style: solid; border-color: var(--accent); }
.slot-clear-btn {
  flex-shrink: 0; width: 22px; height: 22px; padding: 0; border-radius: 50%;
  border: 1px solid var(--border-light); background: var(--bg-soft); color: var(--muted);
  font-size: 0.85rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.slot-clear-btn:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.slot-count { width: 60px; flex-shrink: 0; padding: 0.4rem 0.35rem; font-size: 0.76rem; }
.ast-grid, .rw-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.5rem; }
.raw-json-advanced { margin: 0.75rem 0; }
.raw-json-advanced summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; }
.raw-json-advanced textarea { margin-top: 0.5rem; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.78rem; }

/* ---------- Attack template list ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1100px) { .tpl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .tpl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tpl-grid { grid-template-columns: 1fr; } }
.tpl-card { padding: 1.1rem 1.2rem; position: relative; overflow: hidden; }
.tpl-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, #22d3ee, #6366f1); }
.tpl-card-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 0.2rem; }
.tpl-card-desc { margin-bottom: 0.6rem; }
.tpl-card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.tpl-card-actions form { display: inline-flex; }
.tpl-empty { text-align: center; padding: 2.5rem 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.tpl-form-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; }

/* ---------- Attack template builder: colored section labels ---------- */
.section-dot-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.88rem; margin-bottom: 0.15rem; }
.section-dot-label-sm { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.3rem; font-weight: 600; }
.section-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-tools { background: #3b82f6; box-shadow: 0 0 6px 0 rgba(59, 130, 246, 0.7); }
.dot-troops { background: #22c55e; box-shadow: 0 0 6px 0 rgba(34, 197, 94, 0.7); }
.dot-ast { background: #a855f7; box-shadow: 0 0 6px 0 rgba(168, 85, 247, 0.7); }
.dot-rw { background: #f97316; box-shadow: 0 0 6px 0 rgba(249, 115, 22, 0.7); }

.slot-chip-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.slot-pick-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
  text-align: left; font-size: 0.78rem; padding: 0.4rem 0.6rem; background: var(--panel-alt);
  border: 1px dashed var(--border-light); border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 4.2rem; transition: border-color 0.12s ease, transform 0.12s ease;
}
.slot-pick-btn:hover { transform: translateY(-1px); }
.slot-pick-tool.filled { border-color: #3b82f6; background: rgba(59, 130, 246, 0.12); }
.slot-pick-troop.filled { border-color: #22c55e; background: rgba(34, 197, 94, 0.12); }
.slot-pick-ast.filled { border-color: #a855f7; background: rgba(168, 85, 247, 0.12); }
.slot-pick-rw.filled { border-color: #f97316; background: rgba(249, 115, 22, 0.12); }
.slot-code-tag { font-weight: 600; }
.slot-qty-tag {
  font-size: 0.66rem; font-weight: 700; color: var(--muted);
}

.modal-filter-chips { display: flex; gap: 0.4rem; }
.modal-amount-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.modal-amount-row label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; margin: 0; flex: 1; }
.modal-amount-row input { width: 7rem; margin: 0; }
.modal-list-item.selected { background: var(--accent-soft); }

/* ---------- Misc ---------- */
.muted { color: var(--muted); font-size: 0.85rem; }
.inline-form { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.send-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin-top: 0.5rem; }
.send-form label { flex: 1; min-width: 90px; }
.card-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; flex-wrap: wrap; }
.card-actions form { display: inline-flex; }
.card-title { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 0.4rem; gap: 0.5rem; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.9rem; }
.info-box { background: var(--panel-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 0.85rem 1rem; }
.info-box-label { color: var(--muted); font-size: 0.78rem; }
.info-box-value { font-size: 1.05rem; font-weight: 600; margin-top: 0.15rem; }

/* ---------- Mobile / responsive ---------- */
@media (max-width: 880px) {
  /* `.container` is a `body { display:flex; flex-direction:column }` child,
     which defaults to `min-width: auto` - forcing it to size itself for
     the widest thing inside instead of shrinking to the viewport. Applies
     to any flex-column descendant chain, so a mobile-only `min-width: 0`
     here is cheap insurance even though the actual culprit below (the
     module tile grid) needed its own explicit fix too. */
  .container { padding: 1.1rem 1rem 2.5rem; min-width: 0; }
  .navbar-row { padding: 0.65rem 1rem; gap: 0.75rem; }
  .navbar-tabs { display: none; }
  .nav-user { display: none; }
  #mobile-nav-toggle { display: flex; }
  .navbar-mobile-panel {
    flex-direction: column; gap: 0.15rem; padding: 0 1rem 0.85rem;
    max-height: 0; overflow: hidden; opacity: 0;
    transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
  }
  .navbar-mobile-panel.open { display: flex; max-height: 70vh; opacity: 1; overflow-y: auto; }
  .navbar-mobile-panel a {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-size: 0.92rem; font-weight: 500;
  }
  .navbar-mobile-panel a:hover { background: var(--panel-alt); color: var(--text); }
  .navbar-mobile-panel a.active { color: #fff; background: linear-gradient(90deg, #6366f1, #a855f7); }
  .navbar-mobile-divider { border-top: 1px solid var(--border); margin: 0.4rem 0; }
  .navbar-mobile-user { padding: 0.4rem 0.75rem; color: var(--muted-dim); font-size: 0.8rem; }
  .page-header h1 { font-size: 1.25rem; }

  .bot-layout { flex-direction: column; }
  .config-sidebar {
    position: static; flex: 1 1 auto; width: 100%;
    flex-direction: row; overflow-x: auto; gap: 0.3rem; padding: 0.6rem;
  }
  .config-sidebar-title { display: none; }
  .config-link { white-space: nowrap; flex-shrink: 0; }

  .card, .auth-card { padding: 1.1rem; }
  .card-grid { grid-template-columns: 1fr; }
  .function-grid { grid-template-columns: 1fr; }
  .field-grid-2 { grid-template-columns: 1fr; }
  .field-grid-3 { grid-template-columns: 1fr; }
  .send-form { flex-direction: column; align-items: stretch; }
  .send-form label { min-width: 0; }
  .toolbar { gap: 0.45rem; }
  .modal { max-width: 100%; }
  .wing-grid { grid-template-columns: 1fr; }
  .ast-grid, .rw-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .brand-tagline { display: none; }
  .server-picker-row { flex-direction: column; align-items: stretch; }
}

/* ---------- Produce Components (collapsible kingdom/building sections) ---------- */
.pc-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
}
.pc-summary::-webkit-details-marker { display: none; }
.pc-summary::before {
  content: "›";
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--muted-dim);
  font-weight: 700;
}
details[open] > .pc-summary::before { transform: rotate(90deg); }
.pc-kingdom {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8rem;
  margin-bottom: 0.8rem;
}
.pc-building {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  margin: 0.6rem 0;
}
.pc-building .pc-summary { font-weight: 600; margin-bottom: 0.5rem; }

.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table tbody tr:hover { background: var(--panel-alt); }
.admin-sortable { cursor: pointer; user-select: none; }
.admin-sortable:hover { color: var(--text); }
.admin-sort-arrow { font-size: 0.65rem; color: #a855f7; margin-left: 0.2rem; }
.admin-user-cell { display: flex; align-items: center; gap: 0.6rem; }
.admin-avatar {
  width: 1.8rem; height: 1.8rem; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
  font-size: 0.78rem; font-weight: 700;
}
.admin-credits-positive { color: var(--success); font-weight: 600; }
.admin-credits-zero { color: var(--muted-dim); }
.admin-running-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 0.4rem;
  background: var(--success); box-shadow: 0 0 6px 0 rgba(34, 197, 94, 0.8);
}
.admin-actions { display: flex; gap: 0.5rem; align-items: center; }
.admin-credit-form { display: flex; gap: 0.4rem; align-items: center; }
.admin-credit-form input[type="number"] { width: 6.5rem; padding: 0.3rem 0.5rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-alt); color: var(--text); }

/* ---------- Pricing page ---------- */
.discord-topup-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; text-decoration: none; color: #fff;
  background: linear-gradient(90deg, #5865F2, #7289DA); border-radius: 1rem;
  padding: 1.25rem 1.5rem; margin: 2rem 0 0; box-shadow: 0 12px 28px -14px rgba(88, 101, 242, 0.65);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.discord-topup-banner:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -14px rgba(88, 101, 242, 0.8); }
.discord-topup-banner-icon { font-size: 1.8rem; flex-shrink: 0; }
.discord-topup-banner-text { flex: 1; font-size: 0.95rem; line-height: 1.4; }
.discord-topup-banner-text strong { font-size: 1.05rem; }
.discord-topup-banner-cta {
  flex-shrink: 0; font-weight: 700; white-space: nowrap; background: rgba(255, 255, 255, 0.18);
  padding: 0.6rem 1.1rem; border-radius: 0.6rem;
}
.pricing-hero { text-align: center; padding: 1.5rem 1rem 2rem; }
.pricing-hero h1 { font-size: 2rem; margin: 0.6rem 0 0.4rem; }
.pricing-eyebrow { display: inline-block; }
.pricing-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; max-width: 1280px; margin: 0 auto; }
.pricing-grid-tight { max-width: none; }
@media (max-width: 760px) {
  .pricing-grid, .pricing-grid-tight { grid-template-columns: 1fr; }
  .pricing-feature-list { column-count: 1; }
}
.pricing-card {
  text-align: left; position: relative; display: flex; flex-direction: column; overflow: hidden;
  padding: 2rem 1.75rem 1.75rem; border-radius: 1rem; background: var(--panel);
  transition: transform 0.18s ease, box-shadow 0.18s ease; box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}
.pricing-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, #22c55e, #06b6d4); }
.pricing-card-highlight::before { background: linear-gradient(90deg, #a855f7, #ec4899); }
.pricing-card:hover { transform: translateY(-4px); box-shadow: 0 16px 40px -16px rgba(0, 0, 0, 0.5); }
.pricing-card-highlight { border-color: #a855f7; box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.5), 0 12px 32px -12px rgba(168, 85, 247, 0.4); }
.pricing-popular {
  position: absolute; top: 0.9rem; right: -2.6rem; transform: rotate(40deg); width: 10rem; text-align: center;
  background: linear-gradient(90deg, #a855f7, #ec4899); color: #fff; font-size: 0.68rem; font-weight: 700;
  padding: 0.3rem 0; box-shadow: 0 4px 12px -2px rgba(168, 85, 247, 0.6); white-space: nowrap; letter-spacing: 0.02em;
}
.pricing-card-icon { font-size: 1.6rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: 0.75rem; background: var(--panel-alt); margin-bottom: 0.9rem; }
.pricing-card-title { font-size: 1.35rem; font-weight: 800; }
.pricing-card-tagline { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 0; }
.pricing-card-price-row { display: flex; align-items: baseline; gap: 0.3rem; margin: 1.1rem 0 0.15rem; }
.pricing-card-price { font-size: 2.6rem; font-weight: 800; background: linear-gradient(90deg, #22c55e, #06b6d4); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pricing-card-price-full { background: linear-gradient(90deg, #a855f7, #ec4899); -webkit-background-clip: text; background-clip: text; }
.pricing-card-period { font-size: 1rem; font-weight: 500; -webkit-text-fill-color: var(--muted); color: var(--muted); }
.pricing-card-sub { color: var(--muted); font-size: 0.82rem; margin-bottom: 1.4rem; padding-bottom: 1.3rem; border-bottom: 1px solid var(--border); }
.pricing-card-cta {
  display: block; margin-top: 1.4rem; text-align: center; color: #fff; font-weight: 700;
  padding: 0.75rem 1rem; border-radius: 0.6rem; text-decoration: none; transition: filter 0.15s ease, transform 0.15s ease;
}
.pricing-card-cta:hover { filter: brightness(1.12); transform: translateY(-1px); }
.pricing-cta-light { background: linear-gradient(90deg, #22c55e, #06b6d4); box-shadow: 0 8px 20px -8px rgba(6, 182, 212, 0.55); }
.pricing-cta-full { background: linear-gradient(90deg, #a855f7, #ec4899); box-shadow: 0 8px 20px -8px rgba(217, 70, 239, 0.55); }
.pricing-feature-list { list-style: none; padding: 0; margin: 0; text-align: left; font-size: 0.87rem; flex: 1; column-count: 2; column-gap: 1.25rem; }
.pricing-feature-list li { display: flex; align-items: center; gap: 0.6rem; break-inside: avoid; margin-bottom: 0.65rem; }
.pricing-check {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 1.25rem; height: 1.25rem; border-radius: 50%; font-size: 0.68rem; font-weight: 800; color: #fff;
}
.pricing-check-light { background: linear-gradient(135deg, #22c55e, #06b6d4); }
.pricing-check-full { background: linear-gradient(135deg, #a855f7, #ec4899); }
.pricing-modules-hero { text-align: center; padding: 0.5rem 1rem 1.75rem; }
.pricing-modules-eyebrow { display: inline-block; color: #a855f7; border-color: #a855f7; background: rgba(168, 85, 247, 0.12); margin-bottom: 0.8rem; }
.pricing-modules-hero h2 { font-size: 1.9rem; margin: 0 0 0.4rem; }
.pricing-modules-highlight { background: linear-gradient(90deg, #a855f7, #ec4899); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pricing-module-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; max-width: 1280px; margin: 0 auto; }
/* Mobile only - `.pricing-module-tile-grid` is a flex item of `.container`
   (`body { display:flex; flex-direction:column }`), and as a flex child
   its automatic minimum width is based on fitting every possible 160px
   auto-fill track at once rather than the space actually available -
   confirmed live this forced the grid (and the whole page) out to
   ~1232px wide on a 390px viewport instead of wrapping. A fixed,
   shrinkable 2-column track list (`minmax(0, 1fr)`, same technique the
   `.pricing-grid` desktop rule above already uses) sidesteps auto-fill's
   sizing quirk entirely. Placed right after the base rule (not in the
   earlier general mobile media block) because a rule declared later in
   the file wins a same-specificity tie regardless of which one's media
   query actually matches - putting it up top let the unscoped desktop
   rule below silently override it. Desktop (the ruleset above, unscoped)
   is untouched, per the user. */
@media (max-width: 880px) {
  .pricing-module-tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.pricing-module-tile {
  position: relative; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 0.9rem;
  padding: 1.4rem 1rem 1.1rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.pricing-module-tile:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 12px 24px -14px rgba(0,0,0,0.55); }
.pricing-module-tile-icon {
  font-size: 1.6rem; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center;
  border-radius: 0.75rem; background: var(--panel); filter: saturate(1.3);
}
.pricing-module-tile-label { font-weight: 700; font-size: 0.88rem; line-height: 1.25; }
.pricing-module-soon {
  position: absolute; top: 0.6rem; right: 0.6rem; font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border-light); border-radius: 999px; padding: 0.1rem 0.45rem;
}
.pricing-module-tiers { display: flex; gap: 0.35rem; justify-content: center; flex-wrap: wrap; }
.badge-tier-light { color: #06b6d4; border-color: #06b6d4; background: rgba(6, 182, 212, 0.12); font-weight: 600; }
.badge-tier-full { color: #d946ef; border-color: #d946ef; background: rgba(217, 70, 239, 0.12); font-weight: 600; }

/* Bot Timetable grid. Attack Scheduling's mode toggle reuses the existing
   .pill-group/.pill pattern instead of a one-off style. */
.tt-table { border-collapse: collapse; font-size: 0.8rem; }
.tt-table th, .tt-table td { padding: 0; text-align: center; }
.tt-table th { padding: 0.25rem 0.5rem; position: sticky; top: 0; background: var(--panel); }
.tt-time { padding: 0 0.5rem; white-space: nowrap; color: var(--muted); }
.tt-cell { width: 18px; height: 14px; margin: 1px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; user-select: none; }
.tt-cell.tt-active { background: #2ecc71; border-color: #2ecc71; }
/* Greys out Attack Scheduling's mode/order controls while the feature's
   own Enable toggle is off - they still submit (see the module docstring
   at as-dependent-fields' script), just aren't interactive-looking. */
.disabled-block { opacity: 0.45; pointer-events: none; }
