@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&family=Josefin+Sans:wght@300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Tajawal:wght@300;500;700;800&display=swap');

:root {
    /* Brand — FacilityOS forest green (#2f6150), the platform's one brand color for
       both the tenant app and the commercial SaaS layer (landing page,
       Super Admin). Status colors (success/warning/danger/info) stay their
       own separate saturated hues on purpose — they carry meaning (SLA
       breach, etc.) that reusing the brand color for status would blur. */
    --brand-primary: #2f6150;
    --brand-primary-dark: #244c40;
    --brand-primary-darker: #1b3a32;
    --brand-primary-light: #e3efe8;
    --brand-primary-contrast: #ffffff;
    --brand-accent: #2f6150;

    /* Surfaces */
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f3f6f4;
    --text: #13211d;
    --text-muted: #6b6b6b;
    --text-faint: #a3a3a3;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;

    /* Semantic */
    --success: #17915a;
    --success-bg: #e4f7ee;
    --warning: #b56a05;
    --warning-bg: #fef3e0;
    --danger: #d6314a;
    --danger-bg: #fce9ec;
    --info: #2f6fed;
    --info-bg: #eaf1fe;

    /* Scale */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-full: 999px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.14);

    --transition: 150ms ease;
    --sidebar-width: 264px;
    --font: 'Fira Sans', -apple-system, "Segoe UI", Roboto, Tahoma, sans-serif;
    /* Display face: thin, geometric, widely tracked — used for the wordmark and large headlines. */
    --font-display: 'Josefin Sans', 'Fira Sans', -apple-system, sans-serif;
    --forest: #1b3a32;
    --sage: #79a891;
    --mint: #e3efe8;
}

/* Dark mode keeps the same green brand, brightened for contrast against
   near-black surfaces (#2f6150 itself reads too dark on #000). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #000000;
        --surface: #0d0d0d;
        --surface-alt: #1a1a1a;
        --text: #f5f5f5;
        --text-muted: #a3a3a3;
        --text-faint: #737373;
        --border: #262626;
        --border-strong: #333333;
        --brand-primary: #7fb59b;
        --brand-primary-dark: #5a9179;
        --brand-primary-darker: #2f6150;
        --brand-primary-light: #14261f;
        --brand-primary-contrast: #0c1713;
        --brand-accent: #7fb59b;
        --success-bg: #0f2a20;
        --warning-bg: #2c2210;
        --danger-bg: #301419;
        --info-bg: #0f1f33;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
        --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
    }
}

:root[data-theme="dark"] {
    --bg: #000000;
    --surface: #0d0d0d;
    --surface-alt: #1a1a1a;
    --text: #f5f5f5;
    --text-muted: #a3a3a3;
    --text-faint: #737373;
    --border: #262626;
    --border-strong: #333333;
    --brand-primary: #7fb59b;
    --brand-primary-dark: #5a9179;
    --brand-primary-darker: #2f6150;
    --brand-primary-light: #14261f;
    --brand-primary-contrast: #0c1713;
    --brand-accent: #7fb59b;
    --success-bg: #0f2a20;
    --warning-bg: #2c2210;
    --danger-bg: #301419;
    --info-bg: #0f1f33;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }

html { overflow-x: clip; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    /* Safety net against any remaining element that overflows its
       container width on a phone screen — every table/grid case we found
       is fixed at the source above, but this stops a stray one from
       widening the whole page and pushing content off-screen. */
    overflow-x: clip;
}

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 var(--space-2); }
h2 { font-size: 1.2rem; margin: var(--space-5) 0 var(--space-3); }

a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-primary-dark); }

hr { border: none; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- App shell */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: var(--space-5) var(--space-3);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    /* Pinned to the viewport: the app shell can be taller than one screen
       (long pages), but the sidebar itself shouldn't scroll away with it —
       only its own nav list scrolls internally if it overflows. */
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text);
    padding: 0 var(--space-2) var(--space-5);
}
.sidebar-brand .logo-mark {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-darker));
    display: flex; align-items: center; justify-content: center;
    color: var(--brand-primary-contrast); font-weight: 800; font-size: .95rem; flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.sidebar-nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; overflow-y: auto; }
.sidebar-section-label {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-faint); padding: var(--space-4) var(--space-3) var(--space-1);
}
.sidebar-section-label:first-child { padding-top: 0; }

.sidebar-nav a {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 9px var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: .88rem; font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.sidebar-nav a svg { flex-shrink: 0; opacity: .85; }

.sidebar-nav a:hover { background: var(--surface-alt); color: var(--text); }
.sidebar-nav a.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary-dark);
    font-weight: 600;
}
[data-theme="dark"] .sidebar-nav a.active,
:root:not([data-theme="light"]) .sidebar-nav a.active { color: var(--brand-primary); }

.main-content { flex: 1; min-width: 0; }

.topbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-5);
    gap: var(--space-4);
    position: sticky; top: 0; z-index: 20;
}

.page-body { padding: var(--space-5); max-width: 1400px; }

/* ---------------------------------------------------------------- Cards & stats */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    /* Grid/flex items default to min-width:auto, which floors their size at
       their content's min-content width — a flex row inside (icon + label +
       badge, none of it wrapping) can easily be wider than the column it's
       supposed to shrink into. Without this, every `grid-template-columns:
       1fr 1fr` card pair in the views (dozens of them, see below) overflows
       the viewport horizontally on a phone instead of actually going 50/50. */
    min-width: 0;
}

a.card { display: block; transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); color: var(--text); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }

.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: var(--space-1);
}
.stat-card .value { font-size: 1.9rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.stat-card .label { color: var(--text-muted); font-size: .82rem; font-weight: 500; }

/* ---------------------------------------------------------------- Page header & empty states */

.page-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.page-header h1 { margin: 0 0 2px; }
.page-header p { margin: 0; color: var(--text-muted); font-size: .88rem; }
.page-header .actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.empty-state {
    text-align: center; padding: var(--space-6) var(--space-4);
    color: var(--text-muted);
}
.empty-state .icon { font-size: 2rem; margin-bottom: var(--space-2); opacity: .6; }
.empty-state p { margin: 0 0 var(--space-3); font-size: .9rem; }

/* ---------------------------------------------------------------- Tables */

table.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .88rem; }
@media (max-width: 900px) {
    /* A handful of views wrap `.data-table` in a `.card` with its own
       `overflow-x:auto`; most don't. Making the table itself scroll (a
       classic `display:block` + `overflow-x:auto` on <table>, leaving
       thead/tbody/tr/td at their normal display) means every table gets a
       horizontal scrollbar on a narrow screen regardless of how its view
       wraps it, instead of silently overflowing the whole page. */
    table.data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
table.data-table th, table.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-alt); }
table.data-table tbody tr { transition: background var(--transition); }
table.data-table tbody tr:hover { background: var(--surface-alt); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------- Badges */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 11px; border-radius: var(--radius-full);
    font-size: .74rem; font-weight: 700; letter-spacing: .01em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------------------------------------------------------------- Buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    background: var(--brand-primary);
    color: var(--brand-primary-contrast);
    border: 1px solid var(--brand-primary);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: .88rem; font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}
/* Buttons are often <a> tags (see .btn on <a href>), and the page's generic
   `a:hover { color: ... }` rule (element+pseudo-class, higher specificity
   than a single .btn class) would otherwise hijack this color and — since
   it happens to equal .btn:hover's background — make the label vanish.
   Naming both classes here (0,2,0 specificity) beats that unconditionally,
   and inverting bg/text is the actual intended hover effect anyway. */
.btn:hover, a.btn:hover {
    background: var(--brand-primary-contrast);
    color: var(--brand-primary);
    box-shadow: var(--shadow-md);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border-strong); box-shadow: none; }
.btn-secondary:hover, a.btn-secondary:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.btn .badge { position: absolute; top: -6px; right: -6px; padding: 1px 6px; font-size: .65rem; }

/* ---------------------------------------------------------------- Forms */

.form-group { margin-bottom: var(--space-4); }
.form-group label { display: block; margin-bottom: var(--space-2); font-size: .82rem; font-weight: 600; color: var(--text); }
.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: .88rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

/* ---------------------------------------------------------------- Alerts */

.alert { padding: 13px 16px; border-radius: var(--radius); margin-bottom: var(--space-4); font-size: .88rem; font-weight: 500; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); }

/* ---------------------------------------------------------------- Auth pages */

/* Deliberately a fixed near-black backdrop in both themes — not built from
   --brand-primary, which flips to white in dark mode and would turn this
   into a glaring white screen instead of reading as "dark". The card itself
   still follows the theme (white in light, near-black in dark). */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top left, #1a1a1a, #000000 65%);
    padding: var(--space-4);
}
.auth-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 44px;
    width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; color: var(--brand-primary); font-size: 1.4rem; font-weight: 800; margin-bottom: var(--space-5); }

/* ---------------------------------------------------------------- Mobile nav */

.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; padding: var(--space-2) var(--space-1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 14px rgba(16, 40, 45, 0.06);
}
.bottom-nav a { display:flex; flex-direction:column; align-items:center; gap:3px; flex:1 1 0; min-width:56px; font-size:.68rem; font-weight:600; color:var(--text-muted); text-align:center; padding:6px 4px; white-space:nowrap; border-radius:var(--radius-sm); }
.bottom-nav a svg { width:21px; height:21px; }
.bottom-nav a:hover, .bottom-nav a.active { color:var(--brand-primary); }
.bottom-nav a.active { background:var(--brand-primary-light); }
.bottom-nav { padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .bottom-nav { display: flex; }
    .page-body { padding-bottom: 84px; }
    .topbar form[action="/search"] { display: none; }
}

/* ---------------------------------------------------------------------
   Phone-width fixes: the views author most two/three-column layouts as
   inline `style="display:grid; grid-template-columns:1fr 1fr"` (there is
   no CSS class for them to hang a media query off), so this collapses
   every one of those — plus the equivalent 3-column form — to a single
   column here via an attribute selector instead of editing 40+ view files
   individually. New inline grids using the same literal pattern are caught
   automatically. `.stat-grid` and any `repeat(auto-fit/auto-fill, minmax(..))`
   grid already reflow on their own and don't need this.
   --------------------------------------------------------------------- */
@media (max-width: 640px) {
    [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }

    .page-body { padding-left: var(--space-3); padding-right: var(--space-3); }

    h1 { font-size: 1.35rem; }

    /* Inline `display:flex; justify-content:space-between` rows (page
       headers with an action button, card title + badge, etc.) are common
       and, unlike the grids above, are usually fine to just wrap instead of
       forcing to a single column — avoids a second attribute-selector rule
       having to special-case every gap/align-items combination in use. */
    [style*="justify-content:space-between"] { flex-wrap: wrap; row-gap: var(--space-2); }

    /* Buttons/inputs at a comfortable touch-target size; the desktop CSS
       sizes them for a mouse cursor. */
    .btn, .form-control, select.form-control { min-height: 44px; }
}

[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border); }

.map-pin { font-size: 1.4rem; line-height: 1; text-align: center; }

/* ==================================================================
   Landing page
   ================================================================== */

.landing { background: var(--bg); color: var(--text); font-family: var(--font); }

.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    max-width: 1240px; margin: 0 auto;
}
.landing-nav .brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 800; font-size: 1.15rem; }
.landing-nav .brand .logo-mark {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-darker));
    display: flex; align-items: center; justify-content: center; color: var(--brand-primary-contrast); font-weight: 800;
}
.landing-nav .links { display: flex; align-items: center; gap: var(--space-5); }
.landing-nav .links a:not(.btn) { color: var(--text-muted); font-weight: 600; font-size: .9rem; }
.landing-nav .links a:not(.btn):hover { color: var(--text); }

.hero {
    position: relative;
    overflow: hidden;
    padding: 88px var(--space-6) 100px;
    background:
        radial-gradient(700px 400px at 15% 0%, var(--brand-primary-light), transparent 60%),
        var(--bg);
}
.hero-inner { max-width: 780px; margin: 0 auto; text-align: center; position: relative; z-index: 1; }
.hero .eyebrow {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--brand-primary-light); color: var(--brand-primary-dark);
    padding: 6px 14px; border-radius: var(--radius-full);
    font-size: .78rem; font-weight: 700; margin-bottom: var(--space-5);
}
.hero h1 {
    font-size: 3rem; line-height: 1.1; margin: 0 0 var(--space-4);
    letter-spacing: -0.03em;
}
.hero h1 span { color: var(--brand-primary); }
.hero p.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 620px; margin: 0 auto var(--space-6); line-height: 1.6; }
.hero-cta { display: flex; gap: var(--space-3); justify-content: center; flex-wrap: wrap; margin-bottom: var(--space-6); }
.hero-cta .btn { padding: 13px 26px; font-size: .95rem; }

.hero-flow {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    flex-wrap: wrap; font-size: .85rem; font-weight: 700; color: var(--text-muted);
    max-width: 720px; margin: 0 auto;
}
.hero-flow .node {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-full);
    padding: 8px 18px; box-shadow: var(--shadow-sm);
}
.hero-flow .arrow { color: var(--text-faint); }

.section { padding: 72px var(--space-6); max-width: 1200px; margin: 0 auto; }
.section-head { text-align: center; max-width: 620px; margin: 0 auto var(--space-6); }
.section-head .kicker { color: var(--brand-primary); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--space-2); }
.section-head h2 { font-size: 2rem; margin: 0 0 var(--space-3); letter-spacing: -0.02em; }
.section-head p { color: var(--text-muted); font-size: 1.02rem; line-height: 1.6; margin: 0; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-5); }
.feature-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-5); box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.feature-card .icon {
    width: 44px; height: 44px; border-radius: var(--radius);
    background: var(--brand-primary-light); color: var(--brand-primary-dark);
    display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-4);
}
.feature-card h3 { margin: 0 0 var(--space-2); font-size: 1.02rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: .88rem; line-height: 1.55; }

.stats-strip {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-5);
    background: linear-gradient(135deg, var(--brand-primary-darker), var(--brand-primary));
    border-radius: var(--radius-lg); padding: var(--space-6); color: var(--brand-primary-contrast);
}
.stats-strip .stat { text-align: center; }
.stats-strip .stat .value { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; }
.stats-strip .stat .label { font-size: .82rem; opacity: .85; margin-top: 4px; }

.roles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.role-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); }
.role-card h3 { margin: 0 0 var(--space-2); font-size: .98rem; display: flex; align-items: center; gap: var(--space-2); }
.role-card p { margin: 0; color: var(--text-muted); font-size: .85rem; line-height: 1.55; }

.cta-banner {
    text-align: center; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 64px var(--space-6); box-shadow: var(--shadow-sm);
}
.cta-banner h2 { font-size: 1.8rem; margin: 0 0 var(--space-3); }
.cta-banner p { color: var(--text-muted); margin: 0 0 var(--space-5); }

.landing-footer {
    border-top: 1px solid var(--border); padding: var(--space-6);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3);
    max-width: 1240px; margin: 0 auto; color: var(--text-muted); font-size: .85rem;
}

/* Problem / solution */
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); align-items: stretch; }
.compare-card { border-radius: var(--radius-lg); padding: var(--space-5); }
.compare-card.problem { background: var(--danger-bg); border: 1px solid var(--danger); }
.compare-card.solution { background: var(--brand-primary-light); border: 1px solid var(--brand-primary); }
.compare-card h3 { margin: 0 0 var(--space-3); font-size: 1.1rem; }
.compare-card ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 8px; font-size: .88rem; color: var(--text); }
.compare-card.problem h3 { color: var(--danger); }
.compare-card.solution h3 { color: var(--brand-primary-darker); }
:root[data-theme="dark"] .compare-card.solution h3 { color: var(--brand-primary); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .compare-card.solution h3 { color: var(--brand-primary); } }

/* Service category cards */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.category-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); text-align: center; font-weight: 600; font-size: .88rem; transition: var(--transition); }
.category-card:hover { border-color: var(--brand-primary); transform: translateY(-2px); }
.category-card .icon { font-size: 1.6rem; display: block; margin-bottom: 6px; }

/* How it works — vertical flow */
.flow-steps { display: flex; flex-direction: column; gap: 0; max-width: 480px; margin: 0 auto; }
.flow-step { display: flex; align-items: flex-start; gap: var(--space-4); padding-bottom: var(--space-5); position: relative; }
.flow-step:not(:last-child)::before { content: ''; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2px; background: var(--border); }
.flow-step .num { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-primary); color: var(--brand-primary-contrast); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .9rem; }
.flow-step .body h4 { margin: 4px 0; font-size: .95rem; }
.flow-step .body p { margin: 0; color: var(--text-muted); font-size: .85rem; }

/* Pricing */
.pricing-toggle { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.pricing-toggle button { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 8px 20px; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--text-muted); }
.pricing-toggle button.active { background: var(--brand-primary); color: var(--brand-primary-contrast); border-color: var(--brand-primary); }
.pricing-toggle .save-badge { font-size: .76rem; font-weight: 700; color: var(--success); background: var(--success-bg); padding: 3px 10px; border-radius: var(--radius-full); }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-4); align-items: start; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.price-card.featured { border: 2px solid var(--brand-primary); box-shadow: var(--shadow-md); position: relative; }
.price-card.featured::before { content: 'Most Popular'; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--brand-primary); color: var(--brand-primary-contrast); font-size: .7rem; font-weight: 800; padding: 4px 12px; border-radius: var(--radius-full); letter-spacing: .03em; }
.price-card h3 { margin: 0; font-size: 1.1rem; }
.price-card .price { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.price-card .price span { font-size: .85rem; font-weight: 500; color: var(--text-muted); }
.price-card .desc { color: var(--text-muted); font-size: .84rem; margin: 0; min-height: 34px; }
.price-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: .84rem; }
.price-card ul li { display: flex; align-items: center; gap: 8px; }
.price-card ul li::before { content: '✓'; color: var(--success); font-weight: 800; }
.price-card .btn { margin-top: auto; text-align: center; }

/* FAQ accordion (native details/summary) */
.faq-list { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-2); }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: .92rem; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '+'; display: inline-block; width: 1em; color: var(--brand-primary); font-weight: 800; }
.faq-item[open] summary::before { content: '−'; }
.faq-item p { margin: var(--space-2) 0 0 1.4em; color: var(--text-muted); font-size: .88rem; line-height: 1.6; }

/* Testimonials */
.testimonial-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--space-4); }
.testimonial-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); }
.testimonial-card .quote { font-size: .92rem; line-height: 1.6; margin: 0 0 var(--space-3); }
.testimonial-card .author { font-weight: 700; font-size: .85rem; }
.testimonial-card .role { color: var(--text-muted); font-size: .8rem; }

/* Auth form pages (register) reusing the landing shell */
.auth-card { max-width: 460px; margin: 40px auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); }
.auth-card h1 { font-size: 1.4rem; margin: 0 0 var(--space-2); }
.auth-card p.lead-sm { color: var(--text-muted); font-size: .88rem; margin: 0 0 var(--space-5); }

@media (max-width: 720px) {
    .compare-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .hero h1 { font-size: 2.1rem; }
    .hero { padding: 56px var(--space-4) 64px; }
    .section { padding: 48px var(--space-4); }
    .landing-nav .links a:not(.btn) { display: none; }
}

/* ==================================================================
   Motion & illustrations
   ================================================================== */

@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes blobFloat { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(20px, -24px) scale(1.05); } 66% { transform: translate(-16px, 14px) scale(0.97); } }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(214, 49, 74, .45); } 70% { box-shadow: 0 0 0 8px rgba(214, 49, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(214, 49, 74, 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drawLine { from { stroke-dashoffset: 240; } to { stroke-dashoffset: 0; } }
@keyframes dotPulse { 0%, 100% { opacity: .4; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.15); } }

@media (prefers-reduced-motion: no-preference) {
    .page-body > *:not(script) { animation: fadeInUp .45s cubic-bezier(.16,.8,.3,1) both; }
    .page-body > *:nth-child(2) { animation-delay: .04s; }
    .page-body > *:nth-child(3) { animation-delay: .08s; }
    .page-body > *:nth-child(4) { animation-delay: .12s; }
    .page-body > *:nth-child(n+5) { animation-delay: .16s; }

    .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s cubic-bezier(.16,.8,.3,1), transform .6s cubic-bezier(.16,.8,.3,1); }
    .reveal.is-visible { opacity: 1; transform: translateY(0); }
    .reveal-stagger.is-visible { transition-delay: calc(var(--reveal-index, 0) * 70ms); }

    .stat-card, .feature-card, .role-card { animation: fadeInUp .5s cubic-bezier(.16,.8,.3,1) both; }
}

.empty-state .icon { display: inline-block; animation: floatY 3.2s ease-in-out infinite; }

.badge-pulse { position: relative; }
.badge-pulse::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    animation: pulseRing 1.8s cubic-bezier(.4,0,.6,1) infinite;
}

.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
    border-top-color: currentColor;
    animation: spin .7s linear infinite; display: inline-block;
}

/* Hero decorative blobs (behind the illustration/content, purely visual) —
   grayscale in a monochrome brand, so kept faint (a soft spotlight rather
   than a colorful smudge). */
.hero-blobs { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; isolation: isolate; }
.hero-blob {
    position: absolute; border-radius: 50%; filter: blur(40px); opacity: .12;
    animation: blobFloat 14s ease-in-out infinite;
}
:root[data-theme="dark"] .hero-blob { opacity: .18; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .hero-blob { opacity: .18; }
}
.hero-blob.b1 { width: 320px; height: 320px; background: var(--brand-primary); top: -80px; left: 6%; }
.hero-blob.b2 { width: 260px; height: 260px; background: var(--brand-accent); top: 40px; right: 8%; animation-duration: 18s; animation-delay: -4s; }
.hero-blob.b3 { width: 200px; height: 200px; background: var(--brand-primary-dark); bottom: -60px; left: 40%; animation-duration: 16s; animation-delay: -8s; }

.hero-illustration { position: relative; z-index: 1; max-width: 560px; margin: 48px auto 0; }
.hero-illustration svg .draw { stroke-dasharray: 240; stroke-dashoffset: 240; animation: drawLine 1.6s ease forwards .3s; }
.hero-illustration svg .dot { animation: dotPulse 2.4s ease-in-out infinite; }
.hero-illustration svg .float { animation: floatY 4s ease-in-out infinite; }

.auth-page { position: relative; overflow: hidden; }
.auth-page .hero-blob { opacity: .25; }
.auth-card { position: relative; z-index: 1; animation: fadeInUp .5s cubic-bezier(.16,.8,.3,1) both; }

.error-illustration { animation: floatY 3.5s ease-in-out infinite; margin-bottom: var(--space-4); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------------------------------------------------------------------
   PWA: install prompt + update-available toast
   --------------------------------------------------------------------- */
.pwa-install-btn {
    position: fixed;
    bottom: 70px;
    right: 16px;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
}

.pwa-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    background: var(--surface-elevated, var(--surface));
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-lg);
    font-size: .875rem;
}

.pwa-toast .btn {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: .8rem;
}

.pwa-ios-hint { flex-wrap: wrap; }

/* ---------------------------------------------------------------------
   Toast notification stack (flash messages + JS-driven feedback)
   --------------------------------------------------------------------- */
.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
}

.toast {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 34px 15px 14px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--border);
    animation: toastIn .35s cubic-bezier(.16,.8,.3,1) both;
}
.toast-success { background: var(--success-bg); color: var(--success); }
.toast-error { background: var(--danger-bg); color: var(--danger); }
.toast span { flex: 1; line-height: 1.4; }
.toast-close {
    position: absolute; top: 6px; right: 8px;
    border: none; background: transparent;
    font-size: 1.05rem; line-height: 1; cursor: pointer;
    color: inherit; opacity: .6; padding: 4px;
    transition: opacity var(--transition);
}
.toast-close:hover { opacity: 1; }
.toast-out { animation: toastOut .3s ease forwards; }
.toast-progress {
    position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
    background: currentColor; opacity: .35;
    animation: toastShrink 5s linear forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(28px) scale(.98); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(28px); } }
@keyframes toastShrink { from { width: 100%; } to { width: 0%; } }

@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
    .toast-progress { animation: none; }
}

/* ---------------------------------------------------------------------
   Micro-interactions: extra hover/press polish
   --------------------------------------------------------------------- */
.stat-card { transition: transform var(--transition), box-shadow var(--transition); }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

table.data-table tbody tr[onclick] { position: relative; }
table.data-table tbody tr[onclick]:hover { box-shadow: inset 3px 0 0 var(--brand-primary); }

.clickable-row {
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    color: var(--text);
}
.clickable-row:hover {
    transform: translateX(3px);
    border-color: var(--brand-primary) !important;
    box-shadow: var(--shadow-sm);
    color: var(--text);
}

/* ---------------------------------------------------------------------
   List / Board view toggle
   --------------------------------------------------------------------- */
.view-toggle {
    display: inline-flex;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
}
.view-toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.view-toggle-btn:hover { color: var(--text); }
.view-toggle-btn.active { background: var(--surface); color: var(--brand-primary); box-shadow: var(--shadow-sm); }

/* ---------------------------------------------------------------------
   Kanban board (Work Orders)
   --------------------------------------------------------------------- */
.kanban-board[hidden], #view-list[hidden] { display: none !important; }

.kanban-board {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    padding-bottom: var(--space-3);
    align-items: flex-start;
}
.kanban-column {
    flex: 0 0 260px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
}
.kanban-column-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    color: var(--text-muted);
    padding: 4px 4px var(--space-3);
}
.kanban-count {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-full);
    min-width: 20px; text-align: center; font-size: .72rem; padding: 1px 6px; color: var(--text-muted);
}
.kanban-column-body { display: flex; flex-direction: column; gap: var(--space-2); min-height: 40px; }
.kanban-empty { text-align: center; color: var(--text-muted); font-size: .78rem; padding: var(--space-3) 0; opacity: .6; }

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition), opacity .15s;
    display: flex; flex-direction: column; gap: 6px;
}
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .4; cursor: grabbing; }
.kanban-card.kanban-card-moving { animation: fadeIn .25s ease; }
.kanban-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-card-property { font-size: .82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-card-assignee { font-size: .76rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kanban-column.drop-allowed { border-color: var(--brand-primary); background: var(--brand-primary-light); }
.kanban-column.drop-disallowed { opacity: .45; }
.kanban-column.drag-over.drop-allowed { background: var(--brand-primary-light); box-shadow: inset 0 0 0 2px var(--brand-primary); }

@media (prefers-reduced-motion: reduce) {
    .kanban-card, .stat-card, .clickable-row { transition: none; }
}

/* ---------------------------------------------------------------------
   Notification bell dropdown
   --------------------------------------------------------------------- */
.notif-wrap { position: relative; }
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 340px; max-width: calc(100vw - 32px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); z-index: 500; overflow: hidden;
    animation: fadeInUp .18s cubic-bezier(.16,.8,.3,1) both;
}
.notif-dropdown-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .85rem;
}
.notif-dropdown-head button {
    background: none; border: none; color: var(--brand-primary);
    font-size: .78rem; font-weight: 600; cursor: pointer; padding: 0; font-family: inherit;
}
.notif-dropdown-head button:hover { text-decoration: underline; }
.notif-dropdown-list { max-height: 360px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border);
    color: var(--text); transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-alt); }
.notif-item-unread { background: var(--surface-alt); }
.notif-item-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: transparent; }
.notif-item-unread .notif-item-dot { background: var(--brand-primary); }
.notif-item-critical .notif-item-dot { background: var(--danger); }
.notif-item-critical .notif-item-title { color: var(--danger); }
.notif-item-warning .notif-item-dot { background: var(--warning); }
.notif-item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-item-title { font-size: .85rem; font-weight: 600; }
.notif-item-message { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item-time { font-size: .72rem; color: var(--text-faint); }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.notif-dropdown-foot {
    display: block; text-align: center; padding: 10px; font-size: .8rem; font-weight: 600;
    border-top: 1px solid var(--border); color: var(--brand-primary);
}
.notif-dropdown-foot:hover { background: var(--surface-alt); }

@media (max-width: 900px) {
    .notif-dropdown { position: fixed; top: 64px; right: 8px; left: 8px; width: auto; }
}

/* ---------------------------------------------------------------------
   Navigation loading bar
   --------------------------------------------------------------------- */
.page-loading-bar {
    position: fixed; top: 0; left: 0; height: 3px; width: 0%;
    background: var(--brand-primary); z-index: 2000; opacity: 0;
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .page-loading-bar { transition: none !important; }
}

/* ---------------------------------------------------------------------
   Report / dashboard chart cards
   --------------------------------------------------------------------- */
.report-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.chart-card h2 { margin: 0 0 var(--space-4); font-size: 1rem; }
.chart-card canvas { max-height: 260px; }

.text-muted { color: var(--text-muted); }

/* ---------------------------------------------------------------------
   Live Operations Map: live panel + status markers (tracking extension)
   --------------------------------------------------------------------- */
.live-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.live-panel-stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4); text-align: center; display: block; color: var(--text);
    transition: transform var(--transition), box-shadow var(--transition);
}
.live-panel-stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text); }
.live-panel-stat .value { font-size: 1.6rem; font-weight: 800; }
.live-panel-stat .label { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.map-dot { border: none !important; background: transparent !important; }
.map-dot span {
    display: block; width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
.map-dot-pulse span { animation: pulseRing 1.8s cubic-bezier(.4,0,.6,1) infinite; }

.map-status-badge {
    display: inline-block; padding: 2px 8px; border-radius: var(--radius-full);
    font-size: .7rem; font-weight: 700; letter-spacing: .02em; margin: 2px 0;
}
.map-popup { font-size: .85rem; line-height: 1.5; min-width: 180px; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }

/* ---------------------------------------------------------------------
   Property Command Center (spec §68)
   --------------------------------------------------------------------- */
.command-center-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--space-4);
}
.command-center-side .live-panel-stat { text-align: left; }
@media (max-width: 900px) {
    .command-center-grid { grid-template-columns: 1fr; }
    .command-center-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); }
    .command-center-side .live-panel-stat { margin-bottom: 0 !important; text-align: center; }
}

/* ---------------------------------------------------------------------------
   Brand mark — every `.logo-mark` (sidebar, admin, auth, landing, register)
   renders the official FacilityOS logo (public/assets/brand/logo-mark.svg)
   instead of a text "F", so the mark changes in one place. The text node is
   kept in the markup for screen readers/no-CSS fallbacks, just hidden.
   --------------------------------------------------------------------------- */
.logo-mark {
    font-size: 0 !important;
    color: transparent !important;
    background: url('/assets/brand/logo-mark.svg') center / contain no-repeat !important;
    box-shadow: none !important;
    border-radius: 9px !important;
    display: inline-block !important;
    width: 34px; height: 34px; flex-shrink: 0;
}
.auth-brand .logo-mark { width: 44px; height: 44px; border-radius: 12px !important; }
.wordmark { font-weight: 800; letter-spacing: -.02em; }
.wordmark b { color: var(--brand-primary); font-weight: 800; }

/* ---------------------------------------------------------------------------
   Mobile app shell (≤900px): the full sidebar becomes a slide-in drawer
   opened from the topbar hamburger or the bottom-nav "Menu" tab, so a phone
   user reaches every module their role can see — not just the 5 tabs.
   --------------------------------------------------------------------------- */
.menu-btn, .sidebar-user, .nav-scrim { display: none; }
.bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1 1 0; min-width: 56px;
    font: inherit; font-size: .68rem; font-weight: 600; color: var(--text-muted);
    background: none; border: 0; padding: 6px 4px; border-radius: var(--radius-sm); cursor: pointer;
}
.bottom-nav button:hover, .bottom-nav button[aria-expanded="true"] { color: var(--brand-primary); }

@media (max-width: 900px) {
    .menu-btn { display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; }
    .topbar {
        position: sticky; top: 0; z-index: 90; gap: var(--space-2);
        padding: var(--space-2) var(--space-3);
        padding-top: calc(var(--space-2) + env(safe-area-inset-top, 0px));
    }
    /* Name + logout live in the drawer on phones; the bar keeps bell, theme and menu. */
    .topbar > div:last-child { margin-left: auto; gap: var(--space-2) !important; }
    .topbar > div:last-child > span,
    .topbar > div:last-child > form { display: none; }
    .topbar > div:first-child:not(.notif-wrap) { font-size: .95rem; }

    .sidebar {
        display: flex !important;
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 210;
        width: min(86vw, 320px); height: 100dvh;
        transform: translateX(-104%); visibility: hidden;
        transition: transform .26s cubic-bezier(.16,.8,.3,1), visibility 0s linear .26s;
        box-shadow: none; overflow-y: auto; overscroll-behavior: contain;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .sidebar.open { transform: none; visibility: visible; transition: transform .26s cubic-bezier(.16,.8,.3,1); box-shadow: var(--shadow-lg); }
    .sidebar-nav { overflow: visible; flex: 1 0 auto; }
    .sidebar-nav a { padding: 12px var(--space-3); font-size: .95rem; }
    .sidebar-user {
        display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
        margin-top: var(--space-4); padding: var(--space-3); border-top: 1px solid var(--border);
        position: sticky; bottom: 0; background: inherit;
    }
    .admin-shell .sidebar-user { border-top-color: rgba(255,255,255,.12); color: #fff; }
    .nav-scrim { display: block; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); }
    .nav-scrim[hidden] { display: none; }
    body.menu-open { overflow: hidden; }

    /* Tables scroll inside their card instead of stretching the page. */
    .card:has(> table), .card:has(> .data-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 560px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
    .page-header .actions { width: 100%; }
    .page-header .actions .btn { flex: 1 1 auto; }
    .notif-dropdown { position: fixed; left: var(--space-3); right: var(--space-3); top: 60px; width: auto; max-width: none; }
}

/* Landing page mobile menu */
.landing-burger { display: none; padding: 0 12px; }
.landing-drawer { display: none; }
@media (max-width: 720px) {
    .landing-nav { position: sticky; top: 0; z-index: 100; background: var(--bg); gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
    .landing-nav .links { display: none; }
    .landing-burger { display: inline-flex; align-items: center; margin-left: auto; }
    .landing-drawer:not([hidden]) {
        display: flex; flex-direction: column; gap: var(--space-1);
        position: sticky; top: 61px; z-index: 99; background: var(--bg);
        padding: var(--space-3) var(--space-4) var(--space-4); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-md);
    }
    .landing-drawer a:not(.btn) { padding: 13px 4px; font-weight: 600; border-bottom: 1px solid var(--border); color: var(--text); }
    .landing-drawer .btn { margin-top: var(--space-3); text-align: center; }
}

/* Typography: Josefin Sans (light, geometric, tracked) for display; Fira Sans for everything else. */
.wordmark, .display, .hero h1, .section-title, .landing h1, .landing h2.display { font-family: var(--font-display); }
.wordmark { font-weight: 300; letter-spacing: .14em; text-transform: uppercase; }
.wordmark b { font-weight: 700; }
.eyebrow-caps { text-transform: uppercase; letter-spacing: .22em; font-size: .72rem; font-weight: 500; }

/* ---- Smart insights panel ------------------------------------------------ */
.smart-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); margin-bottom: var(--space-5); border-left: 4px solid var(--brand-primary); }
.smart-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.smart-head h2 { margin: 0; font-size: 1rem; }
.smart-spark { color: var(--brand-primary); }
.smart-clear { margin: 0; color: var(--success); font-weight: 600; }
.smart-list { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.smart-item { display: flex; align-items: center; gap: var(--space-3); padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: inherit; transition: border-color var(--transition), transform var(--transition); }
.smart-item:hover { border-color: var(--brand-primary); transform: translateX(2px); }
.smart-badge { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.smart-item.danger .smart-badge { background: var(--danger-bg); color: var(--danger); }
.smart-item.warning .smart-badge { background: var(--warning-bg); color: var(--warning); }
.smart-item.info .smart-badge { background: var(--info-bg); color: var(--info); }
.smart-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.smart-text strong { font-size: .9rem; } .smart-text small { color: var(--text-muted); font-size: .78rem; }
.smart-go { color: var(--text-faint); }
@media (max-width: 640px) { .smart-list { grid-template-columns: 1fr; } }

/* ---- Command palette ------------------------------------------------------- */
.cmdk { position: fixed; inset: 0; z-index: 400; background: rgba(8, 20, 16, .55); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 12vh var(--space-3) 0; }
.cmdk[hidden] { display: none; }
.cmdk-box { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.cmdk-input { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 16px 18px; outline: none; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 11px 12px; border-radius: var(--radius); color: var(--text); }
.cmdk-item small { color: var(--text-faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.cmdk-item.active, .cmdk-item:hover { background: var(--brand-primary-light); color: var(--brand-primary-dark); }
.cmdk-empty { padding: 20px; text-align: center; color: var(--text-muted); }
.cmdk-foot { display: flex; gap: var(--space-4); padding: 9px 14px; border-top: 1px solid var(--border); font-size: .72rem; color: var(--text-faint); }
.cmdk-hint { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: .8rem; }
.cmdk-hint kbd { font: inherit; font-size: .7rem; border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px; background: var(--surface-alt); }
@media (max-width: 900px) { .cmdk-hint { display: none; } }
.cmdk-hint { white-space: nowrap; }
.topbar > div:last-child > span { white-space: nowrap; }

/* ===========================================================================
   Design system v2 — one consistent, calmer visual language for every
   management screen (headers, cards, tables, forms, buttons, badges, alerts).
   Loaded last so it refines the base rules above for all views at once.
   =========================================================================== */

/* Page headers: every screen opens the same way (a bare h1 counts too). */
.page-body { padding: var(--space-6); max-width: 1480px; margin: 0 auto; }
.page-header, .page-body > h1:first-child { margin-bottom: var(--space-5); }
.page-header { align-items: flex-end; padding-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.page-header h1, .page-body > h1:first-child { font-size: 1.65rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.page-header h1::after { content: ""; display: block; width: 36px; height: 3px; border-radius: 2px; margin-top: 10px; background: var(--brand-primary); }
.page-header p { margin-top: 8px; font-size: .92rem; max-width: 70ch; }
.page-body h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; }
.page-body > h2 { margin: var(--space-6) 0 var(--space-3); }

/* Cards */
.card { border-color: var(--border); box-shadow: 0 1px 2px rgba(19, 33, 29, .04), 0 8px 24px -16px rgba(19, 33, 29, .12); }
a.card { transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); }
a.card:hover { border-color: var(--sage); transform: translateY(-2px); box-shadow: 0 14px 32px -18px rgba(27, 58, 50, .35); }
.stat-card { border-left: 3px solid var(--brand-primary); }
.stat-card .value { letter-spacing: -.02em; }
.stat-card .label { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 600; }

/* Tables: quiet header, comfortable rows, tabular numbers, clear hover */
.card:has(> table.data-table), .card:has(> .data-table) { padding: 0; overflow: hidden; }
table.data-table { font-variant-numeric: tabular-nums; }
table.data-table th { background: var(--surface); border-bottom: 1px solid var(--border-strong); font-size: .7rem; font-weight: 600; letter-spacing: .1em; color: var(--text-muted); padding: 13px 16px; white-space: nowrap; }
table.data-table td { padding: 13px 16px; vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--brand-primary-light); }
table.data-table td:first-child a, table.data-table td:first-child strong { font-weight: 600; }
table.data-table td[colspan] { text-align: center; padding: 36px 16px; color: var(--text-muted); font-size: .9rem; }
table.data-table th[data-sort] { cursor: pointer; user-select: none; }
table.data-table th[data-sort]:hover { color: var(--brand-primary); }
table.data-table th[data-sort]::after { content: " ↕"; opacity: .35; }
table.data-table th[data-sort="asc"]::after { content: " ↑"; opacity: 1; color: var(--brand-primary); }
table.data-table th[data-sort="desc"]::after { content: " ↓"; opacity: 1; color: var(--brand-primary); }
.table-tools { display: flex; align-items: center; gap: var(--space-3); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.table-tools input { flex: 1; max-width: 340px; min-height: 36px; }
.table-tools .count { margin-left: auto; font-size: .78rem; color: var(--text-muted); white-space: nowrap; }

/* Forms */
.form-group { margin-bottom: var(--space-4); }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.form-control { border-color: var(--border-strong); border-radius: var(--radius); transition: border-color var(--transition), box-shadow var(--transition); }
.form-control:hover { border-color: var(--sage); }
.form-control:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 22%, transparent); outline: none; }

/* Buttons */
.btn { font-weight: 600; letter-spacing: .005em; border-radius: var(--radius); }
.btn:not(.btn-secondary):not(.btn-danger) { background: linear-gradient(180deg, var(--brand-primary), var(--brand-primary-dark)); }
.btn:not(.btn-secondary):hover { box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand-primary) 60%, transparent); }
.btn-danger { background: var(--danger); color: #fff; border: 0; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: .8rem; }

/* Badges & alerts */
.badge-info { background: var(--info-bg); color: var(--info); }
.alert { border-left: 4px solid currentColor; box-shadow: var(--shadow-sm); }

/* Sidebar polish */
.sidebar-section-label { letter-spacing: .16em; font-size: .66rem; }
.sidebar-nav a { position: relative; }
.sidebar-nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-primary); }
.topbar { backdrop-filter: saturate(1.4) blur(8px); background: color-mix(in srgb, var(--surface) 88%, transparent); }

@media (max-width: 900px) {
    .page-body { padding: var(--space-4) var(--space-3) 96px; }
    .page-header h1, .page-body > h1:first-child { font-size: 1.35rem; }
}

/* Endorsement line: "by idiibi & FUM" — idiibi brings the intelligence, FUM the management. */
.lockup { display: inline-flex; flex-direction: column; line-height: 1.05; }
.byline { font-family: var(--font); font-size: .56rem; font-weight: 500; text-transform: uppercase; letter-spacing: .26em; color: var(--sage); margin-top: 4px; white-space: nowrap; }
.auth-brand .lockup { align-items: center; }
.sidebar-brand .byline { color: var(--text-faint); }
.admin-shell .sidebar-brand .byline, .landing-nav .byline, .lp-footer .byline { color: var(--sage); }

/* ===========================================================================
   Arabic / RTL. The document gets dir="rtl" lang="ar" from I18n; flex and grid
   layouts mirror on their own, so this only fixes what is physically
   positioned (sidebar edge, drawer, left/right paddings) and swaps in an
   Arabic type pair that matches the brand's light/geometric + clear-text
   pairing (Tajawal for display, IBM Plex Sans Arabic for text).
   =========================================================================== */
html[lang="ar"] {
    --font: 'IBM Plex Sans Arabic', 'Fira Sans', 'Segoe UI', Tahoma, sans-serif;
    --font-display: 'Tajawal', 'IBM Plex Sans Arabic', 'Segoe UI', sans-serif;
}
/* Tracking breaks Arabic letter-joining, so it is switched off entirely. */
html[lang="ar"] *, html[lang="ar"] *::before, html[lang="ar"] *::after { letter-spacing: 0 !important; }
html[lang="ar"] .wordmark { text-transform: none; }
html[lang="ar"] .byline, html[lang="ar"] .lp-caps, html[lang="ar"] .sidebar-section-label, html[lang="ar"] table.data-table th { text-transform: none; }
html[lang="ar"] .lp-hero h1, html[lang="ar"] .lp-head h2, html[lang="ar"] .lp-display { font-weight: 700; line-height: 1.25; }
html[lang="ar"] .lp-hero h1 b, html[lang="ar"] .lp-head h2 b { font-weight: 800; }

html[dir="rtl"] body { text-align: start; }
html[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
html[dir="rtl"] .sidebar-nav a.active::before { left: auto; right: -12px; border-radius: 3px 0 0 3px; }
html[dir="rtl"] table.data-table th, html[dir="rtl"] table.data-table td { text-align: right; }
html[dir="rtl"] .command-center-side .live-panel-stat { text-align: right; }
html[dir="rtl"] .smart-item:hover { transform: translateX(-2px); }
html[dir="rtl"] .smart-panel { border-left: 1px solid var(--border); border-right: 4px solid var(--brand-primary); }
html[dir="rtl"] .stat-card { border-left: 1px solid var(--border); border-right: 3px solid var(--brand-primary); }
html[dir="rtl"] .alert { border-left: 0; border-right: 4px solid currentColor; }
html[dir="rtl"] .table-tools .count { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .cmdk-hint, html[dir="rtl"] .topbar > div:last-child { margin-left: 0; }
html[dir="rtl"] .page-header h1::after { margin-right: 0; }
/* Values that are inherently left-to-right stay readable inside RTL forms. */
html[dir="rtl"] input[type="email"], html[dir="rtl"] input[type="url"], html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="number"], html[dir="rtl"] input[type="password"], html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="time"], html[dir="rtl"] code, html[dir="rtl"] .mono { direction: ltr; text-align: right; }
html[dir="rtl"] .logo-mark { margin: 0; }
html[dir="rtl"] .lockup { align-items: flex-start; }

/* Mobile drawer opens from the right edge. */
@media (max-width: 900px) {
    html[dir="rtl"] .sidebar { left: auto; right: 0; transform: translateX(104%); }
    html[dir="rtl"] .sidebar.open { transform: none; }
    html[dir="rtl"] .topbar > div:last-child { margin-right: auto; margin-left: 0; }
}

/* Marketing site. */
html[dir="rtl"] .landing-nav .links, html[dir="rtl"] .lp-cta, html[dir="rtl"] .lp-trust { direction: rtl; }
html[dir="rtl"] .lp-trust span::before { margin-right: 0; margin-left: 7px; }
html[dir="rtl"] .lp-role li::before { margin-right: 0; margin-left: 9px; }
html[dir="rtl"] .lp-demo li::before { margin-right: 0; margin-left: 10px; }
html[dir="rtl"] .lp-chip.c1 { left: auto; right: -26px; }
html[dir="rtl"] .lp-chip.c2 { right: auto; left: -18px; }
html[dir="rtl"] .lp-shape.s1 { right: auto; left: -210px; }
html[dir="rtl"] .lp-shape.s2 { right: auto; left: 190px; }
html[dir="rtl"] .lp-shape.s3 { right: auto; left: -120px; }
html[dir="rtl"] .lp-row em { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .lp-quote .lp-shape { right: auto !important; left: -70px; }
html[dir="rtl"] .lp-role::after { right: auto; left: -50px; }
.lang-switch { font-weight: 600; white-space: nowrap; }
.landing-nav .lang-switch { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .btn { white-space: nowrap; }
