/* Shell: sidebar, top bar, drawer, modal, toasts, page frame. */
.shell { min-height: 100dvh; display: block; }
.frame { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.main { flex: 1; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); width: 100%; max-width: 1360px; margin-inline: auto; min-width: 0; }
.main > * + * { margin-top: 16px; }
.sidebar { display: none; }

/* Logo (colours from tokens) */
.logo { display: inline-flex; align-items: center; min-height: 44px; color: var(--logo-ink); text-decoration: none; }
.logo-ink { fill: var(--logo-ink); }
.logo-dot, .kdot { fill: var(--gold); }
.kdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex: none; margin-inline-end: 6px; vertical-align: middle; }
.ag-bg { fill: var(--agency); }
.ag-fg { stroke: var(--agency-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Top bar */
.topbar { position: relative; z-index: 20; background: color-mix(in srgb, var(--bg) 94%, transparent); border-bottom: 1px solid var(--line); padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.tb-row { display: flex; align-items: center; gap: 4px; min-height: 52px; }
.menu-btn { margin-inline-start: -10px; }
.logo-sm { margin-inline-end: auto; }
.tb-agency, .tb-prefs { display: none; }
.tb-end { display: flex; align-items: center; gap: 8px; }
.chip-sample { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip-sample::after, .btn-pilot::after { content: ""; position: absolute; inset: -10px 0; }
.chip-sample .tip { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: 260px; padding: 10px 12px; border-radius: 8px; background: var(--ink); color: var(--on-ink); font-size: 12px; line-height: 1.5; white-space: normal; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: opacity 150ms ease; z-index: 30; }
.chip-sample:hover .tip, .chip-sample:focus .tip, .chip-sample:focus-visible .tip { opacity: 1; }
.btn-pilot { position: relative; min-height: 40px; padding: 0 12px; }
.filters { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.5fr) minmax(0, 0.7fr); gap: 8px; padding: 0 0 10px; }
.filters-cur { grid-template-columns: 1fr; justify-items: end; display: none; }
.ctl { position: relative; display: block; min-width: 0; }
.ctl-label { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 2px; }
.ctl select { appearance: none; -webkit-appearance: none; width: 100%; min-height: 44px; padding-block: 0; padding-inline: 8px 24px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-size: 16px; text-overflow: ellipsis; cursor: pointer; }
/* Arabic month names run longer than the marketplace label: give the period more room */
:lang(ar) .filters:not(.filters-cur) { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1.15fr) minmax(0, 0.7fr); }
.ctl-ic { position: absolute; inset-inline-end: 8px; bottom: 15px; pointer-events: none; color: var(--text-3); }

/* Agency switcher */
.agency { position: relative; }
.agency-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 4px 6px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: start; }
.agency-btn:hover { background: var(--surface-2); }
.ag-text { display: grid; line-height: 1.25; }
.ag-name { font-weight: 600; font-size: 14px; }
.ag-sub { font-size: 12px; color: var(--text-3); }
.ag-chev { color: var(--text-3); }
.agency-logo { border-radius: 8px; }
.menu { position: absolute; top: calc(100% + 6px); inset-inline-start: 0; min-width: 260px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); z-index: 40; }
.menu-cap { font-size: 12px; color: var(--text-3); padding: 6px 10px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: start; color: var(--text); }
.menu-item span { flex: 1; }
.menu-item:hover { background: var(--surface-2); }

/* Drawer + modal dialogs */
.drawer, .modal { border: 0; padding: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow-3); }
.drawer::backdrop, .modal::backdrop { background: var(--overlay); }
.drawer { margin: 0; inset-block: 0; inset-inline-start: 0; width: min(320px, 86vw); height: 100dvh; max-height: none; border-inline-end: 1px solid var(--line); }
.drawer:not([open]), .modal:not([open]) { display: none; }
.drawer-in { display: flex; flex-direction: column; gap: 12px; min-height: 100%; padding: calc(8px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding-inline-start: 8px; }
.drawer-agency { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.drawer-prefs { display: flex; gap: 4px; margin-top: auto; }
.drawer-note { padding: 0 8px; }
.modal { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); margin: auto; border-radius: 16px; overflow: auto; }
.modal-flow { width: min(560px, calc(100vw - 24px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 6px 20px; }
.modal-body { padding: 8px 20px 16px; display: grid; gap: 12px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-2); }
.mail-row { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 0; }
.mail-addr { flex: 1 1 auto; min-width: 0; min-height: 44px; display: flex; align-items: center; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; font-size: 16px; font-weight: 500; color: var(--text); }
.btn-copy { min-width: 44px; min-height: 44px; }
.ticks { display: grid; gap: 8px; }
.ticks li { display: flex; gap: 10px; align-items: flex-start; }
.ticks .ico { margin-top: 3px; color: var(--profit); }

/* Toasts */
.toasts { position: fixed; inset-inline: 0; bottom: calc(16px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; z-index: 60; pointer-events: none; padding: 0 16px; }
.toast { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--ink); color: var(--on-ink); font-size: 14px; box-shadow: var(--shadow-2); opacity: 0; transform: translateY(8px); transition: opacity 200ms ease, transform 200ms ease; max-width: 100%; }
.toast.on { opacity: 1; transform: none; }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar { display: block; border-inline-end: 1px solid var(--line); background: var(--surface); }
  .side-in { position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; padding: 16px 12px; }
  .sidebar .logo { padding-inline: 8px; }
  .side-foot { margin-top: auto; padding: 8px; }
  .menu-btn, .logo-sm { display: none; }
  .tb-agency, .tb-prefs { display: block; }
  .tb-prefs { display: flex; }
  .topbar { padding-inline: 32px; }
  .tb-end { margin-inline-start: auto; }
  .tb-agency { margin-inline-end: auto; }
  .filters { display: flex; gap: 8px; padding: 2px 0 12px; width: 100%; }
  .topbar:has(.filters-cur) { display: flex; align-items: center; gap: 16px; }
  .topbar:has(.filters-cur) .tb-row { flex: 1; min-width: 0; }
  .filters-cur { display: block; width: auto; padding: 0; }
  .filters-cur .ctl-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .filters-cur .ctl-ic { bottom: 15px; }
  .ctl { width: 168px; }
  .ctl-cur { width: 104px; }
  .ctl select { font-size: 14px; }
  .main { padding: 24px 32px 56px; }
  .main > * + * { margin-top: 20px; }
  .chip-sample::after, .btn-pilot::after { content: ""; position: absolute; inset: -10px 0; }
.chip-sample .tip { inset-inline-end: auto; inset-inline-start: 0; }
}

/* Touch targets: 44px minimum on phones */
@media (max-width: 767px) {
  .btn-pilot, .chip-sample, .seg button, .th-btn, .logo-sm { min-height: 44px; }
  .logo-sm { min-width: 44px; }
  th .th-btn { min-width: 44px; min-height: 44px; }
}
