/* AFRA V6.18: Mobile-first correction for Android/iOS and compact corporate dashboard.
   Loaded after all prior theme styles to prevent overlapping legacy rules. */
:root { --a18-ink:#153956; --a18-blue:#194f7e; --a18-red:#bd2744; --a18-line:#d8e7f2; }
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; scroll-padding-top:80px; }
* { box-sizing:border-box; }
body { overflow-x:clip; }
button, [role="button"], a, select, summary, input[type="checkbox"], input[type="radio"] {
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}
button, a, select, input, textarea { -webkit-user-select:auto; user-select:auto; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {outline:3px solid #3984bc;outline-offset:3px}
img,svg { max-width:100%; }
.marketing-checkbox {display:flex!important;align-items:flex-start;gap:10px;padding:13px 14px;border:1px solid #cfe2ef;background:#f3f9ff;border-radius:15px;line-height:1.85;cursor:pointer;color:#295270}
.marketing-checkbox input {width:20px!important;height:20px!important;flex:0 0 20px;margin:4px 0 0!important;padding:0!important;accent-color:#ba2443;min-height:20px!important}
.marketing-checkbox span {flex:1;font-size:13px;font-weight:600}
.customer-chat-form{display:grid;gap:11px;margin-top:18px;padding-top:17px;border-top:1px solid #dbe7f1}
.customer-chat-form label{font-size:13px;font-weight:800;color:#234f76}
.customer-chat-form textarea{width:100%;min-height:106px;padding:13px;border-radius:15px;resize:vertical;line-height:1.8;border:1px solid #cbdfee;background:#f9fcff;color:var(--ink,#143457)}
.customer-chat-form button{border:0;min-height:49px;border-radius:13px;background:linear-gradient(130deg,#c72b47,#ad203e);font-weight:850;color:white}
.customer-chat-form p{font-size:12px;color:#24795e}
.chat-bubble,.reply-item{max-width:100%;overflow-wrap:anywhere}
.chat-author{display:inline-flex;padding:3px 9px;border-radius:999px;background:#e6f1ff;color:#1b598e;font-size:11px;font-weight:800}
.chat-office{background:#edf6ff!important;border-right:3px solid #3072ab}
.chat-customer{background:#fff3f5!important;border-right:3px solid #ca3652}
.chat-customer .chat-author{background:#ffe1e7;color:#ac2440}
.tp-btn-whatsapp{background:linear-gradient(130deg,#177f59,#0e6849)!important;color:white!important}
.tp-success .tp-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:10px}
/* General app-scale responsive typography and controls */
@media(max-width:900px){
  html,body { max-width:100%; }
  .afra-app-dock { z-index:85; }
  .afra-app-dock a { min-height:54px;touch-action:manipulation; }
  .afra-app-dock svg {pointer-events:none;}
  .btn, .tp-btn, button:not(.slide-arrow), input, select, textarea { min-height:44px; }
  /* Tablet: keep all content inside viewport with no fixed desktop widths */
  .work-main,.dash-main,.dash-page,.panel,.request-card-grid,.request-card,.customer-private,.access-card,.auth-layout,.tp-container {min-width:0;max-width:100%}
}
@media(max-width:850px){
  /* The admin top bar must be ONE row, not a five-button panel. */
  .work-head {position:sticky!important;top:0!important;z-index:90!important;display:flex!important;align-items:center!important;justify-content:space-between!important;gap:8px!important;flex-wrap:nowrap!important;min-height:66px!important;padding:8px 12px!important;background:rgba(255,255,255,.97)!important;border-bottom:1px solid #d7e4ef!important}
  .work-brand {flex:1 1 auto;min-width:0!important;max-width:calc(100% - 158px);gap:8px!important}
  .work-brand img {width:40px!important;height:40px!important;object-fit:contain;flex:0 0 40px}
  .work-brand span {min-width:0;max-width:100%}
  .work-brand strong {display:block!important;font-size:clamp(13px,3.6vw,17px)!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.45}
  .work-brand small {display:none!important}
  .head-buttons {display:flex!important;flex:0 0 auto!important;gap:6px!important;align-items:center!important;justify-content:flex-end!important;width:auto!important;flex-wrap:nowrap!important;max-width:156px}
  .head-buttons>a {display:none!important}
  .head-buttons>.afra-n-bell {display:inline-flex!important;min-width:42px!important;width:42px!important;min-height:42px!important;height:42px!important;padding:8px!important;flex:0 0 42px}
  #themeToggle {position:relative;display:grid!important;place-items:center;min-width:42px!important;width:42px!important;height:42px!important;padding:0!important;font-size:0!important;line-height:1!important;flex:0 0 42px!important}
  #themeToggle::after {content:'☾';font:800 23px/1 sans-serif;color:#1c5c8d}
  #logout:not([hidden]) {display:inline-flex!important;align-items:center;justify-content:center;min-width:55px!important;min-height:42px!important;width:auto!important;padding:0 9px!important;font-size:11px!important;flex:0 0 auto!important}
  .work-main {padding:12px!important;width:100%!important;max-width:100%!important}
  .dashboard {display:block!important;grid-template-columns:1fr!important;min-width:0!important}
  .dash-main {padding:12px!important;width:100%!important;min-width:0!important;border-radius:18px!important}
  .dash-welcome {display:flex!important;flex-wrap:wrap!important;gap:8px!important;min-height:0!important;padding:15px!important;align-items:center!important;border-radius:17px!important}
  .dash-welcome h1 {font-size:clamp(19px,5.7vw,25px)!important;margin:0!important}
  .dash-welcome>div{min-width:0;flex:1 1 145px}
  .dash-welcome .online-dot {display:none!important}
  .dash-menu-toggle {display:inline-flex!important;min-height:42px!important;padding:9px 12px!important;font-size:12px!important;border-radius:13px!important;flex:0 0 auto}
  .dash-rail {display:block!important;position:fixed!important;top:0!important;right:0!important;bottom:0!important;left:auto!important;width:min(370px,90vw)!important;max-width:90vw!important;height:100dvh!important;max-height:100dvh!important;overflow-x:hidden!important;overflow-y:auto!important;overscroll-behavior:contain;z-index:201!important;border-radius:22px 0 0 22px!important;padding:14px!important;background:#fff!important;transform:translateX(108%)!important;visibility:hidden!important;pointer-events:none!important;transition:transform .25s ease,visibility .25s!important;box-shadow:-12px 0 45px rgba(0,0,0,.15)!important}
  .dash-rail.menu-open {visibility:visible!important;pointer-events:auto!important;transform:translateX(0)!important}
  #dashOverlay:not([hidden]) {display:block!important;position:fixed!important;inset:0!important;background:rgba(8,26,49,.54)!important;z-index:200!important;touch-action:manipulation}
  body.dashboard-menu-open{overflow:hidden!important}
  .dash-nav{display:flex!important;flex-direction:column!important;gap:8px!important;overflow:visible!important;padding-bottom:calc(30px + env(safe-area-inset-bottom,0px))!important}
  .dash-nav .nav-group {min-width:0!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:3px!important}
  .dash-nav button {display:flex!important;width:100%!important;justify-content:flex-start!important;white-space:normal!important;text-align:right!important;min-height:48px!important;font-size:13px!important;padding:10px 13px!important}
  .dash-nav button[hidden] {display:none!important}
  .dash-nav-icon {flex:0 0 32px}
  .afra-dash-sidebar-brand {gap:7px!important;margin-bottom:12px!important;padding:12px!important;min-height:68px}
  .afra-dash-sidebar-brand strong {font-size:14px!important}
  .dash-sidebar-close{margin-inline-start:auto;display:grid;place-items:center;width:38px;height:38px;flex:0 0 38px;border-radius:11px;border:1px solid rgba(255,255,255,.32);background:rgba(255,255,255,.12);color:white;font:700 24px/1 sans-serif;touch-action:manipulation}
  .dash-rail .rail-bottom {display:none}
  .dashboard-hero{grid-template-columns:1fr!important;gap:12px!important;padding:17px!important}
  .dashboard-hero h2{font-size:clamp(19px,5.5vw,25px)!important}
  .stats-grid {grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:9px!important}
  .stat {min-width:0!important;padding:14px!important}
  .stat strong{font-size:24px!important}
  .admin-request-grid,.request-card-grid {display:grid!important;grid-template-columns:1fr!important;gap:13px!important}
  .admin-request-card,.request-card {max-width:100%!important;min-width:0!important}
  .request-meta p {overflow-wrap:anywhere}
  .form-grid,.form-grid-2 {display:grid!important;grid-template-columns:1fr!important;gap:12px!important}
  .form-grid label,.form-grid .wide{min-width:0!important;grid-column:1/-1!important}
  .form-grid input,.form-grid select,.form-grid textarea{width:100%!important;min-width:0!important;max-width:100%!important;font-size:16px!important;min-height:46px!important;padding:10px 13px!important}
  .admin-packages-grid{grid-template-columns:1fr!important}
  .package-manager-head{align-items:flex-start!important;gap:11px}
  .panel {padding:16px!important;margin-bottom:16px;min-width:0;overflow-wrap:anywhere}
  /* Customer account: keep header to one compact row */
  .topbar {position:sticky!important;top:0;z-index:80;display:flex!important;align-items:center!important;justify-content:space-between!important;gap:8px!important;flex-wrap:nowrap!important;min-height:65px!important;padding:8px 12px!important}
  .topbar .brand {flex:1 1 auto!important;min-width:0!important;max-width:calc(100% - 150px);gap:8px!important}
  .topbar .brand img {width:42px!important;height:42px!important;flex:0 0 42px}
  .topbar .brand span {min-width:0;overflow:hidden}
  .topbar .brand strong {font-size:clamp(13px,3.5vw,16px)!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}
  .topbar .brand small {display:none!important}
  .topbar .head-links {width:auto!important;max-width:150px;flex:0 0 auto!important;display:flex!important;align-items:center!important;justify-content:flex-end!important;gap:6px!important;flex-wrap:nowrap!important}
  .topbar .head-links>a {display:none!important}
  .topbar .afra-n-bell {width:41px!important;height:41px!important;min-height:41px!important;flex:0 0 41px!important}
  #customerTheme {width:42px!important;min-width:42px!important;height:42px!important;padding:0!important;font-size:0!important;position:relative}
  #customerTheme::after {content:'☾';font:800 23px/1 sans-serif;color:#1c5c8d}
  #customerLogout:not([hidden]) {display:inline-flex!important;align-items:center!important;min-height:41px!important;padding:0 7px!important;font-size:10px!important}
  .auth-layout {min-height:0!important;grid-template-columns:1fr!important;gap:14px!important}
  .travel-visual {min-height:240px!important;border-radius:22px!important}
  .travel-visual-overlay {padding:20px!important}
  .travel-visual h1 {font-size:clamp(23px,6vw,34px)!important;line-height:1.4!important}
  .travel-visual p{font-size:13px!important;line-height:1.8!important}
  .value-row{gap:7px!important;margin-top:12px!important}
  .value-row span {font-size:11px!important;padding:6px 9px!important}
  .access-card {border-radius:22px!important;padding:18px!important;width:100%!important}
  .access-title h2 {font-size:23px!important}
  .auth-tabs {display:flex!important;overflow-x:auto!important;scroll-snap-type:x proximity;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  .auth-tabs button {flex:0 0 auto!important;scroll-snap-align:start;min-height:44px!important;min-width:75px!important;font-size:12px!important}
  .pane input,.password-panel input,.customer-chat-form textarea{font-size:16px!important;min-height:47px!important}
  .customer-private{padding-inline:0!important}
  .dash-banner{min-height:150px!important;padding:20px!important;border-radius:20px!important}
  .dash-banner h1{font-size:24px!important}
  .request-grid,.stat-row{grid-template-columns:1fr!important;gap:12px!important}
  .reply-panel,.password-panel {padding:17px!important;border-radius:19px!important}
  .password-panel form{display:grid!important;grid-template-columns:1fr!important;gap:13px!important}
  .requests-title {flex-direction:column!important;align-items:stretch!important}
  .reply-panel button, .customer-chat-form button,.pane button,.password-panel button {touch-action:manipulation;min-height:48px!important}
}
@media(max-width:410px){
  .work-brand {max-width:calc(100% - 147px)}
  .head-buttons{max-width:146px;gap:4px!important}
  .topbar .brand {max-width:calc(100% - 142px)}
  .topbar .head-links{max-width:142px;gap:4px!important}
  .work-head .work-brand strong,.topbar .brand strong {font-size:12.5px!important}
}
html[data-theme="dark"] .marketing-checkbox{background:#1b3651;color:#d9eafa;border-color:#355979}
html[data-theme="dark"] .customer-chat-form textarea{background:#132d45;color:#f0f8ff;border-color:#386181}
html[data-theme="dark"] .chat-office{background:#21405e!important;color:#ecf8ff}
html[data-theme="dark"] .chat-customer{background:#412638!important;color:#fff3f7}
@media(max-width:850px){html[data-theme="dark"] .work-head,html[data-theme="dark"] .topbar{background:rgba(13,34,55,.98)!important;border-color:#31516f!important}html[data-theme="dark"] .dash-rail{background:#142d47!important;border-color:#355979!important}}
@media(prefers-reduced-motion:reduce){.dash-rail,.dash-nav button{transition:none!important}html{scroll-behavior:auto!important}}
