/* ============================================================
   UNTOUCHABLES.APP — COMPONENT LIBRARY
   
   All UI components. Requires theme.css loaded first.
   ============================================================ */


/* ============================================================
   1. LAYOUT SHELL
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface-ground);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width var(--duration-slow) var(--ease-out);
}

.sidebar__brand {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
}

.sidebar__brand-icon {
  width: 28px;
  height: 28px;
  background: var(--gold-400);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__brand-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-inverse);
}

.sidebar__brand-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
}

.sidebar__section {
  margin-bottom: var(--space-4);
}

.sidebar__section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-ghost);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-nav);
  font-size: var(--text-base);
  font-weight: 400;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.sidebar__link:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar__link--active {
  background: var(--surface-active);
  color: var(--text-primary);
}

.sidebar__link--active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 16px;
  background: var(--gold-400);
  border-radius: 0 1px 1px 0;
}

.sidebar__link-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar__link--active .sidebar__link-icon {
  opacity: 1;
}

.sidebar__link-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--danger-400);
  color: #fff;
  line-height: 1.4;
}

/* --- Sidebar footer (user info) --- */
.sidebar__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar__user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--gold-400);
  flex-shrink: 0;
}

.sidebar__user-info {
  flex: 1;
  min-width: 0;
}

.sidebar__user-name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* --- Main Content --- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--duration-slow) var(--ease-out);
}

/* --- Top Header Bar --- */
.header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  background: var(--surface-ground);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header__left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.header__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.header__breadcrumb-sep {
  color: var(--text-ghost);
}

.header__breadcrumb a {
  color: var(--text-nav);
}

.header__breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.header__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* On phones the breadcrumb fights the TCT clock + Open-Torn-City link for
   space. Let the breadcrumb truncate so the right-side controls stay intact. */
@media (max-width: 640px) {
  .header__left {
    min-width: 0;
    overflow: hidden;
  }
  .header__breadcrumb {
    min-width: 0;
    flex-wrap: nowrap;
  }
  .header__breadcrumb-current {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* --- Page Content --- */
.page {
  padding: var(--space-6);
  max-width: 1400px;
}

.page__header {
  margin-bottom: var(--space-6);
}

.page__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-1);
}

.page__subtitle {
  font-size: var(--text-base);
  color: var(--text-tertiary);
}


/* ============================================================
   2. STAT CARDS
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--surface-base);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-4);
  border-left: 2px solid var(--border-default);
  transition: border-color var(--duration-fast) var(--ease-out);
  position: relative;
}

.stat-card:hover {
  border-left-color: var(--gold-400);
}

.stat-card--gold    { border-left-color: var(--gold-400); }
.stat-card--steel   { border-left-color: var(--steel-400); }
.stat-card--danger  { border-left-color: var(--danger-400); }
.stat-card--active  { border-left-color: var(--active-400); }
.stat-card--warning { border-left-color: var(--warning-400); }
.stat-card--info    { border-left-color: var(--info-400); }

.stat-card__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.stat-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.stat-card__meta {
  font-size: var(--text-xs);
}

.stat-card__meta--up   { color: var(--active-400); }
.stat-card__meta--down { color: var(--danger-400); }
.stat-card__meta--neutral { color: var(--text-tertiary); }


/* ============================================================
   3. DATA TABLES
   ============================================================ */

.data-table-wrap {
  background: var(--surface-base);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

/* On phones, wide multi-column tables (Members, Accounting, OC, RW) need to
   scroll horizontally inside the wrap instead of forcing a page-wide overflow.
   `overflow-x:auto` keeps the rounded border intact while letting the table
   pan beneath it. */
@media (max-width: 768px) {
  .data-table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
  }
}

.data-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table-header__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
}

.data-table-header__actions {
  display: flex;
  gap: var(--space-2);
}

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

.data-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-ghost);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--surface-base);
}

.data-table th.text-right,
.data-table td.text-right {
  text-align: right;
}

.data-table th.text-center,
.data-table td.text-center {
  text-align: center;
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-base);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Member row cells --- */
.member-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.member-cell__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--gold-400);
  flex-shrink: 0;
}

.member-cell__name {
  font-weight: 500;
  color: var(--text-primary);
}

.member-cell__id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ghost);
}

/* --- Data cells --- */
.data-cell {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}


/* ============================================================
   4. STATUS BADGES
   ============================================================ */

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot--online    { background: var(--active-400); }
.status-dot--offline   { background: var(--text-ghost); }
.status-dot--hospital  { background: var(--danger-400); }
.status-dot--jail      { background: var(--info-400); }
.status-dot--traveling { background: var(--warning-400); }
.status-dot--idle      { background: var(--text-tertiary); }
.status-dot--federal   { background: var(--danger-600); }

/* Dot with pulse animation for online/active */
.status-dot--pulse {
  position: relative;
}
.status-dot--pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0;
  animation: status-pulse 2s var(--ease-out) infinite;
}
@keyframes status-pulse {
  0%   { opacity: 0.6; transform: scale(0.8); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* --- Badge (inline label) --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.6;
}

/* Note: doubled-up class selector (.badge.badge--xyz) bumps specificity to
 * (0,2,0) so these design-system variants always win against the legacy
 * .badge { background:var(--surface-2); color:var(--text-muted); } rule in
 * style.css, which is still loaded last during the migration window. */
.badge.badge--online    { background: rgba(61, 140, 92, 0.15); color: var(--active-400); }
.badge.badge--offline   { background: rgba(255, 255, 255, 0.04); color: var(--text-ghost); }
.badge.badge--hospital  { background: rgba(196, 64, 64, 0.15); color: var(--danger-400); }
.badge.badge--jail      { background: rgba(90, 106, 136, 0.15); color: var(--info-400); }
.badge.badge--traveling { background: rgba(212, 146, 46, 0.15); color: var(--warning-400); }
.badge.badge--idle      { background: rgba(255, 255, 255, 0.04); color: var(--text-tertiary); }
.badge.badge--federal   { background: rgba(131, 40, 40, 0.15); color: var(--danger-600); }

.badge.badge--gold      { background: var(--gold-glow); color: var(--gold-400); }
.badge.badge--steel     { background: rgba(92, 122, 153, 0.15); color: var(--steel-400); }


/* ============================================================
   5. BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.98);
}

/* Primary (gold) */
.btn--primary {
  background: var(--gold-400);
  color: var(--text-inverse);
  border: 1px solid var(--gold-400);
}
.btn--primary:hover {
  background: var(--gold-500);
  border-color: var(--gold-500);
  color: var(--text-inverse);
}

/* Secondary (outline) */
.btn--secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn--secondary:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Ghost (no border) */
.btn--ghost {
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid transparent;
}
.btn--ghost:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

/* Danger */
.btn--danger {
  background: rgba(196, 64, 64, 0.12);
  color: var(--danger-400);
  border: 1px solid rgba(196, 64, 64, 0.2);
}
.btn--danger:hover {
  background: rgba(196, 64, 64, 0.2);
}

/* Sizes */
.btn--sm {
  padding: 2px var(--space-3);
  font-size: var(--text-xs);
}

.btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

/* Icon-only */
.btn--icon {
  padding: var(--space-2);
  width: 32px;
  height: 32px;
}

.btn--icon svg {
  width: 16px;
  height: 16px;
}


/* ============================================================
   6. FORM ELEMENTS
   ============================================================ */

.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.form-input:hover {
  border-color: var(--border-strong);
}

.form-input:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 2px var(--border-focus);
}

.form-input::placeholder {
  color: var(--text-ghost);
}

/* Select */
.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  padding-right: var(--space-8);
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-base);
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6860' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-select:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 2px var(--border-focus);
}

/* Search input with icon */
.search-input {
  position: relative;
}

.search-input__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-ghost);
  pointer-events: none;
}

.search-input .form-input {
  padding-left: var(--space-8);
}


/* ============================================================
   7. TABS / NAVIGATION
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  background: var(--void);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-6);
  /* Don't set `overflow-x: auto` on the base — CSS forces overflow-y to also
     compute to auto, which combines with the 1px overhang from the active
     `.tabs--underline .tab` (border-bottom + negative margin trick) to spawn
     a permanent vertical scrollbar. The mobile media query below adds the
     horizontal scroll back with overflow-y explicitly hidden. */
}

.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-nav);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tab:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.tab--active {
  background: var(--surface-base);
  color: var(--gold-400);
  border-bottom: 1.5px solid var(--gold-400);
}

.tab__count {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  background: var(--surface-active);
  color: var(--text-tertiary);
}

.tab--active .tab__count {
  background: var(--gold-glow);
  color: var(--gold-400);
}

/* --- Underline tab variant --- */
.tabs--underline {
  background: transparent;
  border-radius: 0;
  padding: 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0;
}

.tabs--underline .tab {
  border-radius: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tabs--underline .tab--active {
  background: transparent;
  border-bottom-color: var(--gold-400);
}


/* ============================================================
   8. CARDS & PANELS
   ============================================================ */

.card {
  background: var(--surface-base);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
}

.card__body {
  padding: var(--space-5);
}

.card__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* --- Accent card (left border) --- */
.card--accent-gold    { border-left: 2px solid var(--gold-400); }
.card--accent-steel   { border-left: 2px solid var(--steel-400); }
.card--accent-danger  { border-left: 2px solid var(--danger-400); }
.card--accent-active  { border-left: 2px solid var(--active-400); }

/* --- Info panel (full-width alert-like) --- */
.panel {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.panel--info {
  background: rgba(92, 122, 153, 0.08);
  border: 1px solid rgba(92, 122, 153, 0.15);
  color: var(--steel-200);
}

.panel--warning {
  background: rgba(212, 146, 46, 0.08);
  border: 1px solid rgba(212, 146, 46, 0.15);
  color: var(--warning-200);
}

.panel--danger {
  background: rgba(196, 64, 64, 0.08);
  border: 1px solid rgba(196, 64, 64, 0.15);
  color: var(--danger-200);
}

.panel--success {
  background: rgba(61, 140, 92, 0.08);
  border: 1px solid rgba(61, 140, 92, 0.15);
  color: var(--active-200);
}


/* ============================================================
   9. PROGRESS & CHAIN TIMER
   ============================================================ */

.progress {
  width: 100%;
  height: 4px;
  background: var(--surface-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  border-radius: 2px;
  transition: width var(--duration-normal) var(--ease-out);
}

.progress__bar--gold    { background: var(--gold-400); }
.progress__bar--steel   { background: var(--steel-400); }
.progress__bar--danger  { background: var(--danger-400); }
.progress__bar--active  { background: var(--active-400); }

/* Chain timer bar (taller variant) */
.chain-bar {
  height: 6px;
  background: var(--surface-elevated);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.chain-bar__fill {
  height: 100%;
  border-radius: 3px;
  background: var(--gold-400);
  transition: width 1s linear;
}

/* Warning state when time is low */
.chain-bar--critical .chain-bar__fill {
  background: var(--danger-400);
  animation: chain-pulse 1s ease-in-out infinite;
}

@keyframes chain-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}


/* ============================================================
   10. TOOLTIPS & POPOVERS
   ============================================================ */

.tooltip {
  position: relative;
}

.tooltip__content {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--surface-overlay);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 200;
}

.tooltip:hover .tooltip__content {
  opacity: 1;
}


/* ============================================================
   11. EMPTY STATES & LOADING
   ============================================================ */

.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
  color: var(--text-ghost);
  opacity: 0.5;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  max-width: 360px;
  margin: 0 auto;
}

/* --- Skeleton loading --- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-elevated) 25%,
    var(--surface-overlay) 50%,
    var(--surface-elevated) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--text {
  height: 14px;
  width: 60%;
}

.skeleton--avatar {
  width: 30px;
  height: 30px;
}

.skeleton--stat {
  height: 28px;
  width: 80px;
}


/* ============================================================
   12. PAGINATION
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination__btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.pagination__btn:hover {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

.pagination__btn--active {
  background: var(--gold-glow);
  color: var(--gold-400);
}


/* ============================================================
   13. PAGE LOAD ANIMATION
   ============================================================ */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fade-up var(--duration-slow) var(--ease-out) both;
}

.animate-in--d1 { animation-delay: 50ms; }
.animate-in--d2 { animation-delay: 100ms; }
.animate-in--d3 { animation-delay: 150ms; }
.animate-in--d4 { animation-delay: 200ms; }
.animate-in--d5 { animation-delay: 250ms; }
.animate-in--d6 { animation-delay: 300ms; }


/* ============================================================
   14. UTILITY CLASSES
   ============================================================ */

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: var(--space-1); }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.w-full  { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }


/* ============================================================
   14b. SIDEBAR COLLAPSE / RAIL MODE
   ============================================================
   The sidebar is always visible (no hamburger). Two states are toggled
   via a class on <html>:
     - html.nav-expanded   → full 240px sidebar with text labels
     - html.nav-collapsed  → 56px rail with icon-only links
   The state is set by an inline <head> script before first paint to
   avoid any flash, and persisted in localStorage('sidebar-state').
   On phones (<= 1024px) the expanded state floats over the content
   as an overlay with a backdrop instead of pushing it sideways.
   ============================================================ */

/* Collapsed (rail) layout — applies on every viewport when the user has
 * chosen rail mode. Below 1024px this is the default. */
html.nav-collapsed .sidebar {
  width: var(--sidebar-rail-width);
}
html.nav-collapsed .main {
  margin-left: var(--sidebar-rail-width);
}

/* Hide everything that doesn't fit in a 56px column when collapsed */
html.nav-collapsed .sidebar__brand {
  padding: var(--space-4) 0;
  justify-content: center;
}
html.nav-collapsed .sidebar__brand-name,
html.nav-collapsed .sidebar__section-label,
html.nav-collapsed .sidebar__link-text,
html.nav-collapsed .sidebar__user-info,
html.nav-collapsed .sidebar__logout-text {
  display: none;
}
html.nav-collapsed .sidebar__nav {
  padding: var(--space-3) var(--space-1);
}
html.nav-collapsed .sidebar__section {
  margin-bottom: var(--space-3);
}
html.nav-collapsed .sidebar__link {
  justify-content: center;
  padding: var(--space-2) 0;
}
html.nav-collapsed .sidebar__link-icon {
  margin: 0;
  opacity: 0.85;
}
/* The pending-changelog dot needs a fixed position when there's no text */
html.nav-collapsed .sidebar__link-dot {
  position: absolute;
  top: 4px;
  right: 6px;
  margin-left: 0;
}
html.nav-collapsed .sidebar__footer {
  padding: var(--space-2);
}
html.nav-collapsed .sidebar__user {
  justify-content: center;
}
html.nav-collapsed .sidebar__user-avatar {
  margin: 0 auto;
}
html.nav-collapsed .sidebar__logout-form {
  display: flex;
  justify-content: center;
}
html.nav-collapsed .sidebar__logout-btn {
  padding: var(--space-2);
  width: 32px;
  height: 32px;
}

/* Active link still highlights in rail mode */
html.nav-collapsed .sidebar__link--active::before {
  left: 0;
  height: 24px;
  width: 3px;
}

/* The collapse toggle button at the bottom of the sidebar */
.sidebar__collapse-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}
.sidebar__collapse-toggle:hover,
.sidebar__collapse-toggle:focus-visible {
  background: var(--surface-active);
  border-color: var(--border-default);
  color: var(--text-primary);
  outline: none;
}
.sidebar__collapse-toggle i {
  width: 16px;
  height: 16px;
}
/* Show the right chevron icon for the current state */
html.nav-expanded .sidebar__collapse-icon-expand {
  display: none;
}
html.nav-collapsed .sidebar__collapse-icon-collapse {
  display: none;
}
/* The lucide icons that aren't shown still occupy DOM space until the
 * library replaces the <i> tags. Hide their initial state so the button
 * doesn't briefly show two chevrons. */
.sidebar__collapse-icon-collapse,
.sidebar__collapse-icon-expand {
  width: 16px;
  height: 16px;
}

/* Sidebar logout button in expanded mode keeps the original look */
html.nav-expanded .sidebar__logout-icon {
  display: none;
}
html.nav-expanded .sidebar__logout-btn {
  font-size: 11px;
  padding: 4px 8px;
}

/* The pending-changelog dot in expanded mode (default styling) */
.sidebar__link-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger-400);
  box-shadow: 0 0 0 2px rgba(196, 64, 64, 0.25);
  flex-shrink: 0;
}

/* ============================================================
   15. RESPONSIVE
   ============================================================ */

@media (max-width: 1024px) {
  /* On phones / tablet portrait, the expanded sidebar floats above the
   * page content as an overlay. The main content stays at rail-width
   * margin so the rail icons remain accessible underneath. */
  html.nav-expanded .sidebar {
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }
  html.nav-expanded .main {
    margin-left: var(--sidebar-rail-width);
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Backdrop that appears behind the expanded overlay sidebar. Tap
   * outside to collapse. Only visible while body has .sidebar-is-open
   * (set by the toggle JS when expanding on mobile). */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
    z-index: 99; /* one below the sidebar's z-index:100 */
  }
  body.sidebar-is-open .sidebar-backdrop {
    display: block;
  }
  body.sidebar-is-open {
    overflow: hidden;
  }

  /* Stat grids never overflow even with the biggest currency values:
   * `minmax(140px, 1fr)` keeps two cards comfortable side-by-side at 360px
   * and the explicit `minmax(0, 1fr)` lets long numbers shrink instead of
   * forcing the column wider. */
  .stat-card {
    min-width: 0;
  }
  .stat-card__value {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (max-width: 640px) {
  .page {
    padding: var(--space-4);
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .tabs .tab {
    flex-shrink: 0;
  }
}
