/* ===========================================================================
   betenv Owner Panel V2 — Design System
   Mobile-first, black & white only.
   =========================================================================== */

/* --- Inter font (self-hostable later) --------------------------------------- */
@import url('https://rsms.me/inter/inter.css');

/* --- Design tokens ---------------------------------------------------------- */
:root {
  --ink:        #000000;
  --paper:      #ffffff;
  --smoke-900:  #0a0a0a;
  --smoke-700:  #1a1a1a;
  --smoke-500:  #777777;
  --smoke-400:  #9a9a9a;
  --smoke-300:  #cccccc;
  --smoke-200:  #e6e6e6;
  --smoke-100:  #f4f4f4;
  --smoke-50:   #fafafa;

  /* Status colors */
  --green:      #16a34a;
  --green-700:  #15803d;
  --red:        #dc2626;
  --red-700:    #b91c1c;
  --amber:      #d97706;
  --amber-700:  #b45309;
  --blue:       #2563eb;
  --blue-700:   #1d4ed8;
  --grey:       #6b7280;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* Lines */
  --line: 1px solid var(--ink);
  --hairline: 1px solid var(--smoke-200);

  /* Shadows (only used very rarely; we prefer borders) */
  --shadow-pop: 0 1px 0 var(--smoke-200), 0 8px 24px rgba(0,0,0,0.06);

  /* Layout */
  --topbar-h: 56px;
  --bottomnav-h: 64px;
  --sidebar-w: 240px;
  --content-max: 1200px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- Reset ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* --- Base ------------------------------------------------------------------- */
html { font-feature-settings: 'cv11', 'ss01', 'ss03'; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 28px; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 500; line-height: 1.25; }
h3 { font-size: 16px; font-weight: 500; line-height: 1.3; }
small, .text-xs { font-size: 12px; }

::selection { background: var(--ink); color: var(--paper); }

/* --- App shell -------------------------------------------------------------- */
.app {
  display: grid;
  min-height: 100dvh;
  grid-template-rows: var(--topbar-h) 1fr var(--bottomnav-h);
  grid-template-areas:
    "topbar"
    "main"
    "bottomnav";
}
@media (min-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
  }
  .bottomnav { display: none; }
}

.topbar    { grid-area: topbar; }
.sidebar   { grid-area: sidebar; display: none; }
@media (min-width: 1024px) { .sidebar { display: flex; } }
.main      { grid-area: main; min-width: 0; overflow-x: hidden; }
.bottomnav { grid-area: bottomnav; }

/* --- Top bar ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--paper);
  border-bottom: var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.topbar__logo      { height: 22px; width: auto; display: block; }
.topbar__logo-mark { height: 26px; width: 26px; display: block; }

.topbar__search {
  flex: 1;
  height: 38px;
  border: var(--line);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  font-size: 14px;
  background: var(--paper);
  min-width: 0;
}
.topbar__search:focus { outline: none; box-shadow: 0 0 0 2px var(--ink); }

.topbar__icon {
  width: 38px; height: 38px;
  border: var(--line);
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--paper);
  position: relative;
  color: var(--ink);
}
.topbar__icon:hover { background: var(--smoke-100); }
.topbar__icon--owner { padding: 0; overflow: hidden; }
.topbar__icon--owner img { width: 22px; height: 22px; }

.topbar__badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--red); color: var(--paper);
  border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--paper);
  line-height: 1;
}

.topbar--searching .topbar__icon { /* small visual hint when search is open */ }

/* --- Popovers (notifications + owner menu) ---------------------------------- */
[x-cloak] { display: none !important; }

.popover-wrap {
  position: relative;
  display: inline-flex;
}
.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 280px;
  width: max-content;
  max-width: calc(100vw - 24px);
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  z-index: 30;
  overflow: hidden;
}
@media (max-width: 480px) {
  .popover { right: -8px; min-width: 280px; max-width: calc(100vw - 16px); }
}

.popover__topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline);
}
.popover__title { font-size: 14px; font-weight: 500; }
.popover__link  {
  background: none; border: 0;
  font-size: 12px; color: var(--smoke-500); cursor: pointer;
}
.popover__link:hover { color: var(--ink); }

.popover__head {
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-4);
  background: var(--ink); color: var(--paper);
}
.popover__head .list__avatar {
  background: var(--paper); color: var(--ink);
}
.popover__head__title { font-size: 14px; font-weight: 500; }
.popover__head__sub   { font-size: 12px; color: var(--smoke-300); margin-top: 2px; word-break: break-all; }

.popover__list { display: flex; flex-direction: column; }
.popover__list li { list-style: none; }

.popover__item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 11px var(--space-4);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-top: var(--hairline);
  text-align: left;
  cursor: pointer;
}
.popover__list li:first-child .popover__item,
.popover__list > li:first-child > .popover__item { border-top: 0; }
.popover__item:hover { background: var(--smoke-100); }
.popover__item svg { width: 16px; height: 16px; flex-shrink: 0; }
.popover__item--sub {
  padding-left: 44px;
  font-size: 13px;
  background: var(--smoke-50);
}
.popover__item--sub.is-active { background: var(--ink); color: var(--paper); }
.popover__item--sub.is-active:hover { background: var(--smoke-700); }
.popover__item--strong { font-weight: 500; }
.popover__item--danger { color: var(--red); font-weight: 500; }
.popover__item--danger:hover { background: var(--red); color: var(--paper); }
.popover__item--danger:hover svg { stroke: var(--paper); }

.popover__sub {
  border-top: var(--hairline);
  background: var(--smoke-50);
}

.popover__chev {
  color: var(--smoke-400);
  font-size: 16px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.popover__chev--open { transform: rotate(90deg); }

.popover__tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--smoke-300);
  border-radius: var(--radius-sm);
  color: var(--smoke-500);
  letter-spacing: 0.04em;
}

.popover__divider {
  height: 1px;
  background: var(--smoke-200);
  margin: 0;
  list-style: none;
}

.popover__footer {
  display: block;
  padding: 11px var(--space-4);
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  border-top: var(--hairline);
  background: var(--smoke-50);
}
.popover__footer:hover { background: var(--smoke-100); }

/* Notification list item */
.popover__notif {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px var(--space-4);
  border-top: var(--hairline);
  cursor: pointer;
  position: relative;
}
.popover__list > li:first-child > .popover__notif,
.popover__list > .popover__notif:first-child { border-top: 0; }
.popover__notif:hover { background: var(--smoke-50); }
.popover__notif__title { font-size: 13px; font-weight: 500; line-height: 1.35; }
.popover__notif__sub   { font-size: 12px; color: var(--smoke-500); margin-top: 2px; line-height: 1.35; }
.popover__notif .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  flex-shrink: 0;
  margin-top: 8px;
}
.popover__notif:not(.is-unread) .dot { background: transparent; }

.text-left { text-align: left; }

/* --- Progress bar ----------------------------------------------------------- */
.progress {
  height: 6px;
  background: var(--smoke-200);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: var(--space-2);
}
.progress__bar {
  height: 100%;
  background: var(--ink);
  transition: width 0.3s ease;
  border-radius: var(--radius-pill);
}
.progress__bar--striped {
  background: repeating-linear-gradient(
    -45deg,
    var(--ink),
    var(--ink) 4px,
    var(--smoke-700) 4px,
    var(--smoke-700) 8px
  );
}
.progress__bar--success { background: var(--green); }
.progress__bar--warn    { background: var(--amber); }
.progress__bar--danger  { background: var(--red); }

/* Inline icon tile for list items */
.icon-tile {
  width: 32px; height: 32px;
  border: var(--line);
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--paper);
  color: var(--ink);
}
.icon-tile svg { width: 14px; height: 14px; }

/* Stat label with icon */
.stat__label--icon {
  display: flex; align-items: center; gap: 6px;
}
.stat__label--icon svg { width: 13px; height: 13px; flex-shrink: 0; }

/* --- Stepper ---------------------------------------------------------------- */
.stepper {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--smoke-50);
  border: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.stepper__step {
  display: flex; align-items: center; gap: 8px;
  color: var(--smoke-500);
  flex-shrink: 0;
}
.stepper__num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: var(--line);
  border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 500;
  background: var(--paper); color: var(--smoke-500);
}
.stepper__step.is-active { color: var(--ink); font-weight: 500; }
.stepper__step.is-active .stepper__num,
.stepper__step.is-done   .stepper__num {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.stepper__step.is-done { color: var(--ink); }
.stepper__line {
  flex: 1; height: 1px; background: var(--smoke-300); min-width: 16px;
}
.stepper__step.is-done + .stepper__line,
.stepper__line.is-done { background: var(--ink); }
.stepper__label { font-size: 13px; }
@media (max-width: 480px) {
  .stepper__label { font-size: 12px; }
}

/* --- Form grid -------------------------------------------------------------- */
.grid-2-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .grid-2-form { grid-template-columns: 1fr 1fr; gap: var(--space-4); }
}
.grid-4-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 640px)  { .grid-4-form { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1024px) { .grid-4-form { grid-template-columns: repeat(4, 1fr); gap: var(--space-3); } }
.field--full { grid-column: 1 / -1; }

/* --- Page tabs -------------------------------------------------------------- */
.page__tabs {
  display: flex;
  gap: var(--space-4);
  border-bottom: var(--line);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.page__tabs::-webkit-scrollbar { display: none; }
.page__tab {
  padding: 10px 2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--smoke-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  flex-shrink: 0;
  text-decoration: none;
}
.page__tab.is-active { color: var(--ink); border-color: var(--ink); }
.page__tab:hover { color: var(--ink); }

/* --- Country chip ----------------------------------------------------------- */
.country-chip {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  background: var(--smoke-100);
  color: var(--ink);
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}

/* --- Filter bar (sticky search + actions) ----------------------------------- */
.filter-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.filter-bar__search {
  position: relative;
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  border: var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  height: 40px;
  padding-left: 38px;
  padding-right: 12px;
}
.filter-bar__search:focus-within { box-shadow: 0 0 0 2px var(--ink); border-color: var(--ink); }
.filter-bar__search > svg {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  color: var(--smoke-500);
  pointer-events: none;
}
.filter-bar__search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
  height: 100%;
  width: 100%;
  min-width: 0;
}
.filter-bar__btn {
  position: relative;
  flex-shrink: 0;
}
.filter-bar__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  font-weight: 500;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
  line-height: 1;
}

/* --- Chips ------------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 10px;
  border: var(--line);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--paper);
  color: var(--ink);
  white-space: nowrap;
}
.chip__remove {
  background: var(--smoke-200);
  color: var(--ink);
  border: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  font-weight: 500;
}
.chip__remove:hover { background: var(--smoke-300); }
.chip--ghost { color: var(--smoke-500); border-color: var(--smoke-300); }
.chip--button {
  cursor: pointer;
  padding: 0 12px;
  background: var(--paper);
  transition: background 0.1s ease;
}
.chip--button:hover { background: var(--smoke-100); }
.chip--button.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.chips-row, .preset-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.preset-chips { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; padding-bottom: 4px; }
.preset-chips::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .preset-chips { flex-wrap: wrap; }
}

.filter-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: var(--space-3);
  font-size: 13px;
}

/* --- Drawer (slide-in panel) ----------------------------------------------- */
.drawer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
  display: flex;
  align-items: flex-end;
}
@media (min-width: 768px) {
  .drawer { align-items: stretch; justify-content: flex-end; }
}
.drawer__panel {
  width: 100%;
  max-height: 90vh;
  background: var(--paper);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  flex-direction: column;
}
@media (min-width: 768px) {
  .drawer__panel {
    max-width: 480px;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
.drawer__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--line);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.drawer__title { font-size: 16px; font-weight: 500; }
.drawer__close {
  width: 32px; height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--smoke-500);
}
.drawer__close:hover { background: var(--smoke-100); color: var(--ink); }
.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-4);
}
.drawer__footer {
  padding: var(--space-3) var(--space-4);
  border-top: var(--line);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  background: var(--paper);
}
.drawer__handle {
  width: 36px; height: 4px;
  background: var(--smoke-300);
  border-radius: var(--radius-pill);
  margin: 8px auto 0;
}
@media (min-width: 768px) { .drawer__handle { display: none; } }

/* --- Modal ------------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal__panel {
  background: var(--paper);
  border-radius: var(--radius-lg);
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
@media (max-width: 480px) {
  .modal { padding: 0; align-items: stretch; }
  .modal__panel { border-radius: 0; max-height: 100vh; height: 100vh; }
}
.modal__header {
  background: var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.modal__title {
  font-size: 14px; font-weight: 500;
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.modal__title-id { font-family: var(--font-mono); font-size: 13px; opacity: 0.85; }
.modal__close {
  background: transparent;
  border: 0;
  color: var(--paper);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.modal__close:hover { background: rgba(255, 255, 255, 0.1); }
.modal__body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal__footer {
  padding: 12px 16px;
  border-top: var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--paper);
}
.modal__section + .modal__section {
  padding-top: 14px;
  border-top: var(--hairline);
}
.modal__section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--smoke-500);
  font-weight: 500;
  margin-bottom: 10px;
}

/* Read-only field used inside modals */
.kv-field { display: flex; flex-direction: column; gap: 4px; }
.kv-field__label { font-size: 11px; color: var(--smoke-500); }
.kv-field__value {
  border: var(--line);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  background: var(--smoke-50);
  font-family: var(--font-mono);
  word-break: break-all;
}
.kv-field__value--plain { font-family: var(--font-sans); }
.grid-kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) { .grid-kv { grid-template-columns: 1fr 1fr; } }
@media (min-width: 768px) { .grid-kv-3 { grid-template-columns: 1fr 1fr 1fr !important; } }
.grid-kv-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) { .grid-kv-3 { grid-template-columns: 1fr 1fr; } }

/* Events / legs table inside modal */
.events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  border: var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.events-table th, .events-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: var(--hairline);
  white-space: nowrap;
}
.events-table thead th {
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.events-table tbody tr:last-child td { border-bottom: 0; }
.events-table tbody tr:hover td { background: var(--smoke-50); }
.events-table-wrap { overflow-x: auto; }

/* --- Player profile layout -------------------------------------------------- */
.player-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 1024px) {
  .player-grid { grid-template-columns: 1fr 320px; align-items: start; }
}
.player-aside { display: flex; flex-direction: column; gap: var(--space-4); }
.player-balance {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}
.player-balance svg {
  width: 16px; height: 16px;
  color: var(--smoke-500);
  flex-shrink: 0;
}
.player-balance__label { color: var(--smoke-500); }
.player-balance__value { font-weight: 500; margin-left: auto; font-variant-numeric: tabular-nums; }
.player-path {
  display: flex; flex-wrap: wrap; gap: 4px 6px;
  align-items: center;
  font-size: 12px;
}
.player-path__role { color: var(--smoke-500); }
.player-path__sep { color: var(--smoke-400); margin: 0 2px; }
.player-path__name {
  color: var(--ink); font-weight: 500;
  text-decoration: none;
  border-bottom: 1px dotted var(--smoke-400);
}
.player-path__name:hover { border-bottom-color: var(--ink); }

/* Vertical drill-in menu (player profile, etc.) */
.vmenu {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.vmenu__item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: var(--hairline);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}
.vmenu__item:last-child { border-bottom: 0; }
.vmenu__item:hover { background: var(--smoke-50); }
.vmenu__item:active { background: var(--smoke-100); }
.vmenu__icon {
  width: 32px; height: 32px;
  border: var(--line);
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--paper);
}
.vmenu__icon svg { width: 16px; height: 16px; color: var(--ink); }
.vmenu__main { flex: 1; min-width: 0; }
.vmenu__label { font-size: 14px; font-weight: 500; line-height: 1.3; }
.vmenu__sub   { font-size: 12px; color: var(--smoke-500); margin-top: 1px; }
.vmenu__chev::after { content: '›'; color: var(--smoke-400); font-size: 18px; }
.vmenu__badge {
  background: var(--smoke-100);
  color: var(--ink);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
}

/* Compact balance row inside player header */
.balance-strip {
  display: flex;
  align-items: stretch;
  border: var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
}
.balance-strip__cell {
  flex: 1;
  padding: 10px 12px;
  border-right: var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.balance-strip__cell:last-child { border-right: 0; }
.balance-strip__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--smoke-500);
}
.balance-strip__value {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.balance-strip__cell--total { background: var(--ink); color: var(--paper); }
.balance-strip__cell--total .balance-strip__label { color: var(--smoke-300); }

/* Collapsible detail section */
.expandable summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 0;
  font-size: 13px;
  color: var(--smoke-500);
  display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.expandable summary::-webkit-details-marker { display: none; }
.expandable summary::after { content: '▾'; transition: transform 0.15s; }
.expandable[open] summary::after { transform: rotate(180deg); }
.expandable[open] summary { color: var(--ink); }

/* Toggle row used in actions card */
.toggle-row {
  display: flex; align-items: center;
  padding: 10px 0;
  border-bottom: var(--hairline);
  font-size: 13px;
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row__label { flex: 1; }

/* --- Pagination ------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 4px;
  margin-top: var(--space-3);
  font-size: 13px;
}
.pagination .btn--sm { height: 32px; }
.pagination__page {
  display: flex;
  align-items: center;
  border: var(--line);
  border-radius: var(--radius-md);
  height: 32px;
  overflow: hidden;
  background: var(--paper);
}
.pagination__page input {
  border: 0;
  outline: none;
  width: 56px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  height: 100%;
  padding: 0 4px;
  appearance: textfield;
  -moz-appearance: textfield;
}
.pagination__page input::-webkit-outer-spin-button,
.pagination__page input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pagination__go {
  border: 0;
  border-left: var(--hairline);
  background: var(--paper);
  width: 32px;
  height: 100%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.pagination__go:hover { background: var(--smoke-100); }
.pagination__info {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.pagination .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
@media (max-width: 480px) {
  .pagination { gap: 4px; }
  .pagination .btn--sm { padding: 0 8px; font-size: 12px; }
  .pagination__info { font-size: 11px; width: 100%; text-align: center; margin: 4px 0 0; }
}

/* Filter section in drawer */
.filter-section {
  padding: var(--space-4) 0;
  border-bottom: var(--hairline);
}
.filter-section:last-child { border-bottom: 0; }
.filter-section__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--smoke-500);
  margin-bottom: var(--space-3);
  font-weight: 500;
}

/* --- Input group (input + trailing button) --------------------------------- */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; width: 100%; }
.input-group__action {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px;
  border: 0; background: transparent;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--smoke-500);
  border-radius: var(--radius-sm);
}
.input-group__action:hover { color: var(--ink); background: var(--smoke-100); }

/* --- Error state ------------------------------------------------------------ */
.input--error, .select--error {
  border-color: var(--ink) !important;
  box-shadow: 0 0 0 1px var(--ink);
}
.error {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--paper);
  background: var(--ink);
  padding: 6px 10px;
  margin-top: 6px;
  border-radius: var(--radius-sm);
}

/* --- Checkbox group --------------------------------------------------------- */
.checkbox-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: var(--line);
  border-radius: var(--radius-md);
  padding: 8px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--paper);
}
.checkbox {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.checkbox:hover { background: var(--smoke-100); }
.checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--ink);
  cursor: pointer;
  margin: 0;
}
.checkbox__tag {
  margin-left: auto;
  font-size: 10px; font-weight: 500;
  border: 1px solid var(--smoke-300);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--smoke-500);
}

/* --- Status dot ------------------------------------------------------------- */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink);
  flex-shrink: 0;
}
.status-dot--success { background: var(--green); }
.status-dot--danger  { background: var(--red); }
.status-dot--warn    { background: var(--amber); }
.status-dot--info    { background: var(--blue); }
.status-dot--ring {
  background: transparent;
  border: 2px solid var(--amber);
}
.status-dot--off {
  background: transparent;
  border: 1px solid var(--smoke-300);
}

/* --- Sidebar (desktop) ------------------------------------------------------ */
.sidebar {
  flex-direction: column;
  border-right: var(--line);
  background: var(--paper);
  padding: var(--space-4) 0;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}
.sidebar__group { padding: var(--space-3) var(--space-4); }
.sidebar__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--smoke-500);
  padding: 0 var(--space-3);
  margin-bottom: 4px;
}
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
}
.sidebar__link:hover { background: var(--smoke-100); }
.sidebar__link.is-active { background: var(--ink); color: var(--paper); }
.sidebar__link svg { width: 16px; height: 16px; flex-shrink: 0; }

/* --- Bottom nav (mobile) ---------------------------------------------------- */
.bottomnav {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: var(--paper);
  border-top: var(--line);
  position: sticky;
  bottom: 0;
  z-index: 20;
}
.bottomnav__item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1px;
  font-size: 9px;
  color: var(--smoke-500);
  padding: 5px 1px;
  min-width: 0;
  text-align: center;
}
.bottomnav__item.is-active { color: var(--ink); font-weight: 500; }
.bottomnav__item svg { width: 17px; height: 17px; flex-shrink: 0; }
.bottomnav__item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; line-height: 1.1; }

/* --- Main / page container -------------------------------------------------- */
.main { background: var(--paper); }
.page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4);
}
@media (min-width: 768px) {
  .page { padding: var(--space-5); }
}
.page__header {
  display: flex; align-items: end; justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.page__title { font-size: 24px; font-weight: 500; letter-spacing: -0.01em; }
.page__sub   { font-size: 13px; color: var(--smoke-500); margin-top: 2px; }

/* --- Cards ------------------------------------------------------------------ */
.card {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline);
  display: flex; align-items: center; justify-content: space-between;
}
.card__title { font-size: 14px; font-weight: 500; }
.card__body { padding: var(--space-4); }

/* --- Stat card -------------------------------------------------------------- */
.stat {
  border: var(--line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--paper);
  display: flex; flex-direction: column; gap: 4px;
}
.stat__label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--smoke-500); }
.stat__value { font-size: 22px; font-weight: 500; letter-spacing: -0.01em; }
.stat__delta { font-size: 11px; color: var(--smoke-500); }
.stat__delta--up::before { content: '↑ '; }
.stat__delta--down::before { content: '↓ '; }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}

/* Dense variant: 4 per row at every width, smaller cards. Use for 8-KPI grids. */
.grid-stats--dense {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
@media (min-width: 768px) {
  .grid-stats--dense { gap: var(--space-3); }
}
.stat--dense {
  padding: 8px 10px;
  gap: 1px;
  min-width: 0;
}
.stat--dense .stat__label {
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.2;
  min-height: 22px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stat--dense .stat__value {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.stat--dense .stat__delta {
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (min-width: 768px) {
  .stat--dense { padding: 12px 14px; }
  .stat--dense .stat__label { font-size: 11px; min-height: auto; }
  .stat--dense .stat__value { font-size: 22px; }
  .stat--dense .stat__delta { font-size: 11px; }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}
@media (min-width: 768px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
}

/* Key/value table used inside cards */
.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv td { padding: 7px 0; border-bottom: var(--hairline); }
.kv tr:last-child td { border-bottom: 0; }
.kv td:first-child { color: var(--smoke-500); }
.kv td:last-child {
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.kv__head td { font-weight: 500; color: var(--ink); padding-bottom: 10px; border-bottom: var(--line); }

/* Always 2-col, even on phones. Inner list items shrink to fit. */
.grid-2-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
@media (min-width: 1024px) {
  .grid-2-cols { gap: var(--space-4); }
}
.grid-2-cols .list__row {
  padding: 10px 10px;
  gap: 8px;
}
.grid-2-cols .list__avatar {
  width: 28px; height: 28px;
  font-size: 10px;
  border-radius: 5px;
}
.grid-2-cols .list__main  { min-width: 0; }
.grid-2-cols .list__title {
  font-size: 12px; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-2-cols .list__sub   {
  font-size: 10px; line-height: 1.3; color: var(--smoke-500);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.grid-2-cols .list__row { min-height: 50px; }
.grid-2-cols .pill        { font-size: 10px; padding: 1px 6px; }
.grid-2-cols .list__chev  { display: none; }
@media (min-width: 768px) {
  .grid-2-cols .list__row { padding: 12px 16px; gap: 12px; }
  .grid-2-cols .list__avatar { width: 36px; height: 36px; font-size: 12px; border-radius: var(--radius-sm); }
  .grid-2-cols .list__title { font-size: 14px; }
  .grid-2-cols .list__sub   { font-size: 12px; }
  .grid-2-cols .pill        { font-size: 11px; padding: 2px 8px; }
  .grid-2-cols .list__chev  { display: inline; }
}

.range-toggle {
  display: inline-flex;
  border: var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper);
}
.range-toggle button {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  border-right: var(--hairline);
  background: var(--paper);
}
.range-toggle button:last-child { border-right: 0; }
.range-toggle button:hover { background: var(--smoke-100); }
.range-toggle button.is-active { background: var(--ink); color: var(--paper); }

/* --- Pills / badges --------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.4;
}
.pill--solid { background: var(--ink); color: var(--paper); }
.pill--ghost { border-color: var(--smoke-300); color: var(--smoke-500); }

/* Status pill variants */
.pill--success { background: var(--green); color: var(--paper); border-color: var(--green); }
.pill--danger  { background: var(--red);   color: var(--paper); border-color: var(--red); }
.pill--warn    { background: var(--amber); color: var(--paper); border-color: var(--amber); }
.pill--info    { background: var(--blue);  color: var(--paper); border-color: var(--blue); }
.pill--muted   { background: transparent;  color: var(--grey);  border-color: var(--smoke-300); }

/* --- Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 var(--space-4);
  border: var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500;
  transition: transform 0.05s ease;
}
.btn:hover { background: var(--smoke-100); }
.btn:active { transform: scale(0.98); }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--smoke-700); }
.btn--ghost { border-color: var(--smoke-300); }

/* Status button variants */
.btn--danger  { background: var(--red);   color: var(--paper); border-color: var(--red); }
.btn--danger:hover  { background: var(--red-700);   border-color: var(--red-700); }
.btn--success { background: var(--green); color: var(--paper); border-color: var(--green); }
.btn--success:hover { background: var(--green-700); border-color: var(--green-700); }
.btn--warn    { background: var(--amber); color: var(--paper); border-color: var(--amber); }
.btn--warn:hover    { background: var(--amber-700); border-color: var(--amber-700); }
.btn--block { width: 100%; }
.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: 13px; }

/* --- Inputs ----------------------------------------------------------------- */
.input, .select, .textarea {
  display: block;
  width: 100%;
  height: 40px;
  border: var(--line);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}
.textarea { height: auto; min-height: 96px; padding: var(--space-3); resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; box-shadow: 0 0 0 2px var(--ink);
}
.label { font-size: 12px; color: var(--smoke-500); display: block; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--space-3); }

/* --- Switch ----------------------------------------------------------------- */
.switch {
  position: relative; display: inline-block;
  width: 38px; height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch__slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--paper); border: var(--line);
  border-radius: var(--radius-pill);
  transition: 0.15s;
}
.switch__slider::before {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: var(--ink); border-radius: 50%;
  transition: 0.15s;
}
.switch input:checked + .switch__slider { background: var(--ink); }
.switch input:checked + .switch__slider::before { background: var(--paper); transform: translateX(16px); }

/* --- List rows -------------------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.list__row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline);
}
.list__row:last-child { border-bottom: 0; }
.list__row:hover { background: var(--smoke-50); }
.list__avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 12px;
  flex-shrink: 0;
}
.list__avatar--ghost { background: var(--paper); color: var(--ink); border: var(--line); }
.list__main { flex: 1; min-width: 0; }
.list__title { font-size: 14px; font-weight: 500; }
.list__sub   { font-size: 12px; color: var(--smoke-500); }
.list__chev::after { content: '›'; color: var(--smoke-400); font-size: 18px; }

/* --- Sparkline placeholder -------------------------------------------------- */
.spark {
  width: 100%; height: 60px;
  display: block;
}

/* --- Login screen ----------------------------------------------------------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--paper);
}
.login__card {
  width: 100%;
  max-width: 360px;
}
.login__brand {
  text-align: center;
  margin-bottom: var(--space-5);
}
.login__brand-mark {
  width: 44px; height: 44px;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 14px;
}
.login__title { font-size: 22px; font-weight: 500; margin-top: var(--space-3); }
.login__sub   { font-size: 13px; color: var(--smoke-500); margin-top: 2px; }

/* --- Utility: visually hidden ----------------------------------------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Layout helpers --------------------------------------------------------- */
.row { display: flex; align-items: center; gap: var(--space-3); }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.between { justify-content: space-between; }
.grow { flex: 1; }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.muted { color: var(--smoke-500); }
.font-medium { font-weight: 500; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: initial; } .hide-desktop { display: none; } }

/* --- Section heading -------------------------------------------------------- */
.section {
  margin-top: var(--space-5);
}
.section__title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--smoke-500);
  margin-bottom: var(--space-3);
}

/* --- Empty state ------------------------------------------------------------ */
.empty {
  border: 1px dashed var(--smoke-300);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--smoke-500);
}

/* --- Tables (desktop) ------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: var(--space-3); border-bottom: var(--hairline); }
.table th { font-weight: 500; color: var(--smoke-500); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:hover td { background: var(--smoke-50); }
