:root{color-scheme:dark;--bg:#0b1220;--surface:#111b2c;--surface2:#162238;--surface3:#1b2941;--outline:#27364c;--text:#eef4ff;--muted:#93a5bf;--blue:#4e84ff;--blue2:#2a56bf;--green:#33c6a1;--amber:#edb85e;--red:#f37f86;--font:Tahoma,Arial,sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);font-size:14px}button,input,textarea,select{font:inherit}button{cursor:pointer}a{color:var(--blue);text-decoration:none}.startup{padding:50px;text-align:center}.app-shell{display:grid;grid-template-columns:242px minmax(0,1fr);min-height:100vh}.sidebar{background:#101a2b;border-left:1px solid var(--outline);padding:24px 14px;display:flex;flex-direction:column;gap:24px;position:sticky;top:0;height:100vh}.brand{display:flex;gap:12px;align-items:center;padding:3px 10px 23px;border-bottom:1px solid var(--outline)}.brand-icon{display:grid;place-items:center;background:linear-gradient(130deg,#477bff,#70a5ff);border-radius:13px;width:40px;height:40px;color:white;font-size:17px;font-weight:900;box-shadow:0 5px 22px #2359f744}.brand b{font-size:19px;letter-spacing:.4px}.brand small{display:block;color:var(--muted);margin-top:5px;font-size:11px}.nav-title{font-size:11px;color:#7386a2;padding:0 14px 8px}.nav-button{width:100%;display:flex;gap:12px;align-items:center;border:0;color:#a9bad1;background:transparent;text-align:right;border-radius:10px;padding:12px 14px;margin:3px 0;transition:.14s}.nav-button .ni{font-size:16px;opacity:.95;width:23px;text-align:center}.nav-button:hover{background:#1c2b44;color:white}.nav-button.active{background:#1d3357;color:#e9f1ff;box-shadow:inset -3px 0 0 #5489ff}.sidebar-bottom{margin-top:auto;border-top:1px solid var(--outline);padding:20px 12px 0;color:var(--muted);line-height:1.9;font-size:12px}.dot{display:inline-block;height:8px;width:8px;border-radius:50%;background:var(--green);margin-left:7px}.main{min-width:0}.topbar{height:80px;display:flex;justify-content:space-between;align-items:center;padding:18px 32px;border-bottom:1px solid var(--outline);background:#0e1727}.topbar .crumb{font-size:12px;color:var(--muted);margin-bottom:6px}.topbar h1{font-size:23px;font-weight:800;margin:0}.topbar-right{display:flex;align-items:center;gap:12px}.userbubble{width:36px;height:36px;border-radius:50%;background:#24375b;display:grid;place-items:center;color:#adc5ff;font-weight:bold}.content{padding:32px;max-width:1560px;margin:auto}.btn{border:1px solid var(--outline);background:var(--surface2);color:var(--text);padding:10px 15px;border-radius:9px;font-weight:700;min-height:39px}.btn:hover{background:#23334e}.btn.primary{border-color:#4d7dea;background:#416eea;color:white}.btn.primary:hover{background:#5785ff}.btn.danger{border-color:#6c3f49;background:#422732;color:#ffc6c9}.btn.small{padding:6px 10px;min-height:30px;font-size:12px}.btn:disabled{opacity:.45;cursor:not-allowed}.section-header{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-bottom:20px}.section-header h2{font-size:18px;margin:0}.section-header p,.subtitle{color:var(--muted);font-size:12px;line-height:1.8;margin:8px 0 0}.section-header .actions{display:flex;gap:9px;align-items:center}.muted{color:var(--muted)}.kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin-bottom:24px}.kpi{border:1px solid var(--outline);background:linear-gradient(145deg,#16223a,#111b2d);border-radius:14px;padding:20px;min-height:132px;display:flex;flex-direction:column;justify-content:space-between}.kpi .kpi-top{display:flex;justify-content:space-between;color:var(--muted)}.kpi .glyph{background:#22375b;border-radius:9px;padding:6px 9px;color:#91b6ff}.kpi strong{font-size:32px;letter-spacing:-1px}.kpi .kpi-foot{color:#8ba6c9;font-size:11px}.panel-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.panel{border:1px solid var(--outline);border-radius:14px;background:var(--surface);overflow:hidden}.panel h3{font-size:14px;margin:0;padding:19px 21px;border-bottom:1px solid var(--outline)}.panel-pad{padding:22px}.funnel-row{display:flex;align-items:center;gap:12px;margin-bottom:17px}.funnel-row:last-child{margin-bottom:0}.funnel-row .flabel{width:130px;color:#c1cfe0;font-size:12px}.funnel-track{height:9px;flex:1;border-radius:20px;background:#263650;overflow:hidden}.funnel-fill{height:100%;border-radius:20px;background:linear-gradient(90deg,#467bff,#58b7ea)}.funnel-num{color:#c3d0e2;font-weight:bold;width:20px;text-align:left}.list-activity{display:flex;align-items:flex-start;gap:11px;padding:13px 0;border-bottom:1px solid #25334a}.list-activity:last-child{border:0}.acticon{width:32px;height:32px;border-radius:9px;background:#233650;display:grid;place-items:center}.actbody{flex:1;min-width:0}.actbody b{display:block;margin-bottom:5px;font-size:12px}.actbody small{color:var(--muted)}.toolbar{display:flex;gap:10px;align-items:center;margin-bottom:16px;flex-wrap:wrap}.search{background:var(--surface);border:1px solid var(--outline);border-radius:9px;min-width:230px;width:min(400px,100%);padding:11px 13px;color:var(--text);outline:none}.search:focus,input:focus,textarea:focus,select:focus{border-color:#4f7fff;outline:2px solid #4f7fff21}.filterselect{background:var(--surface);border:1px solid var(--outline);border-radius:9px;padding:10px;color:var(--text)}.data-table-wrap{border:1px solid var(--outline);border-radius:13px;overflow:auto;background:var(--surface)}table{width:100%;border-collapse:collapse;text-align:right;white-space:nowrap}th{color:#899bb5;font-size:12px;text-align:right;background:#142034;font-weight:600;padding:15px}td{padding:15px;border-top:1px solid #26334a;font-size:12px;max-width:340px;overflow:hidden;text-overflow:ellipsis}tbody tr:hover{background:#17253b}.name-cell{font-weight:700;color:#e6efff}.pill{display:inline-block;border:1px solid #395175;color:#a9c6fa;background:#1e3150;border-radius:20px;padding:5px 10px;font-size:11px}.pill.green{border-color:#236d5c;color:#66dbbc;background:#153e3b}.pill.orange{border-color:#6e5230;color:#eac083;background:#382e23}.pill.red{border-color:#783b45;color:#fca8ad;background:#40252c}.pill.dim{border-color:#374355;color:#a3aec2;background:#222b3a}.table-actions{display:flex;gap:6px}.empty{padding:58px 20px;text-align:center;color:var(--muted)}.empty .empticon{font-size:38px;margin-bottom:12px}.empty strong{display:block;color:var(--text);font-size:16px;margin-bottom:8px}.overlay{position:fixed;inset:0;background:#030810c9;display:flex;align-items:center;justify-content:center;padding:18px;z-index:20}.modal{width:min(860px,100%);max-height:94vh;display:flex;flex-direction:column;background:#101b2d;border:1px solid #364864;border-radius:16px;box-shadow:0 25px 75px #0008;overflow:hidden}.modal-header{display:flex;align-items:center;justify-content:space-between;padding:20px 24px;border-bottom:1px solid var(--outline)}.modal-header h2{font-size:18px;margin:0}.close{background:transparent;color:#becfe5;border:0;font-size:27px;line-height:1}.modal-content{overflow:auto;padding:24px}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:17px}.field{display:flex;flex-direction:column;gap:8px;min-width:0}.field.full{grid-column:1/-1}.field label{font-size:12px;font-weight:700;color:#cbd9ea}.field input,.field select,.field textarea{width:100%;background:#0d1625;border:1px solid #33445f;color:var(--text);border-radius:9px;padding:11px 12px;min-height:42px;outline:0}.field textarea{resize:vertical;min-height:86px;line-height:1.7}.checks{display:flex;flex-wrap:wrap;gap:8px}.chip-check{cursor:pointer}.chip-check input{position:absolute;opacity:0;width:1px;height:1px}.chip-check span{display:inline-block;padding:8px 12px;border:1px solid #33445f;border-radius:8px;color:#a5b7d1;font-size:11px}.chip-check input:checked+span{background:#204277;color:#e1edff;border-color:#477deb}.modal-footer{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--outline);padding:16px 24px;background:#111d30}.footer-actions{display:flex;gap:9px}.details{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}.detail{padding:13px;background:#18263a;border-radius:10px}.detail small{display:block;color:var(--muted);margin-bottom:8px}.detail strong{font-size:13px;line-height:1.6}.notice{border:1px solid #6a4f2f;background:#342d22;color:#f2d9b0;border-radius:12px;padding:16px;line-height:1.9}.settings-stack{display:grid;gap:14px;max-width:900px}.settings-row{background:var(--surface);border:1px solid var(--outline);border-radius:12px;padding:20px}.settings-row b{display:block;margin-bottom:7px}.settings-row p{color:var(--muted);line-height:1.8;margin:0}.toast{position:fixed;bottom:25px;left:25px;padding:13px 19px;background:#204e49;border:1px solid #2a9d88;color:#e2fff5;box-shadow:0 12px 40px #0008;border-radius:10px;z-index:40}.toast.error{background:#532d36;border-color:#bd6570;color:#ffebec}.mob-nav{display:none}@media(max-width:1000px){.app-shell{grid-template-columns:190px minmax(0,1fr)}.sidebar{padding:15px 7px}.content{padding:22px}.kpi-grid{grid-template-columns:repeat(2,1fr)}.panel-grid{grid-template-columns:1fr}}@media(max-width:650px){.app-shell{display:block}.sidebar{position:static;height:auto;padding:10px;gap:8px}.brand{padding:4px 8px}.sidebar-bottom,.nav-title{display:none}.navigation{display:flex;overflow:auto}.nav-button{min-width:max-content;width:auto;margin:0;padding:9px}.topbar{height:auto;padding:18px;align-items:flex-start}.topbar h1{font-size:19px}.content{padding:15px}.kpi-grid{gap:9px}.kpi{padding:14px;min-height:109px}.kpi strong{font-size:25px}.panel-grid{display:block}.panel{margin-bottom:14px}.form-grid{grid-template-columns:1fr}.details{grid-template-columns:1fr}.modal-content{padding:15px}.section-header{align-items:flex-start;flex-direction:column}}
/* AC7 BLACK THEME */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #090909;
  --surface: #171717;
  --surface2: #222222;
  --surface3: #292929;
  --outline: #383838;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --blue: #e5e5e5;
}

html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-footer {
  background: #111111;
}

html[data-theme="dark"] .kpi {
  background: linear-gradient(145deg, #222, #151515);
}

html[data-theme="dark"] .nav-button.active,
html[data-theme="dark"] .nav-button:hover {
  background: #292929;
  color: #fff;
}

html[data-theme="dark"] .btn.primary {
  background: #363636;
  border-color: #555;
  color: white;
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea {
  background: #111;
  border-color: #444;
}

/* AC7 LIGHT THEME */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface2: #edf0f4;
  --surface3: #e5e9ef;
  --outline: #dce1e8;
  --text: #20242a;
  --muted: #687384;
  --blue: #343b49;
}

html[data-theme="light"] .sidebar,
html[data-theme="light"] .topbar,
html[data-theme="light"] .modal,
html[data-theme="light"] .modal-footer {
  background: #ffffff;
}

html[data-theme="light"] .nav-button {
  color: #414b59;
}

html[data-theme="light"] .nav-button.active,
html[data-theme="light"] .nav-button:hover {
  background: #e9edf2;
  color: #20242a;
}

html[data-theme="light"] .kpi {
  background: #ffffff;
}

html[data-theme="light"] .kpi .glyph,
html[data-theme="light"] .acticon {
  background: #edf0f4;
  color: #343b49;
}

html[data-theme="light"] th,
html[data-theme="light"] tbody tr:hover {
  background: #f1f3f6;
}

html[data-theme="light"] td,
html[data-theme="light"] .list-activity {
  border-color: #e2e6eb;
}

html[data-theme="light"] .name-cell,
html[data-theme="light"] .field label,
html[data-theme="light"] .funnel-row .flabel,
html[data-theme="light"] .funnel-num {
  color: #20242a;
}

html[data-theme="light"] .field input,
html[data-theme="light"] .field select,
html[data-theme="light"] .field textarea {
  background: white;
  color: #20242a;
  border-color: #dce1e8;
}

html[data-theme="light"] .detail {
  background: #f1f3f6;
}

html[data-theme="light"] .btn.primary {
  background: #252a32;
  border-color: #252a32;
  color: white;
}

/* ==========================================================================
   AC7 CRM — COMPACT MODERN ERP SIDEBAR & SUBNAV SYSTEM (STAGE B REFINEMENT)
   ========================================================================== */

/* Zero page-level horizontal overflow & clean root scroll flow */
html {
  height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
body {
  min-height: 100%;
  margin: 0;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: auto;
  position: relative;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font, Tahoma, Arial, sans-serif);
}

/* 1. App Shell: Grid on desktop with 265px sidebar and fluid remaining area */
.app-shell {
  display: grid;
  grid-template-columns: 265px minmax(0, 1fr);
  min-height: 100vh;
  height: auto;
  max-height: none;
  overflow: visible;
  width: 100%;
  max-width: 100vw;
}

/* 2. Desktop Sidebar: Pinned 265px, sticky 100vh, single internal scroll */
.sidebar {
  width: 265px;
  min-width: 265px;
  max-width: 265px;
  height: 100vh;
  max-height: 100vh;
  position: sticky !important;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  margin: 0 !important;
  background: var(--surface);
  border-left: 1px solid var(--outline);
  box-sizing: border-box;
  z-index: 100;
  overflow: hidden;
}

/* 3. Main Content Column: Zero internal scrollbar, full remaining width */
.main {
  min-width: 0;
  width: 100%;
  min-height: 100vh;
  height: auto;
  max-height: none;
  overflow: visible;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* 4. Brand Header: Height <= 64px (target <= 75px) */
.brand {
  flex: 0 0 64px;
  height: 64px;
  max-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  padding: 0 16px;
  border-bottom: 1px solid var(--outline);
  box-sizing: border-box;
  background: inherit;
  flex-shrink: 0;
}
.brand-info {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.crm-brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 150, 255, 0.22));
}
.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-text b {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.brand-text small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
}

/* 5. Mobile Menu Buttons (Desktop: Hidden) */
.mobile-menu-btn,
.sidebar-close-btn,
.sidebar-backdrop {
  display: none;
}

/* 6. Single Scrollbar: Only the navigation area scrolls */
.ac7-sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 16px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.25) transparent;
}
.ac7-sidebar-scroll::-webkit-scrollbar {
  width: 5px;
}
.ac7-sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.ac7-sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 4px;
}
.ac7-sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

.nav-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  opacity: 0.85;
  padding: 4px 8px 8px 8px;
  margin: 0;
}

/* 7. Sidebar Navigation Stack */
.sidebar .navigation {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

/* 8. Group Element */
.ac7-nav-group {
  margin-bottom: 2px;
  width: 100%;
}

/* 9. Group Header / Accordion Trigger (Height: 42px) */
.ac7-group-header {
  height: 42px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box;
  width: 100%;
}
.ac7-group-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.ac7-group-lead {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.ac7-group-title {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-size: 13px;
}
.ac7-group-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  opacity: 0.65;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.ac7-nav-group.is-expanded .ac7-group-chevron {
  transform: rotate(-90deg); /* In RTL, chevron pointing left rotates to point down */
}

/* 10. Sub-items Container */
.ac7-group-items {
  margin: 2px 0 4px;
  padding-right: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid rgba(148, 163, 184, 0.15);
}

/* 11. Sub-item Link (Height: 36px, Target 34-38px) */
.ac7-nav-item {
  height: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.12s ease;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box;
  width: 100%;
}
.ac7-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.ac7-nav-item-label {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* 12. Top-level Single Page Item (Height: 42px) */
.ac7-single-item {
  height: 42px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box;
  width: 100%;
}
.ac7-single-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* 13. Active State (Dark Mode) */
html[data-theme="dark"] .ac7-nav-item.is-active,
html[data-theme="dark"] .ac7-single-item.is-active {
  background: rgba(37, 99, 235, 0.18);
  color: #93c5fd;
  font-weight: 600;
  border-right: 3px solid #3b82f6;
}
html[data-theme="dark"] .ac7-nav-item.is-active .ac7-icon,
html[data-theme="dark"] .ac7-single-item.is-active .ac7-icon {
  color: #60a5fa;
}

/* 14. Active State (Light Mode) */
html[data-theme="light"] .ac7-nav-item.is-active,
html[data-theme="light"] .ac7-single-item.is-active {
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
  border-right: 3px solid #2563eb;
}
html[data-theme="light"] .ac7-nav-item.is-active .ac7-icon,
html[data-theme="light"] .ac7-single-item.is-active .ac7-icon {
  color: #2563eb;
}

/* 15. Theme Overrides for Light Mode Sidebar */
html[data-theme="light"] .sidebar {
  background: #f8fafc;
  border-left-color: #e2e8f0;
}
html[data-theme="light"] .brand {
  border-bottom-color: #e2e8f0;
}
html[data-theme="light"] .sidebar-bottom {
  border-top-color: #e2e8f0;
}
html[data-theme="light"] .ac7-group-header {
  color: #64748b;
}
html[data-theme="light"] .ac7-group-header:hover {
  background: #f1f5f9;
  color: #0f172a;
}
html[data-theme="light"] .ac7-nav-group.is-active .ac7-group-header {
  color: #0284c7;
}
html[data-theme="light"] .ac7-group-items {
  border-right-color: #e2e8f0;
}
html[data-theme="light"] .ac7-nav-item,
html[data-theme="light"] .ac7-single-item {
  color: #64748b;
}
html[data-theme="light"] .ac7-nav-item:hover,
html[data-theme="light"] .ac7-single-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}
html[data-theme="light"] .ac7-sidebar-scroll {
  scrollbar-color: rgba(100, 116, 139, 0.25) transparent;
}
html[data-theme="light"] .ac7-sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.25);
}

/* 16. Vector Lucide Icon Component */
.ac7-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
  transition: color 0.15s ease;
}

/* 17. Footer (Compact) */
.sidebar-bottom {
  flex: 0 0 auto;
  margin-top: 0 !important;
  padding: 10px 14px !important;
  border-top: 1px solid var(--outline);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  background: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-bottom .dot {
  flex-shrink: 0;
}

/* 18. Horizontal Subnav Tabs Bar */
.ac7-subnav-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--outline);
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  max-width: 100%;
}
.ac7-subnav-bar .btn.primary {
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}

/* Desktop Topbar Structure: Compact 64px, Sticky Top */
.topbar {
  height: 64px;
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  border-bottom: 1px solid var(--outline);
  background: var(--surface);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 90;
  box-sizing: border-box;
}
.topbar-nav-area {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-title-wrap {
  min-width: 0;
}
.topbar-title-wrap h1 {
  font-size: 19px;
  font-weight: 800;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}
.topbar-title-wrap .crumb {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 3px;
  line-height: 1.2;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Typography & Section Header on Laptops & Desktops */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}
.section-header p, .subtitle {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 4px 0 0;
}

/* Fluid Responsive Content Area: 100% width on laptops, scales gracefully up to 1320px-1440px */
.content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1320px;
  padding: 20px 24px;
  margin: 0 auto;
  box-sizing: border-box;
}
@media (min-width: 1600px) {
  .content {
    max-width: 1440px;
    padding: 24px 32px;
  }
}

/* Auto-flowing KPI Grid: 4 cols on desktop/laptop, 2 cols on medium/tablet, 1 on mobile */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 1100px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}
.kpi {
  border: 1px solid var(--outline);
  background: linear-gradient(145deg, #16223a, #111b2d);
  border-radius: 12px;
  padding: 16px 18px;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}
html[data-theme="dark"] .kpi {
  background: linear-gradient(145deg, #1e1e1e, #141414);
}
html[data-theme="light"] .kpi {
  background: #ffffff;
  border-color: #e2e8f0;
}
.kpi strong {
  font-size: 28px;
  letter-spacing: -0.5px;
  font-weight: 800;
  line-height: 1.2;
}

/* Responsive Panel Grid & Containers */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }
}
.panel {
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-sizing: border-box;
  margin-bottom: 18px;
  width: 100%;
  max-width: 100%;
}
.panel h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  padding: 13px 18px;
  border-bottom: 1px solid var(--outline);
}
.panel-pad {
  padding: 16px 18px;
}

/* Tables: Full Width inside responsive scrollable containers */
.table-wrap, .data-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}
table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
}

/* 19. RESPONSIVE / OFF-CANVAS MOBILE SYSTEM (<= 768px) */
@media (max-width: 768px) {
  /* Lock page width and prevent root horizontal blowout */
  html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
  }

  /* Full screen main content in normal flow */
  .app-shell {
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-x: hidden !important;
    position: relative !important;
  }

  .main {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: visible !important;
    overflow-x: hidden !important;
    display: block !important;
  }

  /* Off-canvas Sidebar Drawer */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: 280px !important;
    min-width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    z-index: 1000 !important;
    transform: translateX(100%) !important; /* Slide out to the right in RTL */
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5) !important;
    border-left: 1px solid var(--outline) !important;
    border-bottom: none !important;
    border-top: none !important;
    border-right: none !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--surface) !important;
    visibility: visible !important;
  }

  /* When body has ac7-sidebar-open class: Drawer slides in */
  body.ac7-sidebar-open .sidebar {
    transform: translateX(0) !important;
  }

  /* Lock body scroll when drawer is open */
  body.ac7-sidebar-open {
    overflow: hidden !important;
  }

  /* Backdrop Overlay (Modern smooth opacity fade with pointer-events lock) */
  .sidebar-backdrop {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.65) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 998 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.22s ease !important;
    cursor: pointer !important;
  }

  body.ac7-sidebar-open .sidebar-backdrop {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  /* Mobile Hamburger Menu Button */
  .mobile-menu-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    background: var(--surface2) !important;
    border: 1px solid var(--outline) !important;
    color: var(--text) !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    transition: background 0.15s ease, border-color 0.15s ease !important;
  }
  .mobile-menu-btn:hover {
    background: var(--surface3) !important;
  }
  .mobile-menu-btn:active {
    transform: scale(0.96);
  }

  /* Mobile Close Button in Drawer Brand */
  .sidebar-close-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    border-radius: 6px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    border: 1px solid var(--outline) !important;
    color: var(--muted) !important;
    cursor: pointer !important;
    margin-right: auto !important; /* In RTL, pushes button to the far left of the brand header */
    transition: all 0.15s ease !important;
    flex-shrink: 0 !important;
  }
  .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    color: var(--text) !important;
  }
  html[data-theme="light"] .sidebar-close-btn {
    background: #e2e8f0 !important;
    color: #475569 !important;
  }
  html[data-theme="light"] .sidebar-close-btn:hover {
    background: #cbd5e1 !important;
    color: #0f172a !important;
  }

  /* Responsive Topbar */
  .topbar {
    height: auto !important;
    min-height: 60px !important;
    padding: 10px 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .topbar-nav-area {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }
  .topbar-title-wrap {
    min-width: 0 !important;
    overflow: hidden !important;
  }
  .topbar-title-wrap h1 {
    font-size: 16.5px !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .topbar-title-wrap .crumb {
    font-size: 11px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-bottom: 2px !important;
  }
  .topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
  }
  .topbar-right .pill.dim,
  .topbar-right a.pill,
  .topbar-right button[data-logout] {
    display: none !important; /* Compact mobile topbar: hide bulky text pills to prevent overflow */
  }

  /* Responsive Content */
  .content {
    padding: 14px !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* Responsive KPI Grid: 2 columns on tablet/large mobile, 1 on small */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* Responsive Panel & Tables: Horizontal scroll contained inside panel */
  .panel {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-bottom: 14px !important;
  }
  .table-wrap, .data-table-wrap {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Subnav Bar on mobile: Horizontal touch scroll, no wrap */
  .ac7-subnav-bar {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
    padding-bottom: 8px !important;
    margin-bottom: 14px !important;
  }
}

/* Extra small screens (<= 480px): KPI grid 1 column */
@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
  .topbar-right .btn:not([data-theme-toggle]) {
    display: none !important;
  }
}

/* =========================================================
   AC7 CRM — ENHANCED MODAL & OVERLAY SYSTEM
   Guarantees full screen coverage, high z-index (10050+),
   no header/sidebar overlap, background scroll locking,
   fixed pinned header & footer, smooth internal scrolling,
   balanced 2-col fields, and 100% RTL & Dark/Light mode.
   ========================================================= */
#modal-host {
  position: relative !important;
  z-index: 10050 !important;
}

body.ac7-modal-open {
  overflow: hidden !important;
  touch-action: none !important;
}

.overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(3, 8, 16, 0.8) !important;
  backdrop-filter: blur(4px) !important;
  -webkit-backdrop-filter: blur(4px) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
  box-sizing: border-box !important;
  z-index: 10050 !important;
}

.modal {
  width: min(860px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
  min-width: 0 !important;
  max-height: calc(100vh - 40px) !important;
  height: auto !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--ac7-panel, var(--surface, #101b2d)) !important;
  color: var(--ac7-ink, var(--text, #eef4ff)) !important;
  border: 1px solid var(--ac7-border, var(--outline, #364864)) !important;
  border-radius: 16px !important;
  box-shadow: 0 25px 75px rgba(0, 0, 0, 0.75) !important;
  overflow: hidden !important;
  position: relative !important;
  z-index: 10051 !important;
  box-sizing: border-box !important;
}

.modal-header {
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 16px 24px !important;
  border-bottom: 1px solid var(--ac7-border, var(--outline, #27364c)) !important;
  background: var(--ac7-panel, var(--surface, #101b2d)) !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 2 !important;
}

.modal-header h2 {
  font-size: 18px !important;
  font-weight: 800 !important;
  margin: 0 !important;
  color: var(--ac7-ink, var(--text, #eef4ff)) !important;
  line-height: 1.3 !important;
}

.modal-header .close {
  background: transparent !important;
  color: var(--ac7-muted, var(--muted, #93a5bf)) !important;
  border: 0 !important;
  font-size: 28px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  padding: 2px 8px !important;
  border-radius: 8px !important;
  transition: all 0.15s ease !important;
}

.modal-header .close:hover,
.modal-header .close:focus-visible {
  color: #ffffff !important;
  background: var(--ac7-primary-soft, rgba(78, 132, 255, 0.18)) !important;
}

.modal-content {
  flex: 1 1 auto !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 20px 24px !important;
  min-height: 0 !important;
  -webkit-overflow-scrolling: touch !important;
  box-sizing: border-box !important;
}

.modal-footer {
  flex-shrink: 0 !important;
  margin-top: auto !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  border-top: 1px solid var(--ac7-border, var(--outline, #27364c)) !important;
  padding: 14px 24px !important;
  background: var(--ac7-panel, var(--surface, #111d30)) !important;
  gap: 12px !important;
  box-sizing: border-box !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 2 !important;
}

.modal-footer .footer-actions {
  display: flex !important;
  gap: 10px !important;
  align-items: center !important;
}

/* Light mode overrides for modal and overlay */
html[data-theme="light"] .overlay {
  background: rgba(15, 23, 42, 0.6) !important;
}
html[data-theme="light"] #modal-host .modal,
html[data-theme="light"] .modal {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 25px 75px rgba(0, 0, 0, 0.2) !important;
}
html[data-theme="light"] #modal-host .modal-header,
html[data-theme="light"] #modal-host .modal-footer,
html[data-theme="light"] .modal-header,
html[data-theme="light"] .modal-footer {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}
html[data-theme="light"] .modal-header h2 {
  color: #0f172a !important;
}
html[data-theme="light"] .modal-header .close {
  color: #64748b !important;
}
html[data-theme="light"] .modal-header .close:hover {
  color: #0f172a !important;
  background: #e2e8f0 !important;
}

/* Responsive Modal Styling for Mobile / Tablets */
@media (max-width: 650px) {
  .overlay {
    padding: 8px !important;
  }
  .modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    min-width: 0 !important;
    max-height: calc(100vh - 16px) !important;
    border-radius: 12px !important;
  }
  .modal .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .modal .form-grid > * {
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
  }
  .modal-header {
    padding: 12px 14px !important;
  }
  .modal-content {
    padding: 14px 12px !important;
    min-width: 0 !important;
  }
  .modal-footer {
    padding: 12px 14px !important;
    flex-wrap: wrap !important;
  }
  .modal-footer .footer-actions {
    width: 100% !important;
    justify-content: flex-end !important;
  }
}

/* ==========================================================================
   AC7 CRM — Searchable Governorate Combobox & Enhanced Modal Styles
   ========================================================================== */
.ac7-gov-combobox-wrap {
  position: relative;
  width: 100%;
}
.ac7-gov-input {
  width: 100%;
  box-sizing: border-box;
  padding-left: 32px !important;
}
.ac7-gov-arrow {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted, #8ba1be);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  line-height: 1;
}
.ac7-gov-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  z-index: 1050;
  max-height: 200px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface, #121f32);
  border: 1px solid var(--outline, #29415e);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}
.ac7-gov-item {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text, #ecf4ff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.12s;
}
.ac7-gov-item:hover,
.ac7-gov-item.ac7-gov-highlight {
  background: var(--surface2, #182a40);
  color: var(--blue, #4a91ff);
}
.ac7-gov-item.selected {
  font-weight: 700;
  background: var(--surface3, #22375b);
}
html[data-theme="light"] .ac7-gov-list {
  background: #ffffff;
  border: 1px solid #d4e2f2;
  box-shadow: 0 8px 24px rgba(20, 45, 80, 0.12);
}
html[data-theme="light"] .ac7-gov-item {
  color: #10243e;
}
html[data-theme="light"] .ac7-gov-item:hover,
html[data-theme="light"] .ac7-gov-item.ac7-gov-highlight {
  background: #eef4fc;
  color: #1766c7;
}
html[data-theme="light"] .ac7-gov-item.selected {
  background: #e1edfc;
  color: #1766c7;
}

/* Theme-Aware Proposal Modal Classes */
.ac7-prop-card {
  background: var(--surface2, #182c47);
  border: 1px solid var(--outline, #344e6e);
  border-radius: 12px;
  padding: 14px;
  color: var(--text, inherit);
}
.ac7-prop-box-gray {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--outline, #344e6e);
  border-radius: 8px;
  padding: 8px 12px;
}
html[data-theme="light"] .ac7-prop-box-gray {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
}
.ac7-prop-alert-amber {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 12px;
  padding: 12px;
  color: #fde047;
}
html[data-theme="light"] .ac7-prop-alert-amber {
  background: #fef9c3;
  border: 1px solid #facc15;
  color: #854d0e;
}
.ac7-prop-alert-amber .ac7-prop-alert-title {
  color: #fbbf24;
  font-weight: 700;
}
html[data-theme="light"] .ac7-prop-alert-amber .ac7-prop-alert-title {
  color: #854d0e;
}


