/* ============================================================================
   Market Live — Centre de Commandement Administratif
   Operate Mode + UI/UX Pro Mobile Ergonomics (Thumb Zone & Sunlight Contrast)
   ============================================================================ */

:root {
  /* Warm alabaster & crisp ink — engineered for outdoor readability */
  --bg-canvas: #F5F5F3;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F8F8F6;
  --bg-hover: #F0F1F4;

  --sidebar-bg: #0F131A;
  --sidebar-surface: #1A212D;
  --sidebar-border: #232B3A;
  --sidebar-text: #E2E8F0;
  --sidebar-muted: #94A3B8;

  --border: #E2E5EB;
  --border-strong: #CBD2DC;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #526074;

  /* Market Live Terracotta brand accent (WCAG AA >= 5.1:1 on white) */
  --brand: #C44400;
  --brand-hover: #A63900;
  --brand-soft: #FFF3EC;
  --brand-border: #FBD6BF;
  --brand-ring: rgba(196, 68, 0, 0.22);

  /* Semantic state tokens (high-contrast WCAG AA+) */
  --danger: #C81E1E;
  --danger-hover: #A61717;
  --danger-bg: #FEF2F2;
  --danger-border: #FECACA;

  --warn: #A14807;
  --warn-bg: #FFFBEB;
  --warn-border: #FDE68A;

  --success: #047857;
  --success-bg: #ECFDF5;
  --success-border: #A7F3D0;

  --info: #1D4ED8;
  --info-bg: #EFF6FF;
  --info-border: #BFDBFE;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Soft directional elevation shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.10), 0 2px 6px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.24), 0 4px 12px -4px rgba(15, 23, 42, 0.08);

  --ease-out-expo: cubic-bezier(0.22, 1, 0.36, 1);

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-width: 256px;
  --topbar-height: 64px;
  --bottom-nav-height: 64px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.48;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  caret-color: var(--brand);
  -webkit-tap-highlight-color: transparent;
}

body.overlay-open {
  overflow: hidden;
}

::selection {
  background: var(--brand-soft);
  color: var(--brand);
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #CBD2DC;
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num {
  font-variant-numeric: tabular-nums;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

a {
  text-underline-offset: 3px;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------------- BUTTONS ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition:
    background-color 0.16s var(--ease-out-expo),
    border-color 0.16s var(--ease-out-expo),
    color 0.16s var(--ease-out-expo),
    transform 0.14s var(--ease-out-expo),
    box-shadow 0.16s var(--ease-out-expo);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-lg {
  min-height: 46px;
  padding: 0 18px;
  font-size: 14.5px;
  border-radius: var(--radius-md);
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: #FFFFFF;
  box-shadow: var(--shadow-xs);
}
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    background: var(--brand-hover);
    box-shadow: var(--shadow-sm);
  }
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
@media (hover: hover) {
  .btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: #B4BECB;
  }
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  box-shadow: 0 1px 2px rgba(200, 30, 30, 0.24);
}
@media (hover: hover) {
  .btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
  }
}

.btn-danger-soft {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
@media (hover: hover) {
  .btn-danger-soft:hover:not(:disabled) {
    background: #FEE2E2;
  }
}

.btn-success-soft {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
@media (hover: hover) {
  .btn-success-soft:hover:not(:disabled) {
    background: #D1FAE5;
  }
}

.btn-warn-soft {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}
@media (hover: hover) {
  .btn-warn-soft:hover:not(:disabled) {
    background: #FEF3C7;
  }
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
@media (hover: hover) {
  .btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
}

.btn-ghost-dark {
  background: rgba(255, 255, 255, 0.08);
  color: #F1F5F9;
  border-color: rgba(255, 255, 255, 0.14);
}
@media (hover: hover) {
  .btn-ghost-dark:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
  }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.14s var(--ease-out-expo);
}
.icon-btn:active {
  transform: scale(0.94);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
@media (hover: hover) {
  .icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }
}

.icon-btn-dark {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--sidebar-border);
  color: var(--sidebar-text);
}
@media (hover: hover) {
  .icon-btn-dark:hover {
    background: var(--sidebar-surface);
    color: #FFFFFF;
  }
}

.refresh-btn.is-loading .refresh-icon {
  animation: spin360 0.75s linear infinite;
}
@keyframes spin360 {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---------------- LOGIN VIEW ---------------- */
.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(640px 360px at 50% -10%, rgba(217, 78, 4, 0.08), transparent 70%),
    var(--bg-canvas);
}

.login-card {
  width: 100%;
  max-width: 412px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 28px 24px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-brand-copy {
  min-width: 0;
}

.brand-logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
}
.brand-logo-wrap-lg {
  width: 56px;
  height: 56px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-xs);
}
.brand-logo-wrap-sm {
  width: 40px;
  height: 40px;
  padding: 2px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--sidebar-border);
  border-radius: 11px;
}
.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mobile-brand-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 2px;
  border: none;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.14s var(--ease-out-expo);
}
.mobile-brand-btn:active {
  transform: scale(0.92);
}
.mobile-brand-btn img {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.login-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1.2;
}
.login-subtitle {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-password-wrap input {
  padding-right: 46px;
}
.input-eye-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.14s ease, background-color 0.14s ease;
}
.input-eye-btn svg {
  width: 18px;
  height: 18px;
}
.input-eye-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input::placeholder,
.field textarea::placeholder {
  color: #59667B;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
}
.field textarea {
  resize: vertical;
  min-height: 88px;
}
.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}

.login-footnote {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------- APP SHELL ---------------- */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 45;
  border-right: 1px solid var(--sidebar-border);
  transition: transform 0.24s var(--ease-out-expo);
}

.sidebar-header {
  min-height: var(--topbar-height);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.02em;
}
.sidebar-sub {
  font-size: 11.5px;
  color: var(--sidebar-muted);
}

/* Mobile health + auto-refresh card inside drawer */
.sidebar-mobile-status {
  padding: 12px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  background: rgba(255, 255, 255, 0.025);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-status-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.sidebar-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--sidebar-surface);
  border: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--sidebar-muted);
  min-width: 0;
}
.sidebar-status-chip strong {
  margin-left: auto;
  color: #FFFFFF;
  font-size: 11.5px;
  white-space: nowrap;
}
.sidebar-auto-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--sidebar-surface);
  border: 1px solid var(--sidebar-border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
}
.sidebar-auto-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  margin: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-group-label {
  padding: 0 10px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, transform 0.12s var(--ease-out-expo);
}
.nav-item:active {
  transform: scale(0.98);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  color: var(--sidebar-muted);
  flex-shrink: 0;
  transition: color 0.14s ease;
}

@media (hover: hover) {
  .nav-item:hover {
    background: var(--sidebar-surface);
    color: #FFFFFF;
  }
  .nav-item:hover svg {
    color: #F1F5F9;
  }
}

.nav-item.active {
  background: rgba(217, 78, 4, 0.16);
  border-color: rgba(255, 134, 71, 0.28);
  color: #FFFFFF;
  font-weight: 600;
}
.nav-item.active svg {
  color: #FF884D;
}

.nav-badge {
  margin-left: auto;
  min-width: 21px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-badge-live {
  background: rgba(239, 68, 68, 0.24);
  color: #FCA5A5;
}
.nav-badge-warn {
  background: rgba(245, 158, 11, 0.24);
  color: #FCD34D;
}
.nav-badge-danger {
  background: rgba(217, 78, 4, 0.30);
  color: #FDBA74;
}

.sidebar-footer {
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.admin-account {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--sidebar-surface);
  border: 1px solid var(--sidebar-border);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-meta {
  min-width: 0;
}
.admin-email {
  font-size: 12.5px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-role {
  font-size: 11px;
  color: var(--sidebar-muted);
}

.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

/* ---------------- TOPBAR ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: var(--topbar-height);
  padding: env(safe-area-inset-top) 24px 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-titles {
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.22;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-subtitle {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.health-chips {
  display: flex;
  align-items: center;
  gap: 8px;
}

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

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

.mobile-health-pill {
  display: none;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-health-pill:active {
  transform: scale(0.95);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.toggle-chip input {
  accent-color: var(--brand);
  margin: 0;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-ok { background: #10B981; }
.dot-warn { background: #F59E0B; }
.dot-danger { background: #EF4444; }
.dot-neutral { background: #94A3B8; }

/* ---------------- MAIN WORKSPACE ---------------- */
.view-root {
  flex: 1;
  padding: 20px 24px 40px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* KPI STRIP */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.14s var(--ease-out-expo);
}
.kpi-card.clickable {
  cursor: pointer;
}
@media (hover: hover) {
  .kpi-card.clickable:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
  }
}
.kpi-card.clickable:active {
  transform: scale(0.985);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kpi-label-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-icon svg {
  width: 14px;
  height: 14px;
}
.kpi-icon.tone-brand {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}
.kpi-icon.tone-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}
.kpi-icon.tone-danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.kpi-icon.tone-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.12;
}
.kpi-value-currency {
  font-size: 22px;
}
.kpi-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* PANELS */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.panel-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.panel-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 8px;
  font-variant-numeric: tabular-nums;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.two-col-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* TOOLBAR / FILTERS */
.toolbar {
  padding: 12px 18px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.search-input {
  width: 268px;
  max-width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23526074' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 11px center;
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input::placeholder {
  color: #59667B;
}
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
}

.filter-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
}

.segmented {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: #E8EBF0;
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}
.segmented::-webkit-scrollbar {
  display: none;
}

.seg-btn {
  height: 30px;
  padding: 0 11px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}
@media (hover: hover) {
  .seg-btn:hover {
    color: var(--text-primary);
  }
}
.seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.policy-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
  font-size: 12px;
  font-weight: 600;
}

/* ---------------- TABLES (DESKTOP) ---------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  padding: 11px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #ECEEF2;
  vertical-align: middle;
  color: var(--text-primary);
}

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

@media (hover: hover) {
  .data-table tbody tr:hover {
    background: #FAFBFD;
  }
}

.cell-main {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}
.cell-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.price-fcfa {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}

.media-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 200px;
}
.media-cell-body {
  min-width: 0;
  flex: 1;
}

.thumb {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-shrink: 0;
}

.thumb-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------------- PILLS / BADGES ---------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 1px 9px;
  border-radius: 99px;
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}
.pill-live,
.pill-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}
.pill-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}
.pill-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}
.pill-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}
.pill-neutral {
  background: #F1F3F6;
  color: #334155;
  border-color: var(--border);
}

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1.6s ease-in-out infinite;
}
@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

/* ---------------- KYC LIST ---------------- */
.kyc-list {
  display: flex;
  flex-direction: column;
}

.kyc-row {
  padding: 16px 18px;
  border-bottom: 1px solid #ECEEF2;
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(260px, 1.4fr) auto;
  gap: 18px;
  align-items: center;
}
.kyc-row:last-child {
  border-bottom: none;
}

.kyc-docs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kyc-doc-thumb {
  width: 104px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-subtle);
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: border-color 0.15s ease, transform 0.14s var(--ease-out-expo), box-shadow 0.15s ease;
}
@media (hover: hover) {
  .kyc-doc-thumb:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.kyc-doc-thumb:active {
  transform: scale(0.97);
}
.kyc-doc-thumb img {
  display: block;
  width: 100%;
  height: 66px;
  object-fit: cover;
  background: #E2E5EB;
}
.kyc-doc-thumb span {
  display: block;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.kyc-doc-missing {
  width: 104px;
  height: 92px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  padding: 6px;
  background: var(--bg-subtle);
}

/* ---------------- LIST ROWS (OVERVIEW) ---------------- */
.compact-list {
  display: flex;
  flex-direction: column;
}
.compact-row {
  padding: 13px 18px;
  border-bottom: 1px solid #ECEEF2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.compact-row:last-child {
  border-bottom: none;
}
@media (hover: hover) {
  .compact-row:hover {
    background: #FAFBFD;
  }
}
.compact-row-main {
  min-width: 0;
  flex: 1;
}

/* ---------------- DRAWER & SHEET HANDLE ---------------- */
.sheet-handle {
  display: none;
  justify-content: center;
  padding: 10px 0 4px;
  flex-shrink: 0;
}
.sheet-handle span {
  width: 38px;
  height: 4px;
  border-radius: 99px;
  background: #CBD2DC;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(2px);
  z-index: 65;
  display: flex;
  justify-content: flex-end;
}

.drawer-panel {
  width: 100%;
  max-width: 680px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.22s var(--ease-out-expo);
}
@keyframes slideInRight {
  from { transform: translateX(32px); opacity: 0.7; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.drawer-header-copy {
  min-width: 0;
}
.drawer-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.drawer-subtitle {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-section-title {
  margin: 0 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.stat-mini {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}
.stat-mini-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
}
.stat-mini-val {
  margin-top: 3px;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* CHAT INSPECTOR */
.chat-feed {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  max-height: 460px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.chat-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-bottom: 3px;
}
.chat-author {
  font-weight: 600;
}
.chat-time {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chat-text {
  font-size: 13.5px;
  color: var(--text-primary);
  word-break: break-word;
}

/* ---------------- MODAL ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(2px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 488px;
  max-height: 90dvh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popIn 0.18s var(--ease-out-expo);
}
@keyframes popIn {
  from { transform: scale(0.96); opacity: 0.7; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes slideUpSheet {
  from { transform: translateY(36px); opacity: 0.85; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.modal-footer {
  padding: 13px 20px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------------- LIGHTBOX ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 13, 18, 0.94);
  display: flex;
  flex-direction: column;
}
.lightbox-bar {
  min-height: 56px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}
.lightbox-caption {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px max(24px, env(safe-area-inset-bottom));
  overflow: auto;
}
.lightbox-stage img {
  max-width: 100%;
  max-height: 82dvh;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  background: #1A212D;
}

/* ---------------- STATES & TOASTS ---------------- */
.empty-state {
  padding: 36px 22px;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-state-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.empty-state-icon svg {
  width: 20px;
  height: 20px;
}
.empty-state-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 5px;
}
.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.5;
}

.skeleton-wrap {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.skeleton-line {
  height: 16px;
  border-radius: 6px;
  background: linear-gradient(90deg, #EFEFF2 25%, #E3E5EA 50%, #EFEFF2 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 390px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  border-radius: 12px;
  background: #0F131A;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: auto;
  animation: toastIn 0.2s var(--ease-out-expo);
}
.toast::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
}
.toast-success::before { background: #10B981; }
.toast-error::before { background: #EF4444; }
@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.reason-box {
  margin-top: 6px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--danger-border);
}

.code-block {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
  z-index: 40;
}

/* ---------------- MOBILE BOTTOM NAV ---------------- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 35;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px -8px rgba(15, 23, 42, 0.10);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 12px;
  transition: color 0.15s ease, transform 0.14s var(--ease-out-expo);
}
.bottom-nav-item:active {
  transform: scale(0.93);
}

.bottom-nav-icon {
  position: relative;
  width: 44px;
  height: 28px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.18s var(--ease-out-expo);
}
.bottom-nav-icon svg {
  width: 20px;
  height: 20px;
}

.bottom-nav-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.bottom-nav-item.active {
  color: var(--brand);
}
.bottom-nav-item.active .bottom-nav-icon {
  background: var(--brand-soft);
}
.bottom-nav-item.active .bottom-nav-label {
  font-weight: 700;
}

.bottom-nav-badge {
  position: absolute;
  top: -3px;
  right: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
}
.bottom-nav-badge.badge-live { background: #C81E1E; }
.bottom-nav-badge.badge-danger { background: var(--brand); }
.bottom-nav-badge.badge-warn { background: #B45309; }

/* ---------------- SUPPORT IN-APP MESSAGING ---------------- */
.support-shell {
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-height: 620px;
  height: calc(100dvh - 130px);
  overflow: hidden;
}

.support-list-pane {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-surface);
}

.support-list-head {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-subtle);
  min-width: 0;
}

.support-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.support-conv-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.conv-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid #ECEEF2;
  background: transparent;
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  transition: background-color 0.14s ease;
}
@media (hover: hover) {
  .conv-item:hover {
    background: var(--bg-subtle);
  }
}
.conv-item.active {
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--brand-border);
}

.conv-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.conv-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.conv-name-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.conv-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.conv-preview {
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--brand);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.support-thread-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: #F8F8F7;
}

.thread-header {
  padding: 13px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.thread-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.thread-header-meta {
  min-width: 0;
  flex: 1;
}

.thread-header-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
}
.thread-header-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-header-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.support-back-btn {
  display: none;
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}
.msg-row.from-support {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-row.from-user {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 15px;
  font-size: 13.5px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-row.from-support .msg-bubble {
  background: var(--brand);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-xs);
}
.msg-row.from-user .msg-bubble {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}
.msg-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.quick-replies {
  padding: 8px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}
.quick-replies::-webkit-scrollbar {
  display: none;
}
.quick-chip {
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.14s ease, color 0.14s ease, background-color 0.14s ease;
}
@media (hover: hover) {
  .quick-chip:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
  }
}
.quick-chip:active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
}

.support-composer {
  padding: 10px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  min-width: 0;
}
.support-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 14px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  line-height: 1.4;
}
.support-composer textarea:focus {
  background: var(--bg-surface);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
}
.support-composer .btn {
  min-height: 44px;
  flex-shrink: 0;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS (TABLET & MOBILE-FIRST ERGONOMICS)
   ============================================================================ */

/* Tablet & smaller desktop */
@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  .kyc-row {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .support-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }
}

/* Mobile shell & Bottom Nav transition (<= 900px) */
@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex;
  }
  .sidebar-mobile-status.mobile-only {
    display: flex;
  }
  .mobile-health-pill.mobile-only {
    display: inline-flex;
  }
  .mobile-bottom-nav {
    display: grid;
  }

  .sidebar {
    width: min(304px, 86vw);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-nav {
    padding: 10px 10px;
    gap: 12px;
  }
  .nav-group {
    gap: 2px;
  }
  .nav-group-label {
    padding: 0 10px 3px;
  }
  .nav-item {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }
  .nav-item svg {
    width: 18px;
    height: 18px;
  }

  .main-wrap {
    margin-left: 0;
  }

  .topbar {
    min-height: 58px;
    padding: env(safe-area-inset-top) 12px 0;
    gap: 8px;
  }
  .topbar-left {
    gap: 9px;
  }
  .page-title {
    font-size: 16px;
  }
  .mobile-health-pill {
    padding: 0 9px;
    font-size: 11px;
  }
  .page-subtitle {
    display: none;
  }
  .health-chips,
  .toggle-chip {
    display: none;
  }
  .refresh-label {
    display: none;
  }
  .refresh-btn {
    width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 11px;
  }
  .refresh-btn svg {
    width: 18px;
    height: 18px;
  }
  .icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 11px;
  }

  .view-root {
    padding: 12px 12px calc(var(--bottom-nav-height) + 26px + env(safe-area-inset-bottom));
    gap: 14px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-nav-height) + 14px + env(safe-area-inset-bottom));
    max-width: none;
  }

  /* Native Master-Detail Support Messaging on Mobile */
  .support-shell {
    grid-template-columns: 1fr;
    height: calc(100dvh - 58px - var(--bottom-nav-height) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 460px;
  }
  .support-list-pane {
    border-right: none;
    height: 100%;
  }
  .support-thread-pane {
    height: 100%;
  }
  .support-shell[data-mobile-pane="list"] .support-thread-pane {
    display: none;
  }
  .support-shell[data-mobile-pane="thread"] .support-list-pane {
    display: none;
  }
  .support-back-btn {
    display: inline-flex;
  }
  .thread-desktop-badge {
    display: none;
  }
  .msg-row {
    max-width: 86%;
  }
  .conv-item {
    padding: 14px 14px;
  }
  .support-composer textarea {
    font-size: 16px;
  }

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

/* Mobile Card Layout, Bottom Sheets & 48px Touch Ergonomics (<= 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari focus zoom on form controls */
  .field input,
  .field select,
  .field textarea,
  .search-input,
  .filter-select {
    font-size: 16px;
    min-height: 44px;
  }

  /* 2x2 Compact KPI Bento Grid on mobile */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .kpi-card {
    padding: 13px 13px 14px;
    border-radius: 14px;
    gap: 6px;
  }
  .kpi-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .kpi-label-wrap {
    width: 100%;
  }
  .kpi-label {
    font-size: 12px;
  }
  .kpi-value {
    font-size: 24px;
  }
  .kpi-value-currency {
    font-size: 17px;
  }
  .kpi-meta {
    font-size: 11.5px;
    line-height: 1.35;
  }

  /* Panels & Toolbars */
  .panel {
    border-radius: 14px;
  }
  .panel-header {
    padding: 13px 14px;
    gap: 10px;
  }
  .panel-header > .segmented {
    width: 100%;
  }
  .panel-actions {
    width: auto;
  }
  .panel-actions .btn {
    min-height: 38px;
  }

  .toolbar {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .toolbar-left,
  .toolbar-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search-input,
  .filter-select {
    width: 100%;
    height: 44px;
  }
  .segmented {
    width: 100%;
    padding: 4px;
  }
  .seg-btn {
    height: 36px;
    padding: 0 13px;
    font-size: 13px;
  }

  .policy-notice {
    width: 100%;
    font-size: 12px;
    line-height: 1.4;
    padding: 7px 10px;
  }

  /* Compact overview rows */
  .compact-row {
    padding: 13px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .compact-row .row-actions {
    width: 100%;
    justify-content: stretch;
  }
  .compact-row .row-actions .btn {
    flex: 1;
    min-height: 42px;
  }

  /* Responsive Mobile Cards: Transform ALL .data-table into zero-overflow cards */
  .table-wrap {
    overflow-x: visible;
  }
  .data-table,
  .data-table tbody {
    display: block;
    width: 100%;
  }
  .data-table thead {
    display: none;
  }
  .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--bg-subtle);
  }
  .data-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow-xs);
  }
  .data-table tbody tr:hover {
    background: var(--bg-surface);
  }
  .data-table td {
    display: block;
    padding: 0;
    border: none;
    min-width: 0;
    overflow-wrap: break-word;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 3px;
  }
  .data-table td.td-primary {
    grid-column: 1 / -1;
    padding-bottom: 10px;
    border-bottom: 1px solid #ECEEF2;
  }
  .data-table td.td-primary::before,
  .data-table td.td-actions::before {
    display: none;
  }
  .data-table td.td-full {
    grid-column: 1 / -1;
  }
  .data-table td.td-status {
    grid-column: 1 / -1;
  }
  .data-table td.td-status .status-stack {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .data-table td.td-actions {
    grid-column: 1 / -1;
    padding-top: 11px;
    margin-top: 2px;
    border-top: 1px solid #ECEEF2;
  }
  .data-table td.td-actions .row-actions {
    justify-content: stretch;
    gap: 8px;
  }
  .data-table td.td-actions .row-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    font-size: 13px;
    padding: 0 12px;
  }

  .media-cell {
    min-width: 0;
  }
  .code-block {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
  }

  /* KYC Mobile Cards */
  .kyc-row {
    padding: 14px;
    gap: 12px;
  }
  .kyc-docs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }
  .kyc-doc-thumb,
  .kyc-doc-missing {
    width: 100%;
  }
  .kyc-doc-thumb img {
    height: 76px;
  }
  .kyc-doc-missing {
    height: 102px;
  }
  .kyc-row .row-actions {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }
  .kyc-row .row-actions .btn {
    flex: 1;
    min-height: 46px;
    font-size: 13.5px;
  }

  /* Bottom Sheet Modals & Drawers on Mobile (Thumb Zone) */
  .sheet-handle.mobile-only {
    display: flex;
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    animation: slideUpSheet 0.24s var(--ease-out-expo);
  }
  .modal-header {
    padding: 10px 16px 14px;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    padding: 12px 16px max(14px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .modal-footer .btn {
    width: 100%;
    min-height: 46px;
    font-size: 14px;
  }

  .drawer-backdrop {
    align-items: flex-end;
    justify-content: center;
  }
  .drawer-panel {
    max-width: 100%;
    height: 92dvh;
    border-left: none;
    border-radius: 20px 20px 0 0;
    animation: slideUpSheet 0.26s var(--ease-out-expo);
  }
  .drawer-header {
    padding: 8px 16px 14px;
  }
  .drawer-body {
    padding: 14px 16px max(24px, env(safe-area-inset-bottom));
  }

  /* Login refinement on small screens */
  .login-card {
    padding: 24px 20px 20px;
    border-radius: 16px;
  }
}

/* Coarse pointer reinforcement */
@media (pointer: coarse) {
  .btn-sm {
    min-height: 40px;
  }
  .btn-xs {
    min-height: 38px;
  }
  .quick-chip {
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* ---------------- PLATFORM SETTINGS DEEP MANAGEMENT ---------------- */
.settings-panel {
  overflow: hidden;
}
.settings-tabs-bar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.settings-sync-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.settings-body {
  padding: 18px;
}
.cfg-status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.cfg-status-banner.tone-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}
.cfg-status-banner.tone-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}
.cfg-status-banner.tone-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}
.access-rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.access-rule-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.access-rule-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.access-rule-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text-primary);
}
.access-rule-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}
.access-toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.access-toggle-pill input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}
.access-rule-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.access-picker-col {
  flex-shrink: 0;
  padding-bottom: 1px;
}
.access-soon-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.access-soon-check input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
}
.access-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
}
.access-account-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
}
.access-account-chip button {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.acc-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--bg-subtle);
}
.acc-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.acc-picker-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  flex-shrink: 0;
}
.acc-picker-info {
  flex: 1;
  min-width: 0;
}
.acc-picker-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
}
@media (max-width: 1020px) {
  .access-rules-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .access-rule-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .access-picker-col .btn {
    width: 100%;
    min-height: 42px;
  }
}
.cfg-status-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cfg-status-sub {
  font-size: 12.5px;
  margin-top: 2px;
  opacity: 0.92;
}
.cfg-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.cfg-three-cols {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.cfg-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cfg-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cfg-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.cfg-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid #ECEEF2;
  background: var(--bg-subtle);
  cursor: pointer;
}
.cfg-switch-row span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cfg-switch-row strong {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-primary);
}
.cfg-switch-row small {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.38;
}
.cfg-switch-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
  flex-shrink: 0;
  cursor: pointer;
}
.cfg-packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.cfg-pack-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cfg-pack-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.cfg-save-bar {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
@media (max-width: 900px) {
  .cfg-grid,
  .cfg-three-cols {
    grid-template-columns: 1fr;
  }
  .settings-body {
    padding: 14px;
  }
  .cfg-save-bar .btn {
    width: 100%;
    min-height: 46px;
  }
}

/* Respect Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
