/*
  Beni for web - iOS design system
  ---------------------------------
  Ports the visual language of Beni.iOS to the browser: system font stack, iOS
  system colours, inset-grouped lists, translucent bars, sheet presentation and
  spring-like easing. Everything is driven by custom properties so light and dark
  are a single palette swap and the whole app reacts to the appearance toggle.
*/

/* ── Palette ─────────────────────────────────────────────────────────────── */

:root {
    /* iOS system colours (light) */
    --ios-blue: #007aff;
    --ios-green: #34c759;
    --ios-indigo: #5856d6;
    --ios-orange: #ff9500;
    --ios-pink: #ff2d55;
    --ios-purple: #af52de;
    --ios-red: #ff3b30;
    --ios-teal: #30b0c7;
    --ios-cyan: #32ade6;
    --ios-yellow: #ffcc00;
    --ios-mint: #00c7be;
    --ios-brown: #a2845e;

    /* Backgrounds */
    --bg-grouped: #f2f2f7;
    --bg-grouped-secondary: #ffffff;
    --bg-base: #ffffff;
    --bg-elevated: #ffffff;
    --bg-bar: rgba(249, 249, 249, .82);
    --bg-sheet-scrim: rgba(0, 0, 0, .4);

    /* Fills */
    --fill-primary: rgba(120, 120, 128, .2);
    --fill-secondary: rgba(120, 120, 128, .16);
    --fill-tertiary: rgba(118, 118, 128, .12);
    --fill-quaternary: rgba(116, 116, 128, .08);

    /* Labels */
    --label: #000000;
    --label-secondary: rgba(60, 60, 67, .6);
    --label-tertiary: rgba(60, 60, 67, .3);
    --label-quaternary: rgba(60, 60, 67, .18);
    --label-inverted: #ffffff;

    --separator: rgba(60, 60, 67, .29);
    --separator-opaque: #c6c6c8;

    /* Shape + motion */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-pill: 999px;

    --shadow-card: 0 2px 8px rgba(0, 0, 0, .08);
    --shadow-raised: 0 4px 16px rgba(0, 0, 0, .10);
    --shadow-sheet: 0 -4px 32px rgba(0, 0, 0, .22);

    --ease-ios: cubic-bezier(.32, .72, 0, 1);
    --ease-spring: cubic-bezier(.34, 1.36, .64, 1);
    --dur-fast: .18s;
    --dur-base: .26s;
    --dur-slow: .38s;

    /* Layout metrics matching the native chrome */
    --navbar-h: 52px;
    --tabbar-h: 60px;
    --content-max: 1080px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    color-scheme: light;
}

/* Dark palette. `data-theme` is stamped by the appearance toggle and always wins
   over the media query so an explicit choice is never overridden by the OS. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ios-blue: #0a84ff;
        --ios-green: #30d158;
        --ios-indigo: #5e5ce6;
        --ios-orange: #ff9f0a;
        --ios-pink: #ff375f;
        --ios-purple: #bf5af2;
        --ios-red: #ff453a;
        --ios-teal: #40c8e0;
        --ios-cyan: #64d2ff;
        --ios-yellow: #ffd60a;
        --ios-mint: #66d4cf;
        --ios-brown: #ac8e68;

        --bg-grouped: #000000;
        --bg-grouped-secondary: #1c1c1e;
        --bg-base: #000000;
        --bg-elevated: #1c1c1e;
        --bg-bar: rgba(28, 28, 30, .82);
        --bg-sheet-scrim: rgba(0, 0, 0, .6);

        --fill-primary: rgba(120, 120, 128, .36);
        --fill-secondary: rgba(120, 120, 128, .32);
        --fill-tertiary: rgba(118, 118, 128, .24);
        --fill-quaternary: rgba(118, 118, 128, .18);

        --label: #ffffff;
        --label-secondary: rgba(235, 235, 245, .6);
        --label-tertiary: rgba(235, 235, 245, .3);
        --label-quaternary: rgba(235, 235, 245, .18);
        --label-inverted: #000000;

        --separator: rgba(84, 84, 88, .6);
        --separator-opaque: #38383a;

        --shadow-card: 0 2px 10px rgba(0, 0, 0, .5);
        --shadow-raised: 0 4px 20px rgba(0, 0, 0, .6);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --ios-blue: #0a84ff;
    --ios-green: #30d158;
    --ios-indigo: #5e5ce6;
    --ios-orange: #ff9f0a;
    --ios-pink: #ff375f;
    --ios-purple: #bf5af2;
    --ios-red: #ff453a;
    --ios-teal: #40c8e0;
    --ios-cyan: #64d2ff;
    --ios-yellow: #ffd60a;
    --ios-mint: #66d4cf;
    --ios-brown: #ac8e68;

    --bg-grouped: #000000;
    --bg-grouped-secondary: #1c1c1e;
    --bg-base: #000000;
    --bg-elevated: #1c1c1e;
    --bg-bar: rgba(28, 28, 30, .82);
    --bg-sheet-scrim: rgba(0, 0, 0, .6);

    --fill-primary: rgba(120, 120, 128, .36);
    --fill-secondary: rgba(120, 120, 128, .32);
    --fill-tertiary: rgba(118, 118, 128, .24);
    --fill-quaternary: rgba(118, 118, 128, .18);

    --label: #ffffff;
    --label-secondary: rgba(235, 235, 245, .6);
    --label-tertiary: rgba(235, 235, 245, .3);
    --label-quaternary: rgba(235, 235, 245, .18);
    --label-inverted: #000000;

    --separator: rgba(84, 84, 88, .6);
    --separator-opaque: #38383a;

    --shadow-card: 0 2px 10px rgba(0, 0, 0, .5);
    --shadow-raised: 0 4px 20px rgba(0, 0, 0, .6);

    color-scheme: dark;
}

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

/* ── Base ────────────────────────────────────────────────────────────────── */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.4;
    letter-spacing: -.01em;
    color: var(--label);
    background: var(--bg-grouped);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: none;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -.022em;
}

p {
    margin: 0;
}

a {
    color: var(--ios-blue);
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
    display: block;
}

::selection {
    background: color-mix(in srgb, var(--ios-blue) 26%, transparent);
}

/* iOS-style thin scrollbars that stay out of the way on desktop. */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--label-quaternary) transparent;
}

*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--label-quaternary);
    border-radius: var(--r-pill);
}

/*
  Icon base size.

  An inline <svg> that only declares a viewBox has no intrinsic CSS size, so inside a
  flex container it resolves to zero width and the glyph vanishes. Every icon therefore
  gets a default box here; the context-specific rules further down (.tab svg, .btn svg,
  .row__icon svg, …) are more specific and override it where a precise size matters.
*/
.icon {
    width: 1.25em;
    height: 1.25em;
    flex: 0 0 auto;
}

/* Bare icon buttons and text buttons: sized explicitly so navigation-bar actions,
   sheet close buttons and inline clear buttons keep a consistent hit target. */
.icon-btn svg { width: 22px; height: 22px; }
.text-btn svg { width: 18px; height: 18px; }
.segmented__icon { width: 15px; height: 15px; margin-right: 4px; }
.feature-icon { width: 13px; height: 13px; }
.lightbox__close svg,
.lightbox__nav svg { width: 20px; height: 20px; }

/* ── Typography scale (mirrors the SwiftUI text styles) ──────────────────── */

.t-large-title { font-size: 34px; font-weight: 700; letter-spacing: -.026em; }
.t-title1 { font-size: 28px; font-weight: 700; letter-spacing: -.024em; }
.t-title2 { font-size: 22px; font-weight: 700; letter-spacing: -.022em; }
.t-title3 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.t-headline { font-size: 17px; font-weight: 600; letter-spacing: -.014em; }
.t-body { font-size: 17px; font-weight: 400; }
.t-callout { font-size: 16px; font-weight: 400; }
.t-subhead { font-size: 15px; font-weight: 400; }
.t-footnote { font-size: 13px; font-weight: 400; }
.t-caption { font-size: 12px; font-weight: 400; }
.t-caption2 { font-size: 11px; font-weight: 400; }
.t-rounded { font-family: -apple-system, "SF Pro Rounded", ui-rounded, "Segoe UI Variable Display", system-ui, sans-serif; }
.t-mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }

.c-secondary { color: var(--label-secondary); }
.c-tertiary { color: var(--label-tertiary); }
.c-blue { color: var(--ios-blue); }
.c-green { color: var(--ios-green); }
.c-red { color: var(--ios-red); }
.c-orange { color: var(--ios-orange); }
.c-purple { color: var(--ios-purple); }
.c-teal { color: var(--ios-teal); }

.w-medium { font-weight: 500; }
.w-semibold { font-weight: 600; }
.w-bold { font-weight: 700; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ── App shell ───────────────────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--bg-grouped);
}

.app-shell__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    /* Leave room for the fixed tab bar plus the home-indicator inset. */
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
}

.app-content {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 16px;
}

.app-content--flush {
    padding: 0;
}

/* Navigation bar: translucent, sticky, with the large-title collapse behaviour. */
.navbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding-top: var(--safe-top);
    background: var(--bg-bar);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: .5px solid var(--separator);
    transition: border-color var(--dur-fast) ease;
}

.navbar--transparent {
    border-bottom-color: transparent;
}

.navbar__row {
    height: var(--navbar-h);
    display: grid;
    grid-template-columns: minmax(44px, auto) 1fr minmax(44px, auto);
    align-items: center;
    gap: 4px;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 8px;
}

.navbar__title {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.014em;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.navbar__side {
    display: flex;
    align-items: center;
    gap: 2px;
}

.navbar__side--trailing {
    justify-content: flex-end;
}

.beni-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    color: var(--label);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.025em;
}

.beni-brand img {
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 9px;
}

.navbar__brand {
    flex: 0 0 auto;
}

.navbar__brand img {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.navbar__large-title {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 2px 16px 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-pill);
    color: var(--ios-blue);
    transition: background var(--dur-fast) ease, transform var(--dur-fast) var(--ease-spring);
}

.icon-btn:hover:not(:disabled) { background: var(--fill-quaternary); }
.icon-btn:active:not(:disabled) { transform: scale(.9); }
.icon-btn:disabled { color: var(--label-tertiary); cursor: not-allowed; }

.icon-btn--label { color: var(--label); }

.text-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 0 8px;
    font-size: 17px;
    color: var(--ios-blue);
    border-radius: var(--r-sm);
    transition: background var(--dur-fast) ease, opacity var(--dur-fast) ease;
}

.text-btn:hover:not(:disabled) { background: var(--fill-quaternary); }
.text-btn:disabled { color: var(--label-tertiary); cursor: not-allowed; }
.text-btn--strong { font-weight: 600; }
.text-btn--destructive { color: var(--ios-red); }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */

/*
  Phones preserve the native layout. Wider screens use the available width to expose
  every destination without horizontal scrolling.
*/
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    padding-bottom: var(--safe-bottom);
    background: var(--bg-bar);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--separator);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, .06);
}

.tabbar__row {
    height: var(--tabbar-h);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr);
    align-items: stretch;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 max(4px, var(--safe-left)) 0 max(4px, var(--safe-right));
}

.tabbar__group {
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    color: var(--label-secondary);
    border-radius: var(--r-md);
    transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}

.tab svg { width: 24px; height: 24px; }

.tab__label {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: -.005em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tab:hover { color: var(--label); }

.tab.is-active {
    color: var(--ios-blue);
    background: color-mix(in srgb, var(--ios-blue) 10%, transparent);
}

.tab-fab-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-fab {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--ios-blue) 92%, white),
        var(--ios-blue));
    box-shadow: 0 4px 12px color-mix(in srgb, var(--ios-blue) 40%, transparent);
    transition: transform var(--dur-fast) var(--ease-spring), filter var(--dur-fast) ease;
}

.tab-fab svg { width: 26px; height: 26px; }
.tab-fab:active { transform: scale(.9); }
.tab-fab:disabled { filter: grayscale(1); opacity: .5; cursor: not-allowed; }

/* ── Side menu ───────────────────────────────────────────────────────────── */

.side-menu {
    position: fixed;
    inset: 0 auto 0 0;
    width: 300px;
    max-width: 86vw;
    z-index: 70;
    display: flex;
    flex-direction: column;
    background: var(--bg-grouped-secondary);
    box-shadow: 4px 0 32px rgba(0, 0, 0, .25);
    transform: translateX(-101%);
    transition: transform var(--dur-base) var(--ease-ios);
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    overflow-y: auto;
}

.side-menu.is-open { transform: translateX(0); }

.side-menu__brand {
    margin: 14px 20px 2px;
    width: fit-content;
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--bg-sheet-scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-base) ease;
}

.scrim.is-open {
    opacity: 1;
    pointer-events: auto;
}

.side-menu__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: .5px solid var(--separator);
}

.side-menu__section {
    padding: 12px 12px 4px;
}

.side-menu__section-title {
    padding: 0 8px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--label-tertiary);
}

.side-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 8px;
    border-radius: var(--r-md);
    color: var(--label);
    text-align: left;
    transition: background var(--dur-fast) ease;
}

.side-menu__item:hover { background: var(--fill-quaternary); }
.side-menu__item.is-active { background: color-mix(in srgb, var(--ios-blue) 12%, transparent); }
.side-menu__item svg { width: 20px; height: 20px; }

/* ── Inset-grouped lists ─────────────────────────────────────────────────── */

.list-group {
    margin: 0 0 24px;
}

.list-group__header {
    padding: 0 16px 7px;
    font-size: 13px
;
    color: var(--label-secondary);
}

.list-group__header--plain {
    font-size: 13px;
    font-weight: 600;
    color: var(--label-secondary);
}

.list-group__footer {
    padding: 7px 16px 0;
    font-size: 13px;
    color: var(--label-secondary);
}

.list-card {
    background: var(--bg-grouped-secondary);
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 11px 16px;
    color: var(--label);
    text-align: left;
    background: transparent;
    position: relative;
    transition: background var(--dur-fast) ease;
}

.row + .row::before {
    content: "";
    position: absolute;
    top: 0;
    left: 16px;
    right: 0;
    height: .5px;
    background: var(--separator);
}

/* Rows that carry a leading icon align their separator past the icon, like iOS. */
.row--icon + .row--icon::before { left: 60px; }

a.row:hover,
button.row:hover { background: var(--fill-quaternary); }

a.row:active,
button.row:active { background: var(--fill-tertiary); }

.row__icon {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.row__icon svg { width: 18px; height: 18px; }

.row__icon--lg {
    width: 44px;
    height: 44px;
    border-radius: 10px;
}

.row__icon--lg svg { width: 21px; height: 21px; }

.row__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.row__title {
    font-size: 17px;
    letter-spacing: -.014em;
}

.row__subtitle {
    font-size: 13px;
    color: var(--label-secondary);
}

.row__trailing {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 17px;
    color: var(--label-secondary);
    text-align: right;
}

.row__chevron {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    color: var(--label-tertiary);
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-grouped-secondary);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.card--pad { padding: 16px; }

.card--tap {
    display: block;
    width: 100%;
    text-align: left;
    color: inherit;
    transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.card--tap:hover { box-shadow: var(--shadow-raised); }
.card--tap:active { transform: scale(.985); }

/* Gradient stat cards, ported from StatCard.swift / MiniStatCard */
.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 110px;
    padding: 16px 8px;
    border-radius: var(--r-lg);
    color: #fff;
    text-align: center;
    overflow: hidden;
    isolation: isolate;
    transition: transform var(--dur-fast) var(--ease-spring);
}

.stat-card:active { transform: scale(.97); }

.stat-card::after {
    /* Soft highlight blob matching the blurred decorative circle on iOS. */
    content: "";
    position: absolute;
    top: -28px;
    right: -14px;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    filter: blur(10px);
    z-index: -1;
}

.stat-card svg { width: 24px; height: 24px; }

.stat-card__value {
    font-family: -apple-system, "SF Pro Rounded", ui-rounded, system-ui, sans-serif;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card__label {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, .92);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grad-blue { background: linear-gradient(135deg, #3366e6, #669aff); box-shadow: 0 8px 18px rgba(51, 102, 230, .3); }
.grad-orange { background: linear-gradient(135deg, #f28033, #ffb266); box-shadow: 0 8px 18px rgba(242, 128, 51, .3); }
.grad-purple { background: linear-gradient(135deg, #9a4ce6, #cc80ff); box-shadow: 0 8px 18px rgba(154, 76, 230, .3); }
.grad-green { background: linear-gradient(135deg, #33b366, #66d999); box-shadow: 0 8px 18px rgba(51, 179, 102, .3); }
.grad-red { background: linear-gradient(135deg, #e64d4d, #ff8080); box-shadow: 0 8px 18px rgba(230, 77, 77, .3); }
.grad-teal { background: linear-gradient(135deg, #1f9aad, #5cc9d9); box-shadow: 0 8px 18px rgba(31, 154, 173, .3); }
.grad-money { background: linear-gradient(135deg, #1a9966, #2bbf8c 55%, #33bf8c); box-shadow: 0 8px 18px rgba(26, 153, 102, .3); }

/* Revenue hero card */
.revenue-card {
    position: relative;
    display: block;
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--r-lg);
    color: #fff;
    text-align: left;
    overflow: hidden;
    isolation: isolate;
    transition: transform var(--dur-fast) var(--ease-spring);
}

.revenue-card:active { transform: scale(.99); }

.revenue-card::after {
    content: "";
    position: absolute;
    top: -30px;
    right: 4%;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    filter: blur(16px);
    z-index: -1;
}

.revenue-card__top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.revenue-card__badge {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .22);
}

.revenue-card__badge svg { width: 24px; height: 24px; }

.revenue-card__amount {
    font-family: -apple-system, "SF Pro Rounded", ui-rounded, system-ui, sans-serif;
    font-size: 27px;
    font-weight: 700;
    line-height: 1.15;
}

.revenue-card__meta {
    margin-left: auto;
    text-align: right;
    flex: 0 0 auto;
}

.progress-track {
    height: 8px;
    margin-top: 12px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .24);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--r-pill);
    background: #fff;
    transition: width var(--dur-slow) var(--ease-ios);
}

/* Neutral progress bar used inside reports */
.meter {
    height: 8px;
    border-radius: var(--r-pill);
    background: var(--fill-tertiary);
    overflow: hidden;
}

.meter__fill {
    height: 100%;
    border-radius: var(--r-pill);
    transition: width var(--dur-slow) var(--ease-ios);
}

/* ── Property cards ──────────────────────────────────────────────────────── */

.prop-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-grouped-secondary);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    color: inherit;
    text-align: left;
    height: 100%;
    transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) ease;
}

.prop-card:hover { box-shadow: var(--shadow-raised); }
.prop-card:active { transform: scale(.985); }

.prop-card__media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--fill-tertiary);
    overflow: hidden;
}

.prop-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.prop-card__media-badge {
    position: absolute;
    top: 8px;
    right: 8px;
}

.prop-card__body {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px;
}

.media-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ios-blue);
    background: color-mix(in srgb, var(--ios-blue) 10%, transparent);
}

.media-placeholder svg { width: 34px; height: 34px; }

.feature-chips {
    display: flex;
    gap: 12px;
    color: var(--label-secondary);
    font-size: 12px;
}

.feature-chips span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.feature-chips svg { width: 13px; height: 13px; }

/* ── Badges + pills ─────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: var(--r-pill);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    background: var(--fill-tertiary);
    color: var(--label);
    backdrop-filter: blur(8px);
}

.badge__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.badge--green { background: color-mix(in srgb, var(--ios-green) 16%, transparent); color: var(--ios-green); }
.badge--blue { background: color-mix(in srgb, var(--ios-blue) 16%, transparent); color: var(--ios-blue); }
.badge--orange { background: color-mix(in srgb, var(--ios-orange) 18%, transparent); color: var(--ios-orange); }
.badge--red { background: color-mix(in srgb, var(--ios-red) 16%, transparent); color: var(--ios-red); }
.badge--purple { background: color-mix(in srgb, var(--ios-purple) 16%, transparent); color: var(--ios-purple); }
.badge--teal { background: color-mix(in srgb, var(--ios-teal) 18%, transparent); color: var(--ios-teal); }
.badge--gray { background: var(--fill-tertiary); color: var(--label-secondary); }

.pill-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 0 4px;
    scrollbar-width: none;
}

.pill-row::-webkit-scrollbar { display: none; }

.pill {
    flex: 0 0 auto;
    padding: 7px 15px;
    border-radius: var(--r-pill);
    font-size: 15px;
    background: var(--fill-tertiary);
    color: var(--label);
    white-space: nowrap;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-spring);
}

.pill:active { transform: scale(.95); }

.pill.is-active {
    font-weight: 600;
    color: #fff;
    background: var(--ios-blue);
}

.pill.is-active[data-tint="green"] { background: var(--ios-green); }
.pill.is-active[data-tint="orange"] { background: var(--ios-orange); }
.pill.is-active[data-tint="red"] { background: var(--ios-red); }
.pill.is-active[data-tint="purple"] { background: var(--ios-purple); }
.pill.is-active[data-tint="teal"] { background: var(--ios-teal); }
.pill.is-active[data-tint="gray"] { background: var(--label-secondary); }

/* Segmented control */
.segmented {
    display: inline-flex;
    width: 100%;
    padding: 2px;
    border-radius: 9px;
    background: var(--fill-tertiary);
    gap: 2px;
}

.segmented__item {
    flex: 1 1 0;
    padding: 6px 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--label);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.segmented__item.is-active {
    font-weight: 600;
    background: var(--bg-elevated);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: var(--r-md);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -.014em;
    transition: transform var(--dur-fast) var(--ease-spring), filter var(--dur-fast) ease, background var(--dur-fast) ease;
}

.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn--primary { color: #fff; background: var(--ios-blue); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn--secondary { color: var(--ios-blue); background: color-mix(in srgb, var(--ios-blue) 12%, transparent); }
.btn--secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--ios-blue) 18%, transparent); }

.btn--tinted { color: var(--label); background: var(--fill-tertiary); }
.btn--destructive { color: #fff; background: var(--ios-red); }
.btn--destructive-tinted { color: var(--ios-red); background: color-mix(in srgb, var(--ios-red) 12%, transparent); }
.btn--plain { color: var(--ios-blue); min-height: 40px; }
.btn--block { width: 100%; }
.btn--pill { border-radius: var(--r-pill); }
.btn--sm { min-height: 36px; padding: 0 14px; font-size: 15px; }

.btn svg { width: 19px; height: 19px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--label-secondary);
    padding-left: 2px;
}

.field__hint {
    font-size: 12px;
    color: var(--label-tertiary);
    padding-left: 2px;
}

.field__error {
    font-size: 12px;
    font-weight: 500;
    color: var(--ios-red);
    padding-left: 2px;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    font: inherit;
    font-size: 17px;
    color: var(--label);
    background: var(--bg-grouped-secondary);
    border: 1px solid var(--separator);
    border-radius: var(--r-md);
    outline: none;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease, background var(--dur-fast) ease;
    appearance: none;
    -webkit-appearance: none;
}

.input::placeholder,
.textarea::placeholder { color: var(--label-tertiary); }

.input:focus,
.select:focus,
.textarea:focus {
    border-color: color-mix(in srgb, var(--ios-blue) 55%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ios-blue) 12%, transparent);
}

.input.is-invalid,
.select.is-invalid,
.textarea.is-invalid {
    border-color: color-mix(in srgb, var(--ios-red) 60%, transparent);
}

.textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.45;
}

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.5 8 10.5l4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

.input-group {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.input-group > .input { flex: 1 1 auto; }
.input-group > .select { flex: 0 0 auto; width: auto; min-width: 104px; }

/* iOS-style switch */
.switch {
    position: relative;
    flex: 0 0 auto;
    width: 51px;
    height: 31px;
    border-radius: var(--r-pill);
    background: var(--fill-primary);
    transition: background var(--dur-base) var(--ease-ios);
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
    transition: transform var(--dur-base) var(--ease-ios);
}

.switch.is-on { background: var(--ios-green); }
.switch.is-on::after { transform: translateX(20px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

/* Search field */
.search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--separator);
    background: var(--fill-tertiary);
    color: var(--label-secondary);
}

.search svg { width: 16px; height: 16px; flex: 0 0 auto; }

.search input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: 17px;
    color: var(--label);
    background: none;
    border: 0;
    outline: none;
}

.search input::placeholder { color: var(--label-tertiary); }

/* Searchable entity picker (mirrors the iOS Searchable Picker rule) */
.picker {
    position: relative;
}

.picker__control {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--separator);
    background: var(--bg-grouped-secondary);
    color: var(--label);
    text-align: left;
    font-size: 17px;
    transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}

.picker.is-open .picker__control {
    border-color: color-mix(in srgb, var(--ios-blue) 45%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ios-blue) 10%, transparent);
}

.picker__control.is-placeholder { color: var(--label-tertiary); }

.picker__panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 264px;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-raised), 0 0 0 .5px var(--separator);
    overflow: hidden;
    animation: pop-in var(--dur-fast) var(--ease-ios);
}

.picker__search {
    padding: 8px;
    border-bottom: .5px solid var(--separator);
}

.picker__list {
    overflow-y: auto;
    padding: 4px;
}

.picker__option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 10px;
    border-radius: var(--r-sm);
    color: var(--label);
    text-align: left;
    font-size: 16px;
}

.picker__option:hover { background: var(--fill-quaternary); }
.picker__option.is-selected { color: var(--ios-blue); font-weight: 500; }
.picker__option svg { width: 16px; height: 16px; margin-left: auto; flex: 0 0 auto; }

.picker__empty {
    padding: 16px 12px;
    text-align: center;
    font-size: 15px;
    color: var(--label-secondary);
}

/* ── Sheets + dialogs ────────────────────────────────────────────────────── */

.sheet-host {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet-host__scrim {
    position: absolute;
    inset: 0;
    background: var(--bg-sheet-scrim);
    animation: fade-in var(--dur-base) ease;
}

.sheet {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: calc(100dvh - 24px);
    display: flex;
    flex-direction: column;
    background: var(--bg-grouped);
    border-radius: 14px 14px 0 0;
    box-shadow: var(--shadow-sheet);
    animation: sheet-up var(--dur-slow) var(--ease-ios);
    overflow: hidden;
}

.sheet--full {
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
}

.sheet__grabber {
    width: 36px;
    height: 5px;
    margin: 6px auto 0;
    border-radius: var(--r-pill);
    background: var(--label-quaternary);
    flex: 0 0 auto;
}

.sheet__bar {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(60px, auto) 1fr minmax(60px, auto);
    align-items: center;
    gap: 8px;
    padding: 6px 8px 10px;
    border-bottom: .5px solid var(--separator);
    background: var(--bg-bar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.sheet__title {
    text-align: center;
    font-size: 17px;
    font-weight: 600;
}

.sheet__body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(16px + var(--safe-bottom));
}

.sheet__footer {
    flex: 0 0 auto;
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(12px + var(--safe-bottom));
    border-top: .5px solid var(--separator);
    background: var(--bg-bar);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

@media (min-width: 700px) {
    .sheet-host { align-items: center; }

    .sheet {
        border-radius: var(--r-lg);
        max-height: min(88dvh, 900px);
    }

    .sheet--full {
        height: min(92dvh, 1000px);
        max-height: min(92dvh, 1000px);
        border-radius: var(--r-lg);
    }

    .sheet__grabber { display: none; }
}

/* Centred alert dialog */
.alert-host {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.alert {
    position: relative;
    width: 100%;
    max-width: 300px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: var(--shadow-raised);
    overflow: hidden;
    text-align: center;
    animation: alert-in var(--dur-base) var(--ease-spring);
}

.alert__content { padding: 20px 16px 16px; }
.alert__title { font-size: 17px; font-weight: 600; }
.alert__message { margin-top: 4px; font-size: 13px; color: var(--label-secondary); }

.alert__actions {
    display: flex;
    border-top: .5px solid var(--separator);
}

.alert__action {
    flex: 1 1 0;
    padding: 12px 8px;
    font-size: 17px;
    color: var(--ios-blue);
    transition: background var(--dur-fast) ease;
}

.alert__action + .alert__action { border-left: .5px solid var(--separator); }
.alert__action:hover { background: var(--fill-quaternary); }
.alert__action--strong { font-weight: 600; }
.alert__action--destructive { color: var(--ios-red); }

/* ── Toasts ──────────────────────────────────────────────────────────────── */

.toast-host {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
    transform: translateX(-50%);
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(440px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    background: rgba(30, 30, 32, .94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-raised);
    animation: toast-in var(--dur-base) var(--ease-spring);
    pointer-events: auto;
}

.toast svg { width: 20px; height: 20px; flex: 0 0 auto; }
.toast--success svg { color: var(--ios-green); }
.toast--info svg { color: var(--ios-cyan); }
.toast--warning svg { color: var(--ios-yellow); }
.toast--error svg { color: var(--ios-red); }

/* ── States ──────────────────────────────────────────────────────────────── */

.state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 56px 28px;
    text-align: center;
}

.state__icon {
    width: 62px;
    height: 62px;
    color: var(--label-tertiary);
}

.state__title { font-size: 22px; font-weight: 600; }
.state__message { font-size: 15px; color: var(--label-secondary); max-width: 34ch; }

.spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid var(--label-quaternary);
    border-top-color: var(--ios-blue);
    animation: spin .7s linear infinite;
}

.spinner--lg { width: 34px; height: 34px; border-width: 3px; }
.spinner--inverted { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }

/* Skeleton placeholders keep the initial load from rendering false zeros. */
.skeleton {
    position: relative;
    border-radius: var(--r-sm);
    background: var(--fill-tertiary);
    overflow: hidden;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--fill-quaternary), transparent);
    animation: shimmer 1.4s infinite;
}

.skeleton--text { height: 13px; }
.skeleton--title { height: 22px; }
.skeleton--card { height: 110px; border-radius: var(--r-lg); }
.skeleton--hero { height: 108px; border-radius: var(--r-lg); }
.skeleton--row { height: 62px; border-radius: var(--r-md); }

/* ── Layout utilities ────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: 2px; }
.stack-4 { gap: 4px; }
.stack-6 { gap: 6px; }
.stack-8 { gap: 8px; }
.stack-12 { gap: 12px; }
.stack-16 { gap: 16px; }
.stack-20 { gap: 20px; }
.stack-24 { gap: 24px; }

.hstack { display: flex; align-items: center; }
.hstack-4 { gap: 4px; }
.hstack-6 { gap: 6px; }
.hstack-8 { gap: 8px; }
.hstack-12 { gap: 12px; }
.hstack-16 { gap: 16px; }
.hstack--top { align-items: flex-start; }
.hstack--wrap { flex-wrap: wrap; }

.spacer { flex: 1 1 auto; min-width: 0; }
.pt-8 { padding-top: 8px; }
.pt-12 { padding-top: 12px; }
.pt-16 { padding-top: 16px; }
.pb-16 { padding-bottom: 16px; }
.pb-24 { padding-bottom: 24px; }
.mt-auto { margin-top: auto; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.full-width { width: 100%; }

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 12px;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.grid-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
    gap: 12px;
}

/* Horizontal carousel with edge-to-edge bleed, like the iOS recent-properties rail. */
.hscroll {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 4px 16px 10px;
    margin: 0 -16px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { flex: 0 0 190px; scroll-snap-align: start; }
.hscroll--sm > * { flex: 0 0 84px; }

.section-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding-bottom: 2px;
}

.section-head__title { font-size: 17px; font-weight: 600; }

/* Quick-action tile */
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 76px;
    padding: 10px 6px;
    border-radius: var(--r-md);
    background: var(--bg-grouped-secondary);
    box-shadow: var(--shadow-card);
    color: var(--label);
    text-align: center;
    transition: transform var(--dur-fast) var(--ease-spring);
}

.quick-action:active:not(:disabled) { transform: scale(.94); }
.quick-action:disabled { opacity: .5; cursor: not-allowed; }
.quick-action svg { width: 23px; height: 23px; }
.quick-action span { font-size: 11px; font-weight: 500; line-height: 1.2; }

/* Metric tile used across report headers */
.metric {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 14px;
    border-radius: var(--r-md);
    background: var(--bg-grouped-secondary);
    box-shadow: var(--shadow-card);
}

.metric__label {
    font-size: 12px
;
    font-weight: 500;
    color: var(--label-secondary);
}

.metric__value {
    font-family: -apple-system, "SF Pro Rounded", ui-rounded, system-ui, sans-serif;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.02em;
    overflow-wrap: anywhere;
}

.metric__detail { font-size: 12px; color: var(--label-tertiary); }

/* ── Charts ──────────────────────────────────────────────────────────────── */

.chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 168px;
    padding: 8px 2px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.chart::-webkit-scrollbar { display: none; }

.chart__col {
    flex: 1 1 0;
    min-width: 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    height: 100%;
}

.chart__bar {
    width: 100%;
    max-width: 34px;
    min-height: 3px;
    border-radius: 5px 5px 2px 2px;
    background: linear-gradient(180deg, var(--ios-teal), color-mix(in srgb, var(--ios-teal) 62%, transparent));
    transition: height var(--dur-slow) var(--ease-ios);
}

.chart__bar--stack {
    display: flex;
    flex-direction: column-reverse;
    background: none;
    overflow: hidden;
}

.chart__bar-seg { width: 100%; }
.chart__bar-seg--rent { background: var(--ios-green); }
.chart__bar-seg--other { background: var(--ios-orange); }

.chart__label {
    font-size: 10px;
    color: var(--label-tertiary);
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--label-secondary);
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* Donut ring for the occupancy report */
.ring {
    position: relative;
    width: 132px;
    height: 132px;
    flex: 0 0 auto;
}

.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--fill-tertiary); }
.ring__fill { stroke: var(--ios-cyan); transition: stroke-dashoffset var(--dur-slow) var(--ease-ios); }

.ring__center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

/* ── Data table (report grids) ───────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--r-md);
    background: var(--bg-grouped-secondary);
    box-shadow: var(--shadow-card);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
}

table.data th,
table.data td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: .5px solid var(--separator);
}

table.data th:first-child,
table.data td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-grouped-secondary);
    white-space: normal;
    min-width: 148px;
}

table.data thead th {
    font-size: 12px;
    font-weight: 600;
    color: var(--label-secondary);
    background: var(--bg-grouped-secondary);
}

table.data tbody tr:last-child td { border-bottom: 0; }

table.data tfoot td {
    font-weight: 600;
    border-top: .5px solid var(--separator-opaque);
    border-bottom: 0;
}

/* ── Photo gallery ───────────────────────────────────────────────────────── */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
}

.gallery__item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--fill-tertiary);
}

.gallery__item img { width: 100%; height: 100%; object-fit: cover; }

.gallery__item-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 2px 6px;
    border-radius: var(--r-pill);
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, .55);
    backdrop-filter: blur(6px);
}

.gallery__item-actions {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 4px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .5));
}

.gallery__action {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0, 0, 0, .45);
}

.gallery__action svg { width: 14px; height: 14px; }

.hero-image {
    position: relative;
    aspect-ratio: 16 / 10;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--fill-tertiary);
}

.hero-image img { width: 100%; height: 100%; object-fit: cover; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .94);
    animation: fade-in var(--dur-fast) ease;
}

.lightbox img {
    max-width: 96vw;
    max-height: 88vh;
    object-fit: contain;
}

.lightbox__close {
    position: absolute;
    top: calc(12px + var(--safe-top));
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }

/* ── Wizard ──────────────────────────────────────────────────────────────── */

.wizard-progress {
    display: flex;
    gap: 5px;
    padding: 10px 16px 12px;
    background: var(--bg-bar);
    border-bottom: .5px solid var(--separator);
}

.wizard-progress__seg {
    flex: 1 1 0;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--fill-primary);
    transition: background var(--dur-base) ease;
}

.wizard-progress__seg.is-done { background: var(--ios-blue); }
.wizard-progress__seg.is-current { background: color-mix(in srgb, var(--ios-blue) 55%, transparent); }

.avatar {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, var(--ios-blue), var(--ios-indigo));
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--lg { width: 72px; height: 72px; font-size: 26px; }

.mi-beni-avatar {
    width: var(--mi-beni-avatar-size);
    height: var(--mi-beni-avatar-size);
    flex: 0 0 var(--mi-beni-avatar-size);
    display: inline-flex;
    overflow: hidden;
    border-radius: 24%;
    box-shadow: 0 3px 10px rgba(48, 85, 189, .22);
}

.mi-beni-avatar img { width: 100%; height: 100%; object-fit: cover; }

.mi-beni-nav { color: var(--ios-purple); }
.mi-beni-nav svg { animation: mi-beni-sparkle 2.8s ease-in-out infinite; }

@keyframes mi-beni-sparkle {
    0%, 100% { opacity: .72; transform: scale(.92) rotate(-3deg); }
    50% { opacity: 1; transform: scale(1.08) rotate(3deg); }
}

.assistant-page {
    min-height: calc(100dvh - var(--tabbar-h) - var(--safe-bottom) - 54px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 12px;
    /* The fixed composer sits above the tab bar, so reserve its footprint in the
       scrollable conversation instead of letting it cover the newest message. */
    padding-bottom: 104px;
}

.assistant-state,
.assistant-welcome {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-align: center;
}

.assistant-welcome p { max-width: 36rem; }
.assistant-messages { display: flex; flex-direction: column; gap: 12px; }
.assistant-message { display: flex; align-items: flex-end; gap: 8px; }
.assistant-message.is-user { justify-content: flex-end; }
.assistant-bubble {
    max-width: min(78%, 620px);
    padding: 10px 12px 6px;
    border-radius: 17px 17px 17px 5px;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-card);
}
.assistant-message.is-user .assistant-bubble {
    color: #fff;
    background: var(--ios-blue);
    border-radius: 17px 17px 5px 17px;
}
.assistant-bubble__content { white-space: pre-wrap; line-height: 1.4; }
.assistant-bubble__time { display: block; margin-top: 3px; font-size: 9px; text-align: right; opacity: .68; }
.assistant-bubble--thinking { display: flex; align-items: center; gap: 8px; color: var(--label-secondary); }
.assistant-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.assistant-chip {
    min-height: 36px;
    padding: 7px 12px;
    color: var(--ios-blue);
    background: color-mix(in srgb, var(--ios-blue) 9%, var(--bg-elevated));
    border: 1px solid color-mix(in srgb, var(--ios-blue) 22%, var(--separator));
    border-radius: 999px;
}
.assistant-composer {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
    z-index: 48;
    width: min(calc(100% - 24px), calc(var(--content-max) - 24px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    padding: 8px;
    margin-top: auto;
    transform: translateX(-50%);
    background: var(--bg-bar);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--separator);
    border-radius: 18px;
    box-shadow: var(--shadow-raised);
}
.assistant-composer .input { min-height: 42px; border: 0; background: transparent; }
.assistant-send {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--ios-blue);
    border-radius: 50%;
}
.assistant-send svg { width: 20px; height: 20px; }
.assistant-send:disabled { opacity: .42; }
.assistant-quota { font-size: 10px; color: var(--label-tertiary); text-align: center; }

/* Offline / connectivity banner */
.banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #fff;
    background: var(--ios-orange);
}

.banner svg { width: 16px; height: 16px; flex: 0 0 auto; }

.notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-md);
    font-size: 14px;
    background: color-mix(in srgb, var(--ios-red) 12%, transparent);
    color: var(--ios-red);
}

.notice--info {
    background: color-mix(in srgb, var(--ios-blue) 10%, transparent);
    color: var(--ios-blue);
}

.notice--warning {
    background: color-mix(in srgb, var(--ios-orange) 14%, transparent);
    color: var(--ios-orange);
}

.notice svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

/* ── Auth screens ────────────────────────────────────────────────────────── */

.auth {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(28px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
    background:
        radial-gradient(120% 90% at 12% -8%, color-mix(in srgb, var(--ios-blue) 22%, transparent), transparent 62%),
        radial-gradient(110% 80% at 92% 8%, color-mix(in srgb, var(--ios-indigo) 20%, transparent), transparent 58%),
        var(--bg-grouped);
}

.auth__panel {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.auth__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.auth__brand img {
    width: 84px;
    height: 84px;
    border-radius: 21px;
    box-shadow: var(--shadow-raised);
}

.auth__card {
    padding: 22px;
    border-radius: var(--r-xl);
    background: color-mix(in srgb, var(--bg-grouped-secondary) 92%, transparent);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    box-shadow: var(--shadow-raised);
}

.auth__divider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--label-tertiary);
}

.auth__divider::before,
.auth__divider::after {
    content: "";
    flex: 1 1 0;
    height: .5px;
    background: var(--separator);
}

/* ── Animations ──────────────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes alert-in {
    from { opacity: 0; transform: scale(.88); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.page-enter { animation: page-in var(--dur-base) var(--ease-ios); }

@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ── Blazor framework chrome ──────────────────────────────────────────────── */

#blazor-error-ui {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    display: none;
    padding: 14px 18px;
    font-size: 14px;
    color: #fff;
    background: var(--ios-red);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, .3);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 14px;
    cursor: pointer;
    font-size: 18px;
}

.blazor-reconnect-modal {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(4px);
}

.blazor-reconnect-modal > div {
    padding: 20px 24px;
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    box-shadow: var(--shadow-raised);
    font-size: 15px;
    text-align: center;
}

/* Desktop refinement: the app keeps its phone-native proportions but gains room. */
@media (min-width: 900px) {
    body { font-size: 16px; }
    .app-content { padding: 0 24px; }
    .hscroll { padding-left: 24px; padding-right: 24px; margin: 0 -24px; }
    .tabbar__row { grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .mi-beni-nav svg { animation: none; }
}

/* ── Print ───────────────────────────────────────────────────────────────── */

/*
  Report export. Beni.iOS renders reports to PDF with PDFReportGenerator; on the web
  the browser's print dialog does the same job, so the print stylesheet strips the
  app chrome and lays the report out for paper.
*/
@media print {
    :root {
        /* Force the light palette: a dark report wastes ink and reads badly on paper. */
        --bg-grouped: #ffffff;
        --bg-grouped-secondary: #ffffff;
        --bg-base: #ffffff;
        --bg-elevated: #ffffff;
        --label: #000000;
        --label-secondary: #444444;
        --label-tertiary: #666666;
        --separator: #cccccc;
        --separator-opaque: #999999;
        --shadow-card: none;
        --shadow-raised: none;
        color-scheme: light;
    }

    body {
        background: #fff;
        font-size: 11pt;
    }

    /* Interactive chrome has no meaning on paper. */
    .navbar,
    .tabbar,
    .side-menu,
    .scrim,
    .toast-host,
    .sheet-host,
    .alert-host,
    .pill-row,
    .segmented,
    .search,
    .picker,
    .icon-btn,
    .text-btn,
    .btn,
    .row__chevron,
    details > summary {
        display: none !important;
    }

    .app-shell__body {
        padding-bottom: 0;
    }

    .app-content {
        max-width: none;
        padding: 0;
    }

    /* Report descriptions are collapsed on screen; print them expanded. */
    details {
        display: block !important;
    }

    .card,
    .list-card,
    .metric,
    .table-wrap {
        box-shadow: none;
        border: 0.5pt solid var(--separator);
        break-inside: avoid;
    }

    .list-group {
        break-inside: avoid;
        margin-bottom: 12pt;
    }

    .grid-metrics,
    .grid-stats {
        grid-template-columns: repeat(4, 1fr);
    }

    /* Tables must print in full rather than scrolling inside a clipped box. */
    .table-wrap {
        overflow: visible;
    }

    table.data {
        white-space: normal;
        font-size: 9pt;
    }

    table.data thead {
        display: table-header-group;
    }

    table.data tr {
        break-inside: avoid;
    }

    .chart {
        overflow: visible;
        break-inside: avoid;
    }

    a {
        color: inherit;
        text-decoration: none;
    }
}
.assistant-credit-card {
    margin: 12px 16px;
    padding: 16px;
    border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
    border-radius: 18px;
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.assistant-credit-card.is-exhausted {
    border-color: color-mix(in srgb, var(--ios-orange) 48%, transparent);
    background: color-mix(in srgb, var(--ios-orange) 9%, var(--surface));
}

.assistant-credit-card h3,
.assistant-credit-card p { margin: 0 0 6px; }

.assistant-credit-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.assistant-credit-balances {
    display: grid;
    grid-template-columns: repeat(2, minmax(112px, 1fr));
    gap: 8px;
    min-width: min(100%, 290px);
}

.assistant-credit-balances span {
    display: grid;
    gap: 2px;
    padding: 9px 11px;
    border: 1px solid color-mix(in srgb, var(--primary) 14%, transparent);
    border-radius: 12px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--label-secondary);
    font-size: 11px;
}

.assistant-credit-balances strong {
    color: var(--label-primary);
    font-size: 20px;
    line-height: 1;
}

.assistant-credit-toggle { margin-top: 12px; }

.assistant-credit-packages { display: flex; gap: 10px; margin-top: 12px; }
.assistant-credit-packages button { flex: 1; display: grid; gap: 2px; }

@media (max-width: 640px) {
    .assistant-credit-summary { flex-direction: column; }
    .assistant-credit-balances { width: 100%; min-width: 0; }
    .assistant-credit-packages { flex-direction: column; }
}
