/* ============================================================
   CricBata v2.0 — Main Design System
   Professional Cricket Ledger
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  line-height: 1.4;
  font-feature-settings: "tnum" 1, "kern" 1;
  -webkit-font-smoothing: antialiased;
}

/* Numbers always tabular */
.num, td, .amount, .rate, .stake {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* --- App Shell --- */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
#splash {
  position: fixed;
  inset: 0;
  background: var(--splash-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 9999;
  transition: opacity 0.4s ease;
}

#splash .splash-icon {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 0 24px rgba(61,127,255,0.4));
  animation: splashPulse 2s ease-in-out infinite;
}

#splash .splash-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e8eaf0;
}

#splash .splash-tag {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #3d7fff;
}

#splash .splash-loader {
  margin-top: 32px;
  width: 120px;
  height: 2px;
  background: #1a1f2e;
  border-radius: 1px;
  overflow: hidden;
}

#splash .splash-loader-bar {
  height: 100%;
  background: linear-gradient(90deg, #3d7fff, #22c55e);
  border-radius: 1px;
  animation: splashLoad 1.6s ease-in-out forwards;
}

@keyframes splashPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 24px rgba(61,127,255,0.4)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 0 32px rgba(61,127,255,0.6)); }
}

@keyframes splashLoad {
  0% { width: 0; }
  60% { width: 80%; }
  100% { width: 100%; }
}

#splash.fade-out { opacity: 0; pointer-events: none; }

/* ============================================================
   PIN / SECURITY SCREEN
   ============================================================ */
#pin-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-root);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 9000;
  padding: 24px;
}

.pin-logo {
  font-size: 28px;
  margin-bottom: 6px;
}

.pin-app-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.pin-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 36px;
}

.pin-prompt {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  letter-spacing: 0.05em;
}

.pin-dots {
  display: flex;
  gap: 14px;
  margin-bottom: 36px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pin-dot-empty);
  border: 1.5px solid var(--border-default);
  transition: background 0.15s, transform 0.15s;
}

.pin-dot.filled {
  background: var(--pin-dot-filled);
  border-color: var(--pin-dot-filled);
  transform: scale(1.1);
}

.pin-dot.error {
  background: var(--color-negative);
  border-color: var(--color-negative);
  animation: pinShake 0.3s ease;
}

@keyframes pinShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(4, 56px);
  gap: 10px;
}

.pin-key {
  background: var(--pin-key-bg);
  border: 1px solid var(--pin-key-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

.pin-key:active, .pin-key.pressed {
  background: var(--pin-key-hover);
  transform: scale(0.94);
}

.pin-key.pin-action {
  font-size: 13px;
  color: var(--text-secondary);
}

.pin-key.pin-bio {
  font-size: 22px;
}

.pin-error-msg {
  margin-top: 16px;
  font-size: 12px;
  color: var(--color-negative);
  height: 16px;
  text-align: center;
}

.pin-lock-msg {
  font-size: 13px;
  color: var(--color-negative);
  text-align: center;
  margin-top: 16px;
}

/* ============================================================
   LOGIN TOGGLE
   ============================================================ */
.login-toggle-row {
  margin-top: 20px;
  text-align: center;
}

.login-toggle-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.15s;
}

.login-toggle-btn:hover {
  opacity: 0.75;
}

/* ============================================================
   ID / PASSWORD LOGIN SCREEN
   ============================================================ */
#id-login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-root);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 9000;
  padding: 24px;
}

#account-setup-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-root);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 9000;
  padding: 24px;
}

/* ============================================================
   TRIAL SETUP SCREEN
   ============================================================ */
#trial-setup-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-root);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  z-index: 9000;
  padding: 24px;
  overflow-y: auto;
}

.trial-helper-text {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

.trial-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
}

.trial-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.trial-divider-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.trial-license-row {
  display: flex;
  gap: 8px;
}

.trial-license-input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 13px;
}

.trial-license-btn {
  white-space: nowrap;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
}

.trial-status-block {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 20px;
}

.trial-status-text {
  font-size: 14px;
  color: var(--text-muted);
}

.trial-spinner-wrap {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.trial-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.trial-success-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.trial-success-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.trial-success-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.id-login-form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.id-login-prompt {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 24px;
}

.id-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.id-field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.id-field-input {
  background: var(--bg-card);
  border: 1.5px solid var(--border-default);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.id-field-input:focus {
  border-color: var(--color-accent);
}

.id-field-pw-wrap {
  position: relative;
}

.id-field-pw-wrap .id-field-input {
  padding-right: 44px;
}

.id-pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

.id-error-msg {
  font-size: 12px;
  color: var(--color-negative);
  text-align: center;
  min-height: 16px;
  margin-bottom: 4px;
}

.id-login-btn {
  width: 100%;
  margin-top: 8px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
}

.id-forgot-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
  margin-top: 12px;
  padding: 4px;
  transition: color 0.15s;
}

.id-forgot-link:hover {
  color: var(--color-accent);
}

/* ============================================================
   FORGOT PASSWORD MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}

.modal-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}



/* ============================================================
   HEADER
   ============================================================ */
#header {
  height: 42px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
  z-index: 100;
}

.header-logo {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.header-logo span.logo-icon { font-size: 18px; }
.header-logo span.logo-text { color: var(--accent-primary); }

.header-match {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  padding: 0 8px;
}

.header-match strong {
  color: var(--text-primary);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.header-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}

.header-btn:hover, .header-btn:active {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
/* Bottom nav base — sizing deferred to premium.css to avoid conflicts */
#bottom-nav {
  display: flex;
  align-items: flex-start;
  flex-shrink: 0;
  flex-grow: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  /* height set in premium.css */
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
  position: relative;
  padding: 0;
  -webkit-user-select: none;
  min-width: 0; /* allow items to shrink */
}

.nav-item .nav-icon {
  font-size: 18px;
  line-height: 1;
  transition: transform 0.15s;
}

.nav-item:active .nav-icon { transform: scale(0.88); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.view.active { display: flex; flex-direction: column; }

/* ============================================================
   PAGE HEADER (inside views)
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 6px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.page-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ============================================================
   TABLES — Primary UI Component
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

table.cb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

table.cb-table thead {
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

table.cb-table thead th {
  background: var(--table-header-bg);
  color: var(--table-header-text);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  text-align: right;
  border-bottom: 2px solid var(--table-header-border);
  box-shadow: 0 2px 4px var(--table-header-shadow);
  white-space: nowrap;
  user-select: none;
}

table.cb-table thead th:first-child { text-align: left; }
table.cb-table thead th.left { text-align: left; }
table.cb-table thead th.center { text-align: center; }

table.cb-table tbody tr {
  background: var(--table-row-bg);
  border-bottom: 1px solid var(--table-border);
  transition: background 0.1s;
}

table.cb-table tbody tr:nth-child(even) {
  background: var(--table-row-alt);
}

table.cb-table tbody tr:hover,
table.cb-table tbody tr:active {
  background: var(--table-row-hover);
}

table.cb-table tbody td {
  padding: 7px 8px;
  text-align: right;
  color: var(--text-primary);
  white-space: nowrap;
  vertical-align: middle;
}

table.cb-table tbody td:first-child { text-align: left; }
table.cb-table tbody td.left { text-align: left; }
table.cb-table tbody td.center { text-align: center; }

/* Total Row */
table.cb-table tfoot tr {
  background: var(--table-total-bg) !important;
  border-top: 2px solid var(--color-gold-dim);
}

table.cb-table tfoot td {
  padding: 8px 10px;
  font-weight: 800;
  font-size: 13px;
  color: var(--color-gold);
  text-align: right;
  white-space: nowrap;
}

table.cb-table tfoot td:first-child { text-align: left; }

/* ============================================================
   AMOUNT STYLING
   ============================================================ */
.amt-pos {
  color: var(--color-positive);
  font-weight: 600;
}

.amt-neg {
  color: var(--color-negative);
  font-weight: 600;
}

.amt-zero {
  color: var(--text-muted);
}

.amt-gold {
  color: var(--color-gold);
  font-weight: 700;
}

/* Chip style for live screen */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-feature-settings: "tnum" 1;
}

.chip-pos {
  background: var(--color-positive-chip);
  color: var(--color-positive);
}

.chip-neg {
  background: var(--color-negative-chip);
  color: var(--color-negative);
}

.chip-gold {
  background: var(--color-gold-chip);
  color: var(--color-gold);
}

/* ============================================================
   K/L BADGES
   ============================================================ */
.badge-kl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 18px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.badge-k {
  background: var(--badge-k-bg);
  color: var(--badge-k-text);
}

.badge-l {
  background: var(--badge-l-bg);
  color: var(--badge-l-text);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-active {
  background: var(--color-positive-chip);
  color: var(--color-positive);
}

.badge-inactive {
  background: var(--color-negative-chip);
  color: var(--color-negative);
}

.badge-declared {
  background: var(--color-gold-chip);
  color: var(--color-gold);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 34px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
}
.btn-primary:hover { background: var(--btn-primary-hover); }

.btn-danger {
  background: var(--btn-danger-bg);
  color: var(--btn-danger-text);
}
.btn-danger:hover { background: var(--btn-danger-hover); }

.btn-success {
  background: var(--btn-success-bg);
  color: var(--btn-success-text);
}
.btn-success:hover { background: var(--btn-success-hover); }

.btn-ghost {
  background: var(--btn-ghost-bg);
  color: var(--btn-ghost-text);
  border: 1px solid var(--btn-ghost-border);
}
.btn-ghost:hover { background: var(--btn-ghost-hover); }

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 11px;
  border-radius: 6px;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 10px;
  border-radius: 5px;
}

.btn-icon {
  width: 34px;
  padding: 0;
}

.btn-icon.btn-sm { width: 28px; }

/* FAB — Floating Action Button */
.fab {
  position: fixed;
  bottom: 68px;
  right: 14px;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-primary);
  color: var(--accent-on-primary, #fff);
  border: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(61,127,255,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 200;
  -webkit-user-select: none;
}

.fab:active { transform: scale(0.92); box-shadow: 0 2px 8px rgba(61,127,255,0.3); }

/* ============================================================
   INPUTS
   ============================================================ */
.input-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cb-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--input-text);
  font-size: 13px;
  font-family: inherit;
  padding: 0 10px;
  height: 36px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  font-feature-settings: "tnum" 1;
}

.cb-input:focus {
  border-color: var(--border-focus);
  background: var(--input-focus-bg);
}

.cb-input::placeholder { color: var(--input-placeholder); }

.activation-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 10px;
}

.cb-input-sm {
  height: 30px;
  font-size: 12px;
  padding: 0 8px;
  border-radius: 6px;
}

textarea.cb-input {
  height: auto;
  padding: 8px 10px;
  resize: none;
  line-height: 1.5;
}

/* Select */
select.cb-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7494' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* Toggle Switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border-default);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle.on {
  background: var(--accent-primary);
}

.toggle.on::after { transform: translateX(16px); }

/* Checkbox */
.cb-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--input-bg);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.cb-check:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.cb-check:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* Tally Checkbox special */
.tally-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-strong);
  background: var(--input-bg);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.tally-check:checked {
  background: var(--color-positive);
  border-color: var(--color-positive);
}

.tally-check:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ============================================================
   ENTRY FORM (Match Bet / Session Bet)
   ============================================================ */
.entry-bar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  padding: 8px 10px;
  flex-shrink: 0;
}

.entry-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.entry-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.entry-field label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.entry-field .cb-input {
  height: 34px;
  font-size: 13px;
  font-weight: 600;
}

.entry-field-rate { width: 70px; }
.entry-field-stake { width: 80px; }
.entry-field-kl { width: 54px; }
.entry-field-team { width: 80px; }
.entry-field-client { flex: 1; min-width: 80px; }
.entry-field-line { width: 70px; }
.entry-field-yn { width: 54px; }
.entry-field-session { width: 110px; }

.entry-add-btn {
  height: 34px;
  padding: 0 16px;
  flex-shrink: 0;
  margin-top: 12px;
}

/* Client Search Suggestions */
.search-suggest {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  max-height: 180px;
  overflow-y: auto;
}

.suggest-item {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.1s;
}

.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.focused { background: var(--bg-hover); }
.suggest-item .suggest-group { font-size: 10px; color: var(--text-muted); margin-top: 1px; }

/* ============================================================
   DIALOGS
   ============================================================ */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.dialog-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.dialog {
  background: var(--dialog-bg);
  border: 1px solid var(--dialog-border);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--dialog-shadow);
  width: 100%;
  max-width: 540px;
  padding: 0;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
}

.dialog-overlay.open .dialog {
  transform: translateY(0);
}

.dialog-handle {
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.dialog-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.dialog-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

.dialog-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.dialog-footer .btn { flex: 1; }

/* Alert Dialog (centered) */
.dialog-overlay.center {
  align-items: center;
  padding: 16px;
}

.dialog-overlay.center .dialog {
  border-radius: 14px;
  transform: scale(0.92);
  opacity: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.dialog-overlay.center.open .dialog {
  transform: scale(1);
  opacity: 1;
}

/* ============================================================
   FORM LAYOUT (inside dialogs)
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  -webkit-user-select: none;
}

.filter-chip.active {
  background: var(--accent-glow);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.sessions-chip-scroll {
  white-space: nowrap;
}

.sessions-chip-scroll::-webkit-scrollbar { display: none; }

.sessions-chip-scroll .filter-chip {
  white-space: nowrap;
}

/* ============================================================
   MATCH TABS
   ============================================================ */
.match-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-surface);
  overflow-x: auto;
  flex-shrink: 0;
}

.match-tabs::-webkit-scrollbar { display: none; }

.match-tab {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s;
  -webkit-user-select: none;
}

.match-tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* ============================================================
   LIST ITEMS (Clients, Groups, etc.)
   ============================================================ */
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.1s;
  background: var(--bg-surface);
}

.list-item:nth-child(even) { background: var(--bg-row-alt); }
.list-item:hover, .list-item:active { background: var(--bg-hover); }

.list-item-main { flex: 1; overflow: hidden; }

.list-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  padding: 6px 12px 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-root);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 5;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  gap: 8px;
  flex: 1;
}

.empty-icon { font-size: 36px; opacity: 0.4; }

.empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   TOASTS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: calc(100% - 24px);
  max-width: 400px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s ease forwards;
}

.toast.success { border-left: 3px solid var(--color-positive); }
.toast.error { border-left: 3px solid var(--color-negative); }
.toast.info { border-left: 3px solid var(--accent-primary); }
.toast.warning { border-left: 3px solid var(--color-gold); }

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

/* ============================================================
   SETTINGS ROWS
   ============================================================ */
.settings-section {
  margin-bottom: 4px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.1s;
}

.settings-row:hover { background: var(--bg-hover); }

.settings-row-left { display: flex; align-items: center; gap: 10px; }

.settings-row-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.settings-row-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-row-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.settings-row-right {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   LANDSCAPE (DESKTOP TERMINAL MODE)
   ============================================================ */
@media (orientation: landscape) and (min-width: 600px) {
  #app {
    flex-direction: row;
  }

  #bottom-nav {
    width: 60px;
    height: 100%;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--nav-border);
    padding: 8px 0;
    gap: 4px;
    overflow-y: auto;
  }

  .nav-item {
    height: 52px;
    flex: none;
    width: 100%;
    border-radius: 0;
    font-size: 8px;
  }

  .nav-item.active::after {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 2px;
    height: 24px;
    border-radius: 0 2px 2px 0;
  }

  #content {
    flex: 1;
    display: flex;
    flex-direction: column;
  }

  #header {
    height: 42px;
  }

  .fab {
    bottom: 14px;
    right: 14px;
  }

  #toast-container {
    bottom: 14px;
  }

  /* Wider tables in landscape */
  table.cb-table { font-size: 13px; }
  table.cb-table thead th { font-size: 11px; padding: 8px 12px; }
  table.cb-table tbody td { padding: 8px 12px; }
  table.cb-table tfoot td { padding: 9px 12px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-1 { gap: 4px; }
.flex-1 { flex: 1; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.p-3 { padding: 12px; }
.relative { position: relative; }

/* Divider */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

/* Warning text */
.warning-text {
  font-size: 11px;
  color: var(--color-gold);
  background: var(--color-gold-bg);
  border: 1px solid var(--color-gold-dim);
  border-radius: 6px;
  padding: 8px 10px;
  line-height: 1.5;
}

/* ============================================================
   MATCH QUICK-ACCESS TABS BAR (2nd nav row)
   ============================================================ */
#match-tabs-bar {
  height: auto;
  min-height: 36px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  padding: 0 6px;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  order: 1;
  z-index: 90;
}

.chip-empty-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 6px;
  font-style: italic;
  white-space: nowrap;
}

.tab-type-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-live    { background: #22c55e; }
.dot-saved   { background: #f59e0b; }
.dot-session { background: #818cf8; }

#match-tabs-bar::-webkit-scrollbar { display: none; }

.match-quick-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.match-quick-tab:hover,
.match-quick-tab:active {
  background: var(--bg-elevated);
  border-color: var(--color-primary);
}

.match-quick-tab.active {
  background: color-mix(in srgb, var(--color-primary) 15%, transparent);
  border-color: var(--color-primary);
}

.match-quick-tab-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-quick-tab-close {
  font-size: 14px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  transition: color 0.1s, background 0.1s;
}

.match-quick-tab-close:hover {
  color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
}

/* Flex order so tabs bar sits above bottom-nav */
#app {
  display: flex !important;
  flex-direction: column !important;
}

/* ============================================================
   STICKY ENTRY BARS (Match Bets + Session Bets)
   ============================================================ */
.mb-sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-surface);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-default);
}

.mb-summary-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
}

.mb-summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  white-space: nowrap;
}

.sb-sticky-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-surface);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-default);
}

.sb-table-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* mbets-content needs to be a proper flex column */
#mbets-content {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* ============================================================
   VOUCHER / STATEMENT STYLES
   ============================================================ */
.stmt-clickable:hover td {
  background: var(--table-row-hover) !important;
}

.stmt-clickable td {
  transition: background 0.1s;
}

/* Success button */
.btn-success {
  background: var(--color-positive, #22c55e);
  color: #fff;
  border: none;
}
.btn-success:hover { opacity: 0.88; }
.btn-success:active { opacity: 0.75; }


/* ============================================================
   LANDSCAPE FIX — Match tabs bar + entry bars + sticky
   ============================================================ */
@media (orientation: landscape) and (min-width: 600px) {

  /* Match tabs bar goes full width below header in landscape */
  #match-tabs-bar {
    order: 0;
    width: 100%;
    border-left: none;
    border-right: none;
  }

  /* Content area fills remaining space */
  #content {
    order: 1;
    flex: 1;
    overflow: hidden;
  }

  /* In landscape the app is row, so wrap content+tabs into a column */
  #app {
    flex-direction: row !important;
  }

  /* Right side: header + match-tabs-bar + content stacked vertically */
  #header, #match-tabs-bar, #content {
    /* These are siblings inside app; need a column wrapper */
  }

  /* Entry bars: compact in landscape */
  .entry-bar {
    padding: 5px 8px;
  }
  .entry-row {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .entry-field .cb-input {
    height: 30px;
    font-size: 12px;
  }
  .entry-field label {
    font-size: 8px;
  }
  .entry-field-rate  { width: 60px; }
  .entry-field-stake { width: 70px; }
  .entry-field-kl    { width: 46px; }
  .entry-field-team  { width: 80px; }
  .entry-field-session { width: 90px; }
  .entry-field-line  { width: 60px; }
  .entry-field-yn    { width: 46px; }
  .entry-add-btn { height: 30px; padding: 0 10px; font-size: 12px; }

  /* Sticky headers height reduced in landscape */
  .mb-sticky-header,
  .sb-sticky-header {
    max-height: 45vh;
    overflow-y: auto;
  }

  /* Match tabs in landscape: smaller */
  .match-tab { font-size: 10px; padding: 5px 10px; }
  .match-quick-tab-name { max-width: 80px; }

  /* Dialogs fit landscape */
  .dialog {
    max-height: 90vh;
    max-width: 95vw;
  }
  .dialog-body {
    max-height: 60vh;
    overflow-y: auto;
  }

  /* Page header smaller in landscape */
  .page-header {
    padding: 6px 10px;
  }
}

/* ============================================================
   LANDSCAPE — Small phones (most Android landscape ~360px tall)
   ============================================================ */
@media (orientation: landscape) and (max-height: 420px) {

  #header { height: 36px; }
  #header .header-logo .logo-text { display: none; }
  #header .header-match { font-size: 11px; }

  #match-tabs-bar { min-height: 30px; }
  .match-quick-tab { padding: 3px 6px; }
  .match-quick-tab-name { font-size: 10px; }

  .entry-bar { padding: 3px 6px; }
  .entry-field .cb-input { height: 26px; font-size: 11px; }
  .entry-add-btn { height: 26px; }

  .match-tabs { padding: 2px !important; }
  .match-tab { font-size: 9px; padding: 4px 8px; }

  /* Bottom nav: don't shrink below premium.css values on small screens */
}

/* ============================================================
   APP MAIN WRAPPER (header + match-tabs-bar + content column)
   ============================================================ */
#app-main {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0; /* critical: prevents flex child from overflowing parent height on Android */
}

@media (orientation: landscape) and (min-width: 600px) {
  #app {
    flex-direction: row !important;
  }
  /* Bottom nav moves to left side in landscape */
  #bottom-nav {
    order: 0;
  }
  /* app-main takes remaining width */
  #app-main {
    order: 1;
    flex: 1;
    flex-direction: column;
  }
  /* match-tabs-bar inside app-main stays under header */
  #match-tabs-bar {
    width: 100%;
  }
}

/* ============================================================
   COMPACT 1-LINER ROWS (Clients & Saved Matches)
   ============================================================ */
.compact-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  padding: 0 8px 0 12px !important;
  height: 40px !important;
  gap: 0 !important;
  overflow: hidden;
}

.compact-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.compact-eq {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 5px;
  flex-shrink: 0;
}

.compact-scroll {
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  /* Hide scrollbar but keep scrollable */
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  font-feature-settings: "tnum" 1;
}
.compact-scroll::-webkit-scrollbar { display: none; }

.compact-scroll.amt-pos { color: var(--color-positive); }

.compact-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding-left: 4px;
}

.compact-actions .btn-xs {
  padding: 2px 7px;
  font-size: 10px;
  height: 24px;
}

/* ============================================================
   SAVED — MULTI-SELECT & SUMMARY
   ============================================================ */

/* Saved match row — tight 2-line layout (title + winner/date/format) */
.saved-row-v2 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.12s;
}

.saved-row-v2:nth-child(even) { background: var(--bg-row-alt); }
.saved-row-v2:active { background: var(--bg-hover); }

.saved-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.saved-row-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-row-meta {
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-feature-settings: "tnum" 1;
}

.saved-row-meta.amt-pos { color: var(--color-positive); }

.saved-row-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.saved-row-actions .btn-xs {
  padding: 0 7px;
  font-size: 10px;
  height: 24px;
}

/* Tick checkbox */
.saved-tick {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.tick-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border-default);
  background: var(--bg-input);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.tick-box.ticked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.tick-box.ticked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 8px;
  height: 5px;
  border-left: 2px solid #0c1220;
  border-bottom: 2px solid #0c1220;
  transform: rotate(-45deg);
}

.saved-row-v2.row-selected {
  background: var(--bg-hover) !important;
  border-left: 2px solid var(--accent-primary);
  padding-left: 8px;
}

/* Bottom Summary Bar */
.saved-summary-bar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 8px;
  z-index: 50;
}

.ssb-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ssb-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-primary);
  min-width: 70px;
}

/* Summary Dialog — Settlement Table */
.stl-matches-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 0 10px 0;
  line-height: 1.4;
  word-break: break-word;
}

.stl-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.stl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.stl-table thead tr {
  background: var(--table-header-bg);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.stl-table th {
  padding: 7px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--table-header-text);
  border-bottom: 2px solid var(--table-header-border);
}

.stl-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

.stl-table tbody tr:nth-child(even) td {
  background: var(--bg-row-alt);
}

.stl-party {
  text-align: left !important;
  font-weight: 600;
}

.stl-num {
  text-align: right !important;
  font-feature-settings: "tnum" 1;
}

.stl-net {
  font-weight: 700;
}

.stl-total-row td {
  background: var(--table-total-bg) !important;
  font-weight: 700;
  color: var(--color-gold) !important;
  border-top: 1px solid var(--border-default);
}

/* Footer summary chips */
.stl-footer {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.stl-footer-item {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.stl-footer-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stl-footer-val {
  font-size: 15px;
  font-weight: 800;
  font-feature-settings: "tnum" 1;
  color: var(--text-primary);
}

/* ============================================================
   CLIENTS — TWO COLUMN LAYOUT (left list 25% / right detail 75%)
   ============================================================ */
.clients-split {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.clients-col-left {
  width: 25%;
  min-width: 92px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  min-height: 0;
}

.clients-search-wrap {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.clients-search-wrap .cb-input {
  padding-left: 8px;
  padding-right: 8px;
  font-size: 11px;
}

.clients-name-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.client-name-row {
  padding: 11px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  word-break: break-word;
  transition: background 0.12s;
}

.client-name-row:nth-child(even) { background: var(--bg-row-alt); }
.client-name-row:hover, .client-name-row:active { background: var(--bg-hover); }

.client-name-row.active {
  background: var(--accent);
  color: #fff;
}

.client-name-row .client-status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--text-muted);
  vertical-align: middle;
}

.client-name-row.is-active-status .client-status-dot { background: var(--success, #2ecc71); }

.clients-col-right {
  width: 75%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.clients-detail-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
}

.clients-detail-panel .empty-state {
  margin: auto;
}

.client-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.client-detail-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  word-break: break-word;
}

.client-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.client-detail-form .form-group { padding: 0; }

@media (max-width: 480px) {
  .clients-col-left { width: 30%; min-width: 78px; }
  .clients-col-right { width: 70%; }
  .client-name-row { font-size: 11px; padding: 10px 5px; }
}

/* ============================================================
   REPORT ADVANCED FILTERS
   ============================================================ */
#report-adv-filters {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

#report-adv-filters .cb-input {
  border-radius: 6px;
  flex-shrink: 0;
}

/* ============================================================
   CLIENT LIMIT INFO ROW
   ============================================================ */
.limit-info-row {
  border: 1px solid var(--border-subtle);
}


/* CLIENTS POLISH V1 */
.clients-layout .clients-list,
.clients-panel-left{
  flex-basis:22% !important;
  max-width:22% !important;
}

.client-item.active,
.client-item.selected,
.client-row.active,
.client-row.selected{
  border-left:4px solid #2563eb !important;
  font-weight:700 !important;
  box-shadow:0 0 8px rgba(37,99,235,.25) !important;
}

html[data-theme="light"] .client-item.active,
html[data-theme="light"] .client-item.selected,
html[data-theme="light"] .client-row.active,
html[data-theme="light"] .client-row.selected{
  color:#111827 !important;
}

.exposure-card,
.pnl-card,
.limit-card{
  padding-top:85% !important;
}


/* THEME CONSISTENCY V1 */
.app-header,
.topbar,
.header,
.navbar,
.bottom-nav,
.tabbar,
.footer-nav{
  background: var(--header-bg) !important;
  color: var(--text-primary) !important;
}

.bottom-nav,
.tabbar,
.footer-nav{
  border-top: 1px solid var(--border-color) !important;
}

.bottom-nav .active,
.tabbar .active{
  color: var(--accent-primary, #2563eb) !important;
}


/* THEME CONSISTENCY V2 — nav overrides removed; handled by premium.css */
#topbar,
#app-header,
header,
.app-header{
  background: var(--header-bg) !important;
  color: var(--text-primary) !important;
}


/* HEADER CLIENT POLISH V1 */

/* Light mode header shell */
html[data-theme="light"] .app-shell,
html[data-theme="light"] .app-header,
html[data-theme="light"] .topbar,
html[data-theme="light"] .header,
html[data-theme="light"] .toolbar,
html[data-theme="light"] .app-toolbar{
    background:#ffffff !important;
    color:#111827 !important;
    border-color:#e5e7eb !important;
}

/* Client selection */
.client-item.active,
.client-item.selected,
.client-row.active,
.client-row.selected,
.client-list-item.active,
.client-list-item.selected{
    border-left:4px solid #2563eb !important;
    background:rgba(37,99,235,.12) !important;
    font-weight:700 !important;
    box-shadow:inset 0 0 0 1px rgba(37,99,235,.15) !important;
}

/* Light mode selected client text */
html[data-theme="light"] .client-item.active,
html[data-theme="light"] .client-item.selected,
html[data-theme="light"] .client-row.active,
html[data-theme="light"] .client-row.selected{
    color:#111827 !important;
}

/* Slightly narrower left panel */
.clients-sidebar,
.clients-panel-left,
.client-list-panel{
    width:22% !important;
    max-width:22% !important;
}


/* PREMIUM THEME REFACTOR V1 */
:root{
  --sheet-bg:#FCFCFD;
  --sheet-text:#111827;
  --sheet-border:#E5EAF2;
}
[data-theme="dark"]{
  --sheet-bg:#0D1B36;
  --sheet-text:#FFFFFF;
  --sheet-border:#1E325C;
}

.dialog,.modal,.sheet,.bottom-sheet,.popup,.confirm-dialog,.subscription-modal{
  background:var(--sheet-bg)!important;
  color:var(--sheet-text)!important;
  border:1px solid var(--sheet-border)!important;
  backdrop-filter:none!important;
  border-radius:24px!important;
}

.dialog *,.modal *,.sheet *,.bottom-sheet *,.popup *,.confirm-dialog *,.subscription-modal *{
  color:inherit!important;
}

.toast{
  background:var(--sheet-bg)!important;
  color:var(--sheet-text)!important;
  border:1px solid var(--sheet-border)!important;
}


/* DATA DENSITY V1 */

/* Client list */
.client-item,
.client-row,
.client-list-item{
  min-height:44px !important;
  padding:8px 12px !important;
}

/* Tables */
table th{
  padding:8px 10px !important;
}
table td{
  padding:7px 10px !important;
}

/* Ledger / reports / saved rows */
.ledger-table td,
.report-table td,
.saved-table td{
  padding-top:6px !important;
  padding-bottom:6px !important;
}

/* Teams / Groups lists */
.team-row,
.group-row,
.list-row{
  min-height:40px !important;
  padding:6px 10px !important;
}

/* Client header visibility */
.client-name,
.client-title{
  font-weight:800 !important;
  color:var(--text-primary,#111827) !important;
}


/* CLIENTS FOCUSED V1 */
.client-name-row{min-height:42px!important;padding:8px 12px!important;font-weight:700!important;}
[data-theme="light"] .client-name-row{color:#111827!important;}
[data-theme="dark"] .client-name-row{color:#F8FAFC!important;}
.client-name-row.active{border-left:4px solid #2563EB!important;font-weight:800!important;}
[data-theme="light"] .client-name-row.active{background:#DCEBFF!important;}
[data-theme="dark"] .client-name-row.active{background:#102044!important;}


/* STEP5G-R2 Summary Selector */
.summary-match-search{width:100%;margin-bottom:8px}
.summary-match-list{max-height:50vh;overflow-y:auto;border:1px solid var(--border-subtle);border-radius:8px}
.summary-match-row{display:flex;align-items:center;gap:8px;padding:6px 8px;border-bottom:1px solid var(--border-subtle);font-size:12px}
.summary-match-footer{position:sticky;bottom:0;background:var(--dialog-bg);padding-top:8px;border-top:1px solid var(--border-subtle)}

/* ============================================================
   ADMIN STAT CARDS
   ============================================================ */
.admin-stat-card {
  flex: 1;
  min-width: 70px;
  background: var(--bg-surface, #0f1525);
  border: 1px solid var(--border-default, #1e2a45);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.admin-stat-card b { font-size: 18px; display: block; color: var(--text-primary); }
.astat-active  b { color: #22c55e; }
.astat-expired b { color: #f59e0b; }
.astat-disabled b { color: #ef4444; }

/* ============================================================
   SPINNER ANIMATION
   ============================================================ */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner {
  animation: spin 1s linear infinite;
}


/* ============================================================
   APPEARANCE BLOCK — Settings
   ============================================================ */

.appearance-section {
  padding: 0 0 8px;
}

.appearance-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 14px 6px;
}

/* ----------------------------------------------------------
   Live Preview Card
---------------------------------------------------------- */
.appearance-preview {
  margin: 10px 12px 4px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  background: var(--bg-surface);
  transition: background 0.3s, border-color 0.3s;
  pointer-events: none;
  user-select: none;
}

/* When preview has inline vars, use them */
.appearance-preview .ap-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--header-bg, var(--bg-surface));
  border-bottom: 1px solid var(--header-border, var(--border-default));
}

.ap-logo {
  font-size: 10px;
  font-weight: 900;
  color: var(--accent-primary, #2563eb);
  letter-spacing: 0.04em;
}

.ap-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.ap-badge {
  font-size: 7px;
  font-weight: 800;
  background: var(--accent-primary, #2563eb);
  color: var(--accent-on-primary, #fff);
  padding: 1px 4px;
  border-radius: 3px;
  letter-spacing: 0.06em;
}

.ap-spacer { flex: 1; }

.ap-btn-mock {
  width: 22px;
  height: 16px;
  border-radius: 5px;
  background: var(--accent-primary, #2563eb);
  opacity: 0.7;
}

.ap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--table-row-bg, var(--bg-surface));
  border-bottom: 1px solid var(--table-header-border, var(--border-subtle));
}

.ap-row-alt {
  background: var(--table-row-alt, var(--bg-elevated));
}

.ap-badge-kl {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.ap-k { background: var(--color-negative, #dc2626); }
.ap-l { background: var(--color-positive, #16a34a); }

.ap-row-text { flex: 1; min-width: 0; }

.ap-row-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-row-sub {
  font-size: 8px;
  color: var(--text-muted);
  margin-top: 1px;
}

.ap-amount {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.ap-pos { color: var(--color-positive, #16a34a); }
.ap-neg { color: var(--color-negative, #dc2626); }

.ap-nav {
  display: flex;
  background: var(--nav-bg, var(--bg-surface));
  border-top: 1px solid var(--nav-border, var(--border-subtle));
  padding: 6px 0 5px;
}

.ap-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 6px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--nav-item-text, var(--text-muted));
}

.ap-nav-active {
  color: var(--nav-indicator, var(--accent-primary));
}

.ap-nav-dot {
  width: 14px;
  height: 10px;
  border-radius: 3px;
  background: var(--bg-elevated);
}

.ap-nav-dot-active {
  background: var(--nav-item-active-bg, rgba(37,99,235,0.12));
  outline: 1px solid var(--accent-primary, #2563eb);
  outline-offset: -1px;
}

/* ----------------------------------------------------------
   Preset Grid
---------------------------------------------------------- */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 4px 14px;
}

.preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.preset-swatch {
  width: 100%;
  aspect-ratio: 3/2;
  border-radius: 10px;
  border: 2px solid;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 4px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.preset-card--active .preset-swatch {
  border-color: var(--accent-primary) !important;
  box-shadow: 0 0 0 2px var(--accent-primary), 0 4px 12px rgba(0,0,0,0.2);
  transform: scale(1.04);
}

.ps-header {
  height: 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.ps-line {
  border-radius: 2px;
  opacity: 0.9;
}

.ps-line--primary {
  height: 4px;
  width: 80%;
}

.ps-line--secondary {
  height: 3px;
  width: 55%;
  opacity: 0.5;
}

.preset-name {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.02em;
}

.preset-card--active .preset-name {
  color: var(--accent-primary);
  font-weight: 700;
}

.preset-check {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--accent-on-primary, #fff);
  font-size: 8px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ----------------------------------------------------------
   Accent Row
---------------------------------------------------------- */
.accent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 14px 4px;
  align-items: flex-start;
}

.accent-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--dot-color);
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.accent-dot--active {
  border-color: var(--bg-surface);
  box-shadow: 0 0 0 2.5px var(--dot-color), 0 4px 12px rgba(0,0,0,0.2);
  transform: scale(1.12);
}

.accent-dot-check {
  font-size: 13px;
  font-weight: 800;
  color: var(--dot-check-color, #fff);  /* set inline per-dot by JS */
  text-shadow: none;
}

/* Black dot needs a subtle border so it's visible on dark themes */
.accent-dot[data-accent="onyx"] {
  border-color: rgba(255,255,255,0.18);
}
.accent-dot--active[data-accent="onyx"] {
  border-color: rgba(255,255,255,0.35);
}

/* White dot needs a border to be visible on light themes */
.accent-dot[data-accent="pearl"] {
  border-color: rgba(0,0,0,0.18);
}
.accent-dot--active[data-accent="pearl"] {
  border-color: rgba(0,0,0,0.25);
}

.accent-rec-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 1.5px solid var(--bg-surface);
}

.accent-labels {
  width: 100%;
  display: flex;
  gap: 10px;
  padding-top: 2px;
}

.accent-label {
  font-size: 8px;
  font-weight: 600;
  color: var(--text-muted);
  width: 36px;
  text-align: center;
  letter-spacing: 0.02em;
}

.accent-label--active {
  color: var(--accent-primary);
  font-weight: 700;
}

/* ============================================================
   Accent-specific button text overrides
   These guarantee readable text regardless of theme selection.
   data-accent is set on <html> by theme.js _applyTokens.
   ============================================================ */
[data-accent="onyx"] .btn-primary,
[data-accent="onyx"] .btn-primary:hover {
  color: #ffffff !important;
}

[data-accent="pearl"] .btn-primary,
[data-accent="pearl"] .btn-primary:hover {
  color: #1a1a1a !important;
}
