/* ==========================================================================
   Module framework: switcher, Modules page, generic list / form, report page
   and the on-screen A4 print format.
   ========================================================================== */

/* ---------- Module switcher (top bar) ---------- */
.mod-switch {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 32px; padding-inline: 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.1); color: #fff; font-weight: 600; white-space: nowrap;
}
.mod-switch:hover { background: rgba(255,255,255,.16); }
.mod-switch svg { width: 15px; height: 15px; }
.mod-pop {
  position: fixed; z-index: 95; width: 320px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-3); padding: 6px;
  animation: pop .16s var(--ease);
}
.mod-pop a { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; color: var(--ink); text-decoration: none !important; }
.mod-pop a:hover, .mod-pop a.on { background: var(--surface-3); }
.mod-pop a small { display: block; color: var(--ink-3); font-size: 11px; line-height: 1.3; }
.mod-pop a b { font-size: 13px; }
.mod-pop .mod-all { justify-content: center; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; font-weight: 600; color: var(--primary-strong); font-size: 12.5px; }
.mod-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.mod-ico svg { width: 16px; height: 16px; }
.tone-teal .mod-ico, .rail-mod.tone-teal .ico { background: var(--primary-soft); color: var(--primary-strong); }
.tone-navy .mod-ico, .rail-mod.tone-navy .ico { background: var(--navy-50); color: var(--navy-700); }
.tone-blue .mod-ico, .rail-mod.tone-blue .ico { background: var(--info-soft); color: var(--info); }
.tone-amber .mod-ico, .rail-mod.tone-amber .ico { background: var(--warning-soft); color: var(--warning); }
.tone-red .mod-ico, .rail-mod.tone-red .ico { background: var(--accent-soft); color: var(--critical); }
.tone-green .mod-ico, .rail-mod.tone-green .ico { background: var(--good-soft); color: var(--good); }
.tone-violet .mod-ico, .rail-mod.tone-violet .ico { background: #efedfb; color: #4a3aa7; }
:root[data-theme="dark"] .tone-navy .mod-ico, :root[data-theme="dark"] .rail-mod.tone-navy .ico { background: #1f3a46; color: #cfe0e6; }
:root[data-theme="dark"] .tone-violet .mod-ico, :root[data-theme="dark"] .rail-mod.tone-violet .ico { background: #2a2552; color: #b9b1f5; }

/* Rail header: the active module */
.rail-mod {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 2px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); text-decoration: none !important;
}
.rail-mod:hover { border-color: var(--line-strong); }
.rail-mod .ico { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.rail-mod .ico svg { width: 15px; height: 15px; }
.rail-mod .label { flex: 1; min-width: 0; line-height: 1.2; }
.rail-mod .label b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-mod .label small { color: var(--ink-3); font-size: 10.5px; }
.rail-mod > svg { width: 14px; height: 14px; color: var(--ink-3); }
.app.rail-collapsed .rail-mod .label, .app.rail-collapsed .rail-mod > svg { display: none; }
.app.rail-collapsed .rail-mod { justify-content: center; }
@media (max-width: 1180px) { .rail-mod .label, .rail-mod > svg { display: none; } .rail-mod { justify-content: center; } }
@media (max-width: 760px) { .mod-switch span { display: none; } }

/* ---------- Modules page ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; align-items: start; }
.mod-card { overflow: hidden; }
.mod-card.daily { grid-column: 1 / -1; border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }
.mod-card.current { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.mod-top { display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: var(--ink); text-decoration: none !important; border-bottom: 1px solid var(--line); }
.mod-top:hover { background: var(--surface-2); }
.mod-top .mod-ico { width: 36px; height: 36px; }
.mod-top b { display: block; font-size: 14.5px; }
.mod-top small { display: block; color: var(--ink-3); font-size: 11.5px; line-height: 1.35; }
.mod-links { padding: 6px 8px 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 6px; }
.mod-card.daily .mod-links { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.mod-h { grid-column: 1 / -1; font-size: 10.5px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; padding: 8px 6px 2px; }
html[lang="ar"] .mod-h { text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.mod-links a { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; color: var(--ink-2); font-size: 12.5px; text-decoration: none !important; min-width: 0; }
.mod-links a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-links a:hover { background: var(--surface-3); color: var(--ink); }
.mod-links a svg { width: 14px; height: 14px; color: var(--ink-3); }

/* ---------- Generic list ---------- */
.xw-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.xw-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.xw-foot { font-size: 11.5px; margin-top: 8px; }
.xw-link { font-weight: 600; }
.tbl .code a, .tbl td a.xw-link { text-decoration: none; }
.tbl td.code { white-space: nowrap; }

/* ---------- Generic form ---------- */
.xw-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 12px; align-items: start; }
.xw-main, .xw-side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.xw-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
.xw-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; }
.xw-f { min-width: 0; }
.xw-f.wide { grid-column: 1 / -1; }
.xw-f small { display: block; color: var(--ink-3); font-size: 11px; font-weight: 600; margin-bottom: 1px; }
.xw-f > div { font-size: 13px; overflow-wrap: anywhere; }
.page-head h1 .badge { vertical-align: middle; font-size: 11px; }
.page-head .eyebrow a { color: inherit; display: inline-flex; gap: 5px; align-items: center; }
@media (max-width: 1000px) { .xw-form { grid-template-columns: minmax(0, 1fr); } .xw-side { position: static; } }

/* ---------- Report page ---------- */
.rp-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 10px; }
.rp-sib { width: auto; max-width: 280px; height: 32px; font-size: 12.5px; }

/* ---------- On-screen A4 print format ---------- */
.a4-wrap { background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; overflow-x: auto; margin-top: 10px; }
.a4 {
  width: 210mm; min-height: 297mm; margin-inline: auto; padding: 14mm 14mm 12mm;
  background: #fff; color: #13232b; box-shadow: 0 6px 28px rgba(16,34,42,.18); border-radius: 2px;
  display: flex; flex-direction: column; gap: 10px; font-size: 11.5px;
}
.a4.landscape { width: 297mm; min-height: 210mm; }
.a4 .tbl { font-size: 11px; }
.a4 .tbl th { background: #172e38; color: #fff; position: static; }
.a4 .tbl td, .a4 .tbl th { padding: 5px 8px; }
.a4 .table-wrap { border: 0; overflow: visible; background: transparent; }
.a4 .print-doc { display: flex; flex-direction: column; gap: 8px; min-height: 100%; }
.a4 .p-foot, .a4 .pf-foot { margin-top: auto; }
.pf-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; border-bottom: 3px solid #19868b; padding-bottom: 10px; }
.pf-head img { height: 40px; width: auto; }
.pf-head img:last-child { justify-self: end; }
.pf-title { text-align: center; display: grid; }
.pf-title b { font-size: 18px; color: #172e38; }
.pf-title span { font-size: 11px; color: #19868b; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.pf-idrow, .pf-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pf-meta { grid-template-columns: repeat(3, 1fr); }
.pf-idrow > div, .pf-meta > div { background: #f4f8f9; border-radius: 6px; padding: 5px 8px; min-width: 0; }
.pf-idrow small, .pf-meta small { display: block; color: #6f818a; font-size: 9.5px; }
.pf-idrow b, .pf-meta b { font-size: 11.5px; overflow-wrap: anywhere; }
.pf-h { font-size: 12px; color: #172e38; margin-top: 4px; border-bottom: 1px solid #dfe7ea; padding-bottom: 3px; }
.pf-foot { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid #c9d5da; padding-top: 6px; font-size: 9.5px; color: #6f818a; }
.a4 .v-sign { margin-top: 18px; }
.a4 .badge { background: none; padding: 0; height: auto; color: inherit; }
.a4 .badge svg { display: none; }
@media print {
  .a4-wrap { background: none; border: 0; padding: 0; }
  .a4 { box-shadow: none; width: auto; min-height: 0; padding: 0; }
}

/* ---------- Shared bits for module pages ---------- */
.xw-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.xw-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.xw-stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (max-width: 1000px) { .xw-grid-2, .xw-grid-3 { grid-template-columns: minmax(0, 1fr); } }
.steps { display: flex; gap: 0; align-items: center; flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.steps .step i { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 10.5px; background: var(--surface-3); color: var(--ink-2); }
.steps .step.done i { background: var(--primary); color: #fff; }
.steps .step.on { color: var(--ink); }
.steps .step.on i { background: var(--navy-700); color: #fff; }
.steps .sep { width: 22px; height: 2px; background: var(--line-strong); margin: 0 6px; border-radius: 2px; }

/* Top bar: keep buttons from being squeezed; drop low-value chips on narrower screens */
.topbar > .icon-btn, .topbar > .top-chip, .topbar > .mod-switch, .topbar > .brand, .topbar > .demo-ribbon { flex-shrink: 0; }
.topbar .search-trigger { min-width: 38px; }
@media (max-width: 1500px) { .topbar .date-chip { display: none; } }
@media (max-width: 1320px) { .topbar .demo-ribbon .txt, .topbar .brand .product { display: none; } }
@media (max-width: 760px) {
  .topbar { gap: 6px; padding-inline: 8px; }
  .topbar .theme-btn, .topbar .role-chip > svg:last-child { display: none !important; }
  .topbar .brand img { height: 24px; }
  .topbar .brand.plate img { height: 26px; padding: 2px 5px; }
  .mod-switch { padding-inline: 7px; }
  .mod-switch > svg:last-child { display: none; }
  .role-chip { padding-inline: 3px; }
  .lang-toggle { min-width: 34px; padding-inline: 6px; }
}
.scen-banner { margin-bottom: 4px; align-items: center; }
.scen-card.current { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent); }
.scen-card svg { color: var(--primary); }
.crm-board { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
.pm-board { grid-template-columns: repeat(5, minmax(220px, 1fr)); }

/* Report page at 390 px: locked filter chips wrap instead of overflowing */
.rp-bar .qv-filters .chip.locked { max-width: 100%; height: auto; min-height: 28px; white-space: normal; }

/* System scenario switch (top bar) */
.scen-switch { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 32px; padding-inline: 8px 10px; border-radius: 8px; border: 1px dashed rgba(255,255,255,.35); background: transparent; color: #fff; font-size: 12.5px; cursor: pointer; }
.scen-switch:hover { background: rgba(255,255,255,.1); }
.scen-switch svg { width: 14px; height: 14px; }
.scen-switch .sc-k { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; }
.scen-switch .sc-l { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scen-pop { width: 340px; }
.scen-pop-h { padding: 4px 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.scen-pop .sc-k { font-weight: 700; font-size: 14px; background: var(--primary-soft); color: var(--primary-strong); }
.scen-pop a.on .sc-k { background: var(--primary); color: #fff; }
.scen-pop a > svg { width: 16px; height: 16px; color: var(--primary); flex: none; }
@media (max-width: 1500px) { .scen-switch .sc-l { display: none; } }
@media (max-width: 760px) { .scen-switch { padding-inline: 5px; gap: 0; border-style: solid; } .scen-switch > svg { display: none; } }
