/* Celvoa back-office design system.
   Default theme is dark; a light theme is applied via [data-theme="light"]. */
:root {
    --bg: #0f172a;
    --surface: #111c2f;
    --surface-2: #16223a;
    --surface-strong: #1f2c46;
    --text: #f8fafc;
    --muted: #cbd5f5;
    --faint: #94a3b8;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.18);

    --brand: #60a5fa;
    --brand-dark: #3b82f6;
    --brand-tint: rgba(96, 165, 250, 0.16);

    --info: #38bdf8;
    --info-tint: rgba(56, 189, 248, 0.16);
    --warn: #f97316;
    --warn-tint: rgba(249, 115, 22, 0.16);
    --danger: #ef4444;
    --danger-tint: rgba(239, 68, 68, 0.16);
    --success: #34d399;
    --success-tint: rgba(52, 211, 153, 0.16);

    --pos: #34d399;
    --neg: #f87171;

    --field-bg: #0e1a2e;
    --topbar-bg: rgba(17, 28, 47, 0.85);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.22);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --sidebar-w: 16.5rem;
    --sidebar-collapsed-w: 4.4rem;
    --topbar-h: 3.75rem;

    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Roboto Mono", "Segoe UI Mono", Consolas, monospace;
}

/* Component variables for dark mode so grids match the dark chrome. */
[data-theme="dark"] {
    --kendo-color-app-surface: #0f172a;
    --kendo-color-on-app-surface: #f8fafc;
    --kendo-color-surface: #111c2f;
    --kendo-color-surface-alt: #0e1a2e;
    --kendo-color-base: #111c2f;
    --kendo-color-base-subtle: #16223a;
    --kendo-color-base-hover: #1f2c46;
    --kendo-color-on-base: #f8fafc;
    --kendo-color-border: rgba(255, 255, 255, 0.14);
    --kendo-color-border-alt: rgba(255, 255, 255, 0.20);
    --kendo-color-primary: #60a5fa;
    --kendo-color-primary-hover: #3b82f6;
    --kendo-color-on-primary: #08111f;
}

/* Light theme. */
[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-strong: #eef2f7;
    --text: #0f172a;
    --muted: #64748b;
    --faint: #94a3b8;
    --line: rgba(15, 23, 42, 0.12);
    --line-strong: #cbd5e1;

    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --brand-tint: #eef2ff;

    --info: #0ea5e9;
    --info-tint: #e0f2fe;
    --warn: #f97316;
    --warn-tint: #ffedd5;
    --danger: #ef4444;
    --danger-tint: #fee2e2;
    --success: #10b981;
    --success-tint: #dcfce7;

    --pos: #16a34a;
    --neg: #dc2626;

    --field-bg: #ffffff;
    --topbar-bg: rgba(255, 255, 255, 0.92);

    --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.10);
    --shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    font-family: var(--font);
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    font-size: 0.925rem;
    line-height: 1.5;
}

/* ---------- Celvoa public landing page ---------- */
.landing-page {
    --landing-bg: #f7fbf8;
    --landing-ink: #102d2e;
    --landing-muted: #526765;
    --landing-line: rgba(16, 45, 46, 0.14);
    --landing-panel: #ffffff;
    --landing-soft: #edf5f1;
    --landing-accent: #1f7a70;
    --landing-accent-2: #bf8b2f;
    --landing-deep: #223a5e;
    background: var(--landing-bg);
    color: var(--landing-ink);
    font-size: 1rem;
}

.landing-page a {
    color: inherit;
}

.landing-nav,
.landing-hero,
.landing-band,
.landing-cta,
.landing-footer {
    inline-size: min(1180px, calc(100% - 2rem));
    margin-inline: auto;
}

.landing-nav {
    align-items: center;
    display: flex;
    justify-content: space-between;
    min-height: 4.5rem;
    gap: 1rem;
}

.landing-brand,
.landing-nav-links,
.landing-actions,
.workflow-strip {
    align-items: center;
    display: flex;
}

.landing-brand {
    gap: 0.65rem;
    font-weight: 800;
    text-decoration: none;
}

.landing-brand-mark {
    align-items: center;
    background: var(--landing-ink);
    border-radius: 8px;
    color: #ffffff;
    display: inline-flex;
    font-size: 0.78rem;
    font-weight: 900;
    height: 2.25rem;
    justify-content: center;
    letter-spacing: 0;
    width: 2.25rem;
}

.landing-nav-links {
    gap: 1rem;
    color: var(--landing-muted);
    font-size: 0.92rem;
    font-weight: 650;
}

.landing-nav-links a {
    text-decoration: none;
}

.landing-nav-cta {
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    color: var(--landing-ink) !important;
    padding: 0.55rem 0.85rem;
}

.landing-nav-cta.login {
    background: var(--landing-ink);
    color: #ffffff !important;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(22rem, 1.08fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    min-height: 82vh;
    padding: clamp(2.5rem, 7vw, 5.5rem) 0 3rem;
    align-items: center;
}

.landing-hero-copy {
    display: grid;
    gap: 1.1rem;
}

.landing-eyebrow {
    color: var(--landing-accent);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    margin: 0;
    text-transform: uppercase;
}

.landing-hero h1 {
    color: var(--landing-ink);
    font-size: clamp(2.6rem, 6vw, 5rem);
    line-height: 0.98;
    letter-spacing: 0;
    margin: 0;
    max-width: 10ch;
}

.landing-lede,
.landing-section-copy,
.landing-band p,
.landing-cta p,
.landing-safe-note {
    color: var(--landing-muted);
}

.landing-lede {
    font-size: clamp(1.02rem, 2vw, 1.22rem);
    line-height: 1.65;
    margin: 0;
    max-width: 44rem;
}

.landing-actions {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.landing-button {
    border-radius: 8px;
    display: inline-flex;
    font-weight: 800;
    justify-content: center;
    min-width: 9.5rem;
    padding: 0.85rem 1.1rem;
    text-decoration: none;
}

.landing-button.primary {
    background: var(--landing-accent);
    color: #ffffff;
}

.landing-button.secondary {
    background: #ffffff;
    border: 1px solid var(--landing-line);
    color: var(--landing-ink);
}

.landing-safe-note {
    border-inline-start: 3px solid var(--landing-accent-2);
    font-size: 0.9rem;
    line-height: 1.55;
    margin: 0;
    padding-inline-start: 0.85rem;
}

.landing-visual {
    align-items: end;
    display: grid;
    grid-template-columns: minmax(12rem, 0.62fr) minmax(18rem, 1fr);
    gap: 1rem;
}

.mock-phone,
.mock-console {
    background: var(--landing-panel);
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(16, 45, 46, 0.12);
    color: var(--landing-ink);
}

.mock-phone {
    display: grid;
    gap: 0.9rem;
    min-height: 25rem;
    padding: 1rem;
}

.mock-phone-header,
.mock-console-header {
    display: grid;
    gap: 0.25rem;
}

.mock-phone-header span,
.mock-console-header span {
    color: var(--landing-muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.mock-phone-header small {
    color: var(--landing-accent);
    font-weight: 750;
}

.mock-rate-card {
    background: var(--landing-soft);
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    display: grid;
    gap: 0.3rem;
    padding: 0.9rem;
}

.mock-rate-card span,
.mock-request-list span,
.mock-table span {
    color: var(--landing-muted);
    font-size: 0.82rem;
}

.mock-rate-card strong {
    color: var(--landing-deep);
    font-size: 1.15rem;
}

.mock-request-list,
.mock-table {
    display: grid;
    gap: 0.55rem;
}

.mock-request-list div,
.mock-table div {
    align-items: center;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    min-height: 3rem;
    padding: 0.65rem 0.75rem;
}

.mock-request-list strong,
.mock-table strong {
    color: var(--landing-accent);
    font-size: 0.82rem;
}

.mock-console {
    display: grid;
    gap: 1rem;
    min-height: 18rem;
    padding: 1.2rem;
}

.mock-workflow-row {
    align-items: center;
    background: #f9f6ec;
    border: 1px solid rgba(191, 139, 47, 0.28);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.75rem;
}

.mock-workflow-row span,
.workflow-strip span {
    background: #ffffff;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    font-size: 0.84rem;
    font-weight: 750;
    padding: 0.45rem 0.65rem;
}

.mock-workflow-row b,
.workflow-strip b {
    color: var(--landing-accent-2);
}

.landing-band {
    padding: clamp(3rem, 7vw, 5rem) 0;
}

.landing-band.alt {
    background: var(--landing-soft);
    inline-size: 100%;
    margin-inline: 0;
}

.landing-band.alt > *,
.landing-band.alt .landing-section-heading,
.landing-band.alt .solution-grid,
.landing-band.alt .feature-list {
    inline-size: min(1180px, calc(100% - 2rem));
    margin-inline: auto;
}

.landing-section-heading {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1.4rem;
    max-width: 45rem;
}

.landing-section-heading h2,
.landing-band h2,
.landing-cta h2 {
    color: var(--landing-ink);
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.08;
    letter-spacing: 0;
    margin: 0;
}

.landing-section-copy,
.landing-band p {
    font-size: 1rem;
    line-height: 1.65;
    max-width: 56rem;
}

.landing-points,
.solution-grid,
.feature-list,
.landing-benefits {
    display: grid;
    gap: 0.85rem;
}

.landing-points {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.landing-points p,
.solution-grid article {
    background: #ffffff;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    margin: 0;
    padding: 1rem;
}

.solution-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.solution-grid h3 {
    color: var(--landing-deep);
    font-size: 1rem;
    margin: 0 0 0.45rem;
}

.solution-grid p {
    font-size: 0.92rem;
    margin: 0;
}

.white-label {
    display: grid;
    gap: 1rem;
}

.workflow-strip {
    background: var(--landing-soft);
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 0.65rem;
    max-width: 48rem;
    padding: 0.9rem;
}

.powered-line {
    color: var(--landing-accent) !important;
    font-size: 0.9rem !important;
    font-weight: 800;
    margin: 0;
}

.feature-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    list-style: none;
    margin-block: 0;
    padding: 0;
}

.feature-list li,
.landing-benefits li {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--landing-line);
    border-radius: 8px;
    display: flex;
    min-height: 3rem;
    padding: 0.75rem 0.9rem;
}

.split {
    align-items: start;
    display: grid;
    gap: 2rem;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.65fr);
}

.landing-benefits {
    list-style: none;
    margin: 0;
    padding: 0;
}

.market {
    border-block: 1px solid var(--landing-line);
}

.landing-cta {
    align-items: center;
    display: flex;
    gap: 2rem;
    justify-content: space-between;
    padding: clamp(3rem, 7vw, 5rem) 0;
}

.landing-cta p {
    margin-bottom: 0;
}

.landing-footer {
    border-top: 1px solid var(--landing-line);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    padding: 1.5rem 0 2rem;
}

.landing-footer p {
    color: var(--landing-muted);
    margin: 0;
    max-width: 38rem;
}

.landing-footer nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.landing-footer a {
    color: var(--landing-muted);
    font-weight: 650;
    text-decoration: none;
}

@media (max-width: 980px) {
    .landing-hero,
    .landing-points,
    .solution-grid,
    .feature-list,
    .split {
        grid-template-columns: 1fr;
    }

    .landing-hero {
        min-height: auto;
    }

    .landing-visual {
        grid-template-columns: 1fr;
    }

    .mock-phone,
    .mock-console {
        min-height: auto;
    }

    .landing-cta {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 700px) {
    .landing-nav {
        align-items: flex-start;
        flex-direction: column;
        padding: 0.9rem 0;
    }

    .landing-nav-links {
        inline-size: 100%;
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .landing-hero h1 {
        max-width: 12ch;
    }

    .landing-button {
        inline-size: 100%;
    }
}

h1, h2, h3 {
    line-height: 1.25;
}

a {
    color: var(--brand-dark);
}

button,
input,
select,
textarea {
    font: inherit;
}

.num,
.amount,
td.num,
th.num,
.rate-readout strong,
.metric-card strong,
table tbody td:is(.num) {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.text-end { text-align: end; }
.text-muted { color: var(--muted); }

/* ---------- App shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.16s ease;
}

.side-nav {
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    min-height: 100vh;
    padding: 1rem 0.85rem 1.5rem;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 100vh;
    overflow-y: auto;
}

.brand {
    align-items: center;
    color: inherit;
    display: flex;
    gap: 0.7rem;
    padding: 0.35rem 0.4rem 1rem;
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--success) 70%, var(--brand)));
    border-radius: 10px;
    color: #fff;
    display: inline-flex;
    font-weight: 800;
    height: 2.5rem;
    width: 2.5rem;
    justify-content: center;
    letter-spacing: 0.02em;
    box-shadow: var(--shadow-sm);
}

.brand strong {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand small {
    color: var(--muted);
    display: block;
    font-size: 0.72rem;
    margin-top: 0.05rem;
}

.side-nav nav {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.nav-section {
    color: var(--faint);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin: 0.9rem 0.55rem 0.3rem;
}

.nav-link {
    align-items: center;
    border-radius: var(--radius-sm);
    color: var(--muted);
    display: flex;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}

body.nav-collapsed .app-shell {
    grid-template-columns: var(--sidebar-collapsed-w) minmax(0, 1fr);
}

body.nav-collapsed .side-nav {
    overflow-x: hidden;
    padding-inline: 0.55rem;
}

body.nav-collapsed .brand {
    justify-content: center;
    padding-inline: 0;
}

body.nav-collapsed .brand > span:not(.brand-mark),
body.nav-collapsed .nav-section,
body.nav-collapsed .nav-link span {
    display: none;
}

body.nav-collapsed .nav-link {
    justify-content: center;
    padding-inline: 0;
}

.nav-link:hover {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

.nav-link.active {
    background: var(--brand-tint);
    color: var(--brand-dark);
    font-weight: 700;
}

.nav-link .nav-icon {
    flex: 0 0 auto;
    color: var(--muted);
}

.nav-link.active .nav-icon {
    color: var(--brand);
}

.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
    stroke-width: 1.9;
}

.nav-spacer {
    flex: 1 1 auto;
}

.user-strip {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 0.55rem;
    margin-top: 0.5rem;
    padding: 0.7rem;
    background: var(--surface-2);
}

.user-strip .user-name {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.user-strip .user-role {
    color: var(--muted);
    font-size: 0.78rem;
}

.user-strip form {
    margin: 0;
}

/* ---------- Main column + global top bar ---------- */
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-global {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    background: var(--topbar-bg);
    backdrop-filter: saturate(140%) blur(6px);
    border-bottom: 1px solid var(--line);
}

.topbar-global .brand-compact {
    display: none;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: inherit;
    font-weight: 700;
}

.env-chip {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--muted);
    display: inline-flex;
    font-size: 0.82rem;
    font-weight: 600;
    gap: 0.45rem;
    padding: 0.35rem 0.7rem;
}

.topbar-spacer {
    flex: 1 1 auto;
}

.topbar-right {
    align-items: center;
    display: flex;
    gap: 0.6rem;
}

.lang-chip {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--muted);
    display: inline-flex;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.7rem;
    text-decoration: none;
}

.lang-chip:hover {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

.theme-toggle {
    cursor: pointer;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
    display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
    display: inline-flex;
}

/* ---------- Language switcher (globe dropdown) ---------- */
.lang-menu {
    position: relative;
}

.lang-menu > summary {
    list-style: none;
    cursor: pointer;
}

.lang-menu > summary::-webkit-details-marker {
    display: none;
}

.lang-menu .lang-caret {
    transition: transform 0.15s ease;
}

.lang-menu[open] .lang-caret {
    transform: rotate(180deg);
}

.lang-menu-panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 6px);
    min-width: 11rem;
    display: grid;
    gap: 0.1rem;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 40;
}

.lang-item {
    align-items: center;
    border-radius: 6px;
    color: var(--text);
    display: flex;
    gap: 0.6rem;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    text-decoration: none;
    font-size: 0.88rem;
}

.lang-item:hover {
    background: var(--surface-strong);
}

.lang-item.active {
    color: var(--brand-dark);
    font-weight: 700;
}

.auth-topbar {
    position: absolute;
    inset-block-start: 1rem;
    inset-inline-end: 1.25rem;
    z-index: 20;
}

.avatar {
    align-items: center;
    background: var(--brand-tint);
    border-radius: var(--radius-pill);
    color: var(--brand-dark);
    display: inline-flex;
    font-weight: 800;
    height: 2.1rem;
    width: 2.1rem;
    justify-content: center;
    font-size: 0.85rem;
}

/* Account menu keeps profile and session commands anchored in the global top bar. */
.profile-menu {
    position: relative;
}

.profile-trigger {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    gap: 0.45rem;
    list-style: none;
    max-width: 15rem;
    padding: 0.2rem 0.55rem 0.2rem 0.2rem;
}

.profile-trigger::-webkit-details-marker {
    display: none;
}

.profile-trigger:hover {
    background: var(--surface-strong);
}

.profile-trigger-name {
    font-size: 0.84rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-menu-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    display: grid;
    gap: 0.1rem;
    inset-inline-end: 0;
    min-width: 12rem;
    padding: 0.35rem;
    position: absolute;
    top: calc(100% + 6px);
    z-index: 45;
}

.profile-menu-item {
    align-items: center;
    border-radius: 6px;
    color: var(--text);
    display: flex;
    font-size: 0.88rem;
    gap: 0.45rem;
    justify-content: flex-start;
    padding: 0.5rem 0.65rem;
    text-decoration: none;
    width: 100%;
}

.profile-menu-item:hover {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

.profile-menu-panel form {
    margin: 0;
}

button.profile-menu-item.as-button {
    background: transparent;
    border: 0;
    color: var(--text);
    min-height: auto;
}

button.profile-menu-item.as-button:hover {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

button.profile-menu-item.danger {
    color: var(--danger);
}

.menu-toggle {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.4rem 0.55rem;
    min-height: auto;
}

.nav-collapse-toggle {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    min-height: auto;
    padding: 0.4rem 0.5rem;
}

body.nav-collapsed .nav-collapse-icon {
    transform: rotate(180deg);
}

.status-dot {
    background: var(--success);
    border-radius: var(--radius-pill);
    box-shadow: 0 0 0 3px rgba(31, 157, 106, 0.16);
    display: inline-block;
    height: 0.6rem;
    width: 0.6rem;
}

.main-surface {
    min-width: 0;
    padding: 1.5rem;
    flex: 1 1 auto;
}

/* ---------- Breadcrumbs + page header ---------- */
.breadcrumbs {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 0.8rem;
    gap: 0.4rem;
    margin-bottom: 0.85rem;
}

.breadcrumbs a {
    color: var(--muted);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--brand-dark);
}

.breadcrumbs .sep {
    color: var(--faint);
}

[dir="rtl"] .breadcrumbs .sep {
    transform: scaleX(-1);
}

.topbar,
.panel-header,
.topbar-actions,
.form-actions,
.amount-row {
    align-items: center;
    display: flex;
}

.topbar {
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.topbar h1,
.panel h2 {
    margin: 0;
}

.topbar h1 {
    font-size: 1.55rem;
    letter-spacing: -0.015em;
}

.eyebrow {
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    margin: 0 0 0.25rem;
    text-transform: uppercase;
}

.topbar-actions {
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ---------- Alerts ---------- */
.notice,
.alert,
.warn-note {
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid transparent;
}

.notice {
    background: color-mix(in srgb, var(--success) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--success) 38%, transparent);
    color: color-mix(in srgb, var(--success) 72%, var(--text));
}

.alert {
    background: color-mix(in srgb, var(--danger) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--danger) 38%, transparent);
    color: color-mix(in srgb, var(--danger) 72%, var(--text));
}

.warn-note {
    background: color-mix(in srgb, var(--warn) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--warn) 38%, transparent);
    color: color-mix(in srgb, var(--warn) 74%, var(--text));
}

.notice p,
.alert p,
.warn-note p {
    margin: 0;
}

/* ---------- Toasts ---------- */
.toast-stack {
    display: grid;
    gap: 0.75rem;
    inline-size: min(24rem, calc(100vw - 2rem));
    inset-block-start: 1rem;
    inset-inline-end: 1rem;
    position: fixed;
    z-index: 120;
    pointer-events: none;
}

.toast-stack .notice,
.notice.toast-message {
    align-items: flex-start;
    box-shadow: var(--shadow);
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin: 0;
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast-stack .notice {
    background: color-mix(in srgb, var(--success) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--success) 38%, transparent);
    color: color-mix(in srgb, var(--success) 72%, var(--text));
}

.toast-message.is-hiding {
    opacity: 0;
    transform: translateY(-0.4rem);
}

.toast-dismiss {
    background: transparent;
    border: 0;
    color: currentColor;
    min-height: 0;
    opacity: 0.7;
    padding: 0 0 0 0.5rem;
}

.toast-dismiss:hover,
.toast-dismiss:focus-visible {
    background: transparent;
    border-color: transparent;
    opacity: 1;
}

/* ---------- Metrics ---------- */
.metrics-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.metric-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.metric-card {
    min-height: 6rem;
    padding: 1.05rem 1.1rem;
}

.metric-card span {
    color: var(--muted);
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
}

.metric-card strong {
    display: block;
    font-size: 1.5rem;
    margin-top: 0.6rem;
    overflow-wrap: anywhere;
    letter-spacing: -0.01em;
}

.metric-card .metric-foot {
    color: var(--faint);
    font-size: 0.75rem;
    margin-top: 0.35rem;
    font-weight: 500;
}

/* ---------- Layout grids ---------- */
.work-grid,
.tables-grid {
    display: grid;
    gap: 1rem;
}

.work-grid {
    grid-template-columns: minmax(0, 2fr) minmax(18rem, 0.95fr);
    margin-bottom: 1.25rem;
    align-items: start;
}

.rail {
    display: grid;
    gap: 1rem;
    align-content: start;
    min-width: 0;
}

.rail-shell {
    display: grid;
    gap: 0.65rem;
    min-width: 0;
}

.rail-toggle {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text);
    justify-self: start;
    min-height: 2.25rem;
    padding: 0.4rem 0.7rem;
}

.rail-toggle:hover {
    background: var(--surface-strong);
    border-color: var(--line-strong);
}

.rail-toggle-icon {
    transition: transform 0.12s ease;
}

.rail-toggle[aria-expanded="false"] .rail-toggle-icon {
    transform: rotate(180deg);
}

.work-grid.rail-collapsed {
    grid-template-columns: minmax(0, 1fr) auto;
}

.customer-summary {
    display: grid;
    gap: 0.55rem;
}

.customer-summary .badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.balance-row {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
}

.balance-row:last-child {
    border-bottom: none;
}

.balance-row .amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.tables-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-library-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1.25rem;
}

.report-library-card {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.report-library-card .filter-chips {
    margin-top: auto;
}

.report-library-card .button-link {
    align-self: flex-start;
}

.report-charts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.report-charts.is-single {
    grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 1100px) {
    .report-charts {
        grid-template-columns: 1fr;
    }
}

.panel {
    min-width: 0;
    padding: 1.15rem;
}

.panel.flush {
    padding: 0;
    overflow: hidden;
}

.page-section {
    margin-top: 1.25rem;
}

.panel-header {
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.panel.flush .panel-header {
    margin-bottom: 0;
    padding: 1.05rem 1.15rem 0.85rem;
}

.panel h2 {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.panel h3 {
    font-size: 0.95rem;
    margin: 0;
}

.panel-sub {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0.15rem 0 0;
}

/* ---------- Pills / badges ---------- */
.pill,
.badge {
    align-items: center;
    border-radius: var(--radius-pill);
    display: inline-flex;
    font-size: 0.76rem;
    font-weight: 600;
    gap: 0.3rem;
    line-height: 1.3;
    padding: 0.22rem 0.6rem;
    white-space: nowrap;
}

.pill {
    background: var(--info-tint);
    border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
    color: color-mix(in srgb, var(--info) 72%, var(--text));
}

.badge::before {
    content: "";
    width: 0.42rem;
    height: 0.42rem;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.badge.is-neutral { background: var(--surface-strong); color: var(--muted); }
.badge.is-success { background: var(--success-tint); color: color-mix(in srgb, var(--success) 72%, var(--text)); }
.badge.is-info { background: var(--info-tint); color: color-mix(in srgb, var(--info) 72%, var(--text)); }
.badge.is-warning { background: var(--warn-tint); color: color-mix(in srgb, var(--warn) 74%, var(--text)); }
.badge.is-danger { background: var(--danger-tint); color: color-mix(in srgb, var(--danger) 72%, var(--text)); }

/* ---------- Forms ---------- */
.entry-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-check {
    align-items: center;
    display: inline-flex;
    gap: 0.5rem;
}

.inline-check input {
    width: auto;
}

.inline-form {
    margin: 0;
}

.public-board {
    background: var(--bg);
}

.public-board-shell {
    margin: 0 auto;
    max-width: 62rem;
    padding: 2rem clamp(1rem, 4vw, 2rem);
}

.single-column {
    grid-template-columns: 1fr;
}

.fieldset {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem 1.15rem;
    margin: 0 0 1rem;
}

.fieldset > legend {
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0 0.4rem;
    text-transform: uppercase;
}

label {
    display: grid;
    gap: 0.35rem;
}

label > span {
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
}

.field-label {
    align-items: center;
    display: inline-flex;
    gap: 0.35rem;
    width: fit-content;
}

.field-tooltip {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    color: var(--muted);
    cursor: help;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.68rem;
    font-weight: 800;
    height: 1rem;
    justify-content: center;
    line-height: 1;
    position: relative;
    width: 1rem;
}

.field-tooltip::after {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    content: attr(data-tooltip);
    display: none;
    font-size: 0.78rem;
    font-weight: 500;
    inset-block-end: calc(100% + 0.45rem);
    inset-inline-start: 50%;
    line-height: 1.4;
    max-width: min(18rem, calc(100vw - 2rem));
    padding: 0.5rem 0.6rem;
    position: absolute;
    transform: translateX(-50%);
    white-space: normal;
    width: max-content;
    z-index: 80;
}

.field-tooltip:hover::after,
.field-tooltip:focus-visible::after {
    display: block;
}

label small,
.rate-readout small,
.help {
    color: var(--muted);
    font-size: 0.77rem;
}

.wide {
    grid-column: 1 / -1;
}

.rate-readout {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 0.25rem;
    min-height: 4.6rem;
    padding: 0.7rem 0.8rem;
}

.rate-readout span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.rate-readout strong {
    font-size: 1.2rem;
    letter-spacing: -0.01em;
}

.amount-row {
    gap: 0.5rem;
}

input,
select,
textarea {
    background: var(--field-bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    min-height: 2.6rem;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    width: 100%;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
    min-height: 4.5rem;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent);
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--info);
    outline-offset: 1px;
}

.amount-row select {
    flex: 0 0 6.5rem;
}

.amount-row input {
    flex: 1 1 auto;
}

.form-actions {
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1.1rem;
    flex-wrap: wrap;
}

.workflow-progress {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    margin-bottom: 1rem;
}

.workflow-progress span {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    padding: 0.55rem 0.7rem;
    text-align: center;
}

.workflow-section-title {
    border-block-start: 1px solid var(--border);
    padding-block-start: 0.9rem;
}

.allocation-target-cell {
    min-width: 16rem;
}

.allocation-target-cell label {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.allocation-selector[hidden] {
    display: none;
}

.allocation-target-cell span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.review-panel {
    border-block-start: 1px solid var(--border);
    padding-block-start: 1rem;
}

.notes-section {
    border-block-start: 1px solid var(--border);
    padding-block-start: 1rem;
}

.completion-panel {
    border-color: color-mix(in oklab, var(--success) 28%, var(--border));
}

/* ---------- Buttons ---------- */
button,
.button-link {
    align-items: center;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: var(--radius-sm);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    gap: 0.4rem;
    font-weight: 600;
    justify-content: center;
    min-height: 2.55rem;
    padding: 0.55rem 0.95rem;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease, transform 0.04s ease;
    white-space: nowrap;
}

button:hover,
.button-link:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

button:active,
.button-link:active {
    transform: translateY(1px);
}

button.secondary,
.secondary-link,
.nav-command {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--text);
}

button.secondary:hover,
.secondary-link:hover,
.nav-command:hover {
    background: var(--surface-strong);
    border-color: var(--line-strong);
}

.customer-import-form {
    margin: 0;
}

.customer-import-trigger {
    position: relative;
}

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}

.import-result-panel {
    margin-bottom: 1rem;
}

button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

button.danger:hover {
    background: color-mix(in srgb, var(--danger) 80%, black);
    border-color: color-mix(in srgb, var(--danger) 80%, black);
}

.compact-action {
    min-height: 2.1rem;
    padding: 0.34rem 0.58rem;
}

.row-actions {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    min-width: 7.25rem;
    white-space: nowrap;
}

button.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--brand-dark);
    min-height: auto;
    padding: 0.3rem 0.5rem;
}

button.ghost:hover {
    background: var(--surface-strong);
}

button:disabled {
    background: var(--surface-strong);
    border-color: var(--line-strong);
    color: var(--faint);
    cursor: not-allowed;
}

.btn-sm,
.actions-cell button,
.actions-cell .button-link {
    min-height: 2.1rem;
    padding: 0.35rem 0.6rem;
    font-size: 0.84rem;
}

.secondary-link,
.nav-command {
    background: var(--surface);
}

.nav-command {
    width: 100%;
    min-height: 2.3rem;
}

/* ---------- Toolbar / search ---------- */
.toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.cheque-filterbar {
    align-items: end;
}

.cheque-filterbar button {
    min-height: 2.6rem;
}

.toolbar .search {
    flex: 1 1 16rem;
    position: relative;
}

.toolbar .search input {
    padding-inline-start: 2.2rem;
}

.toolbar .search .search-icon {
    position: absolute;
    inset-inline-start: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--faint);
    pointer-events: none;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chip {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--muted);
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    text-decoration: none;
}

.chip.active {
    background: var(--brand-tint);
    border-color: #bfdccf;
    color: var(--brand-dark);
    font-weight: 600;
}

.permission-note {
    background: var(--warn-tint);
    border: 1px solid #ecd6a4;
    border-radius: var(--radius-sm);
    color: #7c4d0c;
    margin: 1rem 0 0;
    padding: 0.7rem 0.85rem;
}

.permission-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 1rem;
}

.permission-item,
.language-option {
    align-items: flex-start;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: flex;
    gap: 0.65rem;
    padding: 0.7rem;
}

.permission-item input,
.language-option input,
.security-check input,
.check-row input {
    flex: 0 0 auto;
    margin-top: 0.2rem;
    min-height: auto;
    width: auto;
}

.permission-item strong,
.language-option strong {
    display: block;
}

.permission-item small,
.language-option small {
    color: var(--muted);
    display: block;
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.user-access-list {
    display: grid;
    gap: 1rem;
}

.user-access-row {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
}

.user-access-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.85rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.user-access-head span {
    color: var(--muted);
    display: block;
    font-size: 0.82rem;
    margin-top: 0.1rem;
}

/* Profile security cards use compact detail blocks for repeat operator visits. */
.profile-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-card {
    min-height: 100%;
}

.profile-summary {
    display: grid;
    gap: 0.75rem;
    margin: 0;
}

.profile-summary div {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.7rem;
}

.profile-summary dt {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.profile-summary dd {
    margin: 0.15rem 0 0;
    overflow-wrap: anywhere;
}

.status-pill {
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
}

.status-ok {
    background: var(--success-tint);
    color: color-mix(in srgb, var(--success) 80%, var(--text));
}

.status-warning {
    background: var(--warn-tint);
    color: color-mix(in srgb, var(--warn) 82%, var(--text));
}

.muted {
    color: var(--muted);
    margin: 0.2rem 0 0;
}

.setup-key {
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 0.35rem;
    margin-top: 1rem;
    padding: 0.8rem;
}

.setup-key span,
.setup-key small,
.passkey-row span {
    color: var(--muted);
}

.setup-key code {
    background: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    overflow-wrap: anywhere;
    padding: 0.55rem;
}

.passkey-entry {
    align-items: end;
    margin-top: 1rem;
}

.passkey-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.passkey-row {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    padding: 0.75rem;
}

.passkey-row div {
    display: grid;
    gap: 0.15rem;
}

.passkey-row .nav-command {
    flex: 0 0 auto;
    width: auto;
}

.language-options {
    display: grid;
    gap: 0.65rem;
}

.rate-list {
    display: grid;
    gap: 0.45rem;
}

.rate-list div {
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    min-height: 2.4rem;
    padding: 0.5rem 0.7rem;
}

.subsection {
    border-top: 1px solid var(--line);
    margin-top: 1rem;
    padding-top: 1rem;
}

.subsection h3 {
    font-size: 0.95rem;
    margin: 0 0 0.7rem;
}

.close-form {
    display: grid;
}

/* ---------- Tables ---------- */
table {
    border-collapse: collapse;
    font-size: 0.88rem;
    width: 100%;
}

.panel.flush table {
    margin: 0;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.65rem 0.75rem;
    text-align: start;
    vertical-align: middle;
}

thead th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}

tbody tr:hover {
    background: var(--surface-2);
}

td {
    overflow-wrap: anywhere;
}

td.num,
th.num {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.stacked-inputs {
    display: grid;
    gap: 0.35rem;
}

.actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.actions-cell form {
    margin: 0;
}

.inactive-row {
    color: var(--muted);
}

.inactive-row input:not([type="checkbox"]) {
    background: var(--surface-2);
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.15rem;
}

.tab {
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    color: var(--muted);
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
}

.tab:hover {
    color: var(--brand-dark);
    background: var(--surface-2);
}

.tab.active {
    color: var(--brand-dark);
    border-bottom-color: var(--brand);
}

/* ---------- Empty states ---------- */
.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--muted);
}

.empty-state .empty-icon {
    color: var(--faint);
    margin-bottom: 0.75rem;
}

.empty-state strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.3rem;
}

/* ---------- Detail lists ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.9rem 1.5rem;
}

.detail-grid .detail-item span {
    color: var(--muted);
    display: block;
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.detail-grid .detail-item strong {
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* ---------- Auth ---------- */
.narrow-panel {
    margin: 8vh auto 0;
    max-width: 38rem;
}

.auth-page {
    background: radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--brand) 24%, var(--bg)) 0%, var(--bg) 55%);
}

.auth-shell {
    align-items: center;
    display: grid;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: grid;
    gap: 1rem;
    margin: 0 auto;
    max-width: 26rem;
    padding: 1.5rem;
    width: 100%;
}

.auth-brand {
    align-items: center;
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
}

.auth-brand small {
    color: var(--muted);
    display: block;
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.validation-summary:empty,
.validation-summary ul:empty {
    display: none;
}

.field-validation-error {
    color: var(--danger);
    font-size: 0.82rem;
}

.check-row {
    align-items: center;
    display: flex;
    gap: 0.55rem;
}

.check-row span {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 400;
}

.two-step-card {
    max-width: 28rem;
}

.auth-brand-mark {
    background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--success) 70%, var(--brand)));
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    display: inline-block;
    height: 2rem;
    position: relative;
    width: 2rem;
}

.auth-brand-mark::before,
.auth-brand-mark::after {
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 3px;
    content: "";
    position: absolute;
}

.auth-brand-mark::before {
    inset: 0.5rem 0.62rem 0.62rem 0.5rem;
}

.auth-brand-mark::after {
    background: rgba(255, 255, 255, 0.32);
    bottom: 0.43rem;
    height: 0.5rem;
    inset-inline-end: 0.43rem;
    width: 0.5rem;
}

.auth-card h1,
.auth-card h2 {
    color: var(--text);
    font-size: 1.45rem;
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 0.5rem;
}

.subtitle {
    color: var(--muted);
    font-size: 0.96rem;
    line-height: 1.55;
    margin: 0 0 0.5rem;
}

.helper-text {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
    margin: 0.25rem 0 0;
}

/* Password reveal controls on account setup/reset keep the same compact pattern as login. */
.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-inline-end: 3rem;
}

.password-toggle {
    align-items: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    height: 2rem;
    inset-block-start: 50%;
    inset-inline-end: 0.4rem;
    justify-content: center;
    padding: 0;
    position: absolute;
    transform: translateY(-50%);
    width: 2rem;
}

.password-toggle:hover,
.password-toggle:focus-visible {
    background: var(--brand-tint);
    color: var(--text);
}

.password-toggle-icon {
    fill: none;
    height: 1.1rem;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 1.1rem;
}

.alert-success {
    background: color-mix(in srgb, var(--success) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--success) 38%, transparent);
    color: color-mix(in srgb, var(--success) 72%, var(--text));
}

.alert-warning {
    background: color-mix(in srgb, var(--warn) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--warn) 38%, transparent);
    color: color-mix(in srgb, var(--warn) 74%, var(--text));
}

.passkeys-section {
    background: color-mix(in srgb, var(--surface-2) 72%, transparent);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 0.9rem;
    padding: 1rem;
}

.passkeys-section h3,
.passkeys-section h4 {
    color: var(--text);
    font-size: 1rem;
    margin: 0;
}

.footer-links {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.5;
    margin-top: 1.1rem;
    text-align: center;
}

.link-button,
.footer-links a {
    background: transparent;
    border: 0;
    color: var(--brand-dark);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    min-height: auto;
    padding: 0;
    text-decoration: none;
}

.link-button:hover,
.footer-links a:hover {
    background: transparent;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.recovery-codes {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    list-style: none;
    margin: 0.75rem 0;
    padding: 0;
}

.recovery-codes code {
    background: var(--field-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    display: block;
    font-size: 0.94rem;
    letter-spacing: 0;
    padding: 0.5rem 0.62rem;
    text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tables-grid,
    .report-library-grid,
    .work-grid {
        grid-template-columns: 1fr;
    }
}

/* The list + side form (Quotes, Rates, Currencies, Exchange) only fits two-up on very wide screens;
   below that the data grid needs the full panel width or it scrolls horizontally. */
@media (max-width: 1500px) {
    .work-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .menu-toggle {
        display: inline-flex;
    }

    .topbar-global .brand-compact {
        display: inline-flex;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .side-nav {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(82vw, var(--sidebar-w));
        z-index: 60;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }

    .nav-collapse-toggle {
        display: none;
    }

    body.nav-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    body.nav-collapsed .side-nav {
        padding: 1rem 0.85rem 1.5rem;
        width: min(82vw, var(--sidebar-w));
    }

    body.nav-collapsed .brand {
        justify-content: flex-start;
        padding: 0.35rem 0.4rem 1rem;
    }

    body.nav-collapsed .brand > span:not(.brand-mark),
    body.nav-collapsed .nav-link span {
        display: inline;
    }

    body.nav-collapsed .nav-section {
        display: block;
    }

    body.nav-collapsed .nav-link {
        justify-content: flex-start;
        padding: 0.55rem 0.65rem;
    }

    [dir="rtl"] .side-nav {
        transform: translateX(105%);
    }

    body.nav-open .side-nav {
        transform: translateX(0);
    }

    body.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(16, 33, 29, 0.4);
        z-index: 50;
    }
}

@media (max-width: 680px) {
    .metrics-grid,
    .entry-grid,
    .permission-grid,
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .env-chip,
    .profile-trigger-name,
    .lang-current,
    .lang-menu .lang-caret {
        display: none;
    }

    .topbar-global {
        gap: 0.45rem;
        padding: 0 0.8rem;
    }

    .topbar-global .brand-compact {
        font-size: 0;
        gap: 0;
    }

    .topbar-global .brand-compact .brand-mark {
        font-size: 0.82rem;
    }

    .topbar-right {
        gap: 0.35rem;
    }

    .topbar-right .lang-chip,
    .profile-trigger {
        height: 2.2rem;
        justify-content: center;
        padding: 0;
        width: 2.2rem;
    }

    .profile-menu-panel {
        inset-inline: auto;
        max-width: calc(100vw - 1rem);
        right: 0;
    }

    [dir="rtl"] .profile-menu-panel {
        left: 0;
        right: auto;
    }

    .main-surface {
        padding: 1rem;
    }

    .form-actions {
        align-items: stretch;
    }

    .passkey-row {
        align-items: stretch;
        flex-direction: column;
    }

    .responsive-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Let wide data tables scroll horizontally on phones instead of overflowing the panel.
       Scoped to bare panel tables so enhanced data grids keep their own layout. */
    .panel > table,
    .page-section > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Single-column action forms and tighter detail grids read better on a narrow screen. */
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .topbar-actions {
        width: 100%;
    }
}

@media print {
    .side-nav,
    .topbar-global,
    .topbar-actions,
    .form-actions,
    .no-print {
        display: none !important;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .panel,
    .metric-card {
        box-shadow: none;
        border-color: #ccc;
    }
}

/* ---------- Glossary + inline term explanations ---------- */
.glossary {
    margin: 0;
}

.glossary dt {
    font-weight: 700;
    color: var(--text);
    margin-top: 0.9rem;
}

.glossary dt:first-of-type {
    margin-top: 0;
}

.glossary dd {
    margin: 0.2rem 0 0;
    color: var(--muted);
    line-height: 1.5;
}

abbr[title] {
    cursor: help;
    text-decoration: underline dotted;
    text-underline-offset: 0.15em;
}

/* ---------- Help: contextual field-guide link ---------- */
.panel-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.field-help-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.field-help-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Grid action buttons + date-range filter bar ---------- */
.grid-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.grid-filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: end;
    margin-bottom: 0.85rem;
}

.grid-filterbar-page {
    margin: 0;
    padding: 0 1.15rem 0.85rem;
}

.grid-filterbar label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.grid-date-input {
    min-height: 2.25rem;
    width: 10rem;
}

.grid-filter-count {
    align-self: center;
    margin-inline-start: auto;
    font-size: 0.8rem;
    color: var(--muted);
}

.grid-filter-count-inline {
    display: block;
    margin: 0 1.15rem 0.6rem;
}

/* Compact grid rows keep action-heavy quote/history lists scannable. */
.k-grid .k-table-td {
    padding-block: 0.35rem;
    white-space: nowrap;
}

.k-grid .grid-actions {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.k-grid .grid-actions .k-button {
    font-size: 0.8rem;
    min-height: 1.9rem;
    padding: 0.25rem 0.5rem;
}

/* ---------- Help: user-guide library ---------- */
.help-group {
    margin-top: 1.4rem;
}

.help-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.help-card {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.05rem;
    border: 1px solid var(--line);
    border-radius: var(--radius, 14px);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.help-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

.help-card-icon {
    flex: 0 0 auto;
    color: var(--accent);
    margin-top: 0.1rem;
}

.help-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.help-card-body strong {
    font-size: 0.97rem;
    color: var(--text);
}

.help-card-sub {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.help-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.3rem;
}

.help-tag {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}

.help-card-go {
    flex: 0 0 auto;
    color: var(--muted);
    margin-inline-start: auto;
    margin-top: 0.1rem;
}

.help-card:hover .help-card-go {
    color: var(--accent);
}

/* ---------- Data-grid dark-mode harmonization ---------- */
[data-theme="dark"] .k-grid,
[data-theme="dark"] .k-toolbar,
[data-theme="dark"] .k-grid-toolbar {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--line);
}

[data-theme="dark"] .k-grid-header,
[data-theme="dark"] .k-grid-header-wrap,
[data-theme="dark"] .k-grid .k-table-th,
[data-theme="dark"] .k-grid th {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--line);
}

[data-theme="dark"] .k-grid-content,
[data-theme="dark"] .k-grid .k-table-td,
[data-theme="dark"] .k-grid td {
    background-color: transparent;
    color: var(--text);
    border-color: var(--line);
}

[data-theme="dark"] .k-grid .k-table-alt-row .k-table-td {
    background-color: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
}

[data-theme="dark"] .k-grid .k-table-row:hover .k-table-td,
[data-theme="dark"] .k-grid .k-table-row.k-hover .k-table-td {
    background-color: var(--surface-2);
}

[data-theme="dark"] .k-pager {
    background-color: var(--surface-2);
    color: var(--muted);
    border-color: var(--line);
}

[data-theme="dark"] .k-input,
[data-theme="dark"] .k-picker,
[data-theme="dark"] .k-textbox,
[data-theme="dark"] .k-searchbox {
    background-color: var(--field-bg);
    color: var(--text);
    border-color: var(--line-strong);
}

[data-theme="dark"] .k-popup,
[data-theme="dark"] .k-list,
[data-theme="dark"] .k-menu {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--line);
}

[data-theme="dark"] .k-list-item:hover,
[data-theme="dark"] .k-list-item.k-hover,
[data-theme="dark"] .k-list-item.k-selected {
    background-color: var(--surface-2);
    color: var(--text);
}

/* Grid/toolbar command buttons: the dark cell-text override (color: var(--text)) cascades onto the
   action buttons, which keep light backgrounds — giving light text on a light button. Pin both
   colors so View / Print / Accept / Export labels stay legible in dark mode. */
[data-theme="dark"] .k-grid .grid-actions .k-button-solid-base,
[data-theme="dark"] .k-grid-toolbar .k-button-solid-base,
[data-theme="dark"] .k-toolbar .k-button-solid-base {
    background-color: var(--surface-strong);
    color: var(--text);
    border-color: var(--line-strong);
}

[data-theme="dark"] .k-grid .grid-actions .k-button-solid-base:hover,
[data-theme="dark"] .k-grid-toolbar .k-button-solid-base:hover,
[data-theme="dark"] .k-toolbar .k-button-solid-base:hover {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--brand);
}
/* Record attachments share the existing panel visual language while keeping upload controls compact. */
.record-attachments-card {
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d7dde8);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(20, 35, 55, 0.06);
    margin-top: 1rem;
    padding: 1rem;
}

.record-attachments-header {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 0.9rem;
}

.record-attachments-eyebrow {
    color: var(--muted, #637084);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0;
    margin: 0 0 0.25rem;
    text-transform: uppercase;
}

.record-attachments-header h3 {
    color: var(--text, #111827);
    font-size: 1.05rem;
    margin: 0;
}

.record-attachments-copy,
.record-attachment-help,
.record-attachment-meta {
    color: var(--muted, #637084);
}

.record-attachments-copy {
    margin: 0.35rem 0 0;
}

.record-attachments-error {
    background: #fff4f4;
    border: 1px solid #f1b8b8;
    border-radius: 6px;
    color: #a32121;
    margin-bottom: 1rem;
    padding: 0.75rem 0.9rem;
}

.record-attachments-empty {
    color: var(--muted, #637084);
    padding: 0.75rem 0;
}

.record-attachments-list {
    display: grid;
    gap: 0.65rem;
}

.record-attachment-row {
    align-items: center;
    background: var(--surface-muted, #f8fafc);
    border: 1px solid var(--border, #d7dde8);
    border-radius: 8px;
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1fr);
    padding: 0.85rem;
}

.record-attachment-name {
    color: var(--text, #111827);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-attachment-meta {
    display: flex;
    flex-wrap: wrap;
    font-size: 0.85rem;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.record-attachment-actions,
.record-attachments-composer form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.record-attachment-open,
.record-attachment-delete,
.record-attachment-upload,
.record-attachment-submit {
    border-radius: 6px;
    font-weight: 600;
    padding: 0.5rem 0.8rem;
}

.record-attachment-open,
.record-attachment-upload,
.record-attachment-submit {
    background: var(--accent, #2563eb);
    border: 1px solid var(--accent, #2563eb);
    color: #fff;
    text-decoration: none;
}

.record-attachment-delete {
    background: transparent;
    border: 1px solid #e39a9a;
    color: #a32121;
}

.record-attachments-composer {
    border-top: 1px solid var(--border, #d7dde8);
    margin-top: 1rem;
    padding-top: 1rem;
}

.record-attachment-upload {
    cursor: pointer;
    display: inline-flex;
    overflow: hidden;
    position: relative;
}

.record-attachment-upload:has(input:disabled),
.record-attachment-submit:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.record-attachment-input {
    inset: 0;
    opacity: 0;
    position: absolute;
}

.record-attachment-help {
    font-size: 0.85rem;
    margin: 0.6rem 0 0;
}

@media (min-width: 640px) {
    .record-attachments-card {
        padding: 1.25rem;
    }

    .record-attachment-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}
