/* Exqpay cross-portal consistency pass — light theme, responsive flow, and safe spacing. */
:root {
  --exq-light-bg: #f5f7fb;
  --exq-light-panel: #ffffff;
  --exq-light-text: #172033;
  --exq-light-muted: #647087;
  --exq-light-line: #e1e6ef;
  --exq-light-accent: #b88420;
}
html[data-theme="light"], body[data-theme="light"], [data-theme="light"] {
  color-scheme: light;
  --exq-bg: var(--exq-light-bg);
  --exq-panel: var(--exq-light-panel);
  --exq-card: var(--exq-light-panel);
  --exq-text: var(--exq-light-text);
  --exq-muted: var(--exq-light-muted);
  --exq-line: var(--exq-light-line);
  --surface: var(--exq-light-panel);
  --surface-1: var(--exq-light-panel);
  --surface-2: #f8faff;
  --text: var(--exq-light-text);
  --text-muted: var(--exq-light-muted);
  --border: var(--exq-light-line);
}
html[data-theme="light"] body,
body[data-theme="light"] { background:var(--exq-light-bg); color:var(--exq-light-text); }
html[data-theme="light"] .card,
html[data-theme="light"] .section-card,
html[data-theme="light"] .stat-card,
html[data-theme="light"] .panel-card,
html[data-theme="light"] .modal-content,
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .popover,
html[data-theme="light"] .table-wrap,
html[data-theme="light"] .form-panel,
html[data-theme="light"] .settings-section,
html[data-theme="light"] .admin-live-monitor {
  background:var(--exq-light-panel) !important; color:var(--exq-light-text) !important;
  border-color:var(--exq-light-line) !important; box-shadow:0 4px 18px rgba(22,34,56,.045);
}
html[data-theme="light"] input:not([type=checkbox]):not([type=radio]):not([type=range]),
html[data-theme="light"] select, html[data-theme="light"] textarea {
  color:var(--exq-light-text); background:#fff; border-color:#d6ddea;
}
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color:#78849a; }
html[data-theme="light"] .sidebar, html[data-theme="light"] .admin-sidebar,
html[data-theme="light"] .topbar, html[data-theme="light"] .portal-topbar,
html[data-theme="light"] .mobile-drawer, html[data-theme="light"] .nav-drawer {
  background:#fff !important; color:var(--exq-light-text) !important; border-color:var(--exq-light-line) !important;
}
html[data-theme="light"] .sidebar a, html[data-theme="light"] .admin-sidebar a,
html[data-theme="light"] .topbar a, html[data-theme="light"] .portal-topbar a,
html[data-theme="light"] .mobile-drawer a { color:inherit; }
html[data-theme="light"] .muted, html[data-theme="light"] .text-muted,
html[data-theme="light"] small.muted { color:var(--exq-light-muted) !important; }
/* Consistent document flow prevents cards, actions, and controls from colliding. */
#main-content, .main-panel, .content-scroll, .exq-page, .exq-stack,
.dashboard-stack, .admin-page, .customer-page { min-width:0; }
.main-panel { flex:1 1 auto; }
.content-scroll { overflow-x:clip; }
.exq-page, .dashboard-stack, .admin-page, .customer-page { display:flex; flex-direction:column; gap:20px; }
.exq-page > *, .dashboard-stack > *, .admin-page > *, .customer-page > * { min-width:0; }
.toolbar, .toolbar-actions, .page-actions, .form-actions, .button-row, .table-toolbar {
  display:flex; flex-wrap:wrap; align-items:center; gap:10px; min-width:0; max-width:100%;
}
.toolbar { justify-content:space-between; }
.toolbar > :first-child { flex:1 1 240px; min-width:min(100%,220px); }
.toolbar-actions > *, .page-actions > *, .form-actions > *, .button-row > * { max-width:100%; }
.stats-grid, .dashboard-grid, .admin-charts, .form-grid, .settings-grid,
.admin-feature-toggles { grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr)) !important; }
.card, .section-card, .stat-card, .panel-card, .table-wrap, .form-panel { min-width:0; }
table { width:100%; border-collapse:separate; border-spacing:0; }
.table-wrap, .table-responsive, .data-table-wrap { max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; }
th, td { overflow-wrap:anywhere; }
pre, code, .mono, .address, .transaction-hash { overflow-wrap:anywhere; word-break:break-word; }
input, select, textarea, button { max-width:100%; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { min-width:0; }
img, canvas, svg { max-width:100%; }
.modal, .modal-dialog, .modal-content, .popover, .dropdown-menu { max-width:min(100vw - 24px, 760px); }
.modal-content { max-height:calc(100dvh - 32px); overflow:auto; }
.toast-container, .toasts, .cookie-consent, .whatsapp-widget { max-width:calc(100vw - 24px); }
/* Admin: make common operation pages calmer and more scannable. */
.admin-app .content-scroll { padding:clamp(14px,2vw,28px); }
.admin-app .page-subtitle { max-width:72ch; line-height:1.55; }
.admin-app h1 { line-height:1.2; letter-spacing:-.025em; }
.admin-app h2, .admin-app h3 { line-height:1.3; }
.admin-app .stat-card strong { display:block; font-size:clamp(1.35rem,2vw,1.9rem); line-height:1.25; overflow-wrap:anywhere; }
.admin-app .stat-card small { display:block; line-height:1.5; margin-top:6px; }
.admin-app .btn, .admin-app button { min-height:36px; }
.admin-app label { line-height:1.4; }
@media(max-width:700px) {
  .toolbar { align-items:stretch; }
  .toolbar-actions, .page-actions, .form-actions, .button-row { width:100%; }
  .toolbar-actions > .btn, .page-actions > .btn { flex:1 1 auto; }
  .stats-grid, .dashboard-grid, .admin-charts, .form-grid, .settings-grid,
  .admin-feature-toggles { grid-template-columns:minmax(0,1fr) !important; }
  .admin-app .content-scroll { padding:12px; }
  .card, .section-card, .stat-card { padding:16px !important; }
}


/* Legacy surfaces that still carry dark-theme literals must follow the selected theme. */
html[data-theme="light"] .market-ticker,
html[data-theme="light"] .gift-showcase,
html[data-theme="light"] .hero-art,
html[data-theme="light"] .error-card,
html[data-theme="light"] .health-check,
html[data-theme="light"] .mobile-menu,
html[data-theme="light"] .site-header .nav.mobile-open,
html[data-theme="light"] .nav.mobile-open,
html[data-theme="light"] .swap-widget,
html[data-theme="light"] .swap-card,
html[data-theme="light"] .live-prices,
html[data-theme="light"] .price-card,
html[data-theme="light"] .market-price-card,
html[data-theme="light"] .oauth-btn,
html[data-theme="light"] .topbar-dropdown,
html[data-theme="light"] .topbar-dropdown__item,
html[data-theme="light"] .modal-content,
html[data-theme="light"] .modal-panel,
html[data-theme="light"] .auth-modal,
html[data-theme="light"] .auth-modal__panel,
html[data-theme="light"] .auth-modal__right,
html[data-theme="light"] .auth-modal__aside,
html[data-theme="light"] .auth-modal__promo,
html[data-theme="light"] .auth-side-panel,
html[data-theme="light"] .auth-visual {
  background: var(--exq-light-panel, #fff) !important;
  background-image: none !important;
  color: var(--exq-light-text, #172033) !important;
  border-color: var(--exq-light-line, #e1e6ef) !important;
  box-shadow: 0 8px 28px rgba(22,34,56,.08);
}
html[data-theme="light"] .market-item,
html[data-theme="light"] .market-item strong,
html[data-theme="light"] .market-section h2,
html[data-theme="light"] .gift-showcase h2,
html[data-theme="light"] .hero-art h2,
html[data-theme="light"] .error-card h1,
html[data-theme="light"] .swap-widget label,
html[data-theme="light"] .swap-card label,
html[data-theme="light"] .live-prices strong,
html[data-theme="light"] .auth-modal h1,
html[data-theme="light"] .auth-modal h2,
html[data-theme="light"] .auth-modal__panel h1,
html[data-theme="light"] .auth-modal__panel h2 {
  color: var(--exq-light-text, #172033) !important;
}
html[data-theme="light"] .market-item div small,
html[data-theme="light"] .market-loading,
html[data-theme="light"] .market-section p,
html[data-theme="light"] .gift-showcase p,
html[data-theme="light"] .hero-art p,
html[data-theme="light"] .error-card p,
html[data-theme="light"] .auth-modal p,
html[data-theme="light"] .auth-modal__panel p {
  color: var(--exq-light-muted, #647087) !important;
}
html[data-theme="light"] .dropdown-menu,
html[data-theme="light"] .topbar-dropdown,
html[data-theme="light"] .topbar-dropdown__item:hover,
html[data-theme="light"] .nav-dropdown .dropdown-menu {
  background: #fff !important;
  color: var(--exq-light-text, #172033) !important;
  border-color: var(--exq-light-line, #e1e6ef) !important;
}
html[data-theme="light"] .dropdown-menu a,
html[data-theme="light"] .topbar-dropdown a,
html[data-theme="light"] .nav-dropdown .dropdown-menu a {
  color: var(--exq-light-text, #172033) !important;
}
html[data-theme="light"] select option { background: #fff; color: #172033; }
html[data-theme="light"] .market-symbol { color: #8a5c00; border-color: #d9bd79; }
html[data-theme="light"] .coin-card.featured { background: #fff8e6 !important; color: #172033 !important; }
html[data-theme="light"] .coin-card .code,
html[data-theme="light"] .coin-card .min { color: #647087 !important; }
html[data-theme="light"] .exq-theme-toggle { background: #fff; color: #172033; }

/* Mobile stability hardening: keep the customer app bar viewport-fixed even when
   portal content uses transformed/scrolling containers. JS reparents it to body. */
@media (max-width: 900px) {
  body:has(.customer-bottom-nav) { padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  body > .customer-bottom-nav {
    display: flex !important;
    position: fixed !important;
    left: max(10px, env(safe-area-inset-left, 0px)) !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important;
    min-height: 64px !important;
    height: 64px !important;
    z-index: 2147483000 !important;
    visibility: visible !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    isolation: isolate;
  }
  body > .customer-bottom-nav .customer-bottom-nav__item { min-height: 48px; }
  body:has(.customer-bottom-nav) .content-scroll,
  body:has(.customer-bottom-nav) .main-panel,
  body:has(.customer-bottom-nav) #main-content { scroll-padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 901px) { body > .customer-bottom-nav { display: none !important; } }

/* 2026-10-24: small-screen + dense-data hardening across customer/admin portals. */
:root {
  --exq-space-1: 4px; --exq-space-2: 8px; --exq-space-3: 12px;
  --exq-space-4: 16px; --exq-space-5: 20px;
  --exq-focus: #c58b00;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; }
button, [role="button"], a.btn { touch-action: manipulation; }
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--exq-focus); outline-offset: 2px; }
.exq-page, .exq-stack, .content-scroll, .main-panel, .app, .admin-app, .customer-app,
.admin-page, .customer-page, .two-col, .three-col, .form-grid, .stats-grid, .dashboard-grid,
.card, .section-card, .panel-card, .table-wrap, .table-responsive { min-width: 0; }
/* Light theme: avoid inherited near-black surfaces and low-contrast text from legacy pages. */
html[data-theme="light"] body,
html[data-theme="light"] .app,
html[data-theme="light"] .admin-app,
html[data-theme="light"] .customer-app,
html[data-theme="light"] .main-panel,
html[data-theme="light"] .content-scroll,
html[data-theme="light"] .admin-page,
html[data-theme="light"] .customer-page {
  background: var(--exq-light-bg) !important; color: var(--exq-light-text) !important;
}
html[data-theme="light"] .exq-page,
html[data-theme="light"] .exq-stack,
html[data-theme="light"] .page-header,
html[data-theme="light"] .page-title-row,
html[data-theme="light"] .content-header { color: var(--exq-light-text) !important; }
html[data-theme="light"] .card,
html[data-theme="light"] .section-card,
html[data-theme="light"] .panel-card,
html[data-theme="light"] .admin-form,
html[data-theme="light"] .workflow,
html[data-theme="light"] .workflow-step,
html[data-theme="light"] .activity,
html[data-theme="light"] .activity-row,
html[data-theme="light"] .result-panel,
html[data-theme="light"] .empty-state,
html[data-theme="light"] .search-results,
html[data-theme="light"] .search-result,
html[data-theme="light"] .quick-access,
html[data-theme="light"] .customer-quick-access {
  background-color: #fff !important; color: var(--exq-light-text) !important;
  border-color: var(--exq-light-line) !important;
}
html[data-theme="light"] h1, html[data-theme="light"] h2, html[data-theme="light"] h3,
html[data-theme="light"] h4, html[data-theme="light"] p, html[data-theme="light"] li,
html[data-theme="light"] th, html[data-theme="light"] td,
html[data-theme="light"] .label, html[data-theme="light"] label { color: inherit; }
html[data-theme="light"] .card p, html[data-theme="light"] .muted,
html[data-theme="light"] .page-subtitle, html[data-theme="light"] .help-text,
html[data-theme="light"] .card small { color: var(--exq-light-muted) !important; }
html[data-theme="light"] .card a:not(.btn), html[data-theme="light"] .content-scroll a:not(.btn) { color: #855b00; }
html[data-theme="light"] .data-table th { background: #f4f6fa; color: #39445a; }
html[data-theme="light"] .data-table td { background: #fff; color: #202938; border-color: var(--exq-light-line); }
html[data-theme="light"] .data-table tbody tr:hover td { background: #f8faff; }
html[data-theme="light"] .topbar input, html[data-theme="light"] .portal-topbar input,
html[data-theme="light"] .search-input { background:#fff !important; color:#172033 !important; border-color:#d6ddea !important; }
/* Data-heavy tables remain usable on narrow screens without squeezing every column. */
.table-wrap, .table-responsive, .data-table-wrap, .data-table-container {
  width: 100%; max-width: 100%; overflow-x: auto; overflow-y: visible;
  -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain;
}
.table-wrap table, .table-responsive table, .data-table-wrap table, .data-table-container table { min-width: 620px; }
.table-wrap table.compact, .table-responsive table.compact { min-width: 480px; }
.data-table th, .data-table td, table th, table td { vertical-align: middle; }
.data-table td .btn, table td .btn { white-space: nowrap; }
/* Keep forms readable and avoid horizontal overflow on small phones. */
.form-grid, .settings-grid, .two-col, .three-col, .stats-grid, .dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}
.form-grid label, form label { min-width: 0; overflow-wrap: anywhere; }
.form-grid input, .form-grid select, .form-grid textarea,
form input:not([type=checkbox]):not([type=radio]):not([type=file]), form select, form textarea { width: 100%; min-width: 0; }
input[type=file] { width: 100%; max-width: 100%; font-size: .9rem; }
.image-upload-preview img, .profile-upload-preview img, .media-preview img { max-width: 100%; height: auto; object-fit: contain; }
/* Dialogs should fit short screens and keep the action buttons reachable. */
.modal, .modal-dialog, .modal-content, [role=dialog], .profile-upload-card {
  max-width: min(760px, calc(100vw - 20px));
}
.modal-content, [role=dialog], .profile-upload-card {
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto; overscroll-behavior: contain;
}
/* Navigation and touch targets. */
@media (max-width: 900px) {
  .admin-app .content-scroll, .customer-app .content-scroll { padding: 12px !important; }
  .app.admin-app, .app.customer-app { display: block; width: 100%; min-height: 100dvh; }
  .admin-app .sidebar, .admin-app .admin-sidebar, .customer-app .sidebar, .customer-app .customer-sidebar { display: none; }
  .topbar, .portal-topbar { min-height: 56px; gap: 8px; padding-inline: 12px; }
  .topbar .search, .portal-topbar .search, .global-search { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .toolbar, .table-toolbar { align-items: stretch; }
  .toolbar > :first-child { min-width: 0; }
  .toolbar-actions, .page-actions, .form-actions, .button-row { gap: 8px; }
  .toolbar-actions > button, .page-actions > button, .form-actions > button, .button-row > button { min-height: 42px; }
  .card, .section-card, .panel-card, .admin-form { border-radius: 14px; }
  .admin-app h1, .customer-app h1 { font-size: clamp(1.4rem, 6vw, 1.9rem); overflow-wrap: anywhere; }
  .admin-app h2, .customer-app h2 { font-size: clamp(1.1rem, 4.5vw, 1.45rem); }
  .stats-grid, .dashboard-grid, .admin-charts, .form-grid, .settings-grid,
  .admin-feature-toggles { grid-template-columns: minmax(0, 1fr) !important; }
  .page-actions > *, .toolbar-actions > *, .form-actions > * { flex: 1 1 auto; }
  .customer-bottom-nav { gap: 2px; }
  .customer-bottom-nav__item { flex: 1 1 0; min-width: 0; padding-inline: 2px; }
  .customer-bottom-nav__item span, .customer-bottom-nav__item .label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 480px) {
  .admin-app .content-scroll, .customer-app .content-scroll { padding: 8px !important; }
  .card, .section-card, .panel-card, .admin-form { padding: 12px !important; }
  .toolbar, .page-actions, .toolbar-actions, .form-actions, .button-row { gap: 7px; }
  .toolbar-actions > *, .page-actions > *, .form-actions > *, .button-row > * { flex: 1 1 100%; width: 100%; }
  .btn, button.btn { min-height: 42px; }
  .table-wrap table, .table-responsive table, .data-table-wrap table, .data-table-container table { min-width: 560px; }
  .modal, .modal-dialog, .modal-content, [role=dialog], .profile-upload-card { max-width: calc(100vw - 12px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Admin mobile navigation: preserve labelled groups and icons in the drawer. */
.mobile-drawer-nav .nav-section{display:block;margin:0 0 18px;padding:0 0 12px;border-bottom:1px solid var(--border,rgba(127,139,155,.2))}
.mobile-drawer-nav .nav-section-label{display:block;padding:10px 14px 7px;font-size:.68rem;font-weight:800;letter-spacing:.12em;color:var(--muted,#7c8798)}
.mobile-drawer-nav .nav-link{display:flex;align-items:center;gap:12px;min-height:44px;margin:2px 6px;padding:10px 12px;border-radius:10px;text-decoration:none}
.mobile-drawer-nav .nav-link .nav-icon{display:inline-flex;flex:0 0 20px;width:20px;height:20px;align-items:center;justify-content:center;opacity:.88}
.mobile-drawer-nav .nav-link .nav-label{min-width:0;overflow-wrap:anywhere}
.mobile-drawer-nav .nav-link.active{background:var(--surface-active,rgba(204,153,0,.14));color:var(--text,#172033);font-weight:700}
/* Create/edit workflows stay closed until explicitly launched. */
[data-workflow-launch][hidden]{display:none!important}
.workflow-step-nav{display:flex;gap:8px;flex-wrap:wrap;align-items:center;justify-content:flex-end;margin-top:18px;padding-top:12px;border-top:1px solid var(--border,rgba(127,139,155,.22))}
.workflow-step-nav .btn{min-height:42px}
@media(max-width:640px){
 .mobile-drawer{width:min(88vw,340px);max-width:100vw;overflow-y:auto;overscroll-behavior:contain;padding-bottom:calc(24px + env(safe-area-inset-bottom,0px))}
 .mobile-drawer-nav .nav-section{margin-bottom:12px;padding-bottom:8px}
 .mobile-drawer-nav .nav-link{min-height:46px;font-size:.95rem}
 .workflow-progress{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .workflow-progress-item{min-width:0;display:flex;gap:7px;align-items:center}
 .workflow-progress-item small{overflow-wrap:anywhere}
 .workflow-step-nav{justify-content:stretch}
 .workflow-step-nav .btn{flex:1 1 100%;min-height:44px}
}


/* Admin interaction reliability: the HTML hidden state must win over component display rules. */
[hidden], [aria-hidden="true"]:not([role="dialog"]):not(.exq-modal__backdrop) { display: none !important; }
.workflow[hidden], [data-workflow-launch][hidden], .workflow-step[hidden], [data-tab-panel][hidden], [data-workflow-branch][hidden] { display: none !important; }
.workflow { min-width: 0; }
.workflow-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; margin-bottom: 16px; }
.workflow-progress-item { min-width: 0; padding: 9px 10px; border: 1px solid var(--border, #d9dee7); border-radius: 10px; }
.workflow-progress-item.active { border-color: var(--accent, #d19a00); background: color-mix(in srgb, var(--accent, #d19a00) 10%, transparent); }
.workflow-step-nav { position: sticky; bottom: 0; z-index: 4; background: var(--surface, Canvas); }
.admin-app button:disabled, .admin-app [aria-disabled="true"] { opacity: .58; cursor: not-allowed; }
.admin-app .result-panel:empty { display: none; }
.admin-app .result-panel:not(:empty) { display: block; margin-top: 10px; overflow-wrap: anywhere; }
.admin-app .data-table td, .admin-app .data-table th { overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .workflow-progress { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-progress-item { padding: 8px; }
  .workflow-progress-item small { display: block; overflow-wrap: anywhere; }
  .workflow-step-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-step-nav .btn { width: 100%; min-width: 0; }
  .workflow-step-nav .workflow-cancel { grid-column: 1 / -1; }
}
