/* Shared layout only: preserve the existing Arbitrade colors and business UI. */
html.ar-adaptive { -webkit-text-size-adjust:100%; scroll-padding-bottom:calc(var(--ar-nav-height,68px) + 24px); }
html.ar-adaptive *, html.ar-adaptive *::before, html.ar-adaptive *::after { box-sizing:border-box; }
html.ar-adaptive body { animation:none !important; }
.ar-adaptive .ar-data-scroll { max-width:100%; min-width:0; overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
.ar-adaptive .ar-data-scroll:focus-visible { outline:2px solid #f97316; outline-offset:2px; }
.ar-adaptive .ar-table-hint { margin:6px 0; color:#64748b; font:500 12px/1.4 system-ui,sans-serif; }
.ar-adaptive .ar-table-hint[hidden] { display:none !important; }
.ar-adaptive :is(.ar-data-scroll,.chart-card,.chart-container,.chart-wrapper,.panel,.card) { min-width:0; }
.ar-adaptive .ar-data-scroll table { margin-left:0 !important; margin-right:0 !important; }
.ar-adaptive .ar-data-scroll:focus { scroll-margin-bottom:90px; }
.ar-adaptive .ar-adaptive-filters > summary { display:none; }
.ar-adaptive [data-ar-dialog-overlay] { z-index:11000 !important; }
.ar-adaptive body:has(> .login-container) { overflow-y:auto; padding:0; }
.ar-adaptive body:has(> .login-container)::before,
.ar-adaptive body:has(> .login-container)::after { position:fixed; inset:0; width:100%; height:100%; transform:none; animation:none; pointer-events:none; }

@media(max-width:1180px) {
  html.ar-adaptive :is(.metrics-grid,.metrics-grid-enhanced,.stats-grid,.kpi-grid,.kpi-cards,.dashboard-stats,.hero-stats) { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  html.ar-adaptive :is(.charts-grid,.dashboard-grid,.grid-2,.grid-3) { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  html.ar-adaptive :is(.products-grid,.smartshops-grid,.warehouses-grid,.clients-grid) { grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr)) !important; }
}
@media(max-width:1024px) {
  html.ar-adaptive body:has(> .container) { padding-left:0 !important; padding-right:0 !important; }
  html.ar-adaptive body.ar-flow-header { padding-top:0 !important; }
  html.ar-adaptive .app-header { position:sticky !important; top:0; height:auto !important; min-height:56px; padding:8px 12px !important; }
  html.ar-adaptive .app-header .header-container { height:auto; min-height:40px; display:flex; flex-wrap:wrap; gap:8px 12px; padding:0; }
  html.ar-adaptive .app-header :is(.header-left,.header-right,.header-center) { min-width:0; max-width:100%; }
  html.ar-adaptive .app-header .header-left { flex:1 1 auto; }
  html.ar-adaptive .app-header .header-right { margin-left:auto; flex-shrink:0; }
  html.ar-adaptive .app-header .page-title { display:block !important; max-width:none; white-space:normal; overflow:visible; text-overflow:clip; font-size:16px !important; line-height:1.3; }
  html.ar-adaptive .app-header .header-logo { display:block; max-width:100px; width:auto; object-fit:contain; }
  html.ar-adaptive .app-header .header-center { display:flex !important; flex:1 1 100%; order:3; justify-content:flex-start; }
  html.ar-adaptive .ar-adaptive-filters { margin:0 0 18px; background:white; border:1px solid #eee3d5; border-radius:12px; }
  html.ar-adaptive .ar-adaptive-filters > summary { display:list-item; padding:14px 16px; min-height:48px; font-size:14px; font-weight:600; color:#55483b; cursor:pointer; }
  html.ar-adaptive .ar-adaptive-filters > .filter-bar-dashboard { margin:0 !important; padding:14px !important; box-shadow:none; }
  html.ar-adaptive .app-header .company-selector { width:auto !important; max-width:min(100%,360px); margin:0 !important; min-height:40px; }
  html.ar-adaptive .app-header .header-btn[onclick="generateAiReport()"] { width:auto !important; min-width:90px; white-space:nowrap; }
  html.ar-adaptive .app-header :is(.company-name,.user-name) { max-width:220px; }
  html.ar-adaptive body.ar-no-sidebar .mobile-menu-btn { display:none !important; }
  html.ar-adaptive body.ar-has-sidebar .app-header { padding-left:62px !important; }
  html.ar-adaptive body > :is(.container,.main-container,.dashboard-container,.main-content,.content-wrapper),
  html.ar-adaptive body > main > :is(.container,.main-container,.dashboard-container) { width:100% !important; max-width:100% !important; min-width:0; padding:16px !important; margin:0 !important; }
  html.ar-adaptive :is(.filter-bar-dashboard,.filter-bar,.filters-bar,.filter-controls,.filter-row,.toolbar,.filters-row,.filters-grid) { min-width:0; max-width:100%; flex-wrap:wrap; gap:10px !important; }
  html.ar-adaptive :is(.filter-bar-dashboard,.filter-bar,.filters-bar,.filter-controls,.filter-row,.toolbar,.filters-row) > * { min-width:0; max-width:100%; }
  html.ar-adaptive :is(.filter-bar-dashboard,.filter-bar,.toolbar,.filters-row) :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select) { flex:1 1 160px; min-width:0; max-width:100%; }
  html.ar-adaptive input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=range]):not([type=color]),
  html.ar-adaptive select, html.ar-adaptive textarea { max-width:100%; min-height:44px; font-size:16px !important; }
  html.ar-adaptive input:is([type=checkbox],[type=radio]) { width:20px !important; height:20px !important; min-width:20px !important; min-height:20px !important; padding:0 !important; flex:0 0 20px !important; vertical-align:middle; }
  html.ar-adaptive input[type=hidden] { display:none !important; }
  html.ar-adaptive :is(button,.btn,.header-btn,.user-menu-trigger) { min-height:44px; touch-action:manipulation; }
  html.ar-adaptive :is(.header-btn,.row-actions button,.action-buttons button) { min-width:44px !important; min-height:44px !important; }
  html.ar-adaptive :is(.tabs,.tab-nav,.tabs-container,.view-tabs,.tab-buttons) { max-width:100%; min-width:0; overflow-x:auto; flex-wrap:nowrap !important; white-space:nowrap; overscroll-behavior-x:contain; }
  html.ar-adaptive :is(.tabs,.tab-nav,.tabs-container,.view-tabs,.tab-buttons) > :is(button,a,.tab) { flex-shrink:0; min-height:44px; }
  html.ar-adaptive .tabs-header { display:flex; width:100%; max-width:100%; overflow-x:auto; flex-wrap:nowrap; }
  html.ar-adaptive .tabs-header > :is(button,a) { flex:0 0 auto !important; min-width:max-content; width:auto !important; white-space:nowrap; }
  html.ar-adaptive :is(.charts-grid,.chart-card,.chart-header,.chart-title,.chart-controls,.ar-chart-toolbar) { height:auto !important; min-height:0 !important; }
  html.ar-adaptive :is(.chart-container,.chart-wrapper) { max-width:100%; min-width:0; }
  html.ar-adaptive .ar-chart-toolbar { display:flex; flex-wrap:wrap; gap:6px; }
  html.ar-adaptive .ar-chart-toolbar button { padding:8px 10px !important; font-size:12px !important; }
  html.ar-adaptive .ar-data-scroll { width:100%; margin:0 !important; padding:0 !important; }
  html.ar-adaptive .ar-data-scroll table { min-width:100% !important; width:max-content; max-width:none; }
  html.ar-adaptive .ar-data-scroll :is(th,td) { max-width:320px; padding:10px !important; font-size:13px; }
  html.ar-adaptive .ar-data-scroll .row-actions { display:flex; flex-direction:row !important; flex-wrap:nowrap; }
  html.ar-adaptive [data-ar-dialog-panel] { max-width:calc(100vw - 24px) !important; max-height:calc(var(--ar-visual-height,100dvh) - 32px) !important; overflow-y:auto !important; overscroll-behavior:contain; margin:12px auto !important; padding:20px !important; }
  html.ar-adaptive .modal-backdrop > .modal { position:relative !important; inset:auto !important; transform:none !important; width:min(720px,100%); }
  html.ar-adaptive :is(.modal-backdrop,.modal-overlay):has(> [data-ar-dialog-panel]) { padding:12px !important; align-items:center; overflow-y:auto; }
  html.ar-adaptive .modal:has(> .modal-dialog) { position:fixed !important; inset:0 !important; transform:none !important; width:100% !important; height:var(--ar-visual-height,100dvh) !important; overflow-y:auto; }
  html.ar-adaptive .modal-dialog { width:calc(100% - 24px) !important; max-width:720px !important; margin:12px auto !important; }
  html.ar-adaptive :is(.modal-footer,.dialog-footer) { display:flex; flex-wrap:wrap; gap:8px; }
  html.ar-adaptive :is(.modal-footer,.dialog-footer) .btn { flex:1 1 120px; }
  html.ar-adaptive :is(.help-fab,.floating-btn,.chat-toggle-btn,.chat-widget-toggle) { bottom:calc(var(--ar-nav-height,68px) + env(safe-area-inset-bottom,0px) + 16px) !important; }
  html.ar-adaptive :is(.pagination,.pagination-controls) { display:flex; flex-wrap:wrap; gap:8px; max-width:100%; }
  html.ar-adaptive :is(.stat-value,.metric-value,.kpi-value) { overflow-wrap:anywhere; }
  html.ar-adaptive .metrics-grid-enhanced { padding:0 !important; gap:14px !important; }
  html.ar-adaptive .metric-card-enhanced { padding:20px !important; min-width:0; }
  html.ar-adaptive .metric-header-enhanced { gap:8px; flex-wrap:wrap; margin-bottom:12px; }
  html.ar-adaptive .metric-icon-enhanced { width:44px; height:44px; flex:0 0 44px; border-radius:12px; font-size:22px; }
  html.ar-adaptive .metric-value-enhanced { font-size:32px !important; line-height:1.15; overflow-wrap:anywhere; }
  html.ar-adaptive #insights-panel { grid-template-columns:minmax(0,1fr) !important; }
  html.ar-adaptive #insights-panel > * { min-width:0; }
  html.ar-adaptive #insights-panel h3 { flex-shrink:0; }
  html.ar-adaptive #insights-panel > div > div:first-child { flex-wrap:wrap; gap:8px; }
  html.ar-adaptive :is(.chat-panel,.chat-sidebar-panel) { max-width:calc(100vw - 16px) !important; }
  html.ar-adaptive .chat-panel:not(.active):not(.open) { visibility:hidden; }
  html.ar-adaptive .chat-panel:is(.active,.open) { right:0 !important; visibility:visible; height:var(--ar-visual-height,100dvh) !important; }
  html.ar-adaptive #wnotes-launcher { right:80px !important; bottom:calc(var(--ar-nav-height,68px) + env(safe-area-inset-bottom,0px) + 16px) !important; }
  html.ar-adaptive #wnotes-panel { bottom:calc(var(--ar-nav-height,68px) + env(safe-area-inset-bottom,0px) + 80px) !important; max-height:calc(var(--ar-visual-height,100dvh) - var(--ar-nav-height,68px) - 100px) !important; }
}
@media(max-width:767px) {
  html.ar-adaptive .metric-card-enhanced { padding:14px !important; border-radius:16px; }
  html.ar-adaptive .metric-value-enhanced { font-size:26px !important; margin-bottom:10px; }
  html.ar-adaptive .metric-label-enhanced { font-size:11px; letter-spacing:.4px; margin-bottom:8px; }
  html.ar-adaptive .metric-subtitle-enhanced { font-size:12px; }
  html.ar-adaptive .metric-trend-enhanced { font-size:11px; padding:6px; }
  html.ar-adaptive [data-ar-small-grid] { grid-template-columns:repeat(auto-fit,minmax(min(100%,88px),1fr)) !important; }
  html.ar-adaptive .detail-stats { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  html.ar-adaptive :is(.charts-grid,.dashboard-grid,.grid-2,.grid-3,.form-grid,.form-row,[data-ar-grid]) { grid-template-columns:minmax(0,1fr) !important; }
  html.ar-adaptive [data-ar-small-grid] { grid-template-columns:repeat(auto-fit,minmax(min(100%,88px),1fr)) !important; }
  html.ar-adaptive :is(.metrics-grid,.metrics-grid-enhanced,.stats-grid,.kpi-grid,.kpi-cards,.dashboard-stats,.hero-stats,.stats) { grid-template-columns:repeat(2,minmax(0,1fr)) !important; }
  html.ar-adaptive .app-header .header-logo { max-width:78px; }
  html.ar-adaptive .app-header .page-title { font-size:15px !important; }
  html.ar-adaptive .app-header .header-right { gap:4px; }
  html.ar-adaptive .app-header .header-container { padding:0 !important; }
  html.ar-adaptive .app-header .user-info { display:none; }
  html.ar-adaptive :is(.filter-bar-dashboard,.filter-bar,.toolbar,.filters-row) { flex-direction:row !important; }
  html.ar-adaptive :is(.filter-bar-dashboard,.filter-bar,.toolbar,.filters-row) > :is(input,select,.form-group,.search-box) { flex:1 1 100%; }
  html.ar-adaptive [data-ar-dialog-panel] { padding:16px !important; border-radius:14px !important; }
  html.ar-adaptive [data-ar-dialog-panel] :is(h1,h2) { font-size:20px; overflow-wrap:anywhere; }
  html.ar-adaptive :is(.chart-container,.chart-wrapper) { height:260px !important; min-height:220px !important; }
}
@media(max-width:359px) {
  html.ar-adaptive :is(.metrics-grid,.metrics-grid-enhanced,.stats-grid,.kpi-grid,.kpi-cards,.dashboard-stats,.hero-stats,.stats) { grid-template-columns:minmax(0,1fr) !important; }
}
@media(prefers-reduced-motion:reduce) {
  html.ar-adaptive :is(.welcome-hero,.welcome-content,.welcome-content > *,.particle) { animation:none !important; opacity:1 !important; transform:none !important; }
}
@media print {
  .ar-adaptive .ar-data-scroll { overflow:visible !important; }
  .ar-adaptive .ar-table-hint { display:none !important; }
}

/* Client portal: scoped to its existing, restricted page and controls. */
html.ar-adaptive body.ar-client { padding-top:0; padding-bottom:24px; font-family:Inter,system-ui,sans-serif; color:#25221e; }
.ar-client .client-header { background:#181818; color:white; padding:16px 24px; }
.ar-client .header-content { display:flex; max-width:1500px; margin:0 auto; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.ar-client .header-left,.ar-client .header-right { display:flex; align-items:center; gap:16px; min-width:0; }
.ar-client .client-header .logo { width:130px; max-width:100%; height:auto; }
.ar-client .header-title { color:white; font-size:20px; white-space:normal; }
.ar-client .header-subtitle { font-size:12px; color:#ded7ce; overflow-wrap:anywhere; }
.ar-client .date-display { font-size:12px; color:#ded7ce; }
.ar-client .main-container { display:grid; grid-template-columns:230px minmax(0,1fr); max-width:1500px; margin:0 auto; padding:24px; gap:24px; }
.ar-client .content-area { min-width:0; }
.ar-client .sidebar { border:1px solid #eee3d6; border-radius:14px; background:white; padding:20px; align-self:start; }
.ar-client .sidebar-section+.sidebar-section { margin-top:24px; }
.ar-client .sidebar-title { font-size:14px; margin-bottom:14px; color:#5e4c3e; }
.ar-client .filter-group label { display:block; margin:8px 0; font-size:13px; }
.ar-client :is(input,select) { border:1px solid #d9d3ca; border-radius:8px; padding:10px 12px; background:white; color:#25221e; max-width:100%; }
.ar-client .sidebar select { width:100%; }
.ar-client .stats-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:20px; }
.ar-client .stat-card { background:white; border:1px solid #eee3d6; border-top:3px solid #f97316; padding:20px; border-radius:14px; min-width:0; }
.ar-client .stat-icon { display:flex; align-items:center; justify-content:center; width:38px; height:38px; border-radius:10px; background:#fff0df; color:#c55200; margin-bottom:12px; }
.ar-client .stat-label { font-size:12px; color:#766e63; margin-bottom:8px; }
.ar-client .stat-value { font-size:28px; font-weight:750; line-height:1.3; margin-bottom:6px; overflow-wrap:anywhere; }
.ar-client :is(.stat-change,.stat-sublabel) { font-size:12px; color:#766e63; }
.ar-client :is(.tabs-section,.content-header,.tabs-actions) { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; margin-bottom:16px; min-width:0; }
.ar-client .tabs-container { display:flex; gap:6px; width:100%; padding-bottom:4px; overflow-x:auto; }
.ar-client :is(.tab-btn,.action-btn,.logout-btn,.ar-client-sidebar-close) { border:1px solid #e4d8c9; border-radius:8px; padding:10px 12px; background:white; color:#544738; min-height:44px; cursor:pointer; font:600 13px/1.4 Inter,system-ui,sans-serif; }
.ar-client .tab-btn { flex-shrink:0; }
.ar-client .tab-btn.active { color:white; background:#ed7013; border-color:#ed7013; }
.ar-client .tab-content { display:none; }
.ar-client .tab-content.active { display:block; }
.ar-client .content-header h2 { font-size:20px; }
.ar-client .search-box { display:flex; gap:8px; align-items:center; min-width:0; }
.ar-client .search-box input { width:100%; min-width:0; }
.ar-client .chart-card,.ar-client .data-table-container,.ar-client .info-panel { background:white; border:1px solid #eee3d6; border-radius:14px; padding:16px; margin-bottom:16px; }
.ar-client .chart-card h3 { font-size:15px; margin-bottom:16px; }
.ar-client .chart-card canvas { max-height:300px; }
.ar-client .data-table { border-collapse:collapse; width:100%; font-size:13px; }
.ar-client .data-table :is(th,td) { padding:12px; border-bottom:1px solid #eee7df; text-align:left; }
.ar-client .data-table th { background:#fbf7f0; color:#695a49; }
.ar-client .ar-client-sidebar-close { display:none; }
.ar-client :focus-visible { outline:3px solid #e87515; outline-offset:2px; }
@media(max-width:1024px) {
  html.ar-adaptive .ar-client .main-container { grid-template-columns:190px minmax(0,1fr); gap:16px; }
  .ar-client .client-header { padding:14px 16px; }
  .ar-client .header-right { flex-wrap:wrap; }
}
@media(max-width:767px) {
  html.ar-adaptive .ar-client .main-container { grid-template-columns:minmax(0,1fr); }
  .ar-client .client-header { padding:14px 16px 14px 64px; }
  .ar-client .client-header .logo { width:100px; }
  .ar-client .header-left { flex-wrap:wrap; gap:10px; }
  .ar-client .header-title { font-size:17px !important; }
  .ar-client .header-content { gap:10px; }
  .ar-client .header-right { justify-content:space-between; width:100%; gap:8px; }
  .ar-client .stat-card { padding:14px !important; }
  .ar-client .content-header { align-items:stretch; }
  .ar-client .content-header .search-box { width:100%; }
  html.ar-adaptive .ar-client .mobile-menu-btn { background:#f97316 !important; }
  html.ar-adaptive .ar-client .sidebar { padding:20px !important; border-radius:0 14px 14px 0; overflow-y:auto; max-height:var(--ar-visual-height,100dvh); }
  .ar-client .ar-client-sidebar-close { display:block; margin:0 0 20px auto; }
}
