/* =========================================================
   Bayanak prototype — app.css
   App shell shared by client / broker / admin (§5.2–5.4)

   MASTER COPIES (paste into each page; no includes):

   <body class="app app-client">
     <input type="checkbox" id="nav-toggle" class="nav-toggle" hidden>
     <aside class="sidebar">
       <a class="brand" href="../index.html">[logo] Bayanak</a>
       <!-- broker only: <div class="verif-chip is-verified">Verified</div> -->
       <nav class="nav">
         <a href="dashboard.html" class="is-on">[icon] Dashboard</a>
         ... (one <a> per sidebar item, badge as <span class="count">3</span>)
       </nav>
       <div class="side-foot">...</div>
     </aside>
     <label for="nav-toggle" class="nav-scrim"></label>
     <div class="main">
       <header class="topbar">
         <label for="nav-toggle" class="nav-btn">[menu icon]</label>
         <div class="search">[search icon]<span>Search requests, brokers, declarations</span></div>
         <a class="lang">EN / ع</a>
         <a class="bell" href="notifications.html">[bell]<span class="dot"></span></a>
         <details class="menu">
           <summary>[avatar] Khalid A.</summary>
           <div class="menu-pop"> Profile · Switch to company/individual · Sign out </div>
         </details>
       </header>
       <main class="content"> ...page... </main>
     </div>
     <nav class="proto-pill">Prototype · Client · Broker · Admin · Screen index</nav>
   </body>
   ========================================================= */

.app { background: var(--paper); min-height: 100vh; }
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.nav-scrim { display: none; }
.app > .main { grid-column: 2; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; background: var(--ink); color: #C9D6E0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.brand small { display: block; font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #8FB7AC; }
.side-role { margin: 0 8px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #8BA0B2; }
.verif-chip { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 10px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; width: max-content; }
.verif-chip.is-verified { background: rgba(110, 231, 183, .14); color: #6EE7B7; }
.verif-chip.is-pending { background: rgba(251, 191, 36, .15); color: #FBBF24; }
.verif-chip.is-suspended { background: rgba(248, 113, 113, .16); color: #FCA5A5; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: #C9D6E0; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.is-on { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #34D399; }
[dir="rtl"] .nav a.is-on { box-shadow: inset -3px 0 0 #34D399; }
.nav a .count { margin-inline-start: auto; }
.nav a.is-locked { opacity: .45; }
.nav-sep { margin: 12px 10px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #6F879A; }
.side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #8BA0B2; }

/* ---------- Main / topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  height: 62px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 14px; background: var(--paper); }
.search span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.lang { font-size: 13px; font-weight: 600; color: var(--ink-2); padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; }
.lang:hover { text-decoration: none; border-color: var(--ink-2); }
.bell { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); }
.bell:hover { background: var(--surface-2); }
.bell .dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }
.menu { position: relative; }
.menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: 8px; font-size: 14px; font-weight: 500; white-space: nowrap; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary:hover { background: var(--surface-2); }
.menu-pop { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 230px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 30; }
.menu-pop a, .menu-pop .mi { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 6px; color: var(--ink); font-size: 14px; }
.menu-pop a:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .mh { padding: 8px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.nav-btn { display: none; width: 38px; height: 38px; place-items: center; border-radius: 8px; color: var(--ink); cursor: pointer; }

.content { padding: 28px 32px 96px; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

/* Two-column page: content + right rail */
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.with-rail > *, .with-filters > *, .main > * { min-width: 0; }
.rail { position: sticky; top: 86px; display: flex; flex-direction: column; gap: 16px; }
.next-action { border: 1px solid var(--brand); background: linear-gradient(180deg, var(--brand-lt), var(--surface) 70%); }
.next-action h4 { color: var(--brand-dp); margin-bottom: 6px; }
.next-action h3 { margin-bottom: 6px; }
.next-action .btn { width: 100%; margin-top: 8px; }
.next-action.is-warn { border-color: #F1CFA4; background: linear-gradient(180deg, var(--warn-lt), var(--surface) 70%); }
.next-action.is-warn h4 { color: var(--warn); }
.next-action.is-danger { border-color: #F0B9B9; background: linear-gradient(180deg, var(--danger-lt), var(--surface) 70%); }
.next-action.is-danger h4 { color: var(--danger); }
.next-action.is-idle { border-color: var(--line); background: var(--surface); }
.next-action.is-idle h4 { color: var(--muted); }

/* Request header */
.req-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.req-id { font: 600 13px var(--mono); color: var(--muted); display: flex; gap: 8px; align-items: center; }
.req-title { font-size: 24px; margin: 4px 0 8px; }
.req-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); }
.req-meta span { display: inline-flex; gap: 6px; align-items: center; }
.broker-chip { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.broker-chip:hover { text-decoration: none; border-color: var(--ink-2); }
.broker-chip .t { font-size: 13px; font-weight: 600; line-height: 1.3; }
.broker-chip .s { font-size: 12px; color: var(--muted); }
.stepper-card { padding: 18px 20px 12px; margin-bottom: 20px; }

/* Wizard / form page */
.form-page { max-width: 860px; }
.form-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; padding-top: 20px; margin-top: 8px; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }

/* Assistant (HS) */
.q-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.q-card .q { font-weight: 600; margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.q-card .q .n { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 12px; flex: none; }
.q-card.is-done .q .n { background: var(--brand); }
.q-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.hs-cand { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.hs-cand.is-on { border-color: var(--brand); background: var(--brand-lt); }
.hs-cand .code { font: 600 15px var(--mono); }
.hs-cand .bar { grid-column: 1 / -1; }

/* RFQ tray */
.tray { position: sticky; bottom: 0; z-index: 15; margin: 24px -32px -96px; padding: 14px 32px 80px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(15, 42, 61, .08); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.tray .slots { display: flex; gap: 6px; }
.tray .slot { width: 34px; height: 34px; border-radius: 8px; border: 1.5px dashed var(--line); display: grid; place-items: center; font-size: 11px; color: var(--muted); }
.tray .slot.on { border: 0; }
.tray .slot.on .avatar { width: 34px; height: 34px; font-size: 11px; border-radius: 8px; }
.tray.is-full { background: var(--brand-lt); }

/* Filter sidebar layout */
.with-filters { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.filter-panel { position: sticky; top: 86px; }
.filter-panel .fgroup { padding: 14px 0; border-bottom: 1px solid var(--line); }
.filter-panel .fgroup:first-of-type { padding-top: 0; }
.filter-panel .fgroup h4 { margin-bottom: 8px; }
.filter-panel .check { font-size: 13.5px; margin: 6px 0; }

/* Auth-ish centered panel inside the app (gate pages etc) */
.narrow { max-width: 680px; }
.narrow-md { max-width: 900px; }

/* Charts (static SVG) */
.chart-card svg text { font-family: var(--font); fill: var(--muted); font-size: 11px; }

/* ---------- Responsive shell ---------- */
@media (max-width: 1100px) {
  .with-rail { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app > .main { grid-column: 1; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 264px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-scrim { display: none; position: fixed; inset: 0; z-index: 55; background: rgba(15, 42, 61, .45); }
  .nav-toggle:checked ~ .nav-scrim { display: block; }
  .nav-btn { display: grid; }
  .content { padding: 20px 16px 96px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search span { display: none; }
  .search { flex: 0 0 38px; padding: 0; justify-content: center; }
  .topbar .spacer { display: block; }
  .menu summary .who { display: none; }
  .lang { padding: 5px 7px; }
  .req-head > .broker-chip { max-width: 100%; }
  .with-filters { grid-template-columns: minmax(0, 1fr); }
  .filter-panel { position: static; }
  .tray { margin: 24px -16px -96px; padding: 12px 16px 76px; }
}

/* ---------- Dark mode (app shell only) ---------- */
@media (prefers-color-scheme: dark) {
  body.app {
    --ink: #E6EDF3;
    --ink-2: #B5C3CF;
    --muted: #8A9BAA;
    --paper: #0B1620;
    --surface: #12212D;
    --surface-2: #182B39;
    --line: #26394A;
    --brand: #2BB394;
    --brand-dp: #5FD0B5;
    --brand-lt: #123A33;
    --gold-lt: #3A2E14;
    --info-lt: #15284A;
    --indigo-lt: #23224A;
    --warn-lt: #3A2512;
    --danger-lt: #3E1818;
    --ok-lt: #12321F;
    color-scheme: dark;
  }
  body.app .sidebar { background: #071019; border-inline-end: 1px solid var(--line); }
  body.app .btn-primary { color: #04130F; }
  body.app .pill-new, body.app .pill-cancelled { background: #1D2F3C; color: #A9BACA; }
  body.app .pill-paid { background: #0F3532; color: #5EEAD4; }
  body.app .pill-completed { background: #15803D; }
  body.app .avatar { color: #fff; }
  body.app .alert-info { color: #BFD3FA; border-color: #2A4A80; }
  body.app .alert-warning { color: #F6D2A8; border-color: #6B4316; }
  body.app .alert-danger { color: #F5B5B5; border-color: #6E2020; }
  body.app .alert-success { color: #B5DEC2; border-color: #1F5A33; }
  body.app .table tbody tr:hover, body.app a.notif:hover, body.app .notif.is-unread { background: #152837; }
  body.app .table tr.is-warn td, body.app .doc-row.is-alert { background: #2A1F12; }
  body.app .compare td.best { background: #10302A; }
  body.app .compare td.awaiting, body.app .compare th.awaiting { background: repeating-linear-gradient(135deg, #12212D 0 8px, #162736 8px 16px); }
  body.app .compare td.expired, body.app .compare th.expired { background: #141E26; }
  body.app .gate { background: #050C12; border: 1px solid var(--line); }
  body.app .input.is-error, body.app .otp.is-error span { background: #2A1414; }
  body.app .skeleton { background: linear-gradient(90deg, #1A2D3B, #22384A, #1A2D3B); }
  body.app .doc-viewer { background: #0E1A24; }
  body.app .chip.is-on, body.app .seg .is-on, body.app .pager .pages .is-on { background: var(--brand); color: #04130F; border-color: var(--brand); }
  body.app .q-card .q .n { background: #2F4659; }
  body.app .check.is-on .box { color: #04130F; }
  body.app .toast { background: #E6EDF3; color: #0F2A3D; }
}
.hs-cand .badge { align-self: start; }
