/* App frame + home cards, following the Figma «Dashboard» frame.
   White side menu and top bar separated by thin lines, light content area, white cards.
   Loaded last so it wins over the older shell rules. */
:root { --rail-w: 256px; --shell: #ffffff; --shell-bg: #f5f8fa; --shell-line: #e6e9eb; --shell-chip: #f3f4f5; --shell-on: #1a3640; --shell-on-ink: #fff; --shell-card-line: #e8ebed; }
:root[data-theme="dark"] { --shell: #1a3640; --shell-bg: #13282f; --shell-line: rgba(255,255,255,.08); --shell-chip: rgba(255,255,255,.07); --shell-on: #2e7a93; --shell-card-line: rgba(255,255,255,.08); }

body, #app { background: var(--shell-bg); }

/* ---------- Side menu ---------- */
#app .rail { background: var(--shell); border: 0; border-inline-end: 1px solid var(--shell-line); box-shadow: none; padding: 0 14px 18px; }
#app .rail-top { height: 76px; padding: 0 6px; margin: 0; border: 0; align-items: center; justify-content: space-between; }
#app .rail-top .brand { height: 56px; display: flex; align-items: center; }
#app .brand-logo .bl-full, #app .brand-logo .bl-img { display: none !important; }
#app .brand-logo .bl-word { display: none; width: 104px; height: auto; }
#app:not(.rail-min) .brand-logo .bl-word.bl-teal { display: block; }
:root[data-theme="dark"] #app:not(.rail-min) .brand-logo .bl-word.bl-teal { display: none; }
:root[data-theme="dark"] #app:not(.rail-min) .brand-logo .bl-word.bl-white { display: block; }
/* Collapsed menu: the wordmark alone, smaller */
#app.rail-min .brand-logo .bl-word.bl-teal { display: block; width: 46px; }
:root[data-theme="dark"] #app.rail-min .brand-logo .bl-word.bl-teal { display: none; }
:root[data-theme="dark"] #app.rail-min .brand-logo .bl-word.bl-white { display: block; width: 46px; }
#app .rail-toggle { width: 34px; height: 34px; border-radius: 10px; background: var(--shell-chip); color: var(--ink-2); border: 0; box-shadow: none; }
#app .rail-toggle:hover { background: var(--surface-3); }

#app .rail-scroll { padding-top: 6px; }
#app .rail-group { height: auto; overflow: visible; margin: 0; padding: 18px 10px 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); text-align: start; opacity: 1; visibility: visible; border: 0; }
#app .rail-group:first-child { padding-top: 6px; }
#app .nav-item { width: 100%; height: 46px; padding: 0 14px; gap: 10px; border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 500; box-shadow: none; border: 0; margin: 2px 0; cursor: pointer; text-align: start; }
#app .nav-item .ico-wrap { background: transparent; color: inherit; width: 22px; height: 22px; box-shadow: none; flex: none; }
#app .nav-item .ico-wrap svg { width: 20px; height: 20px; }
#app .nav-item:hover:not([aria-current]) { background: var(--shell-chip); }
#app .nav-item[aria-current="page"] { background: var(--shell-on); color: var(--shell-on-ink); font-weight: 600; box-shadow: none; }
#app .nav-item[aria-current="page"] .ico-wrap { color: var(--shell-on-ink); background: transparent; }
#app .nav-item[aria-current="page"]::before, #app .nav-item[aria-current="page"]::after { display: none; }
#app .nav-count { background: #b1eb51; color: #1a3640; font-weight: 700; margin-inline-start: auto; }
#app .rail-foot { border-top: 1px solid var(--shell-line); padding-top: 12px; margin-top: 8px; background: transparent; display: flex; flex-direction: column; gap: 2px; }

/* ---------- Top bar ---------- */
#app .main { background: transparent; }
#app .topbar { height: 76px; margin: 0; padding: 0 24px; background: var(--shell); border: 0; border-bottom: 1px solid var(--shell-line); border-radius: 0; box-shadow: none; gap: 12px; position: static; -webkit-backdrop-filter: none; backdrop-filter: none; }
#app .topbar .topbar-spacer { display: block; flex: 1; }
#app .search-trigger { flex: 0 1 560px; width: auto; max-width: 560px; height: 50px; padding: 0 18px; border-radius: 999px; background: var(--shell-chip); border: 0; box-shadow: none; color: var(--muted); font-size: 15px; gap: 12px; }
#app .search-trigger svg { color: var(--ink-2); }
#app .search-trigger .kbd { margin-inline-start: auto; background: var(--shell); border: 1px solid var(--shell-line); }
#app .topbar .icon-btn { width: 50px; height: 50px; border-radius: 50%; background: var(--shell-chip); color: var(--ink); border: 0; box-shadow: none; flex: none; }
#app .topbar .icon-btn:hover, #app .topbar .icon-btn[aria-current] { background: var(--surface-3); }
#app .topbar .icon-btn .dot { background: #e5322d; color: #fff; }
/* «تخصيص الرئيسية»: same grey pill as the other top-bar buttons */
#app .topbar .home-cust-btn { display: inline-flex; align-items: center; gap: 8px; height: 50px; padding: 0 18px 0 8px; border-radius: 999px; background: var(--shell-chip); color: var(--ink); border: 0; box-shadow: none; font: inherit; font-size: 14.5px; font-weight: 500; flex: none; cursor: pointer; white-space: nowrap; }
#app .topbar .home-cust-btn:hover { background: var(--surface-3); }
#app .topbar .home-cust-btn svg { color: var(--ink-2); }
#app .topbar .home-cust-btn .hcb-n { order: -1; padding: 5px 10px; border-radius: 999px; background: #1a3640; color: #fff; font-size: 12px; font-weight: 600; }
:root[data-theme="dark"] #app .topbar .home-cust-btn .hcb-n { background: #2e7a93; }
#app .topbar .home-cust-btn:not(:has(.hcb-n)) { padding: 0 18px; }
@media (max-width: 1100px) { #app .topbar .home-cust-btn > span:not(.hcb-n) { display: none; } #app .topbar .home-cust-btn { padding: 0 14px; } }
#app .profile-chip { height: 54px; padding: 0 4px 0 12px; gap: 10px; border-radius: 999px; background: var(--shell-chip); border: 0; box-shadow: none; color: var(--ink); flex: none; }
#app .profile-chip .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; text-align: start; }
#app .profile-chip .who b { font-size: 15px; font-weight: 600; color: var(--ink); white-space: nowrap; }
#app .profile-chip .who span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
#app .profile-chip .avatar { width: 46px; height: 46px; font-size: 15px; font-weight: 700; color: #fff; background: #2e7a93; box-shadow: none; }
#app .profile-chip > svg { color: var(--muted); }

/* ---------- Content area ---------- */
#app .view { background: transparent; border-radius: 0; margin: 0; padding: 26px 24px 40px; }

/* ---------- Home: stat cards (Figma «Dashboard») ---------- */
.kpi4.kf { display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px; background: var(--shell); border: 1px solid var(--shell-card-line); border-radius: 22px; box-shadow: none; color: var(--ink); text-decoration: none; background-image: none; min-width: 0; }
.kpi4.kf::before, .kpi4.kf::after { display: none !important; }
.kpi4.kf:hover { border-color: #2e7a93; }
.kpi4.kf { padding: 16px 14px 14px; gap: 12px; }
.kf-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.kf-t { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--ink); min-width: 0; line-height: 1.25; }
.kf-t > span { min-width: 0; }
.kf-t svg { color: #2e7a93; flex: none; width: 18px; height: 18px; }
.kf-v { display: inline-flex; align-items: baseline; gap: 4px; flex: none; }
.kf-v b { font-size: 21px; font-weight: 700; color: var(--ink); line-height: 1; }
.kf-v b .k4-of { font-size: 13px; font-weight: 500; color: var(--muted); }
.kf-v small { font-size: 12px; color: var(--muted); }
.kf-cmp { display: flex; align-items: center; justify-content: center; height: 32px; padding: 0 10px; border-radius: 999px; background: var(--shell-chip); font-size: 12.5px; color: var(--ink-2); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kf-cmp.up { color: #1f7a4d; }
.kf-cmp.down { color: #c0392b; }
:root[data-theme="dark"] .kf-cmp.up { color: #b1eb51; }
:root[data-theme="dark"] .kf-cmp.down { color: #ff8a80; }
.kf-bar { height: 14px; gap: 6px; margin: 0; }
.kf-bar > span { border-radius: 999px; }
.kf-legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.kf-legend li { display: flex; flex-direction: column; gap: 6px; padding: 0 10px; min-width: 0; }
.kf-legend li + li { border-inline-start: 1px solid var(--shell-card-line); }
.kf-legend li:first-child { padding-inline-start: 0; }
.kf-legend li { padding: 0 7px; }
.kf-n { display: flex; align-items: center; justify-content: flex-start; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.kf-n span { white-space: nowrap; overflow: visible; max-width: none; }
.kf-n .k4-dot { flex: none; }
.kf-legend b { font-size: 15px; font-weight: 700; color: var(--ink); }
.kf-legend b .k4-of { font-size: 11.5px; color: var(--muted); font-weight: 500; }

/* Other home cards share the same white card + thin line */
#view .card, #view .ch-card, #view .dash-card { border-color: var(--shell-card-line); }

/* Collapsed menu keeps the same look, icons only */
#app.rail-min .rail-group { font-size: 0; padding: 10px 0 4px; }
#app.rail-min .nav-item { padding: 0; justify-content: center; }
#app.rail-min .rail-top { flex-direction: column; justify-content: center; gap: 6px; height: auto; padding: 14px 0; }

@media (max-width: 1100px) {
  #app .profile-chip .who { display: none; }
  #app .profile-chip { padding: 0 4px; }
  #app .search-trigger { height: 46px; }
  #app .topbar .icon-btn { width: 46px; height: 46px; }
  #app .topbar { height: 68px; padding: 0 16px; }
  #app .rail-top { height: 68px; }
}
@media (max-width: 760px) {
  #app .view { padding: 18px 14px 32px; }
  #app .topbar .topbar-spacer { display: none; }
  #app .search-trigger { flex: 1 1 auto; }
}
