:root {
    --color-brand: #f78b1e;
    --color-brand-strong: #d96e14;
    --color-brand-soft: #fff1e0;
    --color-sidebar: #191d2b;
    --color-sidebar-line: rgba(255, 255, 255, 0.08);
    --color-sidebar-text: rgba(255, 255, 255, 0.78);
    --color-sidebar-muted: rgba(255, 255, 255, 0.5);
    --color-text: #1b2230;
    --color-heading: #111827;
    --color-muted: #6d7587;
    --color-page: #f3f5f9;
    --color-surface: #ffffff;
    --color-surface-muted: #f8fafc;
    --color-line: #dfe5ef;
    --color-line-strong: #cfd6e1;
    --color-shadow: rgba(15, 23, 42, 0.08);
    --color-topbar-bg: rgba(255, 255, 255, 0.92);
    --color-topbar-border: var(--color-line);
    --color-input-bg: #f8fafc;
    --color-button-bg: white;
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --sidebar-width: 18.5rem;
    --sidebar-width-collapsed: 5.5rem;
    --topbar-height: 4.35rem;
}

[data-theme="dark"] {
    --color-text: #c8cdd8;
    --color-heading: #e4e8f0;
    --color-muted: #78808f;
    --color-page: #111214;
    --color-surface: #1a1c20;
    --color-surface-muted: #20232a;
    --color-line: #2c2f38;
    --color-line-strong: #393c47;
    --color-shadow: rgba(0, 0, 0, 0.35);
    --color-topbar-bg: rgba(26, 28, 32, 0.94);
    --color-topbar-border: #2c2f38;
    --color-input-bg: #20232a;
    --color-button-bg: #20232a;
    --color-brand-soft: rgba(247, 139, 30, 0.13);
    --color-chart-track: #2c2f38;
    --color-chart-grid: #2c2f38;
    --color-trend-point: #20232a;
}

/* ── Scrollbar — global thin style ────────────────────────────── */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-line-strong) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--color-line-strong);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-muted);
}

/* Sidebar always uses dark scrollbar tones regardless of theme */
.app-sidebar-nav {
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.app-sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

.app-sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.18);
}

[data-theme="dark"] * {
    scrollbar-color: #393c47 transparent;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #393c47;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #4a4e5c;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", sans-serif;
    color: var(--color-text);
    background: var(--color-page);
    overflow-x: clip;
    transition: background-color 200ms ease, color 200ms ease;
}

body {
    overflow-y: auto;
}

a,
.btn-link {
    color: var(--color-brand-strong);
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--color-heading);
}

h1:focus {
    outline: none;
}

#app {
    min-height: 100vh;
}

.app-shell {
    min-height: 100vh;
    background: var(--color-page);
    overflow-x: clip;
}

.app-shell-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    border: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%),
        var(--color-sidebar);
    color: white;
    border-right: 1px solid var(--color-sidebar-line);
    overflow: hidden;
    transition: width 180ms ease, transform 180ms ease;
}

.app-shell-sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width-collapsed);
}

.app-sidebar-header {
    display: flex;
    align-items: center;
    min-height: var(--topbar-height);
    padding: 0 1.2rem;
    border-bottom: 1px solid var(--color-sidebar-line);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: white;
    text-decoration: none;
}

.app-brand-logo {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
}

.app-brand-copy {
    display: grid;
    gap: 0.1rem;
}

.app-brand-copy strong {
    font-size: 1.2rem;
    line-height: 1;
}

.app-brand-copy span {
    color: var(--color-sidebar-muted);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.app-shell-sidebar-collapsed .app-brand-copy,
.app-shell-sidebar-collapsed .nav-label,
.app-shell-sidebar-collapsed .nav-section-header .nav-label {
    display: none;
}

.app-shell-sidebar-collapsed .nav-section-header {
    justify-content: center;
    padding: 0.55rem 0.75rem 0.3rem;
}

.app-shell-sidebar-collapsed .app-sidebar-nav a,
.app-shell-sidebar-collapsed .sidebar-signout-button {
    justify-content: center;
    padding: 0.75rem;
}

.app-shell-sidebar-collapsed .nav-subsection-children {
    padding-left: 0;
}

.app-sidebar-nav {
    display: grid;
    gap: 0.1rem;
    padding: 0.6rem 0.6rem;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Section header (Vendite / Acquisti) — non-interactive, prominent */
.nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.55rem 0.95rem 0.3rem;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    pointer-events: none;
    margin-top: 0.5rem;
}

.nav-section-header:first-child {
    margin-top: 0;
}

.nav-section-header .nav-icon {
    background: rgba(247, 139, 30, 0.15);
    border-color: rgba(247, 139, 30, 0.25);
    color: #f78b1e;
}

.nav-section-header-purchases .nav-icon {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.7);
}

.app-sidebar-nav a,
.sidebar-signout-button {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    width: 100%;
    min-height: 2.4rem;
    padding: 0.45rem 0.95rem;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: var(--color-sidebar-text);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.app-sidebar-nav a:hover,
.sidebar-signout-button:hover,
.app-sidebar-nav a:focus-visible,
.sidebar-signout-button:focus-visible {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    outline: none;
    transform: translateX(2px);
}

.app-sidebar-nav a.active {
    background: linear-gradient(135deg, var(--color-brand), #ff8a16);
    color: white;
    box-shadow: 0 20px 44px rgba(247, 139, 30, 0.24);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.72rem;
    font-weight: 800;
    flex: 0 0 auto;
}

.nav-icon-svg,
.topbar-icon-svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

.app-sidebar-nav a.active .nav-icon {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.22);
}

.nav-label {
    font-weight: 700;
    white-space: nowrap;
    flex: 1;
}

/* Static nav subsections (always expanded) */
.nav-subsection-label {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.45rem 0.95rem;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    pointer-events: none;
}

.nav-subsection-children {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding-left: 0.6rem;
    margin-bottom: 0.2rem;
}

.nav-subsection-children a {
    border-radius: 10px;
    font-size: 0.9rem;
}

.app-sidebar-footer {
    display: grid;
    gap: 0.4rem;
    margin-top: auto;
    padding: 0.8rem 0.6rem 1rem;
    border-top: 1px solid var(--color-sidebar-line);
}

.app-main-shell {
    min-width: 0;
    height: 100vh;
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    transition: margin-left 180ms ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-shell-sidebar-collapsed .app-main-shell {
    width: calc(100% - var(--sidebar-width-collapsed));
    margin-left: var(--sidebar-width-collapsed);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: var(--topbar-height);
    padding: 0.75rem 1.35rem;
    background: var(--color-topbar-bg);
    border-bottom: 1px solid var(--color-topbar-border);
    backdrop-filter: blur(14px);
}

.app-topbar-left,
.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.app-topbar-left {
    flex: 1 1 auto;
    min-width: 0;
}

.topbar-menu-button {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 2.6rem;
    height: 2.6rem;
    border: 1px solid var(--color-line);
    border-radius: 12px;
    background: var(--color-button-bg);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
    cursor: pointer;
}

.topbar-menu-button span {
    width: 1rem;
    height: 2px;
    border-radius: 999px;
    background: var(--color-heading);
}

.topbar-search {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 36rem;
    padding: 0 0.95rem;
    min-height: 2.85rem;
    border: 1px solid var(--color-line);
    border-radius: 14px;
    background: var(--color-input-bg);
}

.topbar-search-icon {
    color: var(--color-muted);
    font-size: 1rem;
}

.topbar-search-input {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--color-heading);
    outline: none;
}

.topbar-environment,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-height: 2.85rem;
    padding: 0 0.95rem;
    border: 1px solid var(--color-line);
    border-radius: 14px;
    background: var(--color-button-bg);
}

/* ── User menu wrapper & dropdown ──────────────────────────── */
.topbar-user-wrapper {
    position: relative;
}

.topbar-user-button {
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease;
    color: var(--color-text);
    font: inherit;
}

.topbar-user-button:hover {
    background: var(--color-surface-muted);
    border-color: var(--color-line-strong);
}

.user-chevron {
    color: var(--color-muted);
    transition: transform 200ms ease;
    flex: 0 0 auto;
}

.user-chevron-open {
    transform: rotate(180deg);
}

.user-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: transparent;
    cursor: default;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 100;
    min-width: 14rem;
    padding: 0.4rem;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 16px;
    box-shadow: 0 20px 48px var(--color-shadow), 0 4px 12px var(--color-shadow);
    display: grid;
    gap: 0.1rem;
    animation: dropdown-in 160ms ease both;
}

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

.user-dropdown a,
.user-dropdown-signout {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--color-text);
    text-decoration: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
    white-space: nowrap;
}

.user-dropdown a:hover,
.user-dropdown a.active,
.user-dropdown-signout:hover {
    background: var(--color-surface-muted);
    color: var(--color-heading);
}

.user-dropdown-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 8px;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-line);
    color: var(--color-muted);
    flex: 0 0 auto;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--color-line);
    margin: 0.25rem 0.2rem;
}

.user-dropdown-signout {
    color: var(--color-muted);
}

.user-dropdown-signout:hover {
    color: #e05252;
    background: rgba(224, 82, 82, 0.07);
}

.topbar-environment {
    display: grid;
    gap: 0.05rem;
    min-width: 9rem;
}

.topbar-environment-label,
.topbar-user-copy span,
.user-session span,
.shell-kicker {
    color: var(--color-muted);
    font-size: 0.78rem;
}

.topbar-user-copy {
    display: grid;
    gap: 0.05rem;
    justify-items: start;
    text-align: left;
}

.topbar-user-copy strong {
    line-height: 1.1;
}

.topbar-user-copy span {
    font-size: 0.7rem;
}

.user-avatar {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    border: 1px solid var(--color-line);
    flex: 0 0 auto;
}

.app-content {
    display: grid;
    gap: 1.35rem;
    padding: 1.5rem;
    overflow-x: clip;
    overflow-y: auto;
    flex: 1;
    align-content: start;
}

.workspace-panel {
    overflow: hidden;
}

/* ── Full-page loading screen ── */
.app-loading-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    z-index: 9999;
}

.app-loading-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.app-loading-logo {
    width: 3rem;
    height: 3rem;
    opacity: 0.7;
}

.app-loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 2.5px solid var(--color-line);
    border-top-color: var(--color-brand-strong);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

/* ── Login page (single-card centered) ── */
.auth-shell-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card-login {
    width: 100%;
    max-width: 30rem;
}

.auth-subtitle {
    color: var(--color-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem !important;
}

.auth-button-row {
    display: flex;
    justify-content: center;
    margin-top: 0.75rem;
}

.auth-features {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-line);
}

.auth-feature-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.auth-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.83rem;
    color: var(--color-muted);
    line-height: 1.4;
}

.auth-feature-list li::before {
    content: "•";
    color: var(--color-brand-strong);
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

/* ── Old auth-shell (kept for any other usages) ── */
.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 34rem) minmax(18rem, 1fr);
    gap: 1.25rem;
    align-items: stretch;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card,
.auth-side-card,
.content-panel,
.hero-panel,
.kpi-card,
.review-card,
.user-card,
.invoice-table-shell,
.release-callout,
.action-card {
    border: 1px solid var(--color-line);
    background: var(--color-surface);
    box-shadow: 0 10px 32px var(--color-shadow);
}

.auth-card,
.auth-side-card,
.content-panel,
.hero-panel,
.review-card,
.release-callout {
    border-radius: var(--radius-xl);
}

.auth-card {
    padding: 2rem;
    align-self: center;
}

.auth-card-center {
    max-width: 34rem;
    margin: 0 auto;
    text-align: center;
}

.auth-card h1 {
    margin: 0.3rem 0 0.9rem;
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    line-height: 0.98;
    letter-spacing: -0.04em;
}

.auth-card p {
    margin-top: 0;
    line-height: 1.7;
}

.auth-kicker {
    color: var(--color-brand-strong);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.auth-side-panel {
    display: grid;
}

.auth-side-card {
    padding: 1.75rem;
    align-self: center;
}

.dashboard-hero {
    display: grid;
    gap: 0.35rem;
}

.dashboard-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.7rem);
    letter-spacing: -0.04em;
}

.dashboard-hero p {
    margin: 0;
    color: var(--color-muted);
    font-size: 1.02rem;
}

.hero-panel {
    display: grid;
    gap: 1.1rem;
    padding: 1.5rem;
}

.hero-panel-dashboard {
    background:
        radial-gradient(circle at top right, rgba(247, 139, 30, 0.16), transparent 24%),
        linear-gradient(180deg, var(--color-surface), var(--color-surface-muted));
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.dashboard-kpis-compact .kpi-card {
    min-width: 0;
}

.kpi-card {
    display: grid;
    gap: 0.5rem;
    padding: 1.15rem 1.2rem;
    border-radius: 18px;
    animation: fade-slide-up 420ms ease both;
}

.kpi-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.kpi-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 12px;
    background: var(--color-brand-soft);
    color: var(--color-brand-strong);
    font-weight: 800;
}

.kpi-card strong {
    font-size: 2rem;
    line-height: 1;
    letter-spacing: -0.04em;
}

.kpi-card span,
.summary-row span,
.invoice-row span,
.master-data-row span,
.table-primary-cell span,
.table-file-cell,
.trend-chart-label span,
.chart-empty {
    color: var(--color-muted);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(22rem, 1fr);
    gap: 1.25rem;
}

.panel-grid-analytics {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}

.content-panel {
    padding: 1.35rem;
}

.content-panel h2 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    letter-spacing: -0.03em;
}

.content-panel h3 {
    margin: 0 0 0.6rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.panel-grid-secondary,
.users-grid,
.action-grid,
.invoice-table,
.review-list,
.user-list,
.summary-list,
.trend-chart-shell,
.bar-chart {
    display: grid;
    gap: 1rem;
}

/* Material 3 — list container: no gaps, rounded first/last, dividers */
.master-data-list {
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
    border: 1px solid var(--color-line);
    border-radius: 16px;
    overflow: hidden;
    background: var(--color-surface);
}

.master-data-list .master-data-row {
    border: 0;
    border-bottom: 1px solid var(--color-line);
    border-radius: 0;
}

.master-data-list .master-data-row:last-child {
    border-bottom: 0;
}

.users-grid {
    grid-template-columns: minmax(0, 26rem) minmax(0, 1fr);
}

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

.action-card {
    display: grid;
    gap: 0.55rem;
    text-align: left;
    padding: 1.25rem;
    border-radius: 18px;
    color: var(--color-text);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.action-card:hover,
.action-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.1);
    outline: none;
}

.action-card strong {
    font-size: 1.05rem;
}

.action-card span {
    color: var(--color-muted);
    line-height: 1.6;
}

.action-card-muted {
    background: var(--color-surface-muted);
}

.section-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.period-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.period-tab,
.ghost-button,
.primary-button,
.form-input,
.topbar-search-input {
    font: inherit;
}

.period-tab {
    border: 1px solid var(--color-line);
    background: var(--color-button-bg);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    font-weight: 700;
    cursor: pointer;
}

.period-tab-active,
.primary-button {
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-strong));
    color: white;
    border-color: transparent;
}

.summary-row,
.invoice-row,
.master-data-row,
.review-card,
.user-card {
    border-radius: 16px;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-line);
}

.summary-row-stack {
    align-items: flex-start;
}

.summary-row-stack div {
    display: grid;
    gap: 0.3rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 0;
}

.summary-grid div {
    padding: 1rem;
    border-radius: 16px;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-line);
}

.summary-grid dt {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-bottom: 0.35rem;
}

.summary-grid dd {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.feature-list {
    margin: 0;
    padding-left: 1.2rem;
}

.feature-list li {
    margin-bottom: 0.65rem;
    line-height: 1.7;
}

.form-grid,
.form-grid-single {
    display: grid;
    gap: 1rem;
    margin: 1rem 0 1.25rem;
}

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

.invoice-search-grid-tight {
    align-items: end;
}

.form-grid label,
.form-grid-single label {
    display: grid;
    gap: 0.45rem;
    font-weight: 600;
}

.form-grid-full {
    grid-column: 1 / -1;
}

.form-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--color-line-strong);
    background: var(--color-input-bg);
    box-sizing: border-box;
    outline: none;
}

.form-select-input {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #6d7587 50%),
        linear-gradient(135deg, #6d7587 50%, transparent 50%);
    background-position:
        calc(100% - 1.15rem) calc(1.2rem + 1px),
        calc(100% - 0.8rem) calc(1.2rem + 1px);
    background-size: 0.45rem 0.45rem, 0.45rem 0.45rem;
    background-repeat: no-repeat;
    padding-right: 2.6rem;
}

.currency-field {
    position: relative;
}

.currency-field-input {
    padding-right: 3.25rem;
}

.currency-field-symbol {
    position: absolute;
    top: 50%;
    right: 0.9rem;
    transform: translateY(-50%);
    min-width: 1.8rem;
    text-align: center;
    color: var(--color-brand-strong);
    font-weight: 800;
    pointer-events: none;
}

.field-help {
    display: block;
    margin-top: 0.45rem;
    color: var(--color-muted);
    font-size: 0.82rem;
}

.integrated-create-shell {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-line);
    border-radius: 16px;
    background: var(--color-surface-muted);
}

.integrated-create-header {
    display: grid;
    gap: 0.2rem;
}

.textarea-input {
    min-height: 8rem;
    resize: vertical;
}

.form-input:focus {
    border-color: rgba(247, 139, 30, 0.5);
    box-shadow: 0 0 0 4px rgba(247, 139, 30, 0.12);
}

.form-input-code {
    font-size: 1.2rem;
    letter-spacing: 0.25em;
}

/* ── Material Design 3 — Buttons ───────────────────────────────── */
.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 999px;
    padding: 0 1.5rem;
    height: 2.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: box-shadow 180ms ease, background-color 180ms ease, transform 100ms ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.primary-button {
    border: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,.1), 0 1px 3px 1px rgba(0,0,0,.07);
}

.primary-button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 180ms ease;
}

.primary-button:hover:not(:disabled)::after {
    background: rgba(255,255,255,0.08);
}

.primary-button:hover:not(:disabled) {
    box-shadow: 0 1px 2px rgba(0,0,0,.15), 0 2px 6px 2px rgba(0,0,0,.12);
}

.primary-button:active:not(:disabled) {
    box-shadow: none;
    transform: scale(0.98);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
    box-shadow: none;
}

/* Upload submit — inline icon + label variant */
.upload-submit-button {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 0.75rem;
    padding: 0.75rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-strong));
    color: white;
    font: inherit;
    font-weight: 800;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(247, 139, 30, 0.3);
    transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.upload-submit-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 32px rgba(247, 139, 30, 0.38);
}

.upload-submit-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.ghost-button {
    border: 1px solid var(--color-line-strong);
    background: var(--color-button-bg);
    color: var(--color-text);
    position: relative;
    overflow: hidden;
}

.ghost-button::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 180ms ease;
    border-radius: inherit;
}

.ghost-button:hover:not(:disabled)::after {
    background: color-mix(in srgb, var(--color-text) 6%, transparent);
}

.ghost-button:active:not(:disabled) {
    transform: scale(0.98);
}

.ghost-button:disabled {
    cursor: not-allowed;
    opacity: 0.38;
}

/* Material icon button */
.md-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    font-size: inherit;
    transition: background-color 160ms ease, color 160ms ease;
    flex-shrink: 0;
}

.md-icon-button:hover {
    background: color-mix(in srgb, var(--color-text) 8%, transparent);
    color: var(--color-heading);
}

.md-icon-button:active {
    background: color-mix(in srgb, var(--color-text) 12%, transparent);
}

.md-icon-button .material-symbols-rounded {
    font-size: 1.25rem;
}

/* Material avatar (initials circle) */
.md-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-brand) 15%, var(--color-surface));
    color: var(--color-brand-strong);
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0;
    text-transform: uppercase;
    user-select: none;
}

/* Material Symbols font baseline fix */
.material-symbols-rounded {
    font-family: 'Material Symbols Rounded';
    font-weight: normal;
    font-style: normal;
    font-size: 1.25rem;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

.material-symbols-rounded.filled {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.form-divider {
    margin: 1.5rem 0;
    border: 0;
    border-top: 1px solid var(--color-line);
}

.form-message {
    margin: 0.75rem 0 0;
    color: var(--color-brand-strong);
    font-weight: 700;
}

.invoice-row,
.user-card {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-line);
}

/* ── Material Design 3 — List Items ──────────────────────────────── */
.master-data-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem 0.75rem 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    transition: background-color 150ms ease;
    position: relative;
}

.master-data-row::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: transparent;
    transition: background 150ms ease;
    pointer-events: none;
}

.master-data-row:hover::before {
    background: color-mix(in srgb, var(--color-text) 4%, transparent);
}

/* Leading avatar in list item */
.master-data-row .md-avatar {
    flex-shrink: 0;
}

/* Main content area — grows to fill */
.master-data-row-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.master-data-row-headline {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

a.master-data-row-headline:hover {
    color: var(--color-brand-strong);
    text-decoration: underline;
}

.master-data-row-supporting {
    display: flex;
    flex-wrap: wrap;
    column-gap: 0.75rem;
    row-gap: 0;
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.master-data-row-supporting .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Trailing actions */
.master-data-row-trailing {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.master-data-row-editing {
    flex-direction: column;
    align-items: stretch;
    background: color-mix(in srgb, var(--color-brand) 4%, var(--color-surface));
    border-color: color-mix(in srgb, var(--color-brand) 25%, var(--color-line));
}

.master-data-row-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.invoice-row > div,
.review-card-header > div,
.table-primary-cell,
.invoice-detail-meta,
.user-card-meta {
    display: grid;
    gap: 0.2rem;
}

.invoice-row-meta,
.invoice-detail-meta,
.user-card-meta {
    justify-items: end;
    text-align: right;
}

.invoice-row-button,
.text-link-button {
    cursor: pointer;
}

.invoice-row-button {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    font: inherit;
    text-align: left;
}

.invoice-row-button:hover,
.invoice-row-button:focus-visible,
.text-link-button:hover,
.text-link-button:focus-visible {
    outline: none;
    border-color: rgba(247, 139, 30, 0.22);
}

.review-card {
    padding: 1.2rem;
}

.review-card-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.text-link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text);
    font-weight: 800;
    text-align: left;
}

.stack-actions,
.stack-actions-left {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.stack-actions {
    justify-content: flex-end;
}

.stack-actions-left {
    justify-content: flex-start;
}

.document-frame {
    width: 100%;
    min-height: 70vh;
    border: 1px solid var(--color-line);
    border-radius: 18px;
    background: var(--color-surface);
}

.document-frame-large {
    min-height: 86vh;
}

.bar-chart-row {
    display: grid;
    grid-template-columns: 10rem minmax(0, 1fr) 6rem;
    gap: 0.8rem;
    align-items: center;
    animation: fade-slide-up 420ms ease both;
}

.bar-chart-label,
.bar-chart-value {
    font-size: 0.95rem;
}

.bar-chart-track {
    height: 0.8rem;
    border-radius: 999px;
    background: var(--color-line, #edf1f7);
    overflow: hidden;
}

.bar-chart-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--color-brand), var(--color-brand-strong));
    width: var(--bar-width, 0%);
    box-shadow: 0 10px 28px rgba(247, 139, 30, 0.24);
    animation: bar-grow 900ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    transform-origin: left center;
}

.bar-chart-fill-contrast {
    background: linear-gradient(135deg, #d96e14, #8d3e12);
}

.bar-chart-fill-muted {
    background: linear-gradient(135deg, #ffb15e, #f78b1e);
}

.bar-chart-compact .bar-chart-row {
    grid-template-columns: 8rem minmax(0, 1fr) 6rem;
}

.trend-chart {
    width: 100%;
    height: 15rem;
    overflow: visible;
}

.trend-grid-line {
    stroke: var(--color-line, #e6ebf3);
    stroke-width: 1;
}

.trend-area {
    animation: fade-in 700ms ease both;
}

.trend-line-path {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: draw-line 1.2s ease forwards;
}

.trend-point {
    fill: var(--color-surface, white);
    stroke: var(--color-brand);
    stroke-width: 3;
    filter: drop-shadow(0 10px 18px rgba(247, 139, 30, 0.18));
    animation: point-pop 500ms ease both;
}

.trend-chart-labels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
    gap: 0.6rem;
}

.trend-chart-label {
    display: grid;
    gap: 0.2rem;
}

.trend-chart-label strong {
    font-size: 0.8rem;
}

.invoice-table-shell {
    overflow: auto;
    max-width: 100%;
}

.invoice-data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.invoice-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.95rem 1rem;
    text-align: left;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
    background: var(--color-surface-muted);
    border-bottom: 1px solid var(--color-line);
}

.invoice-data-table tbody td {
    padding: 1rem;
    border-top: 1px solid var(--color-line, #edf1f7);
    vertical-align: top;
}

.invoice-data-row {
    cursor: pointer;
    transition: background-color 180ms ease;
}

.invoice-data-row:hover {
    background: rgba(247, 139, 30, 0.05);
}

.table-file-cell {
    word-break: break-word;
}

.invoice-data-table th,
.invoice-data-table td {
    overflow-wrap: anywhere;
}

.numeric-cell {
    text-align: right;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    background: var(--color-brand-soft);
    color: var(--color-brand-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.value-positive {
    color: #168861;
}

.value-negative {
    color: #c9690a;
}

.release-callout {
    padding: 1.1rem;
}

.release-version {
    display: inline-block;
    margin-bottom: 0.75rem;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    background: var(--color-brand-soft);
    color: var(--color-brand-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

#blazor-error-ui {
    color-scheme: light only;
    background: #fff4e5;
    border-top: 1px solid rgba(247, 139, 30, 0.35);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: rgba(247, 139, 30, 0.18);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--color-brand);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 700;
    color: var(--color-brand-strong);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@keyframes bar-grow {
    from {
        transform: scaleX(0.08);
        opacity: 0.2;
    }

    to {
        transform: scaleX(1);
        opacity: 1;
    }
}

@keyframes draw-line {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes point-pop {
    from {
        opacity: 0;
        transform: scale(0.4);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fade-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
    }
}

@media (max-width: 1100px) {
    .dashboard-kpis,
    .action-grid,
    .panel-grid,
    .panel-grid-analytics,
    .summary-grid,
    .users-grid,
    .form-grid,
    .auth-shell,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .app-sidebar {
        visibility: hidden;
        pointer-events: none;
        transform: translateX(calc(-100% - 1.5rem));
        width: min(18.5rem, calc(100vw - 3rem));
        box-shadow: none;
    }

    .app-sidebar-open {
        visibility: visible;
        pointer-events: auto;
        transform: translateX(0);
        box-shadow: 0 20px 52px rgba(15, 23, 42, 0.32);
    }

    .app-sidebar-nav a.active {
        box-shadow: none;
    }

    .app-main-shell,
    .app-shell-sidebar-collapsed .app-main-shell {
        width: 100%;
        margin-left: 0;
        height: 100vh;
    }

    .app-topbar {
        padding: 0.75rem 1rem;
    }

    .app-topbar-right {
        gap: 0.45rem;
        flex: 0 0 auto;
    }

    .topbar-environment {
        display: none;
    }

    .topbar-user-copy {
        display: none;
    }

    .topbar-user {
        padding: 0 0.55rem;
        min-width: 3.4rem;
    }

    .topbar-search {
        max-width: none;
        padding: 0 0.75rem;
    }

    .topbar-search-input {
        font-size: 0.95rem;
    }

    .app-content {
        padding: 1rem;
        overflow-y: auto;
    }

    .invoice-data-table {
        table-layout: auto;
    }

    .bar-chart-row {
        grid-template-columns: 1fr;
    }

    .trend-chart {
        height: 13rem;
    }
}

@media (max-width: 640px) {
    .app-topbar {
        gap: 0.55rem;
        padding: 0.65rem 0.75rem;
    }

    .app-topbar-left,
    .app-topbar-right {
        gap: 0.5rem;
    }

    .topbar-menu-button {
        width: 2.45rem;
        height: 2.45rem;
    }

    .topbar-search {
        min-height: 2.6rem;
        padding: 0 0.65rem;
    }

    .topbar-search-input {
        font-size: 0.9rem;
    }

    .topbar-user {
        min-height: 2.6rem;
        padding: 0 0.4rem;
    }

    .user-avatar {
        width: 2.15rem;
        height: 2.15rem;
    }

    .content-panel {
        padding: 1rem;
    }
}

@media (min-width: 901px) {
    .app-shell-backdrop {
        display: none;
    }
}

/* ── Release notes list ─────────────────────────────────────────── */

.release-notes-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

/* ── Footer ─────────────────────────────────────────── */

.app-footer {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 2rem;
    border-top: 1px solid var(--color-line);
    font-size: 0.8rem;
    color: var(--color-muted);
    background: var(--color-topbar-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.app-footer a {
    color: var(--color-brand-strong);
    text-decoration: none;
    font-weight: 700;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* ── Customer detail ───────────────────────────────── */

.customer-product-card {
    border: 1px solid var(--color-line);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.customer-product-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--color-surface);
}

.yousign-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0070f3;
    text-decoration: none;
    background: rgba(0, 112, 243, 0.08);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 112, 243, 0.2);
    transition: background 150ms ease;
}

.yousign-link:hover {
    background: rgba(0, 112, 243, 0.15);
}

.customer-payments-table {
    border-top: 1px solid var(--color-line);
    font-size: 0.82rem;
}

.customer-payment-header-row,
.customer-payment-row,
.customer-payment-total-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 0.5rem;
    padding: 0.45rem 1rem;
    align-items: center;
}

.customer-payment-header-row {
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--color-surface-muted);
}

.customer-payment-row {
    border-top: 1px solid var(--color-line);
}

.customer-payment-row.payment-paid {
    background: transparent;
}

.customer-payment-row.payment-pending {
    background: rgba(247, 139, 30, 0.04);
}

.customer-payment-total-row {
    border-top: 2px solid var(--color-line-strong);
    background: var(--color-surface-muted);
    font-size: 0.85rem;
}

/* ── Update popup ────────────────────────────────────── */

.update-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.52);
    backdrop-filter: blur(4px);
    padding: 1.5rem;
}

.update-popup {
    width: 100%;
    max-width: 32rem;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-line);
    box-shadow: 0 32px 64px rgba(15, 23, 42, 0.18);
    padding: 2rem;
    display: grid;
    gap: 1.25rem;
}

.update-popup-header {
    display: grid;
    gap: 0.4rem;
}

.update-popup-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.update-feature-list {
    margin: 0;
    padding-left: 1.25rem;
    display: grid;
    gap: 0.4rem;
    color: var(--color-text);
    font-size: 0.9rem;
    line-height: 1.5;
}

.update-popup-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Theme toggle ────────────────────────────────────── */

.theme-toggle-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: var(--color-button-bg);
    color: var(--color-muted);
    cursor: pointer;
    flex: 0 0 auto;
    transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.theme-toggle-button:hover {
    color: var(--color-heading);
    border-color: var(--color-line-strong);
}

/* ── Update countdown ────────────────────────────────────── */

.update-countdown {
    display: inline-block;
    margin-left: 0.4rem;
    font-size: 0.8em;
    opacity: 0.75;
    font-variant-numeric: tabular-nums;
}

/* ── Build toast notification ────────────────────────────────────── */

.build-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18);
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    max-width: 360px;
    animation: toast-in 200ms ease both;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(1rem) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.build-toast-success { border-left: 3px solid #22c55e; }
.build-toast-failure { border-left: 3px solid #ef4444; }
.build-toast-neutral { border-left: 3px solid var(--color-muted); }

.build-toast-icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-top: 0.1rem;
}

.build-toast-success .build-toast-icon { color: #22c55e; }
.build-toast-failure .build-toast-icon { color: #ef4444; }
.build-toast-neutral .build-toast-icon { color: var(--color-muted); }

/* ── Customer list — MD3 Table ───────────────────────────────── */

/* Toolbar above the table */
.cust-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.cust-toolbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.cust-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cust-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.cust-search-icon {
    position: absolute;
    left: 0.6rem;
    font-size: 1rem;
    color: var(--color-muted);
    pointer-events: none;
}

.cust-search-input {
    padding: 0.45rem 0.75rem 0.45rem 2.1rem;
    border: 1px solid var(--color-line);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.875rem;
    width: 220px;
    outline: none;
    transition: border-color 120ms;
}

.cust-search-input:focus {
    border-color: var(--color-brand);
}

.cust-import-msg {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* Table scroll wrapper */
.md-table-scroll {
    overflow-x: auto;
    border-radius: 0 0 12px 12px;
}

/* The table itself */
.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

/* Header */
.md-table thead tr {
    border-bottom: 1px solid var(--color-line);
}

.md-table thead th {
    padding: 0 0.75rem;
    height: 52px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-muted);
    white-space: nowrap;
    vertical-align: middle;
}

/* Sort button inside th */
.md-th-sort-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-muted);
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    transition: color 120ms;
}

.md-th-sort-btn:hover {
    color: var(--color-text);
}

.md-th-sort-active {
    color: var(--color-brand-strong);
}

.md-th-sort-btn-right {
    justify-content: flex-end;
    width: 100%;
}

/* Body rows */
.md-table tbody .md-tr {
    border-bottom: 1px solid var(--color-line);
    transition: background 100ms;
}

.md-table tbody .md-tr:last-child {
    border-bottom: none;
}

.md-table tbody .md-tr:hover {
    background: color-mix(in srgb, var(--color-text) 4%, transparent);
}

/* Body cells */
.md-table tbody td {
    padding: 0 0.75rem;
    height: 60px;
    vertical-align: middle;
    color: var(--color-text);
}

/* Column widths */
.md-th-avatar, .md-td-avatar { width: 56px; padding-left: 0; padding-right: 0; text-align: center; }
.md-th-name   { min-width: 200px; }
.md-th-city   { min-width: 110px; }
.md-th-num    { width: 110px; text-align: right; }
.md-th-narrow { width: 70px; }
.md-th-date   { width: 90px; }
.md-th-actions { width: 48px; padding: 0; }

/* Avatar cell */
.md-td-avatar {
    width: 56px;
    padding-left: 0.5rem;
    padding-right: 0;
}

/* Name cell */
.md-td-name {
    display: table-cell;
    vertical-align: middle;
}

.md-td-primary-link {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-heading);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.md-td-primary-link:hover {
    color: var(--color-brand-strong);
    text-decoration: underline;
}

.md-td-secondary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--color-muted);
    margin-top: 1px;
}

/* City */
.md-td-city {
    font-size: 0.85rem;
    color: var(--color-text);
}

/* Numeric cells */
.md-td-num {
    text-align: right;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.md-td-muted {
    font-weight: 400;
    color: var(--color-muted);
}

/* Date */
.md-td-date {
    font-size: 0.8rem;
    color: var(--color-muted);
    white-space: nowrap;
}

/* Actions */
.md-td-actions {
    width: 48px;
    padding: 0;
    text-align: center;
}

/* Empty cells / empty state row */
.md-td-empty {
    color: var(--color-muted);
}

.md-td-empty-row {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-muted);
    font-size: 0.875rem;
}

/* Round avatar image — same size as initials circle */
.md-avatar-img {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Avatar initials — color set inline */
.md-table .md-avatar {
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
}

.build-toast-icon svg {
    width: 20px;
    height: 20px;
}

.build-toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.build-toast-content strong {
    font-size: 0.875rem;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.build-toast-content span {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.build-toast-content a {
    color: var(--color-brand);
    text-decoration: none;
    margin-left: 0.25rem;
}

.build-toast-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-muted);
    opacity: 0.6;
    width: 18px;
    height: 18px;
    transition: opacity 120ms;
}

.build-toast-close:hover { opacity: 1; }
.build-toast-close svg { width: 18px; height: 18px; }

/* ── Builds page ────────────────────────────────────── */

.builds-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.builds-header h1 { margin: 0 0 0.25rem; }
.builds-header p { margin: 0; color: var(--color-muted); font-size: 0.9rem; }

.builds-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.build-run {
    border: 1px solid var(--color-line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-surface);
    transition: border-color 120ms;
    cursor: pointer;
}

.build-run:hover { border-color: var(--color-line-strong); }

.build-run-success { border-left: 3px solid #22c55e; }
.build-run-failure { border-left: 3px solid #ef4444; }
.build-run-pending { border-left: 3px solid #f59e0b; }
.build-run-neutral { border-left: 3px solid var(--color-line); }

.build-run-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.build-status-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-muted);
}

.build-run-success .build-status-dot { background: #22c55e; }
.build-run-failure .build-status-dot { background: #ef4444; }
.build-run-pending .build-status-dot { background: #f59e0b; }

.build-run-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.build-run-name {
    font-size: 0.9rem;
    color: var(--color-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.build-run-meta {
    font-size: 0.75rem;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.build-run-timing {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.build-run-time {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.build-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success { background: rgba(34,197,94,0.15); color: #16a34a; }
.badge-failure { background: rgba(239,68,68,0.15); color: #dc2626; }
.badge-pending { background: rgba(245,158,11,0.15); color: #d97706; }
.badge-neutral { background: var(--color-sidebar-bg); color: var(--color-muted); }

.build-run-jobs {
    border-top: 1px solid var(--color-line);
    padding: 0.5rem 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.build-job {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0;
}

.build-job-dot {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-muted);
}

.build-job-success .build-job-dot { background: #22c55e; }
.build-job-failure .build-job-dot { background: #ef4444; }
.build-job-pending .build-job-dot { background: #f59e0b; }

.build-job-name {
    flex: 1;
    font-size: 0.82rem;
    color: var(--color-text);
}

.build-job-duration {
    font-size: 0.75rem;
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Sale Invoice Creation ────────────────────────────────── */
.sale-create-panel {
    max-width: 1200px;
}

.sale-create-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.sale-create-header h2 {
    margin: 0;
}

.sale-create-body {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sale-create-section {
    border: 1px solid var(--color-line);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
}

.sale-create-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    margin: 0 0 1rem;
}

/* Line items table */
.sale-lines-table {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-x: auto;
}

.sale-lines-header,
.sale-lines-row {
    display: grid;
    grid-template-columns:
        minmax(120px, 1.8fr)  /* product */
        minmax(160px, 2.5fr)  /* description */
        60px                   /* unit */
        80px                   /* qty */
        100px                  /* unit price */
        70px                   /* disc % */
        70px                   /* vat % */
        90px                   /* net */
        90px                   /* vat */
        32px;                  /* remove */
    gap: 0.4rem;
    align-items: center;
}

.sale-lines-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--color-line);
}

.sale-lines-row {
    padding: 0.3rem 0;
}

.sale-line-computed {
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: 0.25rem;
    color: var(--color-text);
}

.form-input-sm {
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
    border-radius: 10px;
}

.ghost-button-danger {
    color: var(--color-danger, #ef4444);
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

.ghost-button-danger:hover {
    background: color-mix(in srgb, var(--color-danger, #ef4444) 12%, transparent);
}

/* Totals + actions footer */
.sale-create-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
}

.sale-totals {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 260px;
}

.sale-totals-row {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    font-size: 0.9rem;
    color: var(--color-text);
    padding: 0.2rem 0;
}

.sale-totals-gross {
    border-top: 1px solid var(--color-line);
    padding-top: 0.5rem;
    margin-top: 0.15rem;
    font-size: 1rem;
}

.sale-totals-net-payable {
    border-top: 2px solid var(--color-line);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.sale-create-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.form-message-success {
    color: var(--color-success, #22c55e);
}

.sale-customer-field {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sale-new-customer-btn {
    white-space: nowrap;
    flex-shrink: 0;
    margin-bottom: 0;
    align-self: flex-end;
}

.sale-inline-customer {
    background: color-mix(in srgb, var(--color-accent, #6366f1) 5%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-accent, #6366f1) 20%, transparent);
    border-radius: 8px;
    padding: 1rem;
    margin-top: -0.25rem;
}

/* ── Applicazione nav section ─────────────────────────────── */

.nav-section-header-application .nav-icon {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.25);
    color: #6366f1;
}

/* ── Design / Progettazione page ─────────────────────────── */

.diagram-tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-line);
    margin-top: 0.5rem;
}

.diagram-tab {
    padding: 0.65rem 1.4rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-muted);
    cursor: pointer;
    transition: color 150ms ease, border-color 150ms ease;
    margin-bottom: -1px;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

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

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

/* Toolbar */
.diagram-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0 0.75rem;
    flex-wrap: wrap;
}

/* Diagram outer container — holds the SVG wrapper */
.diagram-wrapper {
    position: relative;
    width: 100%;
    height: 660px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-line);
    background: var(--color-surface-muted);
    overflow: hidden;
}

[data-theme="dark"] .diagram-wrapper {
    background: #111214;
}

/* SVG / canvas wrapper */
.diagram-svg-wrapper {
    width: 100%;
    height: 100%;
}

.diagram-svg-wrapper svg {
    display: block;
    width: 100%;
    height: 100%;
}

.diagram-svg-wrapper canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.diagram-surface-panel:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    padding: 1rem 1rem 1.25rem;
    border-radius: 0;
    background: var(--color-surface);
    box-sizing: border-box;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
}

.diagram-surface-panel:fullscreen .diagram-wrapper {
    height: 100%;
    min-height: 0;
}

/* Legend */
.diagram-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-line);
}

.diagram-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--color-muted);
}

.diagram-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ── VAT lines & line items table ─────────────────────────────── */

.vat-lines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.vat-lines-table th,
.vat-lines-table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--color-line);
}

.vat-lines-table tfoot td {
    border-top: 2px solid var(--color-line);
    border-bottom: none;
    padding-top: 0.5rem;
}

.remove-row-button {
    background: none;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.25rem;
    line-height: 1;
}

.remove-row-button:hover {
    color: var(--color-danger, #ef4444);
}

/* ── Line items ───────────────────────────────────────────────── */

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

.line-items-scroll {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.line-items-table .li-col-product { min-width: 14rem; }
.line-items-table .li-col-desc    { min-width: 11rem; }
.line-items-table .li-col-unit    { width: 4.5rem; }
.line-items-table .li-col-qty     { width: 5rem; }
.line-items-table .li-col-price   { width: 7rem; }
.line-items-table .li-col-disc    { width: 5.5rem; }
.line-items-table .li-col-vat     { width: 5rem; }
.line-items-table .li-col-net     { width: 7rem; white-space: nowrap; }
.line-items-table .li-col-remove  { width: 2rem; }

.line-items-table .form-input {
    width: 100%;
    padding: 0.2rem 0.35rem;
    font-size: 0.85rem;
}

/* ── Product search dropdown ──────────────────────────────────── */

.product-search-wrapper {
    position: relative;
}

.product-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 200;
    min-width: 18rem;
    max-height: 14rem;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}

.product-dropdown li {
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    font-size: 0.87rem;
    line-height: 1.3;
}

.product-dropdown li:hover {
    background: var(--color-surface-muted);
}
