/*
 * The shared components of every page: the top bar, buttons, fields, chips,
 * panels, tiles, tabs, dialogs, toasts, the menu and the combobox. Colours come
 * from theme.css; what belongs to one page lives in that page's stylesheet.
 * Right-to-left throughout, so sides are logical (inline-start = right).
 */

/* ── icons ── */
.icon {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -3px;
}
.icon-lg { width: 20px; height: 20px; }

/* ── the top bar ── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    min-height: 58px;
    padding: 8px 22px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.topbar-start { display: flex; align-items: center; gap: 20px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
/*
 * The Bime Bazar mark (views/partials/brand_mark.ejs). Its motion is short and has a reason:
 * - it rises once as a page opens, the arch first and then the B;
 * - a pointer over it lifts the B a hair and sends a glint across;
 * - on the dashboard the same glint follows each finished engine cycle (dashboard.js `glintOnCycle`).
 * Nothing loops. Reduced motion (theme.css) makes all of it instant.
 */
.brand-mark { display: inline-flex; flex: none; height: 34px; }
.bb-mark {
    height: 100%;
    width: auto;
    overflow: visible;
    filter: drop-shadow(0 3px 7px color-mix(in srgb, var(--brand) 32%, transparent));
}
.bb-arch {
    fill: var(--brand);
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: bb-rise 640ms var(--ease) backwards;
}
.bb-b {
    fill: var(--brand-ink);
    transform-box: fill-box;
    transform-origin: 0 100%;
    animation: bb-b-in 520ms 200ms var(--ease) backwards;
    transition: transform var(--dur-3) var(--ease);
}
.brand:hover .bb-b, .brand:focus-visible .bb-b { transform: translateY(-16px); }
.brand:hover .bb-glint, .bb-mark.glint .bb-glint { animation: bb-glint 1100ms var(--ease); }
@keyframes bb-rise { from { opacity: 0; transform: translateY(36px) scaleY(.72); } to { opacity: 1; transform: none; } }
@keyframes bb-b-in { from { opacity: 0; transform: translateX(-34px); } to { opacity: 1; transform: none; } }
/* User units of the mark's viewBox: from left of the arch to past its right edge. */
@keyframes bb-glint { from { transform: translateX(0); } to { transform: translateX(640px); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: .95rem; font-weight: 700; }
.brand-sub { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.nav { display: flex; align-items: center; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-2); }
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* On a second line too it stays at the inline end (the left), where it sits on one line: never right, then left. */
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }

/* ── buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: .84rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-1);
    transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease),
        color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-danger-quiet { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); box-shadow: none; }
.btn-danger-quiet:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-quiet { background: transparent; box-shadow: none; }
.btn-quiet:hover { background: var(--surface-3); border-color: var(--border); }
.btn-small { min-height: 28px; padding: 4px 10px; font-size: .78rem; border-radius: 8px; }
.btn-icon { width: 34px; padding: 0; }
.btn-small.btn-icon { width: 28px; }

/* ── pills and badges ── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
    cursor: default;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill[data-tone="ok"] .pill-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
.pill[data-tone="busy"] .pill-dot { background: var(--accent); animation: pill-pulse 1.4s ease-in-out infinite; }
.pill[data-tone="bad"] { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); background: var(--danger-bg); }
.pill[data-tone="bad"] .pill-dot { background: var(--danger); }
.pill[data-tone="warn"] { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); color: var(--warn); background: var(--warn-bg); }
.pill[data-tone="warn"] .pill-dot { background: var(--warn); }
.pill .pill-sub { color: var(--muted); font-weight: 400; }
@keyframes pill-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    50%      { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 0%, transparent); }
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: var(--r-pill);
    font-size: .72rem;
    font-weight: 500;
    line-height: 1.7;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-2);
    border: 1px solid transparent;
}
.badge.live, .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    padding: 1px 9px;
    border-radius: var(--r-pill);
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid transparent;
    line-height: 1.75;
}

/* ── fields ── */
.input, .select,
.field input, .field select {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: .85rem;
    transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.input:hover, .select:hover, .field input:hover, .field select:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .field input:focus, .field select:focus,
.search-field:focus-within { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

.field { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); }

.search-field {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
.search-field:hover { border-color: var(--border-strong); }
.search-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    padding: 7px 0;
    color: var(--text);
    font-size: .86rem;
}
.search-field input::-webkit-search-cancel-button { display: none; }
.search-clear {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.search-clear:hover { background: var(--surface-3); color: var(--text); }
.kbd {
    min-width: 20px;
    padding: 0 5px;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    font-family: var(--mono);
    font-size: .7rem;
    line-height: 1.5;
    text-align: center;
    color: var(--muted);
    background: var(--surface-2);
}

/* toggle switch */
.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 999px;
    transition: background-color var(--dur-2) var(--ease);
}
.switch .slider::before {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    top: 3px;
    right: 3px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
    transition: transform var(--dur-2) var(--ease);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(-14px); }
.switch input:focus-visible + .slider { box-shadow: var(--focus); }

/* filter chips — a row of toggles with counts */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 3px 11px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font-size: .8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.filter-chip:hover { border-color: var(--border-strong); }
.filter-chip .count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    color: var(--muted);
    font-size: .72rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.filter-chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.filter-chip[aria-pressed="true"] .count { background: color-mix(in srgb, var(--surface) 22%, transparent); color: var(--surface); }
.filter-chip[data-tone="bad"] .count { background: var(--danger-bg); color: var(--danger); }
.filter-chip[data-tone="bad"][aria-pressed="true"] .count { background: var(--danger); color: #fff; }
.filter-chip:disabled { opacity: .45; cursor: default; }

/* ── panels ── */
.page { padding: 20px 22px 64px; max-width: 1560px; margin: 0 auto; }
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
    margin-bottom: 20px;
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 14px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: .98rem; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.panel-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.muted { color: var(--muted); font-size: .8rem; font-weight: 400; }

/* ── KPI tiles ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-3);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.kpi::before {
    content: "";
    position: absolute;
    inset-block: 14px;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--kpi-tone, transparent);
}
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.kpi-label .icon { width: 15px; height: 15px; }
.kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .78rem; font-weight: 500; color: var(--muted); margin-inline: 2px 8px; }
.kpi-sub { font-size: .76rem; color: var(--muted); min-height: 1.2em; }
.kpi[data-tone="bad"] { --kpi-tone: var(--danger); }
.kpi[data-tone="bad"] .kpi-sub { color: var(--danger); }
.kpi[data-tone="warn"] { --kpi-tone: var(--warn); }
.kpi[data-tone="ok"] { --kpi-tone: var(--ok); }
.kpi[data-tone="accent"] { --kpi-tone: var(--accent); }
.kpis.compact { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.kpis.compact .kpi { padding: 10px 13px; box-shadow: none; background: var(--surface-2); }
.kpis.compact .kpi-value { font-size: 1.15rem; }

/* ── tabs ── */
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: var(--r-2); }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 13px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: .84rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.tab .muted { font-size: .74rem; }

/* ── tables ── */
.table-scroll { overflow: auto; max-height: 440px; }
.table-scroll.tall { max-height: 560px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .82rem; }
th, td { text-align: right; padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 500;
    font-size: .76rem;
}
tbody tr { transition: background-color var(--dur-1) var(--ease); }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
.table-foot { margin: 0; padding: 9px 16px; border-top: 1px solid var(--border); font-size: .78rem; color: var(--muted); }

/* ── empty and loading states ── */
.empty, .empty-state { color: var(--muted); padding: 26px 18px; text-align: center; font-size: .86rem; }
.empty-state .btn { margin-inline-start: 6px; }
.skeleton {
    border-radius: var(--r-2);
    background: var(--skeleton);
    background-size: 200% 100%;
    animation: skeleton 1.3s ease-in-out infinite;
}
@keyframes skeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ── dialogs ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay);
    opacity: 0;
    transition: opacity var(--dur-2) var(--ease);
}
.modal.is-open { opacity: 1; }
.modal-card {
    display: flex;
    flex-direction: column;
    width: min(580px, 100%);
    max-height: min(88vh, 900px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-3);
    transform: translateY(8px) scale(.985);
    transition: transform var(--dur-3) var(--ease);
    overflow: hidden;
}
.modal.is-open .modal-card { transform: none; }
.modal-card.wide { width: min(860px, 100%); }
.modal-card.narrow { width: min(440px, 100%); }
.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 1rem; font-weight: 700; flex: 1; min-width: 0; }
.modal-close { margin-inline-start: auto; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}
.modal-foot .spacer { flex: 1; }
.hint { font-size: .78rem; color: var(--muted); margin: 10px 0 0; line-height: 1.75; }
.hint:first-child { margin-top: 0; }
.confirm-text { margin: 0; white-space: pre-line; line-height: 1.8; color: var(--text-2); }
.confirm-icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
}
.modal-confirm[data-tone="danger"] .confirm-icon { background: var(--danger-bg); color: var(--danger); }
/* A reason picked in the question (review 11-18): ready answers as chips, one at a time, or a written line. */
.confirm-reasons { margin-top: 14px; }
.confirm-reasons-label { margin: 0 0 8px; font-size: .78rem; color: var(--muted); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chip {
    font: inherit;
    font-size: .82rem;
    padding: 4px 11px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.reason-chip:hover { background: var(--surface-3); }
.reason-chip[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.reason-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.confirm-note { margin-top: 10px; width: 100%; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.form-grid label, .form-label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: var(--muted); }
.form-grid input, .form-grid select {
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: .86rem;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.form-grid .checkline { flex-direction: row; align-items: center; gap: 8px; color: var(--text-2); font-size: .84rem; }
.form-grid .checkline input { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.form-section + .form-section { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.form-section h4 { margin: 0 0 10px; font-size: .8rem; font-weight: 600; color: var(--text-2); }
.danger-zone {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
    border-radius: var(--r-2);
    background: color-mix(in srgb, var(--danger-bg) 55%, transparent);
    font-size: .78rem;
    color: var(--text-2);
}
.danger-zone p { margin: 0; flex: 1; }

/* ── toasts ── */
.toast-stack {
    position: fixed;
    bottom: 20px;
    inset-inline-start: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(460px, calc(100vw - 40px));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--accent);
    border-radius: 11px;
    box-shadow: var(--shadow-2);
    font-size: .84rem;
    line-height: 1.7;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--dur-2) var(--ease), transform var(--dur-3) var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(6px); }
.toast.bad { border-inline-start-color: var(--danger); }
.toast.ok { border-inline-start-color: var(--ok); }
.toast-text { flex: 1; min-width: 0; }
.toast-action {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 600;
    font-size: .82rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    white-space: nowrap;
}
.toast-action:hover { background: var(--accent-soft); }
.toast-close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    flex: none;
}
.toast-close:hover { background: var(--surface-3); color: var(--text); }

/* ── the menu ── */
.menu-wrap { position: relative; }
.menu {
    position: absolute;
    top: calc(100% + 6px);
    inset-inline-end: 0;
    z-index: 40;
    min-width: 220px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-3);
    transform-origin: top left;
    animation: menu-in var(--dur-2) var(--ease);
}
.menu form { margin: 0; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: .84rem;
    text-align: right;
    cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.menu-item .icon { color: var(--muted); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.menu-note { padding: 4px 10px 6px; font-size: .72rem; color: var(--muted); }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── the combobox ── */
.combo { position: relative; display: inline-flex; flex-direction: column; }
.combo .search-field { min-width: 240px; }
.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: 35;
    max-height: 300px;
    margin: 0;
    padding: 5px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-3);
    animation: menu-in var(--dur-2) var(--ease);
}
.combo-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: .84rem;
    cursor: pointer;
}
.combo-option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.combo-option.is-current::after { content: "✓"; color: var(--accent); }
.combo-empty { padding: 10px; color: var(--muted); font-size: .8rem; text-align: center; }

/* ── a link-styled button for names inside text ── */
.link-name {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline dotted color-mix(in srgb, currentColor 45%, transparent);
    text-underline-offset: 3px;
}
.link-name:hover { color: var(--accent); }

/* ── a connection problem: one line under the top bar, not a toast every 10 s ── */
.conn-banner {
    position: sticky;
    top: 58px;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 16px;
    background: var(--danger-bg);
    color: var(--danger);
    border-bottom: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    font-size: .82rem;
    font-weight: 500;
}

@media (max-width: 760px) {
    .topbar { padding: 8px 14px; position: static; }
    .topbar-start { width: 100%; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
    /* Six pages since «آف‌پلن» (11-13): on a phone the bar scrolls inside itself, never the page. */
    .nav { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { padding: 5px 8px; }
    .nav .icon, .clock-day, .brand-tagline { display: none; }
    .topbar-actions { width: 100%; }
    .page { padding: 14px 12px 56px; }
    .panel-head { padding: 12px 14px; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    /* An odd last tile (the dashboard's five) takes the whole row. */
    .kpis:not(.compact) > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .kpi { padding: 12px 13px; }
    .kpi-value { font-size: 1.3rem; }
    .modal { align-items: flex-end; padding: 0; }
    .modal-card { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
    .modal-card.wide, .modal-card.narrow { width: 100%; }
    .toast-stack { inset-inline: 12px; bottom: 12px; max-width: none; }
    .conn-banner { top: 0; }
}
