:root {
    --ink: #132231;
    --ink-soft: #33495d;
    --muted: #65798b;
    --paper: #f3f7fa;
    --card: #ffffff;
    --nav: #08131f;
    --nav-soft: #122536;
    --accent: #087f8c;
    --accent-dark: #056671;
    --accent-soft: #e3f5f5;
    --cyan: #47d7e5;
    --line: #d9e4ea;
    --line-strong: #b9cbd5;
    --amber: #8a5300;
    --amber-bg: #fff1cf;
    --red: #ad3030;
    --red-bg: #feeaea;
    --green: #176b4d;
    --green-bg: #e1f3ea;
    --shadow: 0 18px 45px rgba(15, 36, 51, 0.08);
    --shadow-hover: 0 22px 55px rgba(15, 36, 51, 0.14);
    --radius-sm: 0.65rem;
    --radius: 1rem;
    --radius-lg: 1.35rem;
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 0, rgba(71, 215, 229, 0.12), transparent 28rem),
        linear-gradient(180deg, #f8fbfd 0, var(--paper) 38rem);
}
a { color: var(--accent-dark); text-underline-offset: 0.2em; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(8, 127, 140, 0.34); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 50; left: max(1rem, var(--safe-area-left)); top: -5rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm); color: white; background: var(--nav); }
.skip-link:focus { top: calc(var(--safe-area-top) + 1rem); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: var(--safe-area-top);
    padding-right: var(--safe-area-right);
    padding-left: var(--safe-area-left);
    color: white;
    background: rgba(8, 19, 31, 0.96);
    border-bottom: 1px solid rgba(122, 222, 231, 0.18);
    backdrop-filter: blur(18px);
}
.nav-shell, .page-shell { width: min(1160px, calc(100% - 2rem)); margin-inline: auto; }
.nav-shell { min-height: 4.75rem; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.brand { display: inline-flex; align-items: center; gap: 0.7rem; color: white; font-weight: 800; letter-spacing: -0.02em; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 1px solid rgba(71, 215, 229, 0.55); border-radius: 0.7rem; color: var(--cyan); background: linear-gradient(145deg, rgba(71, 215, 229, 0.16), rgba(71, 215, 229, 0.02)); font-size: 0.72rem; letter-spacing: 0.08em; box-shadow: 0 0 24px rgba(71, 215, 229, 0.12); }
.header-actions, .primary-navigation { display: flex; align-items: center; gap: 0.5rem; }
.primary-nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.9rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    color: #c6d4de;
    font-size: 0.9rem;
    font-weight: 780;
    text-decoration: none;
    transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}
.primary-nav-link:hover { color: white; background: rgba(255,255,255,0.06); }
.primary-nav-link.active { color: white; background: var(--nav-soft); border-color: rgba(71, 215, 229, 0.32); box-shadow: inset 0 -2px 0 var(--cyan); }
.nav-icon { display: block; width: 1.35rem; height: 1.35rem; }
.inline-form { display: inline; margin: 0; }

.orbit-menu { position: relative; }
.orbit-menu[open] { z-index: 30; }
.orbit-toggle {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 3rem;
    padding: 0.35rem 0.55rem 0.35rem 0.4rem;
    border: 1px solid rgba(71, 215, 229, 0.26);
    border-radius: 999px;
    color: white;
    background: linear-gradient(135deg, rgba(71, 215, 229, 0.13), rgba(255,255,255,0.04));
    cursor: pointer;
    list-style: none;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.orbit-toggle::-webkit-details-marker { display: none; }
.orbit-toggle:hover { border-color: rgba(71, 215, 229, 0.65); background: rgba(71, 215, 229, 0.14); transform: translateY(-1px); }
.orbit-menu[open] .orbit-toggle { border-color: var(--cyan); background: #143448; box-shadow: 0 0 0 4px rgba(71, 215, 229, 0.1); }
.orbit-toggle-icon {
    display: grid;
    place-items: center;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 50%;
    background: rgba(71, 215, 229, 0.12);
}
.orbit-toggle-icon img { display: block; transition: transform 350ms cubic-bezier(.2,.8,.2,1); }
.orbit-menu[open] .orbit-toggle-icon img { transform: rotate(110deg); }
.orbit-toggle-copy { display: grid; padding-right: 0.25rem; line-height: 1.05; }
.orbit-toggle-copy strong { font-size: 0.82rem; letter-spacing: 0.01em; }
.orbit-toggle-copy small { margin-top: 0.18rem; color: #91a9b9; font-size: 0.62rem; font-weight: 700; }
.orbit-backdrop { position: fixed; z-index: 1; inset: 0; background: rgba(3, 11, 19, 0.56); backdrop-filter: blur(4px); cursor: default; }
.orbit-panel {
    position: absolute;
    z-index: 2;
    top: calc(100% + 0.75rem);
    right: 0;
    width: min(41rem, calc(100vw - 2rem));
    max-height: calc(100vh - 6.5rem);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem;
    color: var(--ink);
    background:
        radial-gradient(circle at 82% 0, rgba(71, 215, 229, 0.2), transparent 15rem),
        linear-gradient(155deg, #f9fdfe, #e9f3f6);
    border: 1px solid rgba(71, 215, 229, 0.36);
    border-radius: 1.45rem;
    box-shadow: 0 30px 90px rgba(0, 9, 17, 0.42);
    animation: orbit-arrive 180ms cubic-bezier(.2,.8,.2,1);
}
.orbit-panel::before {
    content: "";
    position: absolute;
    width: 16rem;
    height: 16rem;
    right: -8rem;
    top: -9rem;
    border: 1px solid rgba(8, 127, 140, 0.2);
    border-radius: 50%;
    box-shadow: 0 0 0 2.5rem rgba(8, 127, 140, 0.04), 0 0 0 5rem rgba(8, 127, 140, 0.025);
    pointer-events: none;
}
@keyframes orbit-arrive {
    from { opacity: 0; transform: translateY(-0.6rem) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.orbit-panel-heading {
    position: relative;
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1rem 1.05rem;
}
.orbit-panel-heading > div { display: grid; }
.orbit-panel-heading strong { font-size: 1.55rem; letter-spacing: -0.04em; }
.orbit-panel-heading span { margin-top: 0.25rem; color: var(--muted); font-size: 0.82rem; }
.orbit-kicker { margin: 0 0 0.25rem; color: var(--accent-dark); font-size: 0.66rem; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase; }
.orbit-close {
    display: grid;
    place-items: center;
    width: 2.45rem;
    height: 2.45rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255,255,255,0.78);
    cursor: pointer;
}
.orbit-grid { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.orbit-destination {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    min-height: 5.3rem;
    padding: 0.75rem;
    color: var(--ink);
    background: rgba(255,255,255,0.84);
    border: 1px solid rgba(185, 203, 213, 0.72);
    border-radius: 1rem;
    text-decoration: none;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.orbit-destination:hover { transform: translateY(-2px); border-color: #85c9cf; box-shadow: 0 12px 24px rgba(15, 36, 51, 0.1); }
.orbit-destination.active { border-color: var(--accent); background: white; box-shadow: inset 3px 0 0 var(--accent); }
.orbit-destination > span:nth-child(2) { display: grid; min-width: 0; gap: 0.2rem; }
.orbit-destination strong { font-size: 0.92rem; }
.orbit-destination small { overflow: hidden; color: var(--muted); font-size: 0.69rem; text-overflow: ellipsis; white-space: nowrap; }
.orbit-icon {
    display: grid;
    place-items: center;
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 0.85rem;
    background: var(--accent-soft);
}
.orbit-icon img { display: block; }
.orbit-arrow { color: var(--accent); font-size: 1.1rem; transition: transform 160ms ease; }
.orbit-destination:hover .orbit-arrow { transform: translateX(0.2rem); }
.orbit-account {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.7rem;
    padding: 0.75rem;
    border-radius: 1rem;
    color: white;
    background: linear-gradient(135deg, #10283a, #087f8c);
}
.orbit-user { display: grid; place-items: center; width: 2.45rem; height: 2.45rem; border: 1px solid rgba(255,255,255,0.28); border-radius: 50%; color: var(--cyan); background: rgba(8,19,31,0.35); font-weight: 900; }
.orbit-account > span:nth-child(2) { display: grid; gap: 0.1rem; }
.orbit-account small { color: #c0d8e1; font-size: 0.65rem; }
.orbit-account strong { overflow: hidden; font-size: 0.82rem; text-overflow: ellipsis; white-space: nowrap; }
.orbit-signout { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.45rem; padding: 0.45rem 0.7rem; border: 1px solid rgba(255,255,255,0.25); border-radius: 0.75rem; color: white; background: rgba(8,19,31,0.3); font-weight: 800; cursor: pointer; }
.orbit-signout:hover { background: rgba(8,19,31,0.52); }

.page-shell { min-height: calc(100vh - 9rem); padding-block: 2.5rem 4rem; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin-bottom: 1.5rem; }
.home-heading { padding: 1rem 0 0.35rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 19ch; margin-bottom: 0.45rem; font-size: clamp(2rem, 4.7vw, 3.5rem); line-height: 1.03; letter-spacing: -0.052em; }
h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); letter-spacing: -0.025em; }
h3 { margin-bottom: 0.3rem; font-size: 1.02rem; }
.lede { max-width: 60ch; margin-bottom: 0; color: var(--ink-soft); font-size: 1.05rem; }
.eyebrow, .card-kicker { margin-bottom: 0.4rem; color: var(--accent-dark); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.13em; text-transform: uppercase; }
.muted, .help-text, .supporting-text { color: var(--muted); }
.small-text, .help-text, .supporting-text { font-size: 0.86rem; }

.card { background: rgba(255,255,255,0.96); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.metric-grid { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 1rem; margin: 1rem 0 2.5rem; }
.metric-card { position: relative; overflow: hidden; display: grid; min-height: 9.5rem; align-content: space-between; padding: 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.metric-card::after { content: ""; position: absolute; right: -2rem; top: -3.5rem; width: 8rem; height: 8rem; border: 1px solid rgba(8,127,140,0.12); border-radius: 50%; }
.metric-primary { color: white; background: linear-gradient(135deg, #0d3442, #087f8c); border-color: transparent; }
.metric-primary::after { border-color: rgba(255,255,255,0.2); box-shadow: 0 0 60px rgba(71,215,229,0.22); }
.metric-label { color: var(--muted); font-size: 0.82rem; font-weight: 750; }
.metric-primary .metric-label, .metric-primary .metric-detail { color: #d4f5f7; }
.metric-card strong { font-size: clamp(1.8rem, 4vw, 2.65rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.05em; }
.metric-detail { color: var(--muted); font-size: 0.78rem; }

.home-section, section[aria-labelledby] { margin-top: 2.25rem; }
.home-columns { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 1.25rem; }
.home-columns .home-section { min-width: 0; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 0.85rem; }
.count-badge { display: inline-grid; place-items: center; min-width: 2rem; height: 2rem; padding: 0 0.55rem; border-radius: 999px; color: var(--accent-dark); background: var(--accent-soft); font-size: 0.8rem; font-weight: 850; }
.card-list { display: grid; gap: 0.85rem; }
.action-list { overflow: hidden; }
.action-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.action-row:last-child { border-bottom: 0; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 2.7rem; height: 2.7rem; border: 1px solid #b7dde0; border-radius: 0.85rem; color: var(--accent-dark); background: var(--accent-soft); font-weight: 850; }
.action-copy h3, .action-copy p { margin-bottom: 0.2rem; }
.action-copy p { color: var(--muted); font-size: 0.88rem; }
.balance-card { display: grid; gap: 0.8rem; padding: 1.15rem; transition: transform 160ms ease, box-shadow 160ms ease; }
.balance-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.balance-card-top { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.balance-card-top h3 { margin-bottom: 0; }
.amount-block { display: grid; flex-shrink: 0; gap: 0.15rem; text-align: right; }
.amount-block span { color: var(--muted); font-size: 0.74rem; font-weight: 700; }
.amount-block strong, .detail-amount, .amount-cell { font-variant-numeric: tabular-nums; }
.amount-block strong { font-size: 1.5rem; letter-spacing: -0.04em; }
.person-line, .supporting-text { margin: 0; }
.card-actions, .button-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 0.35rem; min-height: 2.7rem; border: 1px solid transparent; border-radius: 0.75rem; padding: 0.58rem 0.95rem; font-weight: 800; text-decoration: none; cursor: pointer; transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--accent); box-shadow: 0 8px 22px rgba(8,127,140,0.2); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--ink); background: white; border-color: var(--line-strong); }
.button.secondary:hover { border-color: var(--accent); }
.button.danger { color: white; background: var(--red); }
.button.danger-outline { color: var(--red); border-color: #e9bcbc; background: white; }
.button.small { min-height: 2.25rem; padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.link-button { border: 0; padding: 0; background: none; color: var(--accent-dark); font-weight: 750; cursor: pointer; }
.danger { color: var(--red); }

.status { display: inline-flex; align-items: center; width: fit-content; border: 1px solid transparent; border-radius: 999px; padding: 0.3rem 0.58rem; font-size: 0.76rem; font-weight: 820; line-height: 1.2; }
.status.unpaid { color: var(--red); background: var(--red-bg); border-color: #f5caca; }
.status.awaiting { color: var(--amber); background: var(--amber-bg); border-color: #ead29b; }
.status.confirmed { color: var(--green); background: var(--green-bg); border-color: #b8dec9; }
.status.partial { color: #3d5c91; background: #e9effb; border-color: #cad7ee; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); background: #f8fafb; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 140ms ease; }
tbody tr:hover { background: #f7fbfc; }
.number { text-align: right; }
.row-link { color: var(--ink); font-weight: 800; }
.row-action { width: 3rem; text-align: right; font-size: 1.2rem; }
.transaction-grid { display: grid; gap: 0.65rem; }
.transaction-card { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 1rem; padding: 1rem; color: var(--ink); text-decoration: none; transition: transform 150ms ease, border-color 150ms ease; }
.transaction-card:hover { transform: translateX(3px); border-color: #9ecdd1; }
.transaction-icon { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; color: var(--accent-dark); background: var(--accent-soft); font-size: 1.15rem; }
.transaction-main, .transaction-meta { display: grid; gap: 0.2rem; }
.transaction-main span { color: var(--muted); font-size: 0.85rem; }
.transaction-meta { justify-items: end; }
.transaction-meta > strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.row-arrow { color: var(--accent); font-size: 1.3rem; }

.back-link { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 2.7rem; margin-bottom: 1.15rem; color: var(--ink-soft); font-weight: 780; text-decoration: none; }
.status.rejected { color: var(--red); background: var(--red-bg); border-color: #f0bcbc; }
.back-link span { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid var(--line-strong); border-radius: 0.65rem; background: white; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-card, .share-card, .stack-form, .confirm-card, .confirmation-panel { padding: 1.3rem; }
.card-header { margin-bottom: 0.9rem; }
.card-header h2 { margin: 0; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; align-items: start; gap: 1rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
dt { flex-shrink: 0; color: var(--muted); }
dd { max-width: 70%; margin: 0; text-align: right; }
.detail-amount { font-size: 1.35rem; font-weight: 850; }
.linked-amount { margin: 1rem 0 0.2rem; font-size: 2.5rem; font-weight: 850; letter-spacing: -0.05em; }
.confirmation-panel { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-color: #aed9dc; background: linear-gradient(135deg, #fff, #edfafa); }
.confirmation-panel h2 { margin-bottom: 0.4rem; }
.confirmation-panel p:last-child { margin-bottom: 0; }

.attachment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.attachment-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafb; }
.attachment-preview { display: grid; place-items: center; aspect-ratio: 16 / 10; overflow: hidden; color: var(--accent-dark); background: #e8f1f4; text-decoration: none; }
.attachment-preview img { width: 100%; height: 100%; object-fit: cover; transition: transform 220ms ease; }
.attachment-preview.preview-failed img { display: none; }
.attachment-preview.preview-failed::after { content: "Preview unavailable · download original"; padding: 1rem; text-align: center; font-size: 0.76rem; font-weight: 800; }
.attachment-preview:hover img { transform: scale(1.035); }
.file-tile span { display: grid; place-items: center; width: 3.2rem; height: 3.8rem; border: 2px solid #a8c8cf; border-radius: 0.4rem; font-size: 0.72rem; font-weight: 900; }
.attachment-info { display: grid; gap: 0.15rem; padding: 0.7rem 0.75rem 0.35rem; }
.attachment-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.84rem; }
.attachment-info span { color: var(--muted); font-size: 0.74rem; }
.attachment-actions { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.35rem 0.75rem 0.7rem; font-size: 0.76rem; }

.share-heading, .payment-row { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.member-title { display: flex; align-items: center; gap: 0.75rem; }
.member-title h3, .member-title p { margin: 0; }
.member-title p { color: var(--muted); font-size: 0.82rem; }
.share-heading > strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.payments { margin-block: 1rem; }
.payment-row { padding: 0.85rem 0; border-top: 1px solid var(--line); }
.payment-amount { color: var(--ink); font-size: 1.05rem; font-weight: 850; }
.payment-actions { display: flex; align-items: center; justify-content: end; gap: 0.55rem; flex-wrap: wrap; }
.payment-row p { margin: 0.35rem 0 0; }

.narrow-page, .auth-card { width: min(660px, 100%); margin-inline: auto; }
.auth-card { padding: 1.5rem; }
.stack-form { display: grid; min-width: 0; gap: 1.15rem; }
.field { display: grid; min-width: 0; gap: 0.42rem; }
.field label { font-size: 0.88rem; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; max-width: 100%; min-height: 2.85rem; border: 1px solid var(--line-strong); border-radius: 0.75rem; padding: 0.7rem 0.8rem; color: var(--ink); background: #fbfdfe; transition: border 140ms ease, box-shadow 140ms ease, background 140ms ease; }
.field input[type="date"] { display: block; }
.currency-input { position: relative; }
.currency-input > span { position: absolute; z-index: 1; top: 50%; left: 0.8rem; color: var(--muted); font-weight: 800; transform: translateY(-50%); pointer-events: none; }
.currency-input input { padding-left: 1.65rem; }
.field textarea { min-height: 6rem; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 0; border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(8,127,140,0.14); }
.field input[type="file"] { min-height: auto; padding: 0.65rem; border-style: dashed; }
.errorlist { margin: 0; padding-left: 1.1rem; color: var(--red); font-size: 0.85rem; }
.upload-preview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.upload-item { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 0.75rem; background: #f7fafb; }
.field ul[id$="_participants"] { display: grid; gap: 0.55rem; margin: 0; padding: 0; list-style: none; }
.field ul[id$="_participants"] label { display: flex; align-items: center; gap: 0.65rem; min-height: 2.75rem; padding: 0.65rem 0.75rem; border: 1px solid var(--line); border-radius: 0.75rem; background: #fbfdfe; }
.field ul[id$="_participants"] input { width: 1.15rem; min-height: 1.15rem; margin: 0; }
.field ul[id$="_participants"] input:disabled { opacity: 0.65; }
.percentage-fields { margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 0.85rem; }
.percentage-fields[hidden], .percentage-field[hidden] { display: none; }
.percentage-fields legend { padding-inline: 0.3rem; font-size: 0.88rem; font-weight: 850; }
.percentage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.percentage-field { display: grid; gap: 0.35rem; }
.percentage-input { position: relative; }
.percentage-input input { padding-right: 2rem; }
.percentage-input span { position: absolute; top: 50%; right: 0.8rem; color: var(--muted); transform: translateY(-50%); }
.percentage-total { margin: 0.75rem 0 0; font-weight: 800; }
.percentage-total.valid { color: var(--green); }
.percentage-total.invalid { color: var(--red); }
.rejection-reason { padding: 0.65rem 0.75rem; color: var(--red); background: var(--red-bg); border-radius: 0.65rem; font-size: 0.84rem; }
.upload-item-preview { display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; color: var(--muted); background: #e8f1f4; text-decoration: none; }
.upload-item-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-item-preview.preview-failed img { display: none; }
.upload-item-preview.preview-failed::after { content: "Image selected"; font-size: 0.75rem; font-weight: 800; }
.upload-item-meta { display: grid; gap: 0.1rem; padding: 0.5rem; }
.upload-item-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.74rem; }
.upload-item-meta span { color: var(--muted); font-size: 0.68rem; }
.upload-item-remove { position: absolute; top: 0.35rem; right: 0.35rem; display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border: 1px solid rgba(255,255,255,0.8); border-radius: 50%; color: white; background: rgba(8,19,31,0.82); font-size: 1rem; font-weight: 900; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(8,19,31,0.25); }
.upload-item.error { border-color: #e2a5a5; background: var(--red-bg); }
.upload-error { grid-column: 1 / -1; margin: 0; color: var(--red); font-size: 0.84rem; font-weight: 750; }
.upload-summary { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin: 0; color: var(--muted); font-size: 0.82rem; }

.empty-state { padding: 2rem; text-align: center; }
.empty-state p { margin-bottom: 0.5rem; color: var(--muted); }
.empty-icon { display: inline-grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-bottom: 0.65rem; border: 1px solid #b9dadd; border-radius: 0.85rem; color: var(--accent-dark); background: var(--accent-soft); font-weight: 900; }
.compact-empty { display: flex; align-items: center; gap: 0.85rem; padding: 1rem; }
.compact-empty .empty-icon { flex-shrink: 0; margin: 0; }
.compact-empty h3, .compact-empty p { margin: 0; }
.compact-empty p { color: var(--muted); font-size: 0.86rem; }
.messages { display: grid; gap: 0.5rem; margin-bottom: 1rem; }
#page-content { display: contents; }
.message { padding: 0.85rem 1rem; color: var(--green); background: var(--green-bg); border: 1px solid #b9ddca; border-radius: 0.75rem; }
.update-banner { display: flex; justify-content: space-between; align-items: center; }
.sync-banner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--accent-dark); background: var(--accent-soft); border-color: #b7dde0; }
.offline-status { position: sticky; top: 0; z-index: 40; padding: 0.65rem 1rem; text-align: center; color: #573600; background: var(--amber-bg); font-weight: 800; }
.confirm-card { text-align: center; }
.confirm-card .button-row { justify-content: center; }
.danger-symbol { display: grid; place-items: center; width: 3.3rem; height: 3.3rem; margin: 0 auto 1rem; border-radius: 50%; color: white; background: var(--red); font-size: 1.4rem; font-weight: 900; }
.site-footer { padding: 1rem; color: var(--muted); text-align: center; font-size: 0.8rem; }
.message.error { color: var(--red); background: var(--red-bg); border-color: #f0bcbc; }
.offline-page { max-width: 620px; margin: 4rem auto; }

.dashboard-heading { margin-bottom: 1.15rem; }
.dashboard-filters { display: flex; align-items: end; gap: 0.8rem; padding: 1rem; }
.dashboard-filter { display: grid; gap: 0.35rem; }
.dashboard-filter label { color: var(--muted); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.dashboard-filter input, .dashboard-filter select { min-height: 2.7rem; padding: 0.55rem 0.7rem; color: var(--ink); background: #fbfdfe; border: 1px solid var(--line-strong); border-radius: 0.7rem; }
.dashboard-filter input { width: 5rem; }
.dashboard-filter select { min-width: 8rem; }
.dashboard-filter input:focus, .dashboard-filter select:focus { outline: 0; border-color: var(--accent); background: white; box-shadow: 0 0 0 3px rgba(8,127,140,0.14); }
.dashboard-type-filter { flex: 1; }
.dashboard-type-filter select { width: 100%; }
.dashboard-period-note { margin: 0.7rem 0 1.35rem; color: var(--muted); font-size: 0.82rem; }
.dashboard-metrics { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.change-value.up, .change-badge.up { color: var(--red); }
.change-value.down, .change-badge.down { color: var(--green); }
.change-value.flat, .change-badge.flat { color: var(--ink-soft); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.chart-card, .insight-card { min-width: 0; padding: 1.2rem; }
.chart-heading { align-items: center; margin-bottom: 1.15rem; }
.filter-chip { display: inline-flex; padding: 0.35rem 0.6rem; color: var(--accent-dark); background: var(--accent-soft); border-radius: 999px; font-size: 0.75rem; font-weight: 800; }
.trend-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(3.6rem, 1fr); align-items: end; gap: 0.55rem; min-height: 17rem; overflow-x: auto; padding: 0.6rem 0.2rem 0; scrollbar-width: thin; }
.trend-column { display: grid; grid-template-rows: 1.2rem 12rem auto; align-items: end; gap: 0.4rem; min-width: 0; text-align: center; }
.trend-value { overflow: hidden; color: var(--muted); font-size: 0.7rem; font-weight: 750; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.trend-track { display: flex; align-items: end; width: min(2.6rem, 78%); height: 12rem; margin-inline: auto; overflow: hidden; border-radius: 0.55rem 0.55rem 0.2rem 0.2rem; background: linear-gradient(180deg, #f0f5f7, #e6eef2); }
.trend-bar { display: block; width: 100%; min-height: 0; border-radius: 0.5rem 0.5rem 0.15rem 0.15rem; background: linear-gradient(180deg, var(--cyan), var(--accent)); box-shadow: 0 -8px 22px rgba(71,215,229,0.2); }
.trend-label { overflow: hidden; color: var(--ink-soft); font-size: 0.7rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.insight-card { color: white; background: linear-gradient(155deg, #10283a, #0b1927); border-color: #17394e; }
.insight-card .card-kicker { color: var(--cyan); }
.insight-card h2 { margin-bottom: 1rem; }
.insight-card > p:not(.card-kicker) { color: #cedbe3; line-height: 1.6; }
.insight-stat { display: grid; gap: 0.25rem; margin-top: 2rem; padding: 1rem; background: rgba(71,215,229,0.09); border: 1px solid rgba(71,215,229,0.22); border-radius: 0.85rem; }
.insight-stat span { color: #b8d1db; font-size: 0.75rem; }
.insight-stat strong { color: white; font-size: 1.25rem; }
.dashboard-table-wrap { overflow: hidden; }
.comparison-table th[scope="row"] { color: var(--ink); background: white; font-size: 0.86rem; letter-spacing: 0; text-transform: none; }
.comparison-bars { width: 34%; min-width: 13rem; }
.comparison-bar { display: block; min-width: 0; height: 0.48rem; border-radius: 999px; }
.comparison-bar + .comparison-bar { margin-top: 0.35rem; }
.comparison-bar.current { background: var(--accent); }
.comparison-bar.previous { background: #aebec8; }
.change-badge { display: inline-flex; justify-content: center; min-width: 6.8rem; padding: 0.32rem 0.5rem; border-radius: 999px; background: #f2f6f8; font-size: 0.78rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.change-badge.up { background: var(--red-bg); }
.change-badge.down { background: var(--green-bg); }
.chart-legend { display: flex; gap: 1rem; margin-top: 0.65rem; color: var(--muted); font-size: 0.75rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.chart-legend i { display: inline-block; width: 0.8rem; height: 0.45rem; border-radius: 999px; }
.legend-current { background: var(--accent); }
.legend-previous { background: #aebec8; }
.dashboard-more { margin-top: 0.75rem; text-align: right; font-weight: 750; }

@media (max-width: 860px) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .metric-primary { grid-row: span 2; }
    .home-columns { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .action-row { grid-template-columns: auto 1fr; }
    .action-row .card-actions { grid-column: 2; }
    .dashboard-metrics { grid-template-columns: 1fr 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px), (pointer: coarse) {
    body.orbit-open { overflow: hidden; overscroll-behavior: none; }
    body.orbit-open .site-header {
        background: var(--nav);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
    .orbit-panel {
        position: fixed;
        inset: auto max(0.65rem, var(--safe-area-right)) max(0.65rem, var(--safe-area-bottom)) max(0.65rem, var(--safe-area-left));
        width: auto;
        max-height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom) - 5.5rem);
        max-height: calc(100dvh - var(--safe-area-top) - var(--safe-area-bottom) - 5.5rem);
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        border-radius: 1.35rem;
        animation-name: orbit-rise;
    }
    @keyframes orbit-rise {
        from { opacity: 0; transform: translateY(1.25rem) scale(0.98); }
        to { opacity: 1; transform: translateY(0) scale(1); }
    }
}

@media (max-width: 700px) {
    .nav-shell { min-height: 4.25rem; gap: 0.65rem; }
    .brand { min-width: 0; }
    .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-actions { flex: 0 0 auto; }
    .primary-nav-link { min-height: 2.75rem; padding: 0.45rem 0.65rem; }
    .orbit-toggle { min-height: 2.75rem; }
    .page-shell { padding-top: 1.4rem; }
    .page-heading { align-items: start; flex-direction: column; }
    .create-bill-action { width: 100%; }
    .transaction-card { grid-template-columns: auto 1fr auto; }
    .transaction-meta { grid-column: 2; justify-items: start; }
    .row-arrow { grid-column: 3; grid-row: 1 / span 2; }
    .attachment-grid { grid-template-columns: 1fr; }
    .dashboard-filters { display: grid; grid-template-columns: 5rem 1fr; }
    .dashboard-type-filter { grid-column: 1 / -1; }
    .dashboard-filters .button { grid-column: 1 / -1; }
    .dashboard-filter input, .dashboard-filter select { width: 100%; min-width: 0; }
    .dashboard-table-wrap { overflow-x: auto; }
}

@media (max-width: 520px) {
    .nav-shell, .page-shell { width: min(100% - 1rem, 1160px); }
    .nav-shell { width: calc(100% - 1rem); }
    .brand-mark { width: 2rem; height: 2rem; }
    .primary-nav-link > span { display: none; }
    .primary-nav-link { padding-inline: 0.6rem; }
    .orbit-toggle-copy small { display: none; }
    .orbit-panel { padding: 0.6rem; }
    .orbit-panel-heading { padding: 0.8rem 0.7rem 0.9rem; }
    .orbit-grid { grid-template-columns: 1fr; }
    .orbit-destination { min-height: 4.55rem; }
    .orbit-account { grid-template-columns: auto minmax(0, 1fr); }
    .orbit-account form { grid-column: 1 / -1; }
    .orbit-signout { justify-content: center; width: 100%; }
    .page-shell { padding-bottom: 2.5rem; }
    h1 { font-size: 2.25rem; }
    .metric-grid { grid-template-columns: 1fr; }
    .metric-primary { grid-row: auto; }
    .metric-card { min-height: 8.25rem; }
    .action-row { grid-template-columns: 1fr; }
    .action-row .avatar { display: none; }
    .action-row .card-actions { grid-column: 1; }
    .action-row .card-actions .button { flex: 1; }
    .balance-card-top, .share-heading, .payment-row, .confirmation-panel { flex-direction: column; }
    .amount-block { text-align: left; }
    .card-actions .button { flex: 1; }
    .payment-actions { justify-content: start; }
    dl div { flex-direction: column; gap: 0.3rem; }
    dd { max-width: 100%; text-align: left; }
    .upload-preview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-metrics { grid-template-columns: 1fr; }
    .trend-chart { grid-auto-columns: minmax(3.25rem, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}


/* ALX Apps workspace launcher */
.workspace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 1.25rem;
}
.workspace-card {
    display: flex;
    align-items: center;
    min-height: 8.5rem;
    gap: 1.25rem;
    padding: 1.5rem 1.65rem;
    color: inherit;
    text-decoration: none;
    transition: transform 140ms ease, box-shadow 140ms ease;
}
.workspace-card .brand-mark {
    flex: 0 0 auto;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    font-size: 0.9rem;
}
.workspace-card strong {
    font-size: 1.2rem;
    line-height: 1.25;
}
.workspace-card > span:last-child {
    color: var(--accent);
    font-size: 1.5rem;
}
.workspace-card:hover,
.workspace-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgb(8 19 31 / 14%);
}
.workspace-card > span:nth-child(2) {
    display: grid;
    gap: 0.25rem;
    flex: 1;
}
.workspace-card small {
    color: var(--muted);
}

.ledger-filters { display: grid; grid-template-columns: minmax(12rem, 2fr) repeat(5, minmax(8rem, 1fr)); align-items: end; gap: 0.75rem; padding: 1rem; }
.ledger-filter-field { display: grid; gap: 0.35rem; min-width: 0; }
.ledger-filter-field label, .rejection-form label { color: var(--muted); font-size: 0.72rem; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.ledger-filter-control { width: 100%; min-height: 2.7rem; padding: 0.55rem 0.7rem; color: var(--ink); background: #fbfdfe; border: 1px solid var(--line-strong); border-radius: 0.7rem; }
.ledger-filters .button-row { grid-column: 1 / -1; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 0.75rem; margin-top: 1rem; color: var(--muted); font-size: 0.85rem; font-weight: 750; }
.review-panel { align-items: start; }
.review-actions { display: grid; justify-items: end; gap: 0.8rem; min-width: min(100%, 22rem); }
.rejection-form { display: grid; width: 100%; gap: 0.5rem; }
.rejection-form textarea { width: 100%; min-height: 5rem; padding: 0.65rem; border: 1px solid var(--line-strong); border-radius: 0.7rem; resize: vertical; }
.rejected-panel { border-color: #f0bcbc; background: linear-gradient(135deg, #fff, var(--red-bg)); }

@media (max-width: 980px) {
    .ledger-filters { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .ledger-filters { grid-template-columns: 1fr 1fr; }
    .ledger-filter-field:first-of-type { grid-column: 1 / -1; }
    .review-actions { justify-items: stretch; width: 100%; }
}

@media (max-width: 520px) {
    .ledger-filters { grid-template-columns: 1fr; }
    .ledger-filter-field:first-of-type { grid-column: auto; }
}
.grocery-heading { margin-bottom: 1.5rem; }
.grocery-search { display: grid; grid-template-columns: minmax(9rem, 0.55fr) minmax(15rem, 1.45fr); align-items: center; gap: 1rem; margin-bottom: 1.75rem; padding: 1rem 1.15rem; }
.grocery-search label { display: grid; gap: 0.2rem; }
.grocery-search label strong { font-size: 1rem; }
.grocery-search-control { position: relative; min-width: 0; }
.grocery-search-control > span { position: absolute; top: 50%; left: 0.85rem; color: var(--muted); font-size: 1.35rem; line-height: 1; transform: translateY(-52%); pointer-events: none; }
.grocery-search-control input { width: 100%; min-height: 3rem; padding: 0.7rem 0.9rem 0.7rem 2.65rem; color: var(--ink); background: #fbfdfe; border: 1px solid var(--line-strong); border-radius: 0.8rem; }
.grocery-search-control input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 127, 140, 0.1); }
.grocery-section { margin-bottom: 2.25rem; }
.grocery-section-heading { align-items: end; }
.grocery-heading-actions { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.grocery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.grocery-card { display: grid; align-content: space-between; min-width: 0; min-height: 9.5rem; gap: 1.1rem; padding: 1.1rem; }
.grocery-card.grocery-needed { border-color: #e7c88f; background: linear-gradient(145deg, #fff, #fffaf0); }
.grocery-card-copy { display: flex; align-items: start; min-width: 0; gap: 0.75rem; }
.grocery-card-copy > div { min-width: 0; }
.grocery-card h3 { overflow-wrap: anywhere; margin: 0 0 0.45rem; }
.stock-dot { flex: 0 0 auto; width: 0.8rem; height: 0.8rem; margin-top: 0.34rem; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-strong); }
.stock-dot.in { background: var(--green); }
.stock-dot.out { background: #d88a18; }
.status.grocery-in { color: var(--green); background: var(--green-bg); }
.status.grocery-out { color: #7a4a00; background: var(--amber-bg); }
.grocery-actions { justify-content: flex-end; }
.grocery-actions form { display: inline-flex; }
.grocery-search-empty { margin-top: 0.85rem; }
.shopping-complete-symbol { display: grid; place-items: center; width: 3.3rem; height: 3.3rem; margin: 0 auto 1rem; border-radius: 50%; color: white; background: var(--green); font-size: 1.4rem; font-weight: 900; }

@media (max-width: 700px) {
    .grocery-heading .button { width: 100%; }
    .grocery-search { grid-template-columns: 1fr; gap: 0.65rem; }
    .grocery-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .grocery-section-heading { align-items: start; }
    .grocery-heading-actions { width: 100%; justify-content: space-between; }
    .grocery-actions { align-items: stretch; }
    .grocery-actions > .button, .grocery-actions form, .grocery-actions form .button { flex: 1 1 auto; }
}
