/* =========================================================================
   Tajir Admin · Apple-grade Light theme
   Sapphire Teal #0F766E + Champagne #E5C07B accents on a white surface.
   ========================================================================= */

:root {
    /* Brand */
    --brand-teal: #0F766E;
    --brand-teal-strong: #0D5F58;
    --brand-teal-soft: rgba(15, 118, 110, 0.10);
    --brand-teal-softer: rgba(15, 118, 110, 0.06);
    --brand-champagne: #B48434;       /* shifted darker so it reads on white */
    --brand-champagne-soft: rgba(180, 132, 52, 0.10);

    /* Neutrals */
    --bg: #F5F6F8;
    --bg-elevated: #F9FAFB;
    --surface: #FFFFFF;
    --surface-2: #FAFBFC;
    --border: rgba(15, 23, 42, 0.07);
    --border-strong: rgba(15, 23, 42, 0.12);
    --divider: rgba(15, 23, 42, 0.06);

    /* Text */
    --text: #0B0F14;
    --text-strong: #060A0F;
    --text-muted: #5B6573;
    --text-faint: #8A94A6;

    /* Semantic */
    --success: #15803D;
    --success-soft: rgba(21, 128, 61, 0.10);
    --danger: #B91C1C;
    --danger-soft: rgba(185, 28, 28, 0.10);
    --warning: #B45309;
    --warning-soft: rgba(180, 83, 9, 0.12);

    /* Type */
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', 'Tajawal', system-ui, sans-serif;
    --font-numeric: 'SF Mono', 'JetBrains Mono', 'Roboto Mono', ui-monospace, monospace;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 22px;

    /* Shadows — soft, Apple-style */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 6px 14px rgba(15, 23, 42, 0.04), 0 16px 36px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 24px 56px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
    direction: rtl;
    letter-spacing: -0.005em;
}

a { color: var(--brand-teal); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

button { font-family: inherit; }
h1:focus { outline: none; }

/* -------------------------------------------------------------------------
   Loading
   ------------------------------------------------------------------------- */
.full-screen-loader {
    position: fixed; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px;
    background: var(--bg);
    color: var(--text-muted);
    font-size: 14px;
    z-index: 1000;
}
.spinner {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 3px solid var(--brand-teal-soft);
    border-top-color: var(--brand-teal);
    animation: spin 0.9s linear infinite;
}
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui {
    position: fixed; bottom: 0; left: 0; right: 0;
    padding: 14px 22px;
    background: var(--text);
    color: white;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 1100;
    direction: rtl;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; top: 12px; left: 16px; }

.blazor-error-boundary {
    background: var(--danger);
    color: white;
    padding: 1rem;
    border-radius: var(--r-md);
}
.blazor-error-boundary::after { content: "حدث خطأ غير متوقع"; }

/* WASM bootstrap loader */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem; height: 8rem;
    margin: 20vh auto 1rem auto;
}
.loading-progress circle {
    fill: none;
    stroke: var(--brand-teal-soft);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--brand-teal);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.loading-progress-text:after { content: var(--blazor-load-percentage-text, "تحميل…"); }

/* -------------------------------------------------------------------------
   Login — light, frosted, centered card
   ------------------------------------------------------------------------- */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(60% 50% at 80% 0%, rgba(15, 118, 110, 0.10), transparent 60%),
        radial-gradient(40% 35% at 10% 100%, rgba(180, 132, 52, 0.10), transparent 60%),
        linear-gradient(180deg, #FBFBFD 0%, #F1F3F6 100%);
    color: var(--text);
}

.login-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(15, 23, 42, 0.05) 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.65;
    mask-image: radial-gradient(circle at 50% 50%, black 40%, transparent 75%);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, black 40%, transparent 75%);
}

.login-wrap {
    width: 100%;
    max-width: 440px;
    padding: 56px 28px;
    position: relative;
    z-index: 2;
}

.login-card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 38px 34px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-logo {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-strong) 100%);
    display: grid; place-items: center;
    color: #FCEFD4;
    font-weight: 800;
    font-size: 18px;
    box-shadow: 0 8px 22px rgba(15, 118, 110, 0.22);
}

.login-brand-text { display: flex; flex-direction: column; }
.login-brand-text .name { font-size: 16px; font-weight: 700; color: var(--text-strong); }
.login-brand-text .sub { font-size: 12px; color: var(--text-faint); }

.login-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 6px 0;
    color: var(--text-strong);
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 26px 0;
}

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.field label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.field input {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 13px 14px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    outline: none;
    direction: ltr;
    text-align: right;
}

.field input::placeholder { color: var(--text-faint); }

.field input:focus {
    background: var(--surface);
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 4px var(--brand-teal-soft);
}

.btn-primary-glow {
    margin-top: 6px;
    width: 100%;
    padding: 13px;
    border: 0;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-strong) 100%);
    box-shadow: 0 8px 22px rgba(15, 118, 110, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 0.08s ease, box-shadow 0.15s, opacity 0.15s;
}
.btn-primary-glow:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(15, 118, 110, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-primary-glow:active:not(:disabled) { transform: translateY(0); }
.btn-primary-glow:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary-glow .btn-row { display: inline-flex; align-items: center; gap: 10px; justify-content: center; width: 100%; }

.login-alert {
    margin: 0 0 14px 0;
    padding: 11px 13px;
    border-radius: var(--r-md);
    background: var(--danger-soft);
    border: 1px solid rgba(185, 28, 28, 0.18);
    color: #7F1D1D;
    font-size: 13px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.login-footer {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
}
.login-footer .secure { display: inline-flex; align-items: center; gap: 6px; }
.login-footer svg { width: 14px; height: 14px; }

/* -------------------------------------------------------------------------
   Dashboard shell — light surfaces, soft borders
   ------------------------------------------------------------------------- */
.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    background: var(--bg);
}

.shell-sidebar {
    background: var(--surface);
    color: var(--text);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    border-inline-end: 1px solid var(--border);
}

.shell-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 4px 8px;
}
.shell-brand .logo {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-strong) 100%);
    display: grid; place-items: center;
    color: #FCEFD4;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}
.shell-brand .text strong { display: block; font-size: 14px; color: var(--text-strong); letter-spacing: -0.005em; }
.shell-brand .text span { font-size: 11px; color: var(--text-faint); letter-spacing: 0.02em; }

.shell-nav {
    display: flex; flex-direction: column; gap: 2px;
    margin-top: 4px;
}
.shell-nav .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    padding: 14px 10px 6px 10px;
    font-weight: 600;
}

.shell-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.shell-nav a:hover { background: var(--bg-elevated); color: var(--text); text-decoration: none; }
.shell-nav a.active {
    background: var(--brand-teal-soft);
    color: var(--brand-teal-strong);
    font-weight: 600;
}
.shell-nav a.active::before {
    content: "";
    position: absolute;
    inset-inline-start: -16px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 2px;
    background: var(--brand-teal);
}
.shell-nav svg { width: 18px; height: 18px; flex-shrink: 0; }

.shell-userbox {
    margin-top: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.shell-userbox .avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-strong) 100%);
    color: white;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 13px;
}
.shell-userbox .who { flex: 1; min-width: 0; }
.shell-userbox .who strong {
    display: block;
    color: var(--text-strong);
    font-size: 13px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shell-userbox .who span { color: var(--text-faint); font-size: 11px; }
.shell-userbox button {
    background: transparent;
    border: 0;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 8px;
    width: 32px; height: 32px;
    display: grid; place-items: center;
    transition: background 0.15s, color 0.15s;
}
.shell-userbox button:hover { background: var(--surface); color: var(--danger); }
.shell-userbox svg { width: 16px; height: 16px; }

.shell-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
}

.shell-topbar {
    height: 64px;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.shell-topbar h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--text-strong);
}
.shell-topbar .crumb {
    color: var(--text-faint);
    font-size: 12px;
    margin-top: 2px;
}

.shell-topbar .actions { display: flex; align-items: center; gap: 10px; }

.search { position: relative; }
.search input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 16px 8px 36px;
    font-size: 13px;
    width: 240px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s, width 0.2s ease;
    color: var(--text);
}
.search input:focus { border-color: var(--brand-teal); box-shadow: 0 0 0 4px var(--brand-teal-soft); width: 280px; }
.search svg {
    position: absolute;
    right: 12px; top: 50%;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    color: var(--text-faint);
    pointer-events: none;
}

.chip-time {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 12px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.chip-time .dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px var(--success-soft);
}

.shell-body {
    padding: 26px 28px 56px 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

/* -------------------------------------------------------------------------
   Cards & atoms
   ------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
}
.card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-strong);
    letter-spacing: -0.005em;
}
.card-header .hint {
    color: var(--text-faint);
    font-size: 12px;
}

.card-body { padding: 20px; }
.card-body.compact { padding: 14px; }

.row-kpi {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.kpi::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 65%, var(--brand-teal-softer) 100%);
    z-index: -1;
}
.kpi .head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: 0.005em;
}
.kpi .head .icon {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--brand-teal-soft);
    color: var(--brand-teal);
    display: grid; place-items: center;
}
.kpi .head .icon svg { width: 17px; height: 17px; }

.kpi .value {
    font-family: var(--font-sans);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-strong);
    margin: 0;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}
.kpi .meta {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-faint);
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}

.delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.delta.up { color: var(--success); background: var(--success-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--text-muted); background: rgba(15, 23, 42, 0.05); }
.delta svg { width: 11px; height: 11px; }

/* Chart */
.chart-card { padding: 0; overflow: hidden; }
.chart-svg {
    width: 100%;
    height: 240px;
    display: block;
    padding: 6px 12px 0 12px;
}
.chart-svg .grid line { stroke: var(--divider); stroke-dasharray: 3 4; }
.chart-svg .axis text { fill: var(--text-faint); font-size: 10px; font-family: var(--font-numeric); }
.chart-svg .line { fill: none; stroke: var(--brand-teal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart-svg .area { fill: url(#chart-area-fill); }
.chart-svg .dot { fill: var(--brand-teal); }
.chart-legend {
    display: flex; align-items: center; gap: 18px;
    padding: 0 20px 14px 20px;
    color: var(--text-faint);
    font-size: 12px;
}
.chart-legend .swatch {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 3px; margin-inline-end: 6px;
    vertical-align: middle;
}

.split-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}
.split-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

/* Table */
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tbl th, .tbl td {
    text-align: right;
    padding: 12px 18px;
    border-bottom: 1px solid var(--divider);
    white-space: nowrap;
}
.tbl th {
    color: var(--text-faint);
    font-weight: 600;
    background: var(--surface-2);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.tbl td { color: var(--text); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .mono { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--text-faint); }

/* Status pills */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.pill .pill-dot { width: 6px; height: 6px; border-radius: 50%; }
.pill.s-pending   { color: var(--warning); background: var(--warning-soft); }
.pill.s-pending   .pill-dot { background: var(--warning); }
.pill.s-confirmed { color: #1D4ED8; background: rgba(29, 78, 216, 0.10); }
.pill.s-confirmed .pill-dot { background: #1D4ED8; }
.pill.s-processing { color: #7E22CE; background: rgba(126, 34, 206, 0.12); }
.pill.s-processing .pill-dot { background: #7E22CE; }
.pill.s-ready { color: #0E7490; background: rgba(14, 116, 144, 0.12); }
.pill.s-ready .pill-dot { background: #0E7490; }
.pill.s-delivered { color: var(--success); background: var(--success-soft); }
.pill.s-delivered .pill-dot { background: var(--success); }
.pill.s-cancelled { color: var(--danger); background: var(--danger-soft); }
.pill.s-cancelled .pill-dot { background: var(--danger); }
.pill.s-rejected { color: #525252; background: rgba(82, 82, 82, 0.12); }
.pill.s-rejected .pill-dot { background: #525252; }

/* Seller rows */
.list-rows { display: flex; flex-direction: column; }
.list-rows .row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--divider);
}
.list-rows .row:last-child { border-bottom: 0; }
.list-rows .row .ava {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #EEF1F4, #E4E8ED);
    color: var(--text-muted);
    display: grid; place-items: center;
    font-weight: 700; font-size: 12px;
    flex-shrink: 0;
}
.list-rows .row .main { flex: 1; min-width: 0; }
.list-rows .row .name { font-weight: 600; font-size: 13px; color: var(--text-strong); }
.list-rows .row .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.list-rows .row .num {
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
    font-size: 13px; color: var(--text-strong);
    font-weight: 600;
}

.empty {
    padding: 26px 22px;
    text-align: center;
    color: var(--text-faint);
    font-size: 13px;
}

/* status breakdown bars */
.status-breakdown { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 20px 20px; }
.status-breakdown .row { display: flex; align-items: center; gap: 12px; }
.status-breakdown .row .label { width: 100px; font-size: 12px; color: var(--text-muted); }
.status-breakdown .row .bar {
    flex: 1; height: 7px; border-radius: 4px;
    background: var(--bg-elevated);
    overflow: hidden;
}
.status-breakdown .row .bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--brand-teal), var(--brand-teal-strong));
    border-radius: 4px;
    transition: width 0.4s ease;
}
.status-breakdown .row .count {
    font-family: var(--font-numeric);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 12px;
    width: 36px;
    text-align: end;
    color: var(--text-strong);
}

/* Stat tile (for the bottom row) */
.stat-tile { padding: 16px 20px; }
.stat-tile .v {
    font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
    color: var(--text-strong);
    font-variant-numeric: tabular-nums;
    display: flex; align-items: baseline; gap: 6px;
}
.stat-tile .v .unit { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-tile .sub { margin-top: 4px; font-size: 11.5px; color: var(--text-faint); }
.stat-tile .star { color: var(--brand-champagne); font-size: 16px; }

@media (max-width: 1100px) {
    .row-kpi { grid-template-columns: repeat(2, 1fr); }
    .split-2 { grid-template-columns: 1fr; }
    .split-3 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .shell { grid-template-columns: 1fr; }
    .shell-sidebar { position: relative; height: auto; }
    .row-kpi { grid-template-columns: 1fr; }
    .search input { width: 140px; }
    .search input:focus { width: 160px; }
    .shell-body { padding: 18px; }
    .shell-topbar { padding: 0 18px; }
}

/* =========================================================================
   Public pages — Privacy, Terms, Delete Account.
   Mobile-first responsive layout shared by all unauthenticated screens.
   Same Sapphire Teal + Champagne palette as the admin shell, but laid out
   as a single readable column with a sticky top bar — works from 320px
   phones up to wide desktops. No inline scripts, no third-party fonts
   beyond the ones the admin already preloads.
   ========================================================================= */
.public-shell {
    min-height: 100vh;
    background:
        radial-gradient(60% 50% at 80% 0%, rgba(15, 118, 110, 0.08), transparent 60%),
        radial-gradient(40% 35% at 10% 100%, rgba(180, 132, 52, 0.07), transparent 60%),
        linear-gradient(180deg, #FBFBFD 0%, #F1F3F6 100%);
    color: var(--text);
    display: flex;
    flex-direction: column;
}

.public-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.public-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
}
.public-brand:hover { text-decoration: none; }
.public-brand .logo {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-teal) 0%, var(--brand-teal-strong) 100%);
    display: grid; place-items: center;
    color: #FCEFD4;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}
.public-brand .text { display: flex; flex-direction: column; }
.public-brand .text .name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.005em;
    line-height: 1.2;
}
.public-brand .text .sub {
    font-size: 11px;
    color: var(--text-faint);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.public-topbar nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.public-topbar nav a {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}
.public-topbar nav a:hover {
    background: var(--brand-teal-softer);
    color: var(--brand-teal-strong);
    text-decoration: none;
}
.public-topbar nav a.active {
    background: var(--brand-teal-soft);
    color: var(--brand-teal-strong);
    font-weight: 600;
}

.public-main {
    flex: 1;
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 28px 24px 64px 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.public-hero {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px 28px 26px 28px;
    box-shadow: var(--shadow-sm);
}
.public-hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--brand-teal-soft);
    color: var(--brand-teal-strong);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin-bottom: 14px;
}
.public-hero h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.02em;
    margin: 0 0 10px 0;
    line-height: 1.2;
}
.public-hero p {
    margin: 0;
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.65;
}
.public-hero .meta {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    color: var(--text-faint);
    font-size: 12px;
}
.public-hero .meta strong { color: var(--text); font-weight: 600; }

.public-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-xs);
}
.public-section h2 {
    margin: 0 0 12px 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}
.public-section p {
    margin: 0 0 10px 0;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.75;
}
.public-section p:last-child { margin-bottom: 0; }
.public-section ul {
    margin: 8px 0 0 0;
    padding-inline-start: 22px;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.75;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.public-section ul li { padding-inline-start: 4px; }

.public-footer {
    border-top: 1px solid var(--border);
    padding: 22px 24px 36px 24px;
    color: var(--text-faint);
    font-size: 12.5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    background: rgba(255, 255, 255, 0.5);
}
.public-footer a { color: var(--text-muted); }
.public-footer .links {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
}

/* Loading + error inside public pages */
.public-loading,
.public-error {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 30px 24px;
    text-align: center;
    color: var(--text-muted);
    box-shadow: var(--shadow-xs);
}
.public-error { color: #7F1D1D; background: var(--danger-soft); border-color: rgba(185, 28, 28, 0.18); }
.public-loading .spinner { margin: 0 auto 12px auto; }

/* ----- Delete account form ----- */
.public-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.public-form .field { display: flex; flex-direction: column; gap: 8px; }
.public-form .field label { font-size: 12px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.01em; }
.public-form .field input,
.public-form .field textarea {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 13px 14px;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
    outline: none;
    direction: ltr;
    text-align: right;
    width: 100%;
}
.public-form .field input[dir="rtl"],
.public-form .field textarea[dir="rtl"] {
    direction: rtl;
    text-align: right;
}
.public-form .field input::placeholder,
.public-form .field textarea::placeholder { color: var(--text-faint); }
.public-form .field input:focus,
.public-form .field textarea:focus {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 4px var(--brand-teal-soft);
}
.public-form .field .hint { font-size: 12px; color: var(--text-faint); }

.public-form .danger-callout {
    border: 1px solid rgba(185, 28, 28, 0.20);
    background: var(--danger-soft);
    border-radius: var(--r-md);
    padding: 14px 16px;
    color: #7F1D1D;
    font-size: 13.5px;
    line-height: 1.65;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.public-form .danger-callout svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}
.public-form .danger-callout ul {
    margin: 8px 0 0 0;
    padding-inline-start: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.btn-danger {
    width: 100%;
    padding: 14px;
    border: 0;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
    box-shadow: 0 8px 22px rgba(185, 28, 28, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transition: transform 0.08s ease, box-shadow 0.15s, opacity 0.15s;
}
.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(185, 28, 28, 0.28);
}
.btn-danger:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-secondary {
    width: 100%;
    padding: 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    background: var(--surface);
    transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); }
.btn-secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.public-form .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.public-success {
    border: 1px solid rgba(21, 128, 61, 0.20);
    background: var(--success-soft);
    border-radius: var(--r-lg);
    padding: 22px;
    color: #14532D;
    font-size: 14.5px;
    line-height: 1.65;
    text-align: center;
}
.public-success svg { width: 36px; height: 36px; color: var(--success); margin: 0 auto 10px auto; display: block; }
.public-success strong { display: block; margin-bottom: 6px; font-size: 16px; color: #052E16; }

.steps {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--text-faint);
    font-size: 12.5px;
    margin: -4px 0 8px 0;
}
.steps .dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    color: var(--text-faint);
    display: grid; place-items: center;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.steps .dot.active { background: var(--brand-teal); color: white; border-color: var(--brand-teal); }
.steps .dot.done { background: var(--success); color: white; border-color: var(--success); }
.steps .line { flex: 1; height: 1px; background: var(--border-strong); }
.steps .line.active { background: var(--brand-teal); }

@media (max-width: 720px) {
    .public-topbar { padding: 12px 16px; }
    .public-topbar nav a { padding: 6px 10px; font-size: 12.5px; }
    .public-main { padding: 18px 16px 40px 16px; gap: 16px; }
    .public-hero { padding: 22px 20px; }
    .public-hero h1 { font-size: 22px; }
    .public-section { padding: 18px 18px; }
    .public-form { padding: 20px 18px; }
    .public-form .actions { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
    .public-brand .text .sub { display: none; }
    .public-hero .meta { font-size: 11.5px; }
}
