/* ==========================================================================
   Moglipuff Admin Panel — Discord-style dark theme
   All colors via CSS custom properties. No hardcoded hex anywhere else.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Custom properties (exact Discord dark mode values)
   --------------------------------------------------------------------------- */
:root {
  /* Surface layers */
  --bg-modifier-active:   #18191c;
  --bg-tertiary:          #202225;
  --bg-secondary:         #2f3136;
  --bg-primary:           #36393f;
  --bg-secondary-alt:     #292b2f;
  --bg-floating:          #18191c;

  /* Interactive surfaces */
  --bg-modifier-hover:    #32353b;
  --bg-modifier-selected: #393c43;
  --input-bg:             #202225;
  --input-border:         #040405;

  /* Text */
  --text-normal:          #dcddde;
  --text-muted:           #72767d;
  --text-link:            #00b0f4;
  --header-primary:       #ffffff;
  --header-secondary:     #b9bbbe;
  --interactive-normal:   #b9bbbe;
  --interactive-hover:    #dcddde;
  --interactive-active:   #ffffff;
  --interactive-muted:    #4f545c;

  /* Blurple accent */
  --brand-500:            #5865f2;
  --brand-560:            #4752c4;
  --brand-600:            #3c45a5;

  /* Status colors */
  --status-positive:      #3ba55c;
  --status-positive-bg:   #2d7d46;
  --status-warning:       #faa61a;
  --status-warning-bg:    #c27d0e;
  --status-danger:        #ed4245;
  --status-danger-bg:     #a12d2f;
  --status-info:          #5865f2;

  /* Borders */
  --background-modifier-accent: rgba(79, 84, 92, 0.15);
  --channeltextarea-background: #40444b;

  /* Scrollbar */
  --scrollbar-thin-thumb: #202225;
  --scrollbar-thin-track: transparent;

  /* Back-compat aliases — rules and templates grew alternate names for the
     same palette slots over time; without these definitions every usage
     silently resolved to `initial` (no color at all): 14 rules including the
     .alert-* borders, .badge-op-* backgrounds, .progress-success/error text,
     the builder detail background, and the staged preview's green "New
     Version" column (2026-07-16 UX review). Alias, don't rename — the
     alternate names are scattered across templates and inline styles. */
  --status-green:         var(--status-positive);
  --status-red:           var(--status-danger);
  --status-yellow:        var(--status-warning);
  --status-success:       var(--status-positive);
  --background-secondary: var(--bg-secondary);
  --border-subtle:        var(--background-modifier-accent);
  --brand:                var(--brand-500);
  --red:                  var(--status-danger);
  --text-primary:         var(--text-normal);

  /* Shadows */
  --elevation-low:    0 1px 0 rgba(4,4,5,.2), 0 1.5px 0 rgba(6,6,7,.05), 0 2px 0 rgba(4,4,5,.05);
  --elevation-medium: 0 4px 4px rgba(0,0,0,.16);
  --elevation-high:   0 8px 16px rgba(0,0,0,.24);

  /* Typography */
  --font-primary: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-code:    Consolas, 'Andale Mono WT', 'Andale Mono', 'Lucida Console',
                  'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Monaco, 'Courier New', monospace;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 48px;
}

/* ---------------------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-modifier-active);
  color: var(--text-normal);
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
html { scroll-behavior: smooth; }

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
   Scrollbar
   --------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thin-thumb);
  border-radius: 4px;
  border: 2px solid var(--bg-primary);
}
/* Firefox — without this every dark panel got the OS's light scrollbars. */
* {
  scrollbar-color: var(--scrollbar-thin-thumb) transparent;
  scrollbar-width: thin;
}

/* ---------------------------------------------------------------------------
   Layout shell
   --------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--elevation-low);
  z-index: 10;
}

.sidebar-header {
  padding: 16px 12px 8px;
  border-bottom: 1px solid var(--background-modifier-accent);
  margin-bottom: 4px;
}

.sidebar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--header-primary);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: var(--brand-500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-section-label {
  padding: 16px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-secondary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin: 1px 8px;
  border-radius: 4px;
  color: var(--interactive-normal);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.1s ease, color 0.1s ease;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
  text-decoration: none;
}
.nav-item.active {
  background: var(--bg-modifier-selected);
  color: var(--interactive-active);
}
.nav-item-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 15px;
  /* The sidebar mixes color emoji (👥 🗄️ 🛠️) with monochrome glyphs (⊞ ⌨ ⚙);
     desaturating the emoji gives every row the same visual weight. */
  filter: grayscale(1) brightness(1.4);
  opacity: 0.9;
}
.nav-item.active .nav-item-icon,
.nav-item:hover .nav-item-icon { opacity: 1; }

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* Header bar */
.header-bar {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-secondary);
  box-shadow: var(--elevation-low);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 5;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--bg-secondary-alt);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-normal);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--interactive-muted);
  flex-shrink: 0;
}

.status-green  .status-dot { background: var(--status-positive); }
.status-red    .status-dot { background: var(--status-danger); animation: none; }
.status-yellow .status-dot { background: var(--status-warning); animation: pulse 1.8s ease-in-out infinite; }
.status-blue   .status-dot { background: var(--brand-500); animation: pulse 1.8s ease-in-out infinite; }
.status-grey   .status-dot { background: var(--interactive-muted); }

/* Scan progress badge */
.status-scan {
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.4);
  padding: 3px 10px 3px 6px;
  gap: 6px;
}

.scan-ring {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.scan-ring-bg {
  fill: none;
  stroke: var(--bg-modifier-selected);
  stroke-width: 3.5;
}

.scan-ring-fill {
  fill: none;
  stroke: var(--brand-500);
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

/* Gentle "breathing" pulse for live status dots — eased opacity + a slight
   scale reads as a smooth heartbeat instead of the old hard opacity flicker. */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.8); }
}

/* Per-mod "hold" pin toggle in the Mod Manager name cell */
.mod-pin {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  margin-left: 4px;
  opacity: 0.45;           /* quiet until hovered or active — 0.3 read as disabled (2026-07-16) */
  filter: grayscale(1);
  vertical-align: middle;
  color: var(--text-normal);
}
.mod-pin:hover:not(:disabled) { opacity: 0.9; }
.mod-pin.pinned { opacity: 1; filter: none; }
.mod-pin:disabled { opacity: 0.15; cursor: not-allowed; }
/* Forward-compat ⇄ state colors — the tiny ✓/✕ suffix alone was easy to miss */
.mod-pin.fc-allow  { color: var(--status-positive); opacity: 1; filter: none; }
.mod-pin.fc-forbid { color: var(--status-danger);   opacity: 1; filter: none; }

/* Sidebar build-version label, pinned to the bottom */
.sidebar-version {
  margin-top: auto;
  padding: 10px 16px;
  font-size: 11px;
  opacity: 0.6;
}

/* Dashboard "CONTROLS" subsection inside the server-info card */
.card-controls {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--bg-modifier-selected, rgba(255,255,255,.08));
}
.card-controls-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Header activity badges (scans, uploads, downloads, compression jobs) */
.activity-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* Badges are clickable anchors → strip link styling, keep badge look */
a.status-badge { text-decoration: none; cursor: pointer; }
a.status-badge:hover { filter: brightness(1.15); }

/* Completion colour variants for the scan-style badge background/border */
.status-scan.status-green {
  background: rgba(59, 165, 92, 0.14);
  border-color: rgba(59, 165, 92, 0.5);
}
.status-scan.status-green .scan-ring-fill { stroke: var(--status-green); }
.status-scan.status-red {
  background: rgba(237, 66, 69, 0.14);
  border-color: rgba(237, 66, 69, 0.5);
}

/* Indeterminate spinner for activities with no known total */
.activity-spinner {
  /* inline-block is REQUIRED: CSS transform (the rotate animation) is ignored on
     inline elements, so without this the spinner just sits there with its top lit. */
  display: inline-block;
  vertical-align: middle;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(88, 101, 242, 0.3);
  border-top-color: var(--brand-500);
  flex-shrink: 0;
  animation: activity-spin 0.8s linear infinite;
}
@keyframes activity-spin { to { transform: rotate(360deg); } }

/* Indeterminate progress bar — for downloads where the source doesn't report
   byte-level progress. A sliver slides back and forth to signal "working". */
.progress-indeterminate { overflow: hidden; position: relative; }
.progress-indeterminate .progress-bar-fill {
  width: 35% !important;
  position: absolute;
  animation: progress-indeterminate 1.2s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0%   { left: -35%; }
  100% { left: 100%; }
}

/* Page content */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---------------------------------------------------------------------------
   Typography helpers
   --------------------------------------------------------------------------- */
.page-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 16px;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-secondary);
  margin-bottom: 8px;
  margin-top: 16px;
}

.text-muted { color: var(--text-muted); font-size: 12px; }
.text-normal { color: var(--text-normal); }

/* ---------------------------------------------------------------------------
   Cards / Panels
   --------------------------------------------------------------------------- */
.card {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: var(--elevation-low);
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 12px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--background-modifier-accent);
}
.card-row:last-child { border-bottom: none; }
.card-row-label { color: var(--text-muted); font-size: 14px; }
.card-row-value { color: var(--text-normal); font-size: 14px; font-weight: 500; }

/* Status card (Steam-style with colored left border) */
.status-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: var(--elevation-low);
  padding: 16px;
  border-left: 4px solid var(--interactive-muted);
  margin-bottom: 12px;
}
.status-card.online  { border-left-color: var(--status-positive); }
.status-card.offline { border-left-color: var(--status-danger); }
.status-card.warning { border-left-color: var(--status-warning); }
.status-card.updating { border-left-color: var(--brand-500); }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 16px;
  min-height: 38px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.17s ease;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-primary);
}

.btn-primary {
  background: var(--brand-500);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-560); }
.btn-primary:active:not(:disabled) { background: var(--brand-600); }

.btn-danger {
  background: var(--status-danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #c03537; }

.btn-success {
  background: var(--status-positive);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #2d7d46; }
.btn-success:active:not(:disabled) { background: #25683a; }

.btn-secondary {
  background: #4f545c;
  color: #fff;
}
.btn-secondary:hover:not(:disabled) { background: #5d6269; }

.btn-ghost {
  background: transparent;
  color: var(--text-normal);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-modifier-hover); }

.btn-sm {
  min-height: 28px;
  padding: 2px 10px;
  font-size: 12px;
}

.btn:disabled, .btn[disabled] {
  background: var(--bg-modifier-active);
  color: var(--interactive-muted);
  cursor: not-allowed;
}

/* Keyboard focus — buttons and nav links previously had no themed
   :focus-visible state at all (2026-07-16 review). */
.btn:focus-visible,
.nav-item:focus-visible,
.tab:focus-visible,
.mod-pin:focus-visible,
.builder-trash:focus-visible,
.builder-caret:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* Small input variant — a default .form-input (10px padding, 16px font)
   towered over the btn-sm buttons it sits beside in inline control rows
   (Recovery, manual notes, whitelist add; 2026-07-16 review). */
.input-sm {
  padding: 5px 8px;
  font-size: 13px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ---------------------------------------------------------------------------
   Inputs / Forms
   --------------------------------------------------------------------------- */
input, textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 3px;
  color: var(--text-normal);
  padding: 10px;
  font-size: 16px;
  font-family: var(--font-primary);
  width: 100%;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand-500);
  outline: none;
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.3);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
select option {
  background: var(--bg-secondary);
}

/* Live mod-list search (public home page) — right-aligned above the table. */
.mod-search-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.mod-search-input {
  width: 260px;
  max-width: 100%;
  padding: 8px 12px;
  font-size: 14px;
}
@media (max-width: 600px) {
  .mod-search-input { width: 100%; }
}

/* Single source of truth for form rows/labels/hints — these were defined a
   second time in the Settings section with conflicting values, and the later
   copy silently restyled every form (2026-07-17 consolidation). The values
   below are the EFFECTIVE computed set the app already rendered with (later
   rule per property), so nothing changes visually. */
.form-row {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--header-secondary);
  margin-bottom: 6px;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.form-hint code { background: var(--input-bg); padding: 1px 4px; border-radius: 3px; }

/* Checkbox-with-label row — the markup already used this class everywhere
   but each instance carried the same inline flex styles (2026-07-17). */
.checkbox-row { display: flex; align-items: center; gap: 8px; }

/* Monospace data cell (versions, filenames, hashes) — replaces the identical
   inline style repeated across every table (2026-07-17). */
.cell-mono { font-family: var(--font-code); font-size: 12px; }

/* Checkbox */
input[type="checkbox"] {
  width: auto;
  accent-color: var(--brand-500);
  cursor: pointer;
}

/* Masked input (API keys) */
input.masked { font-family: var(--font-code); letter-spacing: 2px; }

/* ---------------------------------------------------------------------------
   Tables (Steam-inspired, Discord colors)
   --------------------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
}

/* Compact, fits-at-100%-zoom variant for wide tables (mod manager). Uses a fixed
   layout so the 8 columns share the available width and the table can NEVER grow
   past its wrapper.

   IMPORTANT: the headers are sortable <button class="th-sort"> elements injected
   by main.js — the BUTTON (and its .th-sort-label span), not the <th>, owns the
   text and carries its own font/padding/white-space. So the compact typography
   MUST target .th-sort / .th-sort-label. The earlier attempt only styled <th>,
   so the 11px `white-space:nowrap` buttons kept overflowing their narrow columns
   and pushed the table off-screen (the horizontal scrollbar), and the <th> also
   got double padding (its own + the button's) — the "awkward" spacing. We deliberately
   do NOT use table-layout:fixed or hard percentage widths; those produced cramped,
   misaligned-looking columns. Auto layout keeps each column's <th>/<td> the same
   width (so they stay aligned) and shrinks columns to fit once the headers can wrap. */
.mods-compact thead th { padding: 0; vertical-align: bottom; }   /* button supplies the padding */
.mods-compact .th-sort {
  font-size: 10px;
  letter-spacing: 0.2px;
  padding: 6px 6px;
  gap: 3px;
  white-space: normal;        /* wrap header text only when the column is too narrow */
  align-items: flex-end;
}
.mods-compact .th-sort-label { white-space: normal; word-break: break-word; }
.mods-compact tbody td {
  padding: 6px 6px;
  font-size: 12px;
  word-break: break-word;
  vertical-align: top;
}
/* Show the per-cell "(MC x.x.x)" sub-labels — the column headers do NOT carry the
   MC version, so these are real information, not redundant. Kept small + muted. */
.mods-compact .mc-sublabel { display: inline; font-size: 10px; opacity: 0.7; }

/* Stale duplicate rows (Mod Manager): leftovers from past soft updates —
   visually parked so they can't be mistaken for live rows (2026-07-16 review:
   Sodium ×3 all rendered identically, two with bogus "Update" badges). */
.row-stale td { opacity: 0.42; }
.row-stale:hover td { opacity: 0.7; }
.row-stale td:first-child { text-decoration: line-through; text-decoration-color: var(--text-muted); }
.row-stale .badge { text-decoration: none; }

/* Fixed layout + explicit proportions for the MOD MANAGER table specifically
   (#mods-table, 8 columns) so the version columns aren't squeezed by long mod
   names. Scoped by id — the Modpack Builder table shares the .mods-compact class
   but has a DIFFERENT column set, so it must NOT inherit these 8-column widths
   (it keeps auto layout). Percentages sum to 100. */
#mods-table { table-layout: fixed; width: 100%; }
#mods-table th:nth-child(1), #mods-table td:nth-child(1) { width: 21%; }  /* Mod Name */
#mods-table th:nth-child(2), #mods-table td:nth-child(2) { width: 12%; }  /* Installed */
#mods-table th:nth-child(3), #mods-table td:nth-child(3) { width: 9%;  }  /* Source */
#mods-table th:nth-child(4), #mods-table td:nth-child(4) { width: 6%;  }  /* Side */
#mods-table th:nth-child(5), #mods-table td:nth-child(5) { width: 14%; }  /* Soft Update */
#mods-table th:nth-child(6), #mods-table td:nth-child(6) { width: 14%; }  /* Full Update */
#mods-table th:nth-child(7), #mods-table td:nth-child(7) { width: 15%; }  /* Mod Newest Version */
#mods-table th:nth-child(8), #mods-table td:nth-child(8) { width: 9%;  }  /* Status */

/* ── Mod config editor (/server-config) ────────────────────────────────── */
.config-editor { display: grid; grid-template-columns: 280px 1fr; gap: 12px; align-items: start; }
.config-file-list { background: #1e2030; border-radius: 6px; padding: 8px; max-height: 72vh; overflow-y: auto; }
.config-file-list ul { list-style: none; margin: 6px 0 0; padding: 0; }
.config-file-list li { margin: 0; }
.config-filter { width: 100%; box-sizing: border-box; padding: 6px 8px; font-size: 12px;
  background: #14161f; color: inherit; border: 1px solid #2a2d3a; border-radius: 4px; }
.config-file-item { display: block; width: 100%; text-align: left; background: none; border: none;
  color: inherit; font-size: 12px; padding: 5px 6px; border-radius: 4px; cursor: pointer;
  word-break: break-all; font-family: inherit; }
.config-file-item:hover { background: #2a2d3a; }
.config-file-item.active { background: #3a3f55; font-weight: 600; }
.config-edit-pane { display: flex; flex-direction: column; min-width: 0; }
.config-edit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.config-textarea { width: 100%; box-sizing: border-box; min-height: 60vh; resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; line-height: 1.5;
  background: #14161f; color: #e6e6e6; border: 1px solid #2a2d3a; border-radius: 6px; padding: 10px;
  white-space: pre; tab-size: 2; }
.config-status { min-height: 18px; font-size: 12px; margin-top: 6px; }
@media (max-width: 800px) { .config-editor { grid-template-columns: 1fr; } }

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: var(--bg-secondary-alt);
}
thead th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-secondary);
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--background-modifier-accent);
  transition: background-color 0.1s ease;
}
tbody tr:nth-child(even) { background: rgba(0,0,0,.06); }
tbody tr:hover { background: var(--bg-modifier-hover); }
tbody td {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-normal);
}

/* ---------------------------------------------------------------------------
   Sortable table headers (generic, reusable)

   Opt a table in with class="sortable-table"; main.js (initSortableTables)
   wires up the headers. Each sortable <th> declares data-sort-type
   ("text" | "number" | "version"; default "text"), and exactly one column is
   marked data-sort-default (sorted ascending on load and used as the secondary
   tiebreaker when another column is active). A header opts out with
   data-sort-type="none". Inactive columns show a small up/down arrow pair;
   the active column shows a single larger arrow — ▲ = ascending, ▼ =
   descending (the previous inverted mapping fought every other app's
   convention; 2026-07-16 review).
   --------------------------------------------------------------------------- */
th.th-sortable { padding: 0; }   /* the inner button supplies the padding */

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 8px 12px;
  margin: 0;
  background: none;
  border: 0;
  cursor: pointer;
  /* match the static thead th typography */
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: inherit;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}
.th-sort:hover { color: var(--text-normal); }
.th-sort:focus-visible {
  outline: 2px solid var(--brand, #5865f2);
  outline-offset: -2px;
}

.th-sort-arrows {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 0.65;
  flex-shrink: 0;
}
.th-arrow {
  font-size: 7px;
  color: var(--text-muted);
  opacity: 0.45;
  transition: opacity 0.1s ease, color 0.1s ease;
}
.th-sort:hover .th-arrow { opacity: 0.75; }

/* Active column → a single larger arrow (▲ asc, ▼ desc). */
th.sort-asc  .th-arrow-down,
th.sort-desc .th-arrow-up { display: none; }
th.sort-asc  .th-arrow-up,
th.sort-desc .th-arrow-down {
  font-size: 11px;
  opacity: 1;
  color: var(--text-normal);
}

/* ---------------------------------------------------------------------------
   Badges (inline status pills)
   --------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  /* Base look so a bare .badge (Settings "Current" session) renders as a
     pill instead of naked uppercase text (2026-07-16 review). */
  background: var(--bg-modifier-selected);
  color: var(--text-normal);
}
.badge-green  { background: var(--status-positive-bg); color: #57f287; }
.badge-red    { background: var(--status-danger-bg);   color: #ff5c5c; }
.badge-yellow { background: var(--status-warning-bg);  color: #fee75c; }
.badge-blue   { background: rgba(88,101,242,.2);        color: #8b9cf8; }
.badge-grey   { background: #4f545c;                   color: #b9bbbe; }
/* Mod-source badges (Modrinth/CurseForge/GitHub) — deliberately NEUTRAL so
   green/yellow keep their status meaning inside the mods tables (2026-07-16:
   "CurseForge in warning yellow" read as a problem with the mod). */
.badge-source {
  background: transparent;
  border: 1px solid var(--interactive-muted);
  color: var(--interactive-normal);
  padding: 1px 7px;
}

/* ---------------------------------------------------------------------------
   Dividers
   --------------------------------------------------------------------------- */
hr, .divider {
  border: none;
  border-top: 1px solid var(--background-modifier-accent);
  margin: 12px 0;
}

/* ---------------------------------------------------------------------------
   Progress bars
   --------------------------------------------------------------------------- */
.progress-bar {
  background: var(--bg-modifier-active);
  border-radius: 2px;
  overflow: hidden;
  height: 6px;
  width: 100%;
}
.progress-bar-fill {
  height: 100%;
  background: var(--brand-500);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.progress-bar-fill.danger { background: var(--status-danger); }
.progress-bar-fill.success { background: var(--status-positive); }

/* Storage bar */
.storage-bar {
  display: flex;
  height: 10px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
  margin: 8px 0;
}
.storage-bar-segment { height: 100%; }

/* ---------------------------------------------------------------------------
   Console / Log panel
   --------------------------------------------------------------------------- */
.console-panel {
  background: var(--channeltextarea-background);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-code);
  font-size: 13px;
  color: var(--text-normal);
  overflow-y: auto;
  /* NOTE: no `white-space: pre-wrap` here. The panel must NOT preserve
     whitespace, or the newline + indentation Jinja emits between each
     server-rendered <div class="console-line"> renders as a blank line,
     producing big gaps on initial load. Each .console-line keeps its own
     pre-wrap below so stack-trace indentation is still preserved. The live
     WebSocket path appends nodes with no whitespace text nodes, which is why
     only the initial load was affected. */
  word-break: break-all;
  min-height: 300px;
  max-height: calc(100vh - 260px);
  line-height: 1.3;
}

/* Each console line is its own block — keep them tight so output reads like a
   real terminal instead of double-spaced (the panel's pre-wrap + per-div line
   height previously left big gaps). */
.console-line {
  margin: 0;
  padding: 0;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}
/* Belt-and-suspenders: a line that ended up with no content at all takes no
   vertical space (no stray blank rows / gaps). */
.console-line:empty { display: none; }

.console-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
/* .console-input lives in the "Console page additions" section below — the
   older duplicate definition here was fully shadowed by it and has been
   removed (2026-07-17 consolidation). */

/* Log level colors */
.log-info    { color: var(--text-normal); }
.log-warning { color: var(--status-warning); }
.log-error   { color: var(--status-danger); }
.log-debug   { color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg-primary);
  border-radius: 4px;
  box-shadow: var(--elevation-high);
  padding: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-header {
  font-size: 20px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 4px;
}
.modal-subheader {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-normal); }

/* Update progress steps. The old .progress-list markup no longer exists —
   the modal renders .progress-step rows (partials/update_progress.html); the
   fixed icon width now targets the live markup, which also fixes the
   misaligned step icons (2026-07-17 consolidation). */
.progress-step .step-icon { width: 18px; text-align: center; flex-shrink: 0; }
.step-pending  { color: var(--text-muted); }
.step-active   { color: var(--status-warning); }
.step-complete { color: var(--status-positive); }
.step-failed   { color: var(--status-danger); }

/* ---------------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-modifier-active);
}
.login-box {
  background: var(--bg-secondary);
  border-radius: 8px;
  box-shadow: var(--elevation-high);
  padding: 32px;
  width: 100%;
  max-width: 400px;
}
.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--header-primary);
  text-align: center;
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}
.login-error {
  background: var(--status-danger-bg);
  color: #ff5c5c;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------------
   Dashboard grid
   --------------------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   Notification / Alert banners
   --------------------------------------------------------------------------- */
.banner {
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* One visual weight for all banner types — the old solid success/warning/
   danger backgrounds shouted next to the tinted info banner and the tinted
   .alert-* family (2026-07-16 review). */
.banner-info    { background: rgba(88,101,242,.15); color: #8b9cf8; border: 1px solid rgba(88,101,242,.3); }
.banner-success { background: rgba(59,165,92,.14);  color: #57f287; border: 1px solid rgba(59,165,92,.45); }
.banner-warning { background: rgba(250,166,26,.12); color: #fee75c; border: 1px solid rgba(250,166,26,.45); }
.banner-danger  { background: rgba(237,66,69,.14);  color: #ff5c5c; border: 1px solid rgba(237,66,69,.5); }

/* ---------------------------------------------------------------------------
   Tabs (Plex sub-navigation)
   --------------------------------------------------------------------------- */
.tab-bar {
  display: flex;
  border-bottom: 2px solid var(--background-modifier-accent);
  margin-bottom: 20px;
  gap: 4px;
}
.tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--interactive-normal);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  text-decoration: none;
}
.tab:hover { color: var(--interactive-hover); text-decoration: none; }
.tab.active {
  color: var(--interactive-active);
  border-bottom-color: var(--brand-500);
}

/* ---------------------------------------------------------------------------
   File browser — the .file-tree/.file-entry/.file-name component this section
   styled no longer exists in any template; the surviving .file-icon/.file-size/
   .file-actions rules were merged into the "Plex library / file browser"
   section (the only consumer; 2026-07-17 consolidation).
   --------------------------------------------------------------------------- */

/* ---------------------------------------------------------------------------
   Session cards — consolidated into the "Plex overview / sessions" section
   below (this older duplicate .session-card was almost fully shadowed by it;
   its surviving margin-bottom moved there; 2026-07-17 consolidation).
   --------------------------------------------------------------------------- */
.session-card-title {
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 4px;
}
.session-progress {
  margin-top: 8px;
}

/* ---------------------------------------------------------------------------
   Utility classes
   --------------------------------------------------------------------------- */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--header-secondary); margin-bottom: 6px; }
.empty-state-text { font-size: 14px; }

/* HTMX loading indicator */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ---------------------------------------------------------------------------
   Alerts / notices
   --------------------------------------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-size: 14px;
  border-left: 4px solid transparent;
}
.alert a { color: var(--text-link); text-decoration: underline; }
.alert-warning  { background: rgba(250,166,26,.12);  border-color: var(--status-yellow); color: var(--text-normal); }
.alert-danger   { background: rgba(237,66,69,.12);   border-color: var(--status-red);    color: var(--text-normal); }
.alert-success  { background: rgba(59,165,92,.12);   border-color: var(--status-green);  color: var(--text-normal); }
.alert-info     { background: rgba(0,176,244,.1);    border-color: var(--text-link);     color: var(--text-normal); }

/* ---------------------------------------------------------------------------
   Settings page
   --------------------------------------------------------------------------- */
.settings-section { margin-bottom: 16px; }
.settings-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--header-primary);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bg-modifier-hover);
}
.settings-form { display: flex; flex-direction: column; gap: 12px; }
/* duplicate .form-row/.form-label/.form-hint definitions removed — merged
   into the canonical Forms section above (2026-07-17 consolidation) */
.form-select { appearance: none; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.current-session { background: var(--bg-modifier-selected) !important; }

/* ---------------------------------------------------------------------------
   Logs page
   --------------------------------------------------------------------------- */
.logs-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-modifier-hover);
  flex-wrap: wrap;
  gap: 8px;
}
.logs-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-label { font-size: 12px; color: var(--text-muted); margin-right: 4px; }
.logs-meta { font-size: 12px; color: var(--text-muted); }
.logs-table { font-size: 13px; }
/* 140px, not 130 — the (removed) later duplicate in the file-browser section
   was the effective width (2026-07-17 consolidation). */
.col-time   { width: 140px; white-space: nowrap; color: var(--text-muted); }
.col-level  { width: 80px; }
.col-logger { width: 160px; color: var(--text-muted); font-size: 12px; }
.log-message { font-family: monospace; word-break: break-all; }

.badge-level-debug   { background: var(--interactive-muted); color: var(--text-normal); }
.badge-level-info    { background: var(--status-green); }
.badge-level-warning { background: var(--status-yellow); color: #000; }
.badge-level-error   { background: var(--status-red); }

/* ---------------------------------------------------------------------------
   Console page additions
   --------------------------------------------------------------------------- */
.console-wrapper { padding: 0; overflow: hidden; }
.console-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-secondary-alt);
  border-bottom: 1px solid var(--bg-modifier-hover);
  flex-wrap: wrap;
  gap: 8px;
}
.console-label { font-size: 12px; color: var(--text-muted); margin-right: 8px; }
.console-actions { display: flex; align-items: center; gap: 12px; }
.toggle-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--text-muted); }
.console-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary-alt);
  border-top: 1px solid var(--bg-modifier-hover);
}
.console-prompt { color: var(--text-muted); font-family: monospace; font-size: 14px; }
.console-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 6px 10px;
  font-family: monospace;
  font-size: 13px;
  color: var(--text-normal);
  outline: none;
}
/* box-shadow carried over from the removed duplicate definition — it was the
   effective focus style already (the later rule only set border-color). */
.console-input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.3);
}
.console-info-line { color: var(--text-muted); font-style: italic; }
.console-cmd-line  { color: var(--brand-500); }
.quick-commands { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-cmd { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.quick-cmd code { font-size: 12px; }
.quick-cmd-label { font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------------------
   Plex overview / sessions
   --------------------------------------------------------------------------- */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-hint { font-size: 12px; color: var(--text-muted); }
.active-sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.session-card {
  background: var(--bg-secondary-alt);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;   /* carried over from the removed duplicate definition */
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-header { display: flex; justify-content: space-between; align-items: center; }
.session-user { font-weight: 600; font-size: 14px; color: var(--header-primary); }
.session-title { font-size: 13px; color: var(--text-normal); }
.session-show { font-size: 11px; color: var(--text-muted); display: block; }
.session-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.session-quality { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); }
.badge-session-playing { background: var(--status-green); }
.badge-session-paused  { background: var(--status-yellow); color: #000; }

/* History table */
/* (.text-muted and .progress-bar-fill duplicates removed — the canonical
   definitions in the Typography helpers / Progress bars sections were already
   the effective styles; 2026-07-17 consolidation.) */
.progress-bar-mini {
  width: 80px;
  height: 4px;
  background: var(--bg-modifier-hover);
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.progress-bar-error .progress-bar-fill { background: var(--status-red); }
.empty-state-inline { color: var(--text-muted); font-size: 14px; padding: 16px 0; }

/* ---------------------------------------------------------------------------
   Plex library / file browser
   --------------------------------------------------------------------------- */
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-bottom: 12px; font-size: 13px; }
.breadcrumb-item { color: var(--text-link); text-decoration: none; }
.breadcrumb-item:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); padding: 0 2px; }
.file-table { font-size: 13px; }
.file-dir .file-link-dir { color: var(--text-link); text-decoration: none; font-weight: 500; }
.file-dir .file-link-dir:hover { text-decoration: underline; }
/* Merged with the properties from the removed File-browser section — the
   values below are the effective computed set both rules produced together. */
.file-icon { width: 16px; flex-shrink: 0; color: var(--text-muted); margin-right: 6px; }
.file-size { width: 90px; color: var(--text-muted); font-size: 12px; white-space: nowrap; text-align: right; }
.file-mtime { width: 130px; color: var(--text-muted); }
.file-path-cell { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Hover-reveal actions. The reveal must also fire for TABLE rows (the Plex
   library renders .file-actions inside <tr> — the Delete button was
   permanently invisible but clickable; 2026-07-16 review) and for keyboard
   focus. */
.file-actions { width: 80px; text-align: right; opacity: 0; transition: opacity 0.1s; }
tr:hover .file-actions,
.file-actions:focus-within { opacity: 1; }

/* ---------------------------------------------------------------------------
   Upload page
   --------------------------------------------------------------------------- */
.upload-zone {
  border: 2px dashed var(--bg-modifier-hover);
  border-radius: 8px;
  transition: border-color .2s, background .2s;
  cursor: pointer;
  margin-bottom: 16px;
}
.upload-zone.drag-over {
  border-color: var(--brand-500);
  background: rgba(88,101,242,.08);
}
.upload-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 8px;
}
.upload-icon { font-size: 40px; opacity: .7; }
.upload-label { font-size: 16px; color: var(--header-secondary); margin: 0; }
.upload-link { color: var(--text-link); cursor: pointer; text-decoration: underline; }
.upload-hint { font-size: 12px; color: var(--text-muted); margin: 0; }
.upload-queue-header { display: flex; align-items: center; border-bottom: 1px solid var(--bg-modifier-hover); }
.upload-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg-modifier-hover);
  font-size: 13px;
}
.upload-list-item:last-child { border-bottom: none; }
.upload-filename { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-filesize { width: 80px; text-align: right; color: var(--text-muted); }
.upload-progress { width: 120px; }
.upload-speed { width: 80px; text-align: right; font-size: 11px; color: var(--text-muted); }
.upload-actions { padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.upload-status-text { font-size: 13px; color: var(--text-muted); }
.loading-spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--text-muted);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner {
  display: block;
  width: 32px; height: 32px;
  border: 3px solid var(--bg-modifier-hover);
  border-top-color: var(--brand-500);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 32px auto;
}

/* ---------------------------------------------------------------------------
   Compression page
   --------------------------------------------------------------------------- */
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}
.table-toolbar-actions { display: flex; gap: 8px; }
/* CompressionTier enum values: uncompressed, lossless, high_bitrate_intra, lossy, unknown */
.badge-tier-uncompressed      { background: var(--status-danger-bg);  color: #ff5c5c; }
.badge-tier-lossless          { background: var(--status-warning-bg); color: #fee75c; }
.badge-tier-high_bitrate_intra{ background: var(--status-warning-bg); color: #fee75c; }
.badge-tier-high_bitrate      { background: #3a2d52; color: #c4a7ff; }
.badge-tier-lossy             { background: var(--interactive-muted);  color: var(--text-muted); }
.badge-tier-unknown           { background: var(--interactive-muted);  color: var(--text-muted); }

/* Compression scan scope options */
.scan-options {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-normal);
}
.scan-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin: 0;
}
.scan-options input[type="checkbox"] { margin: 0; }
/* JobState enum values: queued, encoding, verifying, complete, failed */
.badge-job-queued    { background: var(--interactive-muted); }
.badge-job-encoding  { background: var(--brand-500); }
.badge-job-verifying { background: var(--status-info); }
.badge-job-complete  { background: var(--status-positive-bg); color: #57f287; }
.badge-job-failed    { background: var(--status-danger-bg);   color: #ff5c5c; }
.badge-job-cancelled { background: var(--interactive-muted);  color: var(--text-muted); }
.badge-job-no_gain   { background: var(--status-warning-bg, #3a3320); color: var(--status-warning, #faa61a); }

/* Compression run-control bar + multi-select toolbar */
.compression-control-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 1rem;
}
.compression-control-bar .control-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.compression-control-bar .control-actions { display: flex; gap: 8px; }
.status-dot-running { background: var(--status-positive); animation: pulse 1.8s ease-in-out infinite; }
.status-dot-paused  { background: var(--status-warning); animation: none; }

.compression-select-bar {
  align-items: center;
  padding-right: 1rem;
}
.compression-select-bar .select-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1rem 0 0;
}
.compression-select-bar #sel-count { font-size: 13px; }

/* Compact checkbox column for the candidate table */
.table th.checkbox-col,
.table td.checkbox-col {
  width: 36px;
  text-align: center;
  padding-left: 12px;
  padding-right: 0;
}
.table td.checkbox-col input[type="checkbox"] { margin: 0; cursor: pointer; }

.badge-op-pending     { background: var(--interactive-muted); }
.badge-op-in_progress { background: var(--brand-500); }
.badge-op-complete    { background: var(--status-green); }
.badge-op-failed      { background: var(--status-red); }
.badge-op-cancelled   { background: var(--interactive-muted); }

/* ---------------------------------------------------------------------------
   Update progress partial
   --------------------------------------------------------------------------- */
.update-progress { display: flex; flex-direction: column; gap: 8px; }
.progress-header { display: flex; justify-content: space-between; align-items: center; }
.progress-title { font-weight: 600; font-size: 14px; color: var(--header-primary); }
.progress-message { font-size: 13px; color: var(--text-muted); margin: 0; }
.progress-success { font-size: 13px; color: var(--status-green); display: flex; flex-direction: column; gap: 4px; }
.progress-error   { font-size: 13px; color: var(--status-red); display: flex; flex-direction: column; gap: 4px; }
.progress-error code { font-size: 12px; background: var(--input-bg); padding: 4px 8px; border-radius: 4px; display: block; }

/* ---------------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--bg-modifier-hover);
}
.page-info { font-size: 13px; color: var(--text-muted); }

/* Infinite-scroll sentinel row — appears briefly while the next page loads. */
.infinite-loading {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.infinite-loading .loading-spinner-sm {
  vertical-align: middle;
  margin-right: 6px;
}

/* ---------------------------------------------------------------------------
   Responsive tweaks
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar { width: 72px; min-width: 72px; }
  .nav-item span:not(.nav-item-icon) { display: none; }
  .sidebar-logo-icon + * { display: none; }
  /* Section labels and the version string clipped mid-word at 72px —
     icons-only means icons only (2026-07-16 review). */
  .nav-section-label { visibility: hidden; height: 12px; padding: 0; }
  .sidebar-version { display: none; }
  .page-content { padding: 12px; }
}

/* ---------------------------------------------------------------------------
   Public landing page — single-column layout
   --------------------------------------------------------------------------- */
.landing-body {
  background: var(--bg-modifier-active);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Landing header */
.landing-header {
  background: var(--bg-secondary);
  box-shadow: var(--elevation-low);
  position: sticky;
  top: 0;
  z-index: 10;
}
.landing-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.landing-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.landing-logo-icon { font-size: 22px; }
.landing-logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--header-primary);
}
.landing-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Landing main content */
.landing-main {
  flex: 1;
  padding: 32px 24px 64px;
}
.landing-content {
  max-width: 860px;
  margin: 0 auto;
}

/* Sections */
.landing-section {
  padding: 24px 0;
}
/* Landing-page section headers — bigger and brighter than admin panel labels
   to function as real section headings, with tighter spacing to their content */
.landing-section .section-label {
  font-size: 15px;
  letter-spacing: 0.9px;
  color: var(--header-primary);
  margin-top: 0;
  margin-bottom: 4px;
}
/* Tighten the gap that the address block and download cards add on top of
   the label's bottom margin — otherwise the label "floats" above content. */
.landing-section .server-address-block { margin-top: 6px; }
.landing-section .download-cards { margin-top: 0; }
.landing-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 10px;
}
.landing-blurb {
  font-size: 16px;
  color: var(--text-normal);
  max-width: 640px;
  line-height: 1.6;
}
.landing-divider {
  border: none;
  border-top: 2px solid rgba(79, 84, 92, 0.35);
  margin: 16px 0;
}
.landing-helper {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Server address block */
.server-address-block {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--channeltextarea-background);
  border-radius: 4px;
  padding: 10px 14px;
  margin-top: 12px;
}
.server-address-code {
  font-family: var(--font-code);
  font-size: 15px;
  color: var(--text-normal);
  background: none;
  border: none;
  padding: 0;
  letter-spacing: 0.3px;
}
.inline-code {
  font-family: var(--font-code);
  font-size: 13px;
  background: var(--channeltextarea-background);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--text-normal);
}

/* Generic 2-column landing row (server address + Discord, etc.) */
.two-col-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  /* default align-items: stretch makes both columns the same height */
}
@media (max-width: 700px) {
  .two-col-row { grid-template-columns: 1fr; }
}
/* Inside a two-col-row, make the wrapper div and the card itself a flex
   column so the action button (.discord-go-btn / .mc-setup-btn) pins to
   the bottom and both cards match the taller card's height exactly. */
.two-col-row > div {
  display: flex;
  flex-direction: column;
}
.two-col-row .discord-invite-card {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.two-col-row .discord-invite-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.two-col-row .discord-go-btn {
  margin-top: auto;  /* push action button to the bottom of the body */
}

/* Public "Request to Join Whitelist" form (landing hero, right column) */
.join-request-field {
  display: flex;
  gap: 8px;
  align-items: center;
}
.join-request-input {
  flex: 1;
  min-width: 0;  /* let the input shrink inside the flex row instead of overflowing */
}

/* Discord invite preview card — mimics the embed Discord renders when you
   paste an invite link in a channel: banner header, overlapping rounded
   server icon, server name + member counts, green "Go to Server" button. */
.discord-invite-card {
  background: var(--bg-secondary);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--elevation-low);
}
.discord-invite-banner {
  height: 60px;
  background: linear-gradient(135deg, var(--brand-500) 0%, #7d87f5 100%);
  background-size: cover;
  background-position: center;
}
.discord-invite-body {
  padding: 14px 16px 16px;
}
.discord-invite-body-fallback { padding: 16px; }
.discord-server-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  margin-top: -28px;  /* lift the icon up over the banner like Discord does */
  align-items: flex-start;
}
.discord-server-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  border: 4px solid var(--bg-secondary);
  background: var(--bg-secondary);
  flex-shrink: 0;
  display: block;
}
.discord-server-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-500);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}
.discord-server-meta {
  flex: 1;
  min-width: 0;
  padding-top: 32px;  /* push name below the banner-overlap zone */
}
.discord-server-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.discord-server-stats {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.discord-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.discord-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.discord-dot.online    { background: var(--status-positive); }
.discord-dot.offline   { background: var(--status-danger); }
.discord-dot.starting,
.discord-dot.stopping  { background: var(--status-warning); }
.discord-dot.updating  { background: var(--status-info); }
.discord-dot.unknown   { background: var(--text-muted); }

/* Channel row: shows the specific text channel this invite drops you into.
   Matches Discord's own channel-list look — plain text with a # icon, no
   background or border. */
.discord-invite-channel {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--interactive-normal);
}
.discord-channel-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--interactive-normal);
}
.discord-go-btn {
  display: block;
  text-align: center;
  background: var(--status-positive);
  color: #fff;
  padding: 11px 18px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.discord-go-btn:hover {
  background: #2e9050;
  text-decoration: none;
  color: #fff;
}

/* Minecraft variant of the invite card — shares structure with the Discord
   card (banner / icon / name+stats / address) so the two sit side-by-side
   with matching visual weight. Banner is grass-green and the icon is a
   pickaxe to distinguish it from the Discord blurple banner. */
.mc-card-banner {
  background: linear-gradient(135deg, #4a7c2e 0%, #7ab852 50%, #5a8a3a 100%);
}
.mc-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-modifier-active);
  font-size: 30px;
  line-height: 1;
}

/* When the server-address-block is rendered inside the Minecraft card it
   spans the card width (default is inline-flex), drops the top margin the
   standalone version uses, and becomes a click-anywhere copy target. */
.server-address-block-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 0;
  margin-bottom: 14px;
  cursor: pointer;
  user-select: none;                  /* prevent text-selection toolbar popup */
  transition: background-color 0.2s ease;
}
.server-address-block-card .server-address-code {
  color: var(--interactive-normal);   /* muted by default, not bright white */
  user-select: none;
  transition: color 0.1s ease;
}
.server-address-block-card:hover .server-address-code,
.server-address-block-card:focus .server-address-code {
  color: var(--text-normal);          /* subtle brightening of the address text only */
}
/* "Copied ✓" feedback: brief green flash on the whole box */
.server-address-block-card.copied {
  background: var(--status-positive-bg);
}
.server-address-block-card.copied .server-address-code {
  color: #57f287;
}
/* The Copy label inside the box is a visual affordance, not an actual button —
   the parent div handles the click. Prevent it from intercepting events. */
.copy-affordance {
  pointer-events: none;
}

/* "Setup Instructions →" button mirrors Discord's "Go to Server" CTA in
   position and size, but uses Blurple instead of green so the two cards
   are distinguishable. Anchor link to the #setup section below. */
.mc-setup-btn {
  background: var(--brand-500);
}
.mc-setup-btn:hover {
  background: var(--brand-560);
}

/* Download cards: side-by-side row */
.download-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 4px;
}
@media (max-width: 600px) {
  .download-cards { grid-template-columns: 1fr; }
}
.download-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.download-card-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
}
.download-card-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.download-btn {
  align-self: flex-start;
  margin-top: 4px;
}

/* Server info */
.server-info-row {
  display: flex;
  align-items: center;
  padding: 8px 0;
}

/* Mod table (landing page variant — no hover nav concerns) */
/* At phone widths the table's natural minimum exceeds the viewport; the wrapper
   keeps that overflow scrolling INSIDE the section instead of widening the page. */
.mod-table-wrap { overflow-x: auto; }
.mod-table {
  width: 100%;
  border-collapse: collapse;
}
.mod-table thead tr {
  background: var(--bg-secondary-alt);
}
.mod-table thead th {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-secondary);
  padding: 8px 12px;
  text-align: left;
}
.mod-table tbody tr {
  border-bottom: 1px solid rgba(79, 84, 92, 0.2);
}
.mod-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.08);
}
.mod-table tbody td {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text-normal);
}
.loader-row td { color: var(--text-muted); }
.mod-link {
  color: var(--text-link);
  text-decoration: none;
}
.mod-link:hover { text-decoration: underline; }
.mod-icon { border-radius: 4px; object-fit: contain; vertical-align: middle; }
.mod-icon-cell { width: 32px; padding-right: 4px; }
.mod-description { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.mod-wiki-link { font-size: 11px; color: var(--text-link); }

/* Setup steps */
.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.setup-step {
  display: flex;
  gap: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--elevation-low);
}
.step-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--header-secondary);
  min-width: 32px;
  padding-top: 2px;
}
.step-body { flex: 1; }
.step-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
  margin-bottom: 6px;
}
.step-text {
  font-size: 14px;
  color: var(--text-normal);
  line-height: 1.55;
}

/* ---------------------------------------------------------------------------
   Missing structural classes
   --------------------------------------------------------------------------- */

/* Page header row: title + action buttons */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.page-header .page-title { margin-bottom: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* Stat card: compact metric tile used in grids */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-secondary);
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--header-primary);
}

/* Plex overview: Status (left ~1/3) and Last Watched (right ~2/3) share one
   card, divided by a thin rule, so the overview is one balanced row of two
   cards with no orphaned half-row. Each side is a normal .stat-card. */
/* Grid (not flex) is used deliberately: `.card` doesn't set a flex-direction, but
   to be bulletproof against any inherited column direction we lay the two halves
   out with an explicit 2-column grid — Status in the 1fr column (~1/3), Last
   Watched in the 2fr column (~2/3), side by side. */
.plex-overview-card { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; align-items: start; }
.plex-overview-card > .stat-card:last-child {
  padding-left: 16px;
  border-left: 1px solid var(--background-modifier-accent);
}
/* Stack the two halves on very narrow screens (the rule becomes a top border). */
@media (max-width: 560px) {
  .plex-overview-card { grid-template-columns: 1fr; }
  .plex-overview-card > .stat-card:last-child {
    padding-left: 0;
    border-left: 0;
    padding-top: 12px;
    border-top: 1px solid var(--background-modifier-accent);
  }
}

/* Update progress modal: step list + log */
.progress-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
  padding: 10px 12px;
  background: var(--bg-secondary-alt);
  border-radius: 6px;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.progress-log {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--bg-modifier-active);
  border-radius: 4px;
  max-height: 140px;
  overflow-y: auto;
}
.log-line {
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--text-muted);
  padding: 1px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------------------------------------------------------------------
   Modpack Builder (popup over the Mod Manager) + compile test
--------------------------------------------------------------------------- */
.builder-modal {
  max-width: 1150px;
  width: 96%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.builder-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.builder-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 6px;
}
.builder-topbar-sep {
  width: 1px;
  align-self: stretch;
  background: var(--background-modifier-accent);
  margin: 0 4px;
}
.builder-searchrow { padding: 4px 0 8px; }
.builder-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 2px;
}
.builder-issues {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 8px;
}
.builder-issues summary { cursor: pointer; }
.builder-issues ul { margin: 6px 0 0; padding-left: 1.3em; }
.builder-op-progress {
  border: 1px solid var(--background-modifier-accent);
  border-radius: 6px;
  margin: 6px 0;
  max-height: 220px;
  overflow-y: auto;
}
.builder-table-wrapper { max-height: none; }
.builder-row-removed td { opacity: 0.55; }
.builder-row-removed td:nth-child(2) { text-decoration: line-through; }
.builder-caret {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}
.builder-caret.open { color: var(--text-normal); }
.builder-row-actions { white-space: nowrap; }
.builder-trash {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0.55;
  padding: 2px 4px;
}
.builder-trash:hover { opacity: 1; }
.builder-detail-cell {
  background: var(--background-secondary);
  padding: 10px 14px !important;
}
.builder-detail { font-size: 13px; }
.builder-detail-incompat {
  color: var(--status-danger);
  font-weight: 600;
  margin-bottom: 8px;
}
.builder-detail-table { width: 100%; margin: 4px 0 8px; }
.builder-detail-table th {
  font-size: 11px;
  text-align: left;
  color: var(--text-muted);
  padding: 2px 8px 2px 0;
}
.builder-detail-table td { padding: 3px 8px 3px 0; font-size: 12px; }
.builder-detail-currentmc td { background: rgba(88, 101, 242, 0.08); }
.builder-detail-section { margin: 6px 0; font-size: 12px; }
.builder-dep { white-space: nowrap; }
.builder-dep-incompatible { color: var(--status-danger); }
.builder-dep-optional, .builder-dep-embedded { color: var(--text-muted); }
.builder-notes { margin: 4px 0 0; padding-left: 1.2em; }
.builder-notes li { margin-bottom: 3px; font-size: 12px; }
.builder-detail-actions { margin-top: 6px; }
.compile-test-summary {
  font-family: var(--font-code);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--background-secondary);
  border: 1px solid var(--background-modifier-accent);
  border-radius: 6px;
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin: 8px 0 0;
}
