/* Shared responsive shell. Loaded after module styles and layout fallbacks. */
#sidebar { overscroll-behavior:contain; }
#content { min-width:0; }
#content img, #content canvas { max-width:100%; }
.toolbar { flex-wrap:wrap; align-items:center; }
.toolbar > * { min-width:0; }
.table-scroll, .product-scroll, .saas-table-wrap { max-width:100%; overflow-x:auto; overscroll-behavior-x:contain; }
.mobile-scrim, .mobile-drawer-close { display:none; }
@media (min-width:901px) {
  main { padding-inline:clamp(24px,3vw,52px); }
  #sidebar { top:0; height:100dvh; }
}
@media (max-width:900px) {
  #app { display:block; }
  #app > main { width:100%; padding:0 20px 24px; }
  .workspace-header { min-height:96px; margin-bottom:20px; }
  #sidebar { display:none; position:fixed; inset:0 auto 0 0; top:0; width:min(320px,86vw); height:100dvh; padding:24px 18px; z-index:201; box-shadow:12px 0 48px #20102f33; }
  #app.menu-open #sidebar { display:flex; }
  #app.menu-open .mobile-scrim { display:block; position:fixed; inset:0; z-index:200; background:color-mix(in srgb,var(--deep) 72%,transparent); border:0; border-radius:0; padding:0; margin:0; }
  .mobile-drawer-close { display:block; align-self:flex-end; background:#ffffff18; color:white; min-height:44px; margin:0; }
  .menu-toggle { display:grid; place-items:center; width:56px; min-height:56px; padding:8px; flex-shrink:0; border:1px solid var(--line); background:var(--lavender); color:var(--purple); border-radius:16px; font-size:24px; line-height:1; }
  #sidebar .nav-group button { font-size:14px; min-height:46px; }
  #sidebar .nav-group summary { padding:12px 10px; }
  #sidebar input { min-height:46px; font-size:16px; }
  .user-pill #identity { display:none; }
  .user-pill { padding:0; border:0; background:transparent; }
  body:has(#app:not([hidden]).menu-open) { overflow:hidden; }
}
@media (max-width:600px) {
  body { font-size:14px; }
  #app > main { padding:0 14px calc(20px + env(safe-area-inset-bottom)); }
  .workspace-header { position:sticky; top:0; z-index:30; background:var(--header-bg); backdrop-filter:blur(12px); padding:12px 0; min-height:82px; gap:8px; margin-bottom:18px; }
  .heading-block { gap:10px; min-width:0; }
  .workspace-header h1 { font-size:20px; line-height:1.2; overflow-wrap:anywhere; }
  .workspace-header #subtitle { display:none; }
  .workspace-header .eyebrow { font-size:8px; margin-bottom:5px; }
  .avatar { width:34px; height:34px; }
  .panel, .saas-workspace { padding:16px; border:1px solid var(--line); border-radius:18px; }
  .page-heading h1, .product-heading h2 { font-size:23px; margin:8px 0; }
  .page-heading p, .product-heading p { line-height:1.55; font-size:13px; }
  #content .metric-grid, .saas-metric-grid, .so-summary { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:10px !important; }
  #content .metric { padding:14px !important; gap:8px !important; }
  #content .metric strong { font-size:23px !important; }
  #content .metric .metric-label, #content .metric small { font-size:11px !important; line-height:1.4 !important; }
  #content .dashboard-grid, .product-form, .saas-detail-grid { grid-template-columns:minmax(0,1fr) !important; }
  #content .shortcut-grid { grid-template-columns:repeat(2,minmax(0,1fr)) !important; gap:10px !important; }
  button, input:not([type=checkbox]):not([type=radio]), select, textarea { min-height:44px; }
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size:16px; max-width:100%; }
  .toolbar { gap:10px; }
  .toolbar > input, .toolbar > select, .toolbar > button { width:100%; max-width:none; flex:1 1 100%; margin:0; }
  #content .filter-bar { align-items:stretch; }
  #content .filter-bar label { flex:1 1 130px; }
  #content .filter-bar input { max-width:100%; width:100%; }
  .sales-overview-actions, .form-actions { flex-wrap:wrap; gap:8px; }
  .form-actions button { flex:1 1 120px; margin:0; }
  .modal-overlay { padding:10px; align-items:end; }
  .product-modal, .invoice-dialog, .saas-customer-dialog { width:100%; max-width:100%; max-height:calc(100dvh - 24px); border-radius:20px; padding:18px; }
  .saas-customer-card { padding:16px; }
  .invoice-line { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .invoice-line > :first-child { grid-column:1/-1; }
  .mobile-card-table { display:block; min-width:0 !important; }
  .mobile-card-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
  .mobile-card-table tbody { display:grid; gap:12px; }
  .mobile-card-table tr { display:block; border:1px solid var(--line); border-radius:14px; padding:6px 12px; background:var(--surface); }
  .mobile-card-table td { display:grid; grid-template-columns:minmax(80px,.75fr) minmax(0,1.25fr); gap:12px; padding:10px 0; max-width:none; align-items:start; }
  .mobile-card-table td::before { content:attr(data-mobile-label); color:var(--muted); font-size:12px; font-weight:600; }
  .mobile-card-table td:last-child { border-bottom:0; }
  .mobile-cell-value { min-width:0; overflow-wrap:anywhere; }
  .mobile-cell-value button { margin:3px; }
  .login { display:block; }
  .login-story { min-height:auto; padding:24px; gap:18px; }
  .login-story > div:nth-child(2), .login-story > small { display:none; }
  .login-entry { padding:32px 22px; }
  .login h2 { font-size:25px; }
}
@media print { .mobile-scrim, .mobile-drawer-close, .menu-toggle { display:none !important; } }

/* Mobile header: keep the menu and title aligned without an account badge. */
@media (max-width:900px) {
  #app .workspace-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:nowrap; }
  #app .workspace-header .user-pill { display:none; }
  #app .workspace-header .heading-block { flex:1; min-width:0; }
}

/* Platform administrator workspace is hosted inside the login container. */
.login-entry:has(#saasAdminDashboard:not([hidden])) { display:block; min-width:0; }
.login:has(#saasAdminDashboard:not([hidden])) { grid-template-columns:minmax(0,1fr); }
.login:has(#saasAdminDashboard:not([hidden])) .login-story { display:none; }
@media(max-width:600px) {
  .login-entry:has(#saasAdminDashboard:not([hidden])) { padding:16px; }
  #saasAdminDashboard { min-width:0; width:100%; }
  #saasAdminDashboard .saas-dashboard-header { padding:20px 16px; gap:14px; }
  #saasAdminDashboard .saas-dashboard-header h2 { font-size:23px; }
  #saasAdminDashboard .saas-workspace { padding:14px; }
  #saasAdminDashboard .saas-toolbar > * { width:100%; max-width:100%; min-width:0; }
  #saasAdminDashboard .saas-metric { padding:14px; min-width:0; }
  #saasAdminDashboard .saas-metric strong { font-size:23px; overflow-wrap:anywhere; }
  #saasAdminDashboard .mobile-cell-value { display:flex; flex-wrap:wrap; gap:6px; }
  #saasAdminDashboard .mobile-cell-value > select { width:100%; }
  #saasAdminDashboard .mobile-cell-value small { width:100%; }
  .saas-device-row { display:flex; flex-wrap:wrap; gap:10px; overflow-wrap:anywhere; }
  .login-entry > div:has(#saasAdminLoginForm) { width:100%; min-width:0; }
}
.data-tools { display:grid; gap:20px; }
.data-tools h2 { margin:4px 0 12px; }
.import-steps { display:flex; gap:28px; flex-wrap:wrap; color:var(--purple); font-weight:600; padding-left:20px; }
.import-note { background:var(--lavender); padding:14px; border-radius:10px; line-height:1.6; }
.import-upload { display:grid; gap:12px; margin:20px 0; justify-items:start; }
.import-upload input { max-width:100%; }
.import-mapping { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin:20px 0; }
.import-mapping label { display:grid; gap:8px; }
.import-success { background:#e8f6ed; color:#17663b; padding:18px; border-radius:12px; }
.data-tools .table-scroll { margin:16px 0; }
.data-tools button { margin:4px; }
.favorite-picker { display:grid; grid-template-columns:1fr 1fr; gap:12px; padding:12px 0 24px; }
.favorite-picker label { display:flex; align-items:center; gap:10px; min-height:44px; }
.favorite-picker input { min-height:20px; width:20px; }
.addon-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; }
.dashboard-insights { margin-bottom:20px; }
.sales-trend { overflow-x:auto; }
.trend-bars { display:flex; align-items:end; gap:18px; min-height:180px; padding:20px 4px; }
.trend-day { display:flex; flex-direction:column; align-items:center; gap:8px; min-width:75px; }
.trend-value { font-size:11px; white-space:nowrap; }
.trend-bar { width:34px; background:var(--purple); border-radius:7px 7px 0 0; }
.dirham-symbol { display:inline-block; width:1em; height:1em; object-fit:contain; vertical-align:-.12em; }
.metric.accent .dirham-symbol { filter:invert(1); }
.mobile-dock { display:none; }
@media(max-width:600px) {
  .import-mapping,.favorite-picker { grid-template-columns:minmax(0,1fr); }
  .import-steps { gap:12px 24px; font-size:12px; }
  .import-upload { justify-items:stretch; }
  #app > main { padding-bottom:calc(90px + env(safe-area-inset-bottom)); }
  #app:not([hidden]) .mobile-dock { display:flex; position:fixed; inset:auto 0 0; z-index:35; background:color-mix(in srgb,var(--surface) 97%,transparent); border-top:1px solid var(--line); padding:8px 10px calc(8px + env(safe-area-inset-bottom)); gap:4px; box-shadow:0 -4px 24px color-mix(in srgb,var(--deep) 8%,transparent); }
  .mobile-dock button { flex:1; min-width:0; min-height:58px; font-size:11px; padding:6px 4px; border-radius:12px; background:transparent; color:var(--muted); overflow-wrap:anywhere; }
  .mobile-dock .mobile-dock-item { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; font-weight:600; }
  .mobile-dock-item svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
  .mobile-dock button.active { background:var(--lavender); color:var(--purple); }
}
@media print { .mobile-dock { display:none !important; } }
.dirham-symbol { width:1.25em; height:1.25em; vertical-align:-.25em; mix-blend-mode:multiply; } .metric.accent .dirham-symbol { mix-blend-mode:screen; }

.crm-metrics { margin:16px 0; }
.crm-toolbar { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin-bottom:16px; }
.crm-toolbar input { flex:1 1 240px; }
.crm-toolbar select { flex:0 1 180px; }
.crm-board { display:grid; grid-auto-columns:minmax(235px,1fr); grid-auto-flow:column; gap:12px; overflow-x:auto; padding:2px 2px 14px; align-items:start; }
.crm-stage { min-height:220px; padding:12px; border:1px solid var(--line); border-radius:16px; background:var(--surface-soft,#f7f4fc); }
.crm-stage-head { display:grid; grid-template-columns:1fr auto; gap:5px; padding:3px 2px 12px; }
.crm-stage-head small { grid-column:1/-1; color:var(--muted); }
.crm-count { min-width:24px; height:24px; display:grid; place-items:center; border-radius:50%; background:var(--lavender); color:var(--purple); font-size:12px; }
.crm-lead-card { display:grid; gap:5px; padding:12px; margin:8px 0; border:1px solid var(--line); border-radius:12px; background:var(--surface,#fff); box-shadow:0 3px 12px #24113a0b; cursor:pointer; overflow-wrap:anywhere; }
.crm-lead-card:focus-visible { outline:3px solid var(--purple); outline-offset:2px; }
.crm-lead-card > small,.crm-lead-card > span { color:var(--muted); font-size:12px; }
.crm-card-foot,.crm-activity-top { display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap; margin-top:5px; }
.crm-follow-up,.crm-overdue,.crm-complete { border-radius:99px; padding:4px 8px; font-size:11px; background:var(--lavender); color:var(--purple); }
.crm-overdue { color:#a32d39; background:#fff0f1; }
.crm-complete { color:#16653b; background:#e9f7ef; }
.crm-dialog { width:min(820px,96vw); max-height:92dvh; overflow:auto; }
.crm-dialog > .product-form { grid-template-columns:repeat(2,minmax(0,1fr)); }
.crm-dialog > .product-form > :last-child:nth-child(odd) { grid-column:1/-1; }
.crm-timeline { margin-top:20px; padding-top:14px; border-top:1px solid var(--line); }
.crm-activity-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; align-items:end; padding:14px; border-radius:12px; background:var(--surface-soft,#f7f4fc); }
.crm-activity-form label:has(textarea) { grid-column:1/-1; }
.crm-activity-list { display:grid; gap:8px; margin-top:12px; }
.crm-activity { border:1px solid var(--line); border-radius:12px; padding:12px; overflow-wrap:anywhere; }
.crm-activity p { white-space:pre-wrap; margin:8px 0; }
@media(max-width:600px) { .crm-board { grid-auto-columns:minmax(82vw,1fr); margin-inline:-4px; } .crm-dialog > .product-form,.crm-activity-form { grid-template-columns:minmax(0,1fr); } .crm-dialog > .product-form > :last-child:nth-child(odd),.crm-activity-form label:has(textarea) { grid-column:auto; } }

.hr-metrics { margin:18px 0; }
.hr-tabs { display:flex; flex-wrap:wrap; gap:8px; padding:8px; margin:10px 0 18px; border:1px solid var(--line); border-radius:14px; background:var(--surface,#fff); }
.hr-tabs button { min-height:42px; }
.hr-form { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin:16px 0; padding:16px; border:1px solid var(--line); border-radius:14px; background:var(--surface-soft,#f7f4fc); }
.hr-form label,.hr-dialog .product-form label { display:grid; align-content:start; gap:6px; color:var(--muted); font-size:13px; }
.hr-form input,.hr-form select,.hr-form textarea,.hr-dialog .product-form input,.hr-dialog .product-form select,.hr-dialog .product-form textarea { width:100%; min-height:42px; padding:9px 11px; border:1px solid var(--line); border-radius:9px; background:var(--surface,#fff); color:var(--text,#211a2c); font:inherit; }
.hr-form textarea,.hr-dialog .product-form textarea { resize:vertical; }
.hr-form > .error,.hr-form > button { align-self:end; }
.hr-dialog { width:min(850px,96vw); max-height:92dvh; overflow:auto; }
.hr-dialog .product-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.hr-dialog .form-actions { grid-column:1/-1; display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; }
.hr-actions { display:flex; flex-wrap:wrap; gap:6px; }
.hr-actions button { min-height:34px; padding:5px 9px; }
.hr-workspace .table-scroll { margin:12px 0 22px; }
@media(max-width:700px) { .hr-form { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:520px) { .hr-form,.hr-dialog .product-form { grid-template-columns:minmax(0,1fr); } .hr-dialog .form-actions { grid-column:auto; } .hr-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); } }

.accounting-hub { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; align-items:start; }
.accounting-group { padding:0; overflow:hidden; }
.accounting-group > .eyebrow,.accounting-group > h2,.accounting-group > p { margin-inline:20px; }
.accounting-group > .eyebrow { margin-top:18px; }
.accounting-links { display:grid; gap:0; margin-top:18px; border-top:1px solid var(--line); }
.accounting-link { display:flex; justify-content:space-between; align-items:center; text-align:left; width:100%; min-height:52px; padding:12px 18px; border:0; border-bottom:1px solid var(--line); border-radius:0; background:var(--surface,#fff); color:var(--text,#211a2c); font-weight:600; }
.accounting-link:hover { color:var(--purple); background:var(--surface-soft,#f7f4fc); }
.accounting-setup-form { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); align-items:end; gap:12px; margin:16px 0; padding:16px; border:1px solid var(--line); border-radius:14px; background:var(--surface,#fff); }
.accounting-setup-form label { display:grid; gap:6px; color:var(--muted); font-size:13px; }
.accounting-setup-form input:not([type=checkbox]) { min-height:42px; padding:8px 10px; border:1px solid var(--line); border-radius:9px; background:var(--surface,#fff); color:var(--text,#211a2c); }
.accounting-setup-form label:has([type=checkbox]) { display:flex; align-items:center; gap:8px; min-height:42px; }
@media(max-width:900px) { .accounting-hub { grid-template-columns:repeat(2,minmax(0,1fr)); } .accounting-setup-form { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:560px) { .accounting-hub,.accounting-setup-form { grid-template-columns:minmax(0,1fr); } }
