/* ==========================================================================
   Al Yusra Transport — Shared Theme
   One stylesheet, linked from every page, so the palette/type/components
   stay identical across Staff, Admin, Agent and Driver portals.
   ========================================================================== */

:root {
    --bg: #101820;
    --surface: #1A2530;
    --surface-raised: #212E3A;
    --hairline: #2A3742;
    --text: #F1ECE0;
    --text-dim: #8B98A3;
    --text-faint: #5C6B78;
    --gold: #D4A24C;
    --gold-dim: #8A6B33;
    --teal: #4FA398;
    --teal-dim: #2E5C55;
    --rust: #C1602E;
    --rust-dim: #7A4023;
    --radius: 10px;
    --scrim: rgba(0,0,0,0.8);
    --scrim-light: rgba(0,0,0,0.55);
}

/* Light mode — opt-in via a `data-theme="light"` attribute on <html>, set by
   the toggle in the topbar/sidebar (see initTheme()/toggleTheme() in
   public/js/app.js). Dark stays the default everywhere nothing is set.
   Accent hues are the exact GOLD/TEAL colors already used in the printed
   PDFs (invoices/vouchers/ledgers), darkened just enough to read on white —
   so a light-mode screen and a printed document use the same brand colors. */
[data-theme="light"] {
    --bg: #F5F2EA;
    --surface: #FFFFFF;
    --surface-raised: #F1ECE0;
    --hairline: #E1D9C8;
    --text: #1A2530;
    --text-dim: #5C6B78;
    --text-faint: #8B98A3;
    --gold: #B8802E;
    --gold-dim: #E0C68C;
    --teal: #3D7A72;
    --teal-dim: #A8CFC8;
    --rust: #A64F26;
    --rust-dim: #E3B39A;
    --scrim: rgba(20,16,8,0.45);
    --scrim-light: rgba(20,16,8,0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', monospace; }
.display { font-family: 'Space Grotesk', sans-serif; }
a { color: inherit; text-decoration: none; }

/* ===== Screen-change polish ===== */
/* Progress bar: swept in from app.js on every navigation (see there for why
   both a click-time and beforeunload trigger exist). Width transitions handle
   the "sweep"; there's no need to animate it back down since the browser is
   about to replace this whole document anyway. */
#navProgressBar {
    position: fixed; top: 0; left: 0; height: 3px; width: 0%;
    background: linear-gradient(90deg, var(--gold), var(--teal));
    z-index: 99999; pointer-events: none;
}

/* Every new page eases in instead of just popping onto the screen — the
   part of a "screen change" that's actually visible once navigation lands. */
@keyframes pageArrive {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.app-shell, .login-shell, .driver-shell {
    animation: pageArrive 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (prefers-reduced-motion: reduce) {
    .app-shell, .login-shell, .driver-shell { animation: none; }
}

/* ===== App shell: sidebar + content ===== */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: var(--surface);
    width: 248px;
    flex-shrink: 0;
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: 84px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid var(--hairline);
    background: var(--surface);
}

.sidebar-brand .brand-mark {
    display: none;
    width: 32px;
    height: 32px;
    border: 1.5px solid var(--gold);
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 14px;
    color: var(--gold);
    flex-shrink: 0;
}

.sidebar-brand .brand-logo-img {
    height: 54px;
    width: auto;
    flex-shrink: 0;
    transition: height 0.15s;
}

.sidebar-brand .brand-text .display {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--text);
}

.sidebar-brand .brand-text .sub {
    font-size: 10.5px;
    color: var(--text-dim);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-dim);
    transition: 0.15s;
}

.sidebar-nav a:hover {
    background: var(--surface-raised);
    color: var(--text);
}

.sidebar-nav a.active {
    background: rgba(212, 162, 76, 0.12);
    color: var(--gold);
}

.sidebar-nav a .icon {
    font-size: 17px;
    flex-shrink: 0;
}

.sidebar-foot {
    padding: 14px;
    border-top: 1px solid var(--hairline);
}

.sidebar-foot button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--rust);
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
}

.sidebar-foot button:hover {
    background: rgba(193, 96, 46, 0.12);
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Top bar (page header inside content area) ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--hairline);
    flex-shrink: 0;
}

.topbar h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 19px;
    font-weight: 600;
}

.topbar p {
    color: var(--text-dim);
    font-size: 12.5px;
    margin-top: 3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 22px;
}

.clock { text-align: right; }
.clock .time { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 500; }
.clock .date { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-dim);
    cursor: pointer;
}

.avatar:hover { background: var(--hairline); color: var(--text); }

/* Light/dark toggle — injected by wireThemeToggle() in app.js, so this is the
   only place its look needs defining; every page gets the same button. */
.theme-toggle-btn {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--surface-raised); border: 1px solid var(--hairline); color: var(--text-dim);
    display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px;
    transition: 0.15s;
}
.theme-toggle-btn:hover { color: var(--gold); border-color: var(--gold); }

/* ===== Page body / shell ===== */
.shell {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px 60px;
}

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gold);
    color: #151109;
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: 0.2s;
}

.btn:hover { background: #e0af58; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--hairline);
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

.btn-danger { background: var(--rust); color: var(--text); }
.btn-danger:hover { background: #d66f38; }

/* ===== KPI strip ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 30px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
}

.kpi::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--accent, var(--gold));
}

.kpi.gold::before { background: var(--gold); }
.kpi.teal::before { background: var(--teal); }
.kpi.rust::before { background: var(--rust); }
.kpi.neutral::before { background: var(--text-faint); }

.kpi-label {
    font-size: 11.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.kpi-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
}

.kpi-value .unit { font-size: 14px; color: var(--text-faint); font-weight: 500; margin-left: 4px; }
.kpi-note { font-size: 11.5px; color: var(--text-faint); margin-top: 8px; }

/* ===== Panels / cards ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
}

.panel-head h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 15px;
    font-weight: 600;
}

.panel-head .count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--text-dim);
    background: var(--surface-raised);
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--hairline);
}

.panel-foot {
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid var(--hairline);
    font-size: 12px;
    color: var(--text-dim);
}

.panel-foot a:hover { color: var(--gold); }

/* ===== Data tables ===== */
.data-table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}

table.data-table thead tr {
    background: var(--surface-raised);
    color: var(--text-faint);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table.data-table th {
    padding: 12px 20px;
    font-weight: 600;
    border-bottom: 1px solid var(--hairline);
}

table.data-table td {
    padding: 14px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--hairline);
}

table.data-table tbody tr:hover { background: var(--surface-raised); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ===== Status pills / badges ===== */
.status-pill {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 20px;
    font-weight: 500;
}

.status-pill.gold   { background: rgba(212,162,76,0.14); color: var(--gold); }
.status-pill.teal   { background: rgba(79,163,152,0.14); color: var(--teal); }
.status-pill.rust   { background: rgba(193,96,46,0.14);  color: var(--rust); }
.status-pill.dim    { background: var(--surface-raised); color: var(--text-dim); }

/* ===== Balance rows ===== */
.balance-list { padding: 6px 10px 10px; }

.balance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 10px;
    border-radius: 8px;
}

.balance-row:hover { background: var(--surface-raised); }

.balance-name { display: flex; align-items: center; gap: 10px; min-width: 0; }

.balance-initial {
    width: 28px; height: 28px;
    border-radius: 7px;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-dim);
    flex-shrink: 0;
}

.balance-name .n {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.balance-name .t { font-size: 10.5px; color: var(--text-faint); }

.balance-amt {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    padding-left: 10px;
}

.balance-amt.owe { color: var(--rust); }
.balance-amt.owed { color: var(--teal); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 15px;
    overflow-y: auto;
}

.modal-overlay.open { display: flex; }

.modal-content {
    background: var(--surface);
    border: 1px solid var(--hairline);
    width: 100%;
    max-width: 560px;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    margin: auto;
}

.modal-content.wide { max-width: 760px; }

.modal-head {
    padding: 20px;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover { color: var(--rust); }

.modal-body { padding: 20px; }

/* ===== Forms ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group { margin-bottom: 15px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--hairline);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
    outline: none;
}

.form-control:focus { border-color: var(--gold); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238B98A3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

/* Financials block (used to visually separate pricing fields in forms) */
.form-financials {
    background: var(--bg);
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--hairline);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 15px;
    display: none;
}

.alert.show { display: block; }
.alert-success { background: rgba(79,163,152,0.14); color: var(--teal); border: 1px solid var(--teal); }
.alert-error { background: rgba(193,96,46,0.14); color: var(--rust); border: 1px solid var(--rust); }

/* ===== Empty / loading states ===== */
.empty-row td {
    text-align: center;
    padding: 32px 20px !important;
    color: var(--text-faint);
}

/* A dressed-up empty state — icon + heading + subtext + optional CTA —
   for the handful of spots where "nothing here yet" is the first thing a
   partner sees and a bare sentence would feel like a dead end. */
.empty-state {
    text-align: center;
    padding: 36px 20px;
}
.empty-state .es-icon {
    font-size: 28px;
    width: 52px; height: 52px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    display: flex; align-items: center; justify-content: center;
}
.empty-state .es-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty-state .es-sub { font-size: 12.5px; color: var(--text-faint); max-width: 320px; margin: 0 auto; }
.empty-state .btn, .empty-state .btn-ghost { margin-top: 16px; }

.spinner {
    display: inline-block;
    width: 13px; height: 13px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid var(--hairline);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 1.6s; }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
}

/* Menu toggle + backdrop are always in the DOM; only shown/active below the
   mobile breakpoint. 1024px (not the more typical ~768px) is deliberate —
   phones in landscape commonly run 800-930px wide, and without headroom past
   that they'd fall back to the always-visible desktop sidebar with no way to
   dismiss it on a small screen. */
.menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--hairline);
    color: var(--text);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    margin-right: 12px;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--scrim-light);
    z-index: 899;
}

@media (max-width: 1024px) {
    .menu-toggle { display: flex; }
    .sidebar { position: fixed; z-index: 900; height: 100vh; transform: translateX(-100%); transition: transform 0.2s; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    /* flex-wrap only kicks in when content actually overflows — a short
       static title (most portals) still fits on one line as before. It's
       the agent dashboard's long "Welcome back, <name>" greeting plus its
       extra topbar-right buttons (quick-create, bell, avatar) that needs
       this: without it, that title got squeezed into a near-unreadable
       narrow column instead of just dropping the buttons to their own row. */
    .topbar { padding: 16px 18px; flex-wrap: wrap; row-gap: 10px; }
    .topbar-right { margin-left: auto; }
    .shell { padding: 22px 18px 40px; }
}

@media (max-width: 520px) {
    .kpi-row { grid-template-columns: 1fr; }
    .clock { display: none; }
}

:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ===================== DRIVER PORTAL ===================== */
/* Mobile-first, bottom tab bar instead of a sidebar — built for a driver
   checking their phone between rides, not a desk-bound dispatcher. */

.driver-shell {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 0 84px;
    background: var(--bg);
}

.driver-topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    background: var(--surface);
    border-bottom: 1px solid var(--hairline);
}

.driver-topbar h1 { font-size: 17px; margin: 0; }
.driver-topbar .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.driver-topbar-title { display: flex; align-items: center; gap: 10px; }
.driver-topbar-logo { height: 34px; width: auto; flex-shrink: 0; }

.lang-toggle-btn {
    background: var(--surface-raised); border: 1px solid var(--hairline); color: var(--text-dim);
    border-radius: 20px; padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
    font-family: 'Inter', sans-serif;
}
.lang-toggle-btn:hover { color: var(--gold); border-color: var(--gold); }

.driver-content { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.driver-bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex; max-width: 560px; margin: 0 auto;
    background: var(--surface); border-top: 1px solid var(--hairline);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.driver-bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 4px 8px; text-decoration: none; color: var(--text-faint); font-size: 11px; font-weight: 600;
}
.driver-bottom-nav a .icon { font-size: 22px; }
.driver-bottom-nav a.active { color: var(--gold); }

.ride-card {
    background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 16px;
}
.ride-card .rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.ride-card .rc-time { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; }
.ride-card .rc-date { font-size: 11.5px; color: var(--text-faint); }
.ride-card .rc-voucher { font-size: 11.5px; color: var(--gold); margin-bottom: 6px; }
.ride-card .rc-voucher .mono { direction: ltr; unicode-bidi: isolate; }
.ride-card .rc-route { font-size: 14px; color: var(--text); margin-bottom: 10px; line-height: 1.5; }
.ride-card .rc-meta { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-dim); margin-bottom: 12px; }
.ride-card .rc-meta span b { color: var(--text-faint); font-weight: 500; }
.ride-card .rc-actions { display: flex; gap: 8px; }
.ride-card .rc-actions .btn { flex: 1; justify-content: center; padding: 12px; font-size: 14px; }

.driver-tabs { display: flex; gap: 8px; margin-bottom: 4px; }
.driver-tabs button {
    flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--hairline); background: var(--surface);
    color: var(--text-dim); font-size: 13px; font-weight: 600; cursor: pointer; font-family: 'Inter', sans-serif;
}
.driver-tabs button.active { background: var(--gold); color: #151109; border-color: var(--gold); }

.invoice-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px;
}
.invoice-row .n { font-size: 13.5px; font-weight: 500; }
.invoice-row .d { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

[dir="rtl"] .driver-topbar, [dir="rtl"] .ride-card .rc-top { direction: rtl; }

/* Urdu needs a script-appropriate face — the Latin UI fonts fall back to
   whatever generic Arabic-script font the OS ships, which looks flat and
   doesn't match the rest of the app. Nastaliq is the script Urdu readers
   expect (plain Naskh/Sans-Arabic reads as "Arabic", not "Urdu" to them),
   sized up and given extra line-height since Nastaliq needs more room to
   stay legible at UI sizes than the Latin faces do. */
[dir="rtl"] {
    font-family: 'Noto Nastaliq Urdu', 'Inter', sans-serif;
}
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] button, [dir="rtl"] textarea {
    font-family: 'Noto Nastaliq Urdu', 'Inter', sans-serif;
    line-height: 2.1;
}
[dir="rtl"] .driver-topbar h1 { font-size: 19px; }
[dir="rtl"] .lang-toggle-btn, [dir="rtl"] .status-pill, [dir="rtl"] .rc-time, [dir="rtl"] .rc-date {
    font-family: 'Inter', sans-serif; line-height: normal;
}
/* Times like "9:00 AM" mix numbers with Latin AM/PM letters — inside an RTL
   paragraph the browser's bidi algorithm can visually reorder them ("AM 9:00").
   Isolating these as their own LTR run keeps them reading left-to-right
   regardless of the surrounding page direction. */
.rc-time, .rc-date, .invoice-row .d, .claim-card .cc-note {
    direction: ltr;
    unicode-bidi: isolate;
}

/* ===================== AGENT PORTAL ===================== */
/* Same desktop sidebar-dashboard shell as staff/vendor, with a few extra
   pieces specific to a partner-facing dashboard: a global search box, a
   quick-create menu, and a notification bell. */

/* --- Collapsible sidebar (desktop polish — icon-only when collapsed).
   Started as an agent-portal-only feature, now shared by every portal's
   sidebar (agent, staff, admin, vendor) — the selectors below are generic
   on purpose (.sidebar, .sidebar-brand, not any agent-specific class). --- */
.sidebar-collapse-btn {
    background: none; border: 1px solid var(--hairline); color: var(--text-dim);
    border-radius: 6px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 12px; flex-shrink: 0; transition: 0.15s;
}
.sidebar-collapse-btn:hover { color: var(--text); border-color: var(--text-faint); }
/* Expanded state: button sits flush right of the logo/text. */
.sidebar-brand .sidebar-collapse-btn { margin-left: auto; }
.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .sidebar-brand .brand-text,
.sidebar.collapsed .sidebar-nav a span:not(.icon),
.sidebar.collapsed .sidebar-foot button span:not(.icon),
.sidebar.collapsed .sidebar-group-label { display: none; }
/* Collapsed: the logo is too wide to read at icon-width, so hide it
   entirely rather than showing a squashed sliver — the collapse button
   becomes the only thing in the header and gets centered on its own. */
#sidebar.collapsed .brand-logo-img,
.sidebar.collapsed .sidebar-brand .brand-mark { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; gap: 8px; padding: 0 8px; height: 64px; }
.sidebar.collapsed .sidebar-brand .sidebar-collapse-btn { margin-left: 0; }
.sidebar.collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-nav a { justify-content: center; }
.sidebar-group-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.6px; color: var(--text-faint);
    text-transform: uppercase; padding: 14px 12px 4px;
}
.sidebar-group-label:first-child { padding-top: 4px; }

/* --- Topbar global search --- */
.topbar-search {
    position: relative; flex: 1; max-width: 420px; margin: 0 24px;
}
.topbar-search input {
    width: 100%; background: var(--surface-raised); border: 1px solid var(--hairline);
    border-radius: 8px; padding: 9px 14px 9px 34px; color: var(--text); font-size: 13px; font-family: 'Inter', sans-serif;
}
.topbar-search input:focus { border-color: var(--gold); outline: none; }
.topbar-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; pointer-events: none; }
.search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface-raised);
    border: 1px solid var(--hairline); border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,0.4);
    max-height: 340px; overflow-y: auto; z-index: 50; display: none;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--hairline); }
.search-results a:last-child { border-bottom: none; }
.search-results a:hover { background: var(--hairline); }
.search-results .sr-title { font-size: 13px; font-weight: 500; }
.search-results .sr-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.search-results .sr-empty { padding: 16px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* --- Quick Create dropdown --- */
.quick-create { position: relative; }
.quick-create-menu {
    position: absolute; top: calc(100% + 8px); right: 0; min-width: 200px; background: var(--surface-raised);
    border: 1px solid var(--hairline); border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,0.4);
    padding: 6px; z-index: 60; display: none;
}
.quick-create-menu.open { display: block; }
.quick-create-menu a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; font-size: 13px; color: var(--text-dim);
}
.quick-create-menu a:hover { background: var(--hairline); color: var(--text); }

/* --- Notification bell --- */
.notif-bell { position: relative; cursor: pointer; color: var(--text-dim); font-size: 19px; display: flex; }
.notif-bell:hover { color: var(--text); }
.notif-badge {
    position: absolute; top: -4px; right: -6px; background: var(--rust); color: #fff; font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px; border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 12px); right: 0; width: 340px; background: var(--surface-raised);
    border: 1px solid var(--hairline); border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,0.4);
    z-index: 60; display: none; max-height: 400px; overflow-y: auto;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-head {
    display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--hairline);
    font-size: 13px; font-weight: 600; position: sticky; top: 0; background: var(--surface-raised);
}
.notif-item { padding: 11px 14px; border-bottom: 1px solid var(--hairline); font-size: 12.5px; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(212,162,76,0.06); }
.notif-item .ni-msg { color: var(--text); }
.notif-item .ni-time { color: var(--text-faint); font-size: 11px; margin-top: 3px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-faint); font-size: 12.5px; }

/* --- Dashboard "upcoming" banner (mirrors a partner-portal schedule widget,
   themed to our palette instead of copying anyone's colors) --- */
.upcoming-banner {
    background: linear-gradient(135deg, var(--surface-raised), var(--surface));
    border: 1px solid var(--hairline); border-left: 3px solid var(--gold);
    border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.upcoming-banner h2 { font-family: 'Space Grotesk', sans-serif; font-size: 15px; font-weight: 600; }
.upcoming-banner p { font-size: 12px; color: var(--text-faint); margin-top: 3px; }

/* A small loyalty line under the greeting — how long they've been a partner
   and how many rides they've done with us, lifetime. Warmth, not a metric. */
.loyalty-marker {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
    font-size: 12px; color: var(--gold); font-weight: 500;
}

/* Two-column dashboard: schedule on the left, a narrower activity feed on
   the right — a standard, professional dashboard shape rather than one long
   stack of panels. */
.dash-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.activity-feed { max-height: 520px; overflow-y: auto; }
.activity-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--hairline); }
.activity-item:last-child { border-bottom: none; }
.activity-item .ai-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex-shrink: 0; margin-top: 5px;
}
.activity-item.type-ride_completed .ai-dot { background: var(--teal); }
.activity-item.type-request_rejected .ai-dot { background: var(--text-faint); }
.activity-item .ai-msg { font-size: 12.5px; color: var(--text); line-height: 1.4; }
.activity-item .ai-time { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

@media (max-width: 1024px) {
    .topbar-search { display: none; }
}

/* --- Rate card / quote-style list rows (Rates, Quotations, Requests) --- */
.rate-cell { text-align: right; }
.price-highlight {
    font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 22px; color: var(--gold);
}
