/* ==========================================================================
   app.css — Trip Manager
   Mobile-first, app-like. Light and dark are both first-class: the tokens
   below are the whole design system, and Bootstrap rides along via
   data-bs-theme on <html> so its modals/forms/alerts follow without overrides.
   ========================================================================== */

/* ==========================================================================
   IDENTITY — wetravelwesplit
   The name is two halves, so the identity is too: TEAL is "we travel" (sea,
   sky, going somewhere) and CORAL is "we split" (the money, the divide). The
   mark is a circle cut in two; the wordmark shows the seam. Anywhere the app
   divides something, those two colours are the vocabulary.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
    color-scheme: light;

    /* "we travel" — the primary. */
    --brand: #0d7d76;
    --brand-strong: #0a625c;
    --brand-soft: #e6f5f4;
    --brand-ink: #ffffff;

    /* "we split" — the accent. Used for the divide, never for chrome. */
    --accent: #f2683c;
    --accent-strong: #d9502a;
    --accent-soft: #fff0eb;
    --accent-ink: #ffffff;

    --ok: #0f8a5f;
    --ok-soft: #e8f7f0;
    --warn: #b45309;
    --warn-soft: #fdf6e7;
    --danger: #d93a37;
    --danger-soft: #fdefee;

    --bg: #f2f6f6;
    --surface: #ffffff;
    --surface-2: #f7fafa;
    --border: #e2ebea;
    --ink: #10201f;
    --ink-2: #445856;
    --muted: #748c8a;

    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 9px;
    --shadow: 0 2px 4px rgba(16, 24, 40, .03), 0 8px 24px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 40px rgba(16, 24, 40, .14);
    --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --tabbar-h: 64px;
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --brand: #2fd4c6;
    --brand-strong: #5ee3d7;
    --brand-soft: #0c2b29;
    --brand-ink: #04201e;

    --accent: #ff8b62;
    --accent-strong: #ffa383;
    --accent-soft: #331a12;
    --accent-ink: #24100a;

    --ok: #34d399;
    --ok-soft: #0c2a20;
    --warn: #fbbf24;
    --warn-soft: #2b2213;
    --danger: #f87171;
    --danger-soft: #2d1618;

    --bg: #060f0f;
    --surface: #0e1a1a;
    --surface-2: #142222;
    --border: #21393a;
    --ink: #e9f3f2;
    --ink-2: #b9cccb;
    --muted: #7f9997;

    --shadow: 0 2px 4px rgba(0, 0, 0, .22), 0 8px 24px rgba(0, 0, 0, .38);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    -webkit-text-size-adjust: 100%;
    transition: background-color .2s ease, color .2s ease;
}
body.has-nav .content { padding-bottom: calc(var(--tabbar-h) + 22px + var(--safe-bottom)); }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.dinline { display: inline; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* Numbers line up in columns instead of jittering. */
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App bar ---------- */
.appbar {
    position: sticky; top: 0; z-index: 1020;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    padding-top: var(--safe-top);
}
.appbar-inner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 11px 16px; max-width: 780px; margin: 0 auto;
}
/* ---------- Brand ---------- */
.brand {
    font-weight: 800; font-size: 1.02rem; color: var(--ink);
    display: inline-flex; align-items: center; gap: 9px;
    letter-spacing: -.035em; text-decoration: none; white-space: nowrap;
}
.brand-mark { width: 30px; height: 30px; flex: 0 0 auto; }
.brand-mark.lg { width: 62px; height: 62px; }

/* The wordmark carries the idea: one word, two halves, a visible seam. */
.brand-text .t1 { color: var(--ink); }
.brand-text .t2 { color: var(--brand); }
.brand-text .seam { color: var(--accent); font-weight: 900; margin: 0 .06em; }
:root[data-theme="dark"] .brand-text .t1 { color: var(--ink); }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--ink-2);
    display: grid; place-items: center; cursor: pointer; font-size: .85rem;
    transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }

.lang-switch {
    display: flex; gap: 2px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 10px; padding: 2px;
}
.lang-switch a {
    color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 700;
    padding: 3px 9px; border-radius: 8px; line-height: 1.5;
}
.lang-switch a.on { background: var(--brand); color: var(--brand-ink); }

.me {
    font-size: .82rem; color: var(--ink-2); max-width: 26vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Content ---------- */
.content { max-width: 780px; margin: 0 auto; padding: 18px 16px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.page-head h2 {
    font-size: 1.32rem; margin: 0; font-weight: 800; letter-spacing: -.02em;
    display: flex; align-items: center; gap: 9px; min-width: 0;
}
.page-head h2 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.section-title {
    font-size: .78rem; font-weight: 800; margin: 26px 0 10px;
    text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
    display: flex; align-items: center; gap: 7px;
}
.section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title-row .section-title { margin-bottom: 10px; }

.flag {
    width: 30px; height: 20px; object-fit: cover; border-radius: 4px;
    border: 1px solid var(--border); vertical-align: middle; flex: 0 0 auto;
}

/* ---------- Surfaces ---------- */
.card-form, .panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

/* ---------- Bootstrap tuning ---------- */
.form-control, .form-select {
    border-radius: var(--radius-sm); padding: .58rem .78rem;
    background: var(--surface-2); border-color: var(--border); color: var(--ink);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand); box-shadow: var(--ring); background: var(--surface);
}
.form-label { font-size: .82rem; font-weight: 700; color: var(--ink-2); margin-bottom: .3rem; }
.form-text { color: var(--muted); }

.btn { border-radius: var(--radius-sm); font-weight: 700; }
.btn-lg { padding: .72rem 1rem; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-ink); }
.btn-outline-primary { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, transparent); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.modal-content {
    border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow-lg);
}
.modal-header, .modal-footer { border-color: var(--border); }
.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 600; }

/* ---------- Chips ---------- */
.chip {
    font-size: .74rem; font-weight: 700; padding: 4px 10px; border-radius: 30px;
    white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
    background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border);
}
.chip-brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap i {
    position: absolute; top: 50%; transform: translateY(-50%);
    inset-inline-start: 13px; color: var(--muted); font-size: .82rem; pointer-events: none;
}
.search-wrap input { padding-inline-start: 36px; }

.filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
    font-size: .76rem; font-weight: 700; padding: 6px 12px; border-radius: 30px;
    white-space: nowrap; cursor: pointer; transition: all .12s ease;
}
.filter-chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

/* ---------- Trip list ---------- */
.trip-list { display: grid; gap: 11px; }
.trip-card {
    display: block; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow);
    transition: transform .1s ease, border-color .15s ease;
}
.trip-card:hover { border-color: color-mix(in srgb, var(--brand) 42%, var(--border)); }
.trip-card:active { transform: scale(.99); }
.trip-card.is-archived { opacity: .62; }
.trip-card-top { display: flex; align-items: center; gap: 11px; }
.trip-card-name { display: flex; flex-direction: column; min-width: 0; }
.trip-card-name strong { font-size: 1.04rem; font-weight: 800; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-card-name span { font-size: .8rem; }
.trip-card-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.trip-card-foot { margin-top: 9px; font-size: .8rem; display: flex; align-items: center; gap: 6px; }

/* ---------- Summary ---------- */
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.summary-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 13px 14px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 1px;
}
.summary-box span { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.summary-box strong { font-size: 1.28rem; font-weight: 800; letter-spacing: -.02em; }
.summary-box small { color: var(--muted); font-size: .72rem; }
@media (min-width: 600px) { .summary-grid { grid-template-columns: repeat(4, 1fr); } }

/* Your own position in the trip, called out above the detail. */
.you-box {
    border-radius: var(--radius); padding: 15px 17px; margin: 14px 0;
    border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.you-box.owe { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.you-box.get { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.you-box .label { font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.you-box .value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.you-box.owe .value { color: var(--danger); }
.you-box.get .value { color: var(--ok); }

/* ---------- Plan banner ---------- */
.plan-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    border-radius: var(--radius-sm); padding: 9px 9px 9px 14px; margin-bottom: 14px;
    font-size: .84rem; font-weight: 700;
    border: 1px solid var(--border); background: var(--surface);
}
.plan-banner.trial { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.plan-banner.free { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.plan-banner .btn { flex: 0 0 auto; }

/* ---------- Action row ---------- */
.action-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.action-row .btn { flex: 1 1 auto; font-size: .84rem; }

/* ---------- Rows (members / expenses / users / settlements) ---------- */
.member-list, .expense-list, .user-list, .settle-list { display: grid; gap: 8px; }
.member-row, .user-row, .expense-row, .settle-row {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 11px 13px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 11px; justify-content: space-between;
}
.member-actions, .expense-actions { display: flex; gap: 5px; flex: 0 0 auto; }

/* Balance bar: how far each member sits from square. */
.member-main { min-width: 0; flex: 1 1 auto; }
.member-main strong { font-weight: 700; }
.bal-bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 7px; overflow: hidden; }
.bal-bar i { display: block; height: 100%; border-radius: 3px; }
.bal-bar i.owe { background: var(--danger); }
.bal-bar i.get { background: var(--ok); }
.bal-amt { text-align: end; flex: 0 0 auto; font-weight: 800; letter-spacing: -.01em; }
.bal-amt.owe { color: var(--danger); }
.bal-amt.get { color: var(--ok); }
.bal-amt.zero { color: var(--muted); font-weight: 700; }
.bal-amt small { display: block; font-size: .68rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-items: center; font-size: .76rem; font-weight: 800;
    background: var(--brand-soft); color: var(--brand);
}

/* ---------- Expenses ---------- */
.expense-main { flex: 1 1 auto; min-width: 0; }
.expense-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.expense-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.expense-amt { text-align: end; white-space: nowrap; flex: 0 0 auto; }
.expense-amt strong { font-weight: 800; letter-spacing: -.01em; }
.expense-thumb {
    width: 42px; height: 42px; border-radius: 10px; object-fit: cover; flex: 0 0 auto;
    border: 1px solid var(--border);
}
.placeholder-thumb {
    display: grid; place-items: center; background: var(--brand-soft);
    color: var(--brand); font-size: .9rem; border-color: transparent;
}

/* ---------- Settle up ---------- */
.settle-row { gap: 9px; }
.settle-flow { display: flex; align-items: center; gap: 9px; flex: 1 1 auto; min-width: 0; font-size: .88rem; }
.settle-flow .arrow { color: var(--muted); font-size: .72rem; flex: 0 0 auto; }
.settle-amt { font-weight: 800; color: var(--brand); white-space: nowrap; }
html[dir="rtl"] .settle-flow .arrow { transform: scaleX(-1); }

/* ---------- Split editor (inside the expense modal) ---------- */
.split-people { display: grid; gap: 5px; max-height: 210px; overflow-y: auto; padding: 3px; }
.split-person {
    display: flex; align-items: center; gap: 9px; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-2);
}
.split-person.off { opacity: .45; }
.split-person label { flex: 1 1 auto; margin: 0; cursor: pointer; font-size: .87rem; font-weight: 600; min-width: 0; }
.split-person input[type="checkbox"] { width: 17px; height: 17px; flex: 0 0 auto; }
.split-person input[type="number"] { width: 86px; flex: 0 0 auto; padding: .28rem .45rem; font-size: .84rem; }
.split-person .share-out { font-size: .78rem; font-weight: 700; color: var(--muted); flex: 0 0 auto; }
.split-summary {
    margin-top: 9px; font-size: .8rem; font-weight: 700; padding: 8px 11px;
    border-radius: var(--radius-xs); background: var(--surface-2); color: var(--ink-2);
    display: flex; justify-content: space-between; gap: 10px;
}
.split-summary.bad { background: var(--danger-soft); color: var(--danger); }

.seg { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 3px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
    flex: 1; text-align: center; font-size: .8rem; font-weight: 700; padding: 6px 4px;
    border-radius: 7px; cursor: pointer; color: var(--muted); margin: 0; transition: all .12s ease;
}
.seg input:checked + label { background: var(--brand); color: var(--brand-ink); }

/* ---------- Member picker (trip form) ---------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 7px; }
.member-check {
    display: flex; align-items: center; gap: 9px; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 9px 11px;
    cursor: pointer; font-size: .87rem; transition: all .12s ease;
}
.member-check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }
.member-check input { width: 17px; height: 17px; flex: 0 0 auto; }

.role-badge { font-size: .66rem; font-weight: 800; padding: 2px 8px; border-radius: 30px; margin-inline-start: 6px; text-transform: uppercase; letter-spacing: .04em; }
.role-admin { background: var(--danger-soft); color: var(--danger); }
.role-tripLeader { background: var(--warn-soft); color: var(--warn); }
.role-member { background: var(--brand-soft); color: var(--brand); }

/* ---------- Map / timeline / comments ---------- */
.map-container { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
#planMap { width: 100%; height: 330px; }
:root[data-theme="dark"] .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(.94) contrast(.88); }
:root[data-theme="dark"] .leaflet-container { background: var(--surface-2); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }

.timeline { display: grid; gap: 9px; }
.timeline-item {
    background: var(--surface); border: 1px solid var(--border);
    border-inline-start: 3px solid var(--brand); border-radius: var(--radius-sm);
    padding: 11px 13px; box-shadow: var(--shadow);
}
.comments { display: grid; gap: 8px; }
.comment-box {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 10px 13px; box-shadow: var(--shadow);
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ico {
    width: 62px; height: 62px; border-radius: 20px; margin: 0 auto 14px;
    display: grid; place-items: center; font-size: 1.5rem;
    background: var(--brand-soft); color: var(--brand);
}
.empty-state p { margin: 0 0 16px; font-weight: 600; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: stretch;
    padding-bottom: var(--safe-bottom);
}
.tabbar .tab, .tab-logout button {
    flex: 1; background: none; border: none; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 10px 4px; font-size: .66rem; font-weight: 700;
    text-decoration: none; cursor: pointer; width: 100%;
    transition: color .15s ease;
}
.tabbar .tab i { font-size: 1.08rem; }
.tabbar .tab.active { color: var(--brand); }
.tab-logout { flex: 1; margin: 0; display: flex; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 26px; box-shadow: var(--shadow-lg);
    padding: 34px 28px; width: 100%; max-width: 415px;
}
.auth-logo {
    width: 62px; height: 62px; border-radius: 19px; background: var(--brand); color: var(--brand-ink);
    display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto 15px;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 38%, transparent);
}
.auth-title { text-align: center; font-size: 1.36rem; font-weight: 800; margin-bottom: 22px; letter-spacing: -.02em; }
.auth-hint { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 16px; }
.auth-lang { text-align: center; margin-top: 12px; font-size: .84rem; }
.auth-lang a { text-decoration: none; color: var(--muted); }
.auth-lang a.on { color: var(--brand); font-weight: 800; }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* ==========================================================================
   PUBLIC / MARKETING
   The landing page a visitor sees before signing up. Same tokens as the app,
   so light/dark and RTL come for free.
   ========================================================================== */
body.public { background: var(--bg); }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }
.sec { padding: 68px 18px; }
.band { background: var(--surface); border-block: 1px solid var(--border); padding: 68px 0; }

.sec-title {
    font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 900; letter-spacing: -.03em;
    text-align: center; margin: 0 0 8px;
}
.sec-sub { text-align: center; color: var(--muted); font-weight: 600; margin: 0 0 34px; }

.btn-ghost {
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--border); font-weight: 700;
}
.btn-ghost:hover { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }

/* ---------- Site nav ---------- */
.site-nav {
    position: sticky; top: 0; z-index: 1020;
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.site-nav-inner {
    max-width: 1080px; margin: 0 auto; padding: 11px 18px;
    display: flex; align-items: center; gap: 16px;
}
.site-nav .brand { text-decoration: none; flex: 0 0 auto; }
.site-links { display: none; gap: 20px; margin-inline-start: auto; }
.site-links a { color: var(--ink-2); text-decoration: none; font-size: .88rem; font-weight: 700; }
.site-links a:hover { color: var(--brand); }
.site-actions { display: flex; align-items: center; gap: 7px; margin-inline-start: auto; }
@media (min-width: 900px) {
    .site-links { display: flex; }
    .site-actions { margin-inline-start: 0; }
}
@media (max-width: 560px) { .site-actions .btn-ghost { display: none; } }

/* ---------- Hero ---------- */
.hero { padding: 56px 18px 20px; position: relative; overflow: hidden; }
.hero::before {
    content: ''; position: absolute; inset-inline-start: 50%; top: -220px;
    width: 780px; height: 480px; transform: translateX(-50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--brand) 24%, transparent), transparent);
    pointer-events: none; z-index: 0;
}
.hero-inner { max-width: 780px; margin: 0 auto; text-align: center; position: relative; z-index: 1; }
.hero-badge {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--brand-soft); color: var(--brand);
    font-size: .78rem; font-weight: 800; padding: 6px 14px; border-radius: 30px; margin-bottom: 18px;
}
.hero-title {
    font-size: clamp(1.9rem, 6vw, 3.3rem); font-weight: 900;
    letter-spacing: -.04em; line-height: 1.2; margin: 0 0 16px;
}
.hero-sub {
    font-size: clamp(.96rem, 2vw, 1.1rem); color: var(--ink-2);
    line-height: 1.75; max-width: 620px; margin: 0 auto 26px;
}
.hero-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero-cta .btn { min-width: 190px; }
.hero-note { margin-top: 14px; color: var(--muted); font-size: .82rem; font-weight: 600; }
.hero-note i { color: var(--ok); }

/* Worked example — the product's answer, shown rather than described. */
.hero-demo {
    max-width: 460px; margin: 40px auto 0; text-align: start;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
}
.demo-head { display: flex; gap: 6px; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.demo-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.demo-body { padding: 12px; display: grid; gap: 8px; }
.demo-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: var(--surface-2); border-radius: var(--radius-xs); }
.demo-ava { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: .76rem; flex: 0 0 auto; }
.demo-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.demo-main strong { font-size: .88rem; }
.demo-amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.demo-settle { border: 1px dashed color-mix(in srgb, var(--ok) 45%, transparent); background: var(--ok-soft); border-radius: var(--radius-xs); padding: 11px; margin-top: 2px; }
.demo-settle-label { font-size: .72rem; font-weight: 800; color: var(--ok); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.demo-settle-row { display: flex; align-items: center; gap: 8px; font-size: .86rem; font-weight: 700; padding: 3px 0; }
.demo-settle-row i { color: var(--muted); font-size: .7rem; }
.demo-settle-row strong { margin-inline-start: auto; font-variant-numeric: tabular-nums; color: var(--ok); }

/* ---------- Pain ---------- */
.pain-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .pain-grid { grid-template-columns: repeat(3, 1fr); } }
.pain-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.pain-card i { font-size: 1.3rem; color: var(--danger); margin-bottom: 12px; display: block; }
.pain-card strong { display: block; margin-bottom: 6px; font-size: 1rem; }
.pain-card p { margin: 0; font-size: .88rem; line-height: 1.65; }

/* ---------- Features ---------- */
.feat-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .feat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .feat-grid { grid-template-columns: repeat(4, 1fr); } }
.feat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; transition: border-color .15s ease, transform .12s ease;
}
.feat-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); transform: translateY(-2px); }
.feat-ico {
    width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
    background: var(--brand-soft); color: var(--brand); font-size: 1rem; margin-bottom: 13px;
}
.feat-card strong { display: block; margin-bottom: 6px; font-size: .98rem; }
.feat-card p { margin: 0; font-size: .86rem; line-height: 1.65; }

/* ---------- Steps ---------- */
.steps { display: grid; gap: 14px; grid-template-columns: 1fr; counter-reset: s; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; text-align: center; }
.step-n {
    width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
    background: var(--brand); color: var(--brand-ink); font-weight: 900; margin: 0 auto 13px;
}
.step strong { display: block; margin-bottom: 6px; }
.step p { margin: 0; font-size: .86rem; line-height: 1.65; }

/* ---------- Pricing ---------- */
.bill-toggle {
    display: flex; gap: 4px; justify-content: center; margin: 0 auto 30px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 30px; padding: 4px; width: fit-content;
}
.bill-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.bill-toggle label {
    padding: 8px 20px; border-radius: 30px; cursor: pointer; margin: 0;
    font-size: .85rem; font-weight: 800; color: var(--muted);
    display: inline-flex; align-items: center; gap: 7px; transition: all .14s ease;
}
.bill-toggle input:checked + label { background: var(--brand); color: var(--brand-ink); }
.save-tag { font-size: .65rem; background: var(--ok); color: #fff; padding: 2px 7px; border-radius: 20px; font-weight: 800; }
.bill-toggle input:checked + label .save-tag { background: rgba(255,255,255,.28); }

.price-grid { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 880px) { .price-grid { grid-template-columns: repeat(3, 1fr); } }
.price-card {
    position: relative; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 26px 22px; box-shadow: var(--shadow);
}
.price-card.featured {
    border-color: var(--brand); border-width: 2px;
    box-shadow: 0 12px 40px color-mix(in srgb, var(--brand) 22%, transparent);
}
@media (min-width: 880px) { .price-card.featured { transform: scale(1.035); } }
.price-tag {
    position: absolute; top: -11px; inset-inline-start: 50%; transform: translateX(-50%);
    background: var(--brand); color: var(--brand-ink);
    font-size: .68rem; font-weight: 800; padding: 4px 13px; border-radius: 20px; white-space: nowrap;
}
.price-tag.alt { background: var(--ok); color: #fff; }
html[dir="rtl"] .price-tag { transform: translateX(50%); }
.price-name { font-size: 1.15rem; font-weight: 900; letter-spacing: -.02em; }
.price-for { margin-bottom: 16px; }
.price-amt { display: flex; align-items: baseline; gap: 6px; }
.price-amt .num { font-size: 2.6rem; font-weight: 900; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.price-amt .cur { font-size: .95rem; font-weight: 800; color: var(--muted); }
.price-per { margin-bottom: 18px; }
.price-list { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 9px; }
.price-list li { display: flex; align-items: flex-start; gap: 9px; font-size: .86rem; line-height: 1.5; }
.price-list i { color: var(--ok); font-size: .72rem; margin-top: .32em; flex: 0 0 auto; }

/* ---------- FAQ ---------- */
.faq { max-width: 760px; margin: 0 auto; }
.faq .accordion-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm) !important; margin-bottom: 9px; overflow: hidden; }
.faq .accordion-button { background: var(--bg); color: var(--ink); font-weight: 800; font-size: .95rem; padding: 16px 18px; }
.faq .accordion-button:not(.collapsed) { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.faq .accordion-button:focus { box-shadow: var(--ring); }
.faq .accordion-body { font-size: .89rem; line-height: 1.75; padding: 4px 18px 18px; }
html[dir="rtl"] .faq .accordion-button::after { margin-inline-start: auto; margin-inline-end: 0; }

/* ---------- Closing CTA ---------- */
.cta-box {
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 62%, #000));
    border-radius: 26px; padding: 52px 26px; text-align: center; color: #fff;
}
.cta-box h2 { font-size: clamp(1.4rem, 3.2vw, 2rem); font-weight: 900; letter-spacing: -.03em; margin: 0 0 10px; }
.cta-box p { opacity: .9; margin: 0 0 24px; font-weight: 600; }
.cta-box .btn-light { background: #fff; color: var(--brand); border-color: #fff; font-weight: 800; }
.cta-box .btn-outline-light { border-color: rgba(255,255,255,.55); color: #fff; font-weight: 800; }
.cta-box .btn-outline-light:hover { background: rgba(255,255,255,.16); border-color: #fff; }

/* ---------- Footer ---------- */
.site-foot { background: var(--surface); border-top: 1px solid var(--border); padding: 40px 18px 0; }
.site-foot-inner {
    max-width: 1080px; margin: 0 auto; display: flex; flex-wrap: wrap;
    gap: 24px; justify-content: space-between; padding-bottom: 28px;
}
.foot-links { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.foot-links a { color: var(--ink-2); text-decoration: none; font-size: .86rem; font-weight: 600; }
.foot-links a:hover { color: var(--brand); }
.site-foot-base { max-width: 1080px; margin: 0 auto; border-top: 1px solid var(--border); padding: 16px 0; text-align: center; }

/* ==========================================================================
   CHAT · POLLS · SUGGESTIONS · WEATHER
   ========================================================================== */
.chat-tabs { gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.chat-tabs::-webkit-scrollbar { display: none; }
.chat-tabs .nav-link {
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
    font-size: .8rem; font-weight: 700; padding: 7px 13px; border-radius: 30px; white-space: nowrap;
}
.chat-tabs .nav-link.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
@media (max-width: 460px) { .chat-tabs .nav-link span { display: none; } }

/* ---------- Messages ---------- */
.msg-list {
    display: flex; flex-direction: column; gap: 9px;
    max-height: 56vh; overflow-y: auto; padding: 4px 2px 10px;
}
.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg.own { flex-direction: row-reverse; }
.msg-bubble {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 8px 11px; max-width: 78%;
    box-shadow: var(--shadow);
}
.msg.own .msg-bubble {
    background: var(--brand-soft); border-color: transparent;
    border-end-end-radius: 5px;
}
.msg:not(.own) .msg-bubble { border-end-start-radius: 5px; }
.msg-who { font-size: .72rem; font-weight: 800; color: var(--brand); margin-bottom: 3px; }
.msg-text { font-size: .9rem; line-height: 1.55; word-break: break-word; }
.msg-foot {
    display: flex; align-items: center; gap: 8px; justify-content: flex-end;
    font-size: .66rem; color: var(--muted); margin-top: 3px;
}
.msg-img { max-width: 100%; border-radius: 10px; display: block; cursor: zoom-in; }
.msg-video { max-width: 100%; border-radius: 10px; display: block; }
.msg-audio { display: flex; align-items: center; gap: 8px; }
.msg-audio audio { height: 34px; max-width: 210px; }

/* ---------- Composer ---------- */
.composer {
    position: sticky; bottom: 0; background: var(--bg);
    padding-top: 8px; margin-top: 4px;
}
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer-row .form-control { flex: 1 1 auto; }
.composer-status {
    font-size: .74rem; color: var(--muted); font-weight: 600;
    padding: 5px 4px 0;
}
.icon-btn.rec {
    background: var(--danger); border-color: var(--danger); color: #fff;
    animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Polls ---------- */
.poll-opt {
    position: relative; display: flex; align-items: center; gap: 9px;
    padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-xs);
    background: var(--surface-2); margin-bottom: 6px; cursor: pointer; overflow: hidden;
}
.poll-opt.chosen { border-color: var(--brand); }
.poll-label { flex: 1 1 auto; font-size: .88rem; font-weight: 600; z-index: 1; }
.poll-count { font-size: .78rem; font-weight: 800; color: var(--muted); z-index: 1; }
.poll-opt input { z-index: 1; }
/* The bar sits behind the label rather than beside it, so a long option keeps
   its full width instead of being squeezed by the result. */
.poll-bar {
    position: absolute; inset-inline-start: 0; top: 0; bottom: 0;
    background: var(--brand-soft); z-index: 0; transition: width .25s ease;
}
.poll-opt.chosen .poll-bar { background: color-mix(in srgb, var(--brand) 20%, transparent); }

/* ---------- Suggestions ---------- */
.sugg-row {
    display: flex; align-items: flex-start; gap: 11px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 11px 13px; box-shadow: var(--shadow); margin-bottom: 8px;
}
.sugg-vote { flex: 0 0 auto; }
.sugg-main { flex: 1 1 auto; min-width: 0; }
.vote-btn {
    display: flex; flex-direction: column; align-items: center; gap: 0;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2);
    border-radius: var(--radius-xs); padding: 4px 10px; cursor: pointer; min-width: 44px;
    font-weight: 800; transition: all .12s ease;
}
.vote-btn i { font-size: 1rem; line-height: 1; }
.vote-btn span { font-size: .78rem; }
.vote-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Weather ---------- */
.wx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.wx-day {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 11px 8px; text-align: center;
    box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.wx-date strong { display: block; font-size: .8rem; }
.wx-ico { font-size: 1.35rem; color: var(--brand); margin: 3px 0; }
.wx-desc { font-size: .68rem; line-height: 1.3; min-height: 1.7em; }
.wx-temp strong { font-size: 1rem; }
.wx-temp span { font-size: .8rem; }
.wx-rain { font-size: .68rem; color: var(--brand); font-weight: 700; }

/* ---------- Invite link ---------- */
.share-box { padding: 13px 15px; }
.share-box .form-control { font-size: .78rem; }

.claim-list { display: grid; gap: 7px; }
.claim-name {
    display: flex; align-items: center; gap: 11px; width: 100%;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 11px 13px; cursor: pointer;
    font-weight: 700; font-size: .92rem; color: var(--ink); text-align: start;
    transition: all .12s ease;
}
.claim-name:hover { border-color: var(--brand); background: var(--brand-soft); }
.claim-name span:nth-child(2) { flex: 1 1 auto; }
.claim-name i { font-size: .7rem; }

/* ---------- Auth extras ---------- */
.or-sep { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: .78rem; }
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 9px; }

/* ---------- Country + currency pickers ---------- */
.country-field { position: relative; }
.country-field .flag {
    position: absolute; top: 50%; transform: translateY(-50%);
    inset-inline-start: 11px; pointer-events: none; z-index: 2;
}
.country-field .form-select { padding-inline-start: 50px; }

.cur-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.cur-chip {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0;
    border: 1px solid var(--border); background: var(--surface-2);
    border-radius: 30px; padding: 5px 12px; font-size: .8rem; font-weight: 700;
    transition: all .12s ease;
}
.cur-chip:has(input:checked) {
    background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.cur-chip input { width: 15px; height: 15px; }

/* ==========================================================================
   Print — this IS the PDF export. The browser's own print-to-PDF gives real
   selectable text and correct Arabic shaping, which the old html2canvas
   screenshot could not.
   ========================================================================== */
.report-page { max-width: 820px; margin: 0 auto; padding: 26px 20px 60px; }
.report-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 18px; }
.report-sheet {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow);
}
.report-head { text-align: center; border-bottom: 2px solid var(--brand); padding-bottom: 15px; margin-bottom: 18px; }
.report-head h1 { color: var(--brand); font-size: 1.4rem; font-weight: 800; margin: 0 0 5px; }
.report-head h2 { font-size: 1.12rem; margin: 0; font-weight: 700; }
.report-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px 18px; font-size: .87rem; margin-bottom: 20px; }
.report-meta div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted var(--border); padding-bottom: 4px; }
.report-meta span { color: var(--muted); }
.report-meta strong { font-weight: 700; }

.report-table { width: 100%; border-collapse: collapse; font-size: .85rem; margin-bottom: 20px; }
/* Bootstrap's reboot puts captions under the table; these are section headings. */
.report-table caption {
    caption-side: top; text-align: start; font-weight: 800;
    padding: 8px 0; font-size: .95rem; color: var(--ink);
}
.report-table th {
    background: var(--brand); color: var(--brand-ink); padding: 8px 10px;
    text-align: start; font-weight: 700; font-size: .8rem;
}
.report-table th:last-child, .report-table td:last-child { text-align: end; }
.report-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.report-table tbody tr:nth-child(even) { background: var(--surface-2); }
.report-table .pos { color: var(--ok); font-weight: 700; }
.report-table .neg { color: var(--danger); font-weight: 700; }
.report-foot { font-size: .78rem; color: var(--muted); text-align: center; margin-top: 22px; }

@media print {
    .site-nav, .site-foot { display: none !important; }
    /* Force the light palette: dark tokens burn ink and read badly on paper. */
    :root, :root[data-theme="dark"] {
        color-scheme: light;
        --bg: #fff; --surface: #fff; --surface-2: #f6f7fb;
        --border: #d8dbe6; --ink: #111; --ink-2: #333; --muted: #666;
        --brand: #4f46e5; --brand-ink: #fff; --ok: #047857; --danger: #b91c1c;
        --shadow: none; --shadow-lg: none;
    }
    body { background: #fff; }
    .appbar, .tabbar, .report-toolbar, .no-print { display: none !important; }
    .report-page { padding: 0; max-width: none; }
    .report-sheet { border: none; border-radius: 0; padding: 0; box-shadow: none; }
    .report-table { page-break-inside: auto; }
    .report-table tr { page-break-inside: avoid; page-break-after: auto; }
    .report-table thead { display: table-header-group; }
    a[href]::after { content: none !important; }
    @page { margin: 14mm; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
