/* ==========================================================================
   MSM Management — design tokens on top of the Syncfusion Material 3 theme
   ========================================================================== */

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('/fonts/plus-jakarta-sans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Josefin Sans';
    font-style: normal;
    font-weight: 600 700;
    font-display: swap;
    src: url('/fonts/josefin-sans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    /* Syncfusion Material 3 palette (RGB triplets) mapped to the MSM brand */
    --color-sf-primary: 107, 91, 149;          /* #6B5B95 */
    --color-sf-primary-container: 234, 230, 245;
    --color-sf-on-primary-container: 45, 36, 72;
    --color-sf-secondary: 0, 150, 182;
    --color-sf-tertiary: 0, 180, 216;          /* #00B4D8 */

    /* Brand: single source. App.razor overrides --brand-primary/--brand-secondary from the organization profile; the rest derives from them */
    --brand-primary: #6B5B95;
    --brand-secondary: #00B4D8;
    --brand-primary-dark: color-mix(in srgb, var(--brand-primary) 70%, black);
    --brand-secondary-light: color-mix(in srgb, var(--brand-secondary) 70%, white);
    --brand-gradient: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    /* Legacy names used by the component stylesheets: aliases of the brand variables */
    --msm-violet: var(--brand-primary);
    --msm-violet-dark: var(--brand-primary-dark);
    --msm-cyan: var(--brand-secondary);
    --msm-cyan-light: var(--brand-secondary-light);
    --msm-gradient: var(--brand-gradient);

    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e3e7ef;
    --text: #1e293b;
    --text-muted: #556274;
    --success: #10b981;
    --warning: #f59e0b;
    /* Darker twins of success, warning and cyan for text and links (4.5:1 on --surface and --bg); the light ones stay for fills and icons */
    --success-text: #047857;
    --warning-text: #b45309;
    --link: #0369a1;
    --danger: #ef4444;
    --info: #3b82f6;

    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
    --font-title: 'Josefin Sans', 'Plus Jakarta Sans', sans-serif;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

.e-control, .e-css { font-family: var(--font) !important; }
.e-tab .e-tab-header .e-tab-text, .e-tab .e-tab-header .e-tab-wrap { font-family: var(--font) !important; }
h1:focus { outline: none; }
a { color: var(--msm-violet); }

/* ---------- App shell ---------- */
.app-shell { --sidebar-w: 264px; display: flex; min-height: 100vh; }
.app-shell.collapsed { --sidebar-w: 72px; }

.app-sidebar {
    position: sticky; top: 0; height: 100vh; flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
    overflow-x: hidden; overflow-y: auto;
    background: linear-gradient(180deg, #2d2448 0%, #1c2440 60%, #10233a 100%);
    color: #e6e9f2;
    transition: width .2s ease, flex-basis .2s ease;
    z-index: 30;
}
.app-shell.collapsed .nav-text { display: none; }
.app-shell.collapsed .nav-section { margin: 10px 0 2px; border-top: 1px solid rgba(255, 255, 255, .08); }
.app-overlay { display: none; }
.toggle-mobile { display: none !important; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 8px;
    height: 60px; padding: 0 20px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.app-header-title { font-weight: 700; color: var(--text); }
.app-header-spacer { flex: 1; }
.header-icon-btn.e-btn { color: var(--text-muted); }
/* The Syncfusion icon font has no bell: drawn here as a mask so it follows the text colour, size and hover of any e-icons host */
.e-icons.msm-bell::before {
    content: ""; display: inline-block; width: 1em; height: 1em; vertical-align: middle; background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 22a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 12 22zm7-6v-5c0-3.07-1.64-5.64-4.5-6.32V4a2.5 2.5 0 0 0-5 0v.68C6.63 5.36 5 7.92 5 11v5l-2 2v1h18v-1l-2-2z'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 22a2.5 2.5 0 0 0 2.45-2h-4.9A2.5 2.5 0 0 0 12 22zm7-6v-5c0-3.07-1.64-5.64-4.5-6.32V4a2.5 2.5 0 0 0-5 0v.68C6.63 5.36 5 7.92 5 11v5l-2 2v1h18v-1l-2-2z'/></svg>") center / contain no-repeat;
}
.user-avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 34px; height: 34px; border-radius: 50%; margin-left: 6px;
    background: var(--msm-gradient); color: #fff; font-size: 12px; font-weight: 700;
}
.header-user.e-btn, .header-lang.e-btn { font-weight: 600; text-transform: none; color: var(--text); }

/* Every page uses the whole content area with this one padding; no page-specific max-width (R5) */
.app-content { padding: 24px 28px 40px; width: 100%; box-sizing: border-box; }
/* The only width cap of the layout, one value shared by the insert/edit pages and the dialogs. A page whose PageHeader has
   FormPage="true" (class form-page, rendered as soon as the page is, also while the data is loading) is capped as a whole: header
   with its buttons, sections above or below the form, the busy overlay and the two-column detail layouts all share the same right
   edge. Dialogs and their full-screen container are excluded: a modal placed at the top level of the page stays centred */
:root { --form-max-width: 1400px; }
.app-content:has(.form-page) > :not(.e-dlg-container, .e-dialog) { max-width: var(--form-max-width); box-sizing: border-box; }

/* ---------- Navigation ---------- */
.nav-brand {
    display: flex; align-items: center; gap: 10px;
    height: 60px; padding: 0 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    font-family: var(--font-title); font-weight: 700; font-size: 18px; color: #fff;
    white-space: nowrap; overflow: hidden;
}
.nav-brand img { width: 40px; height: auto; background: #fff; border-radius: 8px; padding: 3px; }

.nav-menu { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
    margin: 14px 10px 4px; min-height: 12px;
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: rgba(230, 233, 242, .45);
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    color: rgba(230, 233, 242, .85); text-decoration: none; font-weight: 500;
    white-space: nowrap; overflow: hidden;
    transition: background .15s, color .15s;
}
.nav-item .e-icons { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--msm-gradient); color: #fff; box-shadow: 0 6px 18px rgba(0, 180, 216, .25); }
.nav-item:focus-visible, .nav-group:focus-visible { outline: 2px solid var(--msm-cyan-light); outline-offset: 2px; }

.nav-group {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 10px 12px; border: none; border-radius: 10px; background: none; cursor: pointer;
    color: rgba(230, 233, 242, .85); font: inherit; font-weight: 500; text-align: left; white-space: nowrap; overflow: hidden;
}
.nav-group .e-icons:first-child { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-group:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-group .nav-label { flex: 1; }
.nav-chevron { font-size: 12px; transition: transform .15s; }
.nav-group.expanded .nav-chevron { transform: rotate(180deg); }
.nav-children { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 6px; }
.nav-child { padding: 8px 12px 8px 46px; font-size: 14px; }
.app-shell.collapsed .nav-children { display: none; }
.nav-divider { height: 1px; margin: 12px 8px; background: rgba(255, 255, 255, .08); }
/* Critical contract coverage issues (NavMenu badge) */
.nav-badge {
    margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 800; text-align: center; line-height: 16px;
}
.nav-group { position: relative; }
.app-shell.collapsed .nav-group .nav-badge { position: absolute; top: 2px; left: 34px; margin-left: 0; }

/* ---------- Page structure ---------- */
/* Title block on the left (it keeps its width), actions on the right. When the actions do not fit next to the title they
   move below it and stay right-aligned (margin-left: auto), wrapping from the right with the entity switch first. */
.page-header {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-header > :first-child { flex: 0 1 auto; min-width: 0; }
.page-header h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; }
.page-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-left: auto; max-width: 100%; }
.year-picker { width: 110px; }
.month-picker { width: 200px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card .e-grid { border: none; border-radius: var(--radius); }
/* A plain table never widens the page: it stays in its box (a size container) and, marked "stack" with a data-label (the
   column name) on every cell, becomes one card per row when its box is narrower than the table needs (560 px, 720 px with
   "stack-wide"): every value next to its column name, like the grids on a phone. No horizontal scroll bar */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; container: table-box / inline-size; }
@container table-box (max-width: 560px) {
    table.stack, table.stack > tbody, table.stack > tfoot, table.stack > tbody > tr, table.stack > tfoot > tr { display: block; width: 100%; }
    table.stack > thead { display: none; }
    table.stack > tbody > tr { padding: 6px 0; border-bottom: 1px solid var(--border); }
    table.stack > tbody > tr > td {
        display: block; position: relative; box-sizing: border-box; width: 100%; min-height: 30px; padding: 5px 8px 5px 40% !important;
        border: none !important; text-align: left !important; white-space: normal !important; overflow-wrap: break-word;
    }
    table.stack > tbody > tr > td:not([data-label]) { padding-left: 8px !important; }
    table.stack > tbody > tr > td[data-label]::before {
        content: attr(data-label); position: absolute; left: 8px; top: 7px; width: calc(40% - 20px);
        color: var(--text-muted); font-size: 12px; font-weight: 600; line-height: 1.3; overflow-wrap: break-word;
    }
    table.stack > tfoot > tr { display: flex; justify-content: space-between; gap: 12px; }
    table.stack > tfoot > tr > td { display: block; border: none !important; }
}
@container table-box (max-width: 720px) {
    table.stack-wide, table.stack-wide > tbody, table.stack-wide > tfoot, table.stack-wide > tbody > tr, table.stack-wide > tfoot > tr { display: block; width: 100%; }
    table.stack-wide > thead { display: none; }
    table.stack-wide > tbody > tr { padding: 6px 0; border-bottom: 1px solid var(--border); }
    table.stack-wide > tbody > tr > td {
        display: block; position: relative; box-sizing: border-box; width: 100%; min-height: 30px; padding: 5px 8px 5px 40% !important;
        border: none !important; text-align: left !important; white-space: normal !important; overflow-wrap: break-word;
    }
    table.stack-wide > tbody > tr > td:not([data-label]) { padding-left: 8px !important; }
    table.stack-wide > tbody > tr > td[data-label]::before {
        content: attr(data-label); position: absolute; left: 8px; top: 7px; width: calc(40% - 20px);
        color: var(--text-muted); font-size: 12px; font-weight: 600; line-height: 1.3; overflow-wrap: break-word;
    }
    table.stack-wide > tfoot > tr { display: flex; justify-content: space-between; gap: 12px; }
    table.stack-wide > tfoot > tr > td { display: block; border: none !important; }
}
/* ---------- Breakdown tables (.dash-table): dashboard cards, business-lines tabs, project and property details ---------- */
/* Same look as the grids: a header over its column (text left, numbers right, header included), amounts on one line in
   tabular figures, negative amounts in red, a bold totals row. "dash-fixed": equal-width numeric columns, the first one
   (the name, with its sub-text) takes the rest. In a narrow box "dash-stack" turns the rows into cards (see below). */
.dash-empty { margin: 0; padding: 28px 8px; text-align: center; color: var(--text-muted); font-size: 14px; }
.dash-table-scroll { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th, .dash-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: top; }
.dash-table thead th { white-space: normal; color: var(--text-muted); font-size: 12px; font-weight: 700; vertical-align: bottom; }
.dash-table tbody th { font-weight: 600; }
.dash-table tfoot th, .dash-table tfoot td { font-weight: 800; border-bottom: none; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dash-table td.num { white-space: nowrap; }
.dash-table .negative { color: var(--danger); }
.dash-table .muted { color: var(--text-muted); }
.dash-table tbody tr:hover { background: var(--surface-hover, rgba(0, 0, 0, .02)); }
.dash-table .dash-total th, .dash-table .dash-total td { font-weight: 800; border-top: 2px solid var(--border); border-bottom: none; }
.dash-table .dash-sub { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); white-space: normal; }
.dash-table .dash-info { display: inline-flex; margin-left: 4px; color: var(--text-muted); cursor: help; vertical-align: middle; }
.dash-table .dash-info .e-icons { font-size: 13px; }
.dash-table th > .e-tooltip { display: inline-block; vertical-align: middle; }
.dash-table.dash-fixed { table-layout: fixed; }
.dash-table.dash-fixed th.num, .dash-table.dash-fixed td.num { width: 18%; }
.dash-table.dash-fixed tbody th, .dash-table.dash-fixed tfoot th { white-space: normal; overflow-wrap: anywhere; }
.dash-note { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }
/* A chart that fills its dashboard card (the card is as tall as the one next to it): at least 320 px, the rest is the chart's */
.dash-card-body:has(> .dash-chart-fill) { display: flex; flex-direction: column; }
.dash-chart-fill { flex: 1 1 320px; min-height: 320px; min-width: 0; }
/* Kanban column titles wrap instead of being cut with an ellipsis ("Proposta di valore") */
.e-kanban .e-header-cells .e-header-text { white-space: normal; text-overflow: clip; overflow: visible; }
/* Dashboard tables (RevenueChart, "Tabella"): in a box narrower than the table needs, one card per month with every amount
   next to its column name (the comparison of the entities, wider, from a wider box) */
.dash-table-scroll { container: dash-table / inline-size; }
@container dash-table (max-width: 720px) {
    table.dash-stack, table.dash-stack > tbody, table.dash-stack > tfoot, table.dash-stack > tbody > tr, table.dash-stack > tfoot > tr { display: block; width: 100%; }
    table.dash-stack > thead { display: none; }
    table.dash-stack > tbody > tr, table.dash-stack > tfoot > tr { padding: 4px 0 8px; border-bottom: 1px solid var(--border); }
    table.dash-stack > * > tr > th { display: block; border: none !important; padding: 6px 8px 2px !important; font-weight: 800; }
    table.dash-stack > * > tr > td { display: flex; width: auto !important; justify-content: space-between; gap: 12px; border: none !important; padding: 3px 8px !important; }
    table.dash-stack > * > tr > td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; white-space: normal; text-align: left; }
}
@container dash-table (max-width: 1100px) {
    table.dash-stack-wide, table.dash-stack-wide > tbody, table.dash-stack-wide > tfoot, table.dash-stack-wide > tbody > tr, table.dash-stack-wide > tfoot > tr { display: block; width: 100%; }
    table.dash-stack-wide > thead { display: none; }
    table.dash-stack-wide > tbody > tr, table.dash-stack-wide > tfoot > tr { padding: 4px 0 8px; border-bottom: 1px solid var(--border); }
    table.dash-stack-wide > * > tr > th { display: block; border: none !important; padding: 6px 8px 2px !important; font-weight: 800; }
    table.dash-stack-wide > * > tr > td { display: flex; width: auto !important; justify-content: space-between; gap: 12px; border: none !important; padding: 3px 8px !important; }
    table.dash-stack-wide > * > tr > td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; white-space: normal; text-align: left; }
}
/* "dash-stack-sm": the same cards, but only in a box narrower than 480 px (a table of three or four short columns fits well below 720 px) */
@container dash-table (max-width: 480px) {
    table.dash-stack-sm, table.dash-stack-sm > tbody, table.dash-stack-sm > tfoot, table.dash-stack-sm > tbody > tr, table.dash-stack-sm > tfoot > tr { display: block; width: 100%; }
    table.dash-stack-sm > thead { display: none; }
    table.dash-stack-sm > tbody > tr, table.dash-stack-sm > tfoot > tr { padding: 4px 0 8px; border-bottom: 1px solid var(--border); }
    table.dash-stack-sm > * > tr > th { display: block; border: none !important; padding: 6px 8px 2px !important; font-weight: 800; }
    table.dash-stack-sm > * > tr > td { display: flex; width: auto !important; justify-content: space-between; gap: 12px; border: none !important; padding: 3px 8px !important; }
    table.dash-stack-sm > * > tr > td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 600; white-space: normal; text-align: left; }
}
/* Syncfusion charts (SfChart, SfAccumulationChart) draw their first frame 600 px wide, before they have measured their
   box: clipped to the box (horizontally only, the tooltips stay free), they never widen the page, not even for that frame */
.e-control.e-chart, .e-control.e-accumulationchart { max-width: 100%; min-width: 0; overflow-x: clip; }
/* FileName: a file name on one line in its box, cut with "…" before the extension (the full name is the tooltip) */
.file-name { display: inline-flex; max-width: 100%; min-width: 0; vertical-align: bottom; }
.file-name-stem { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name-ext { flex: none; white-space: nowrap; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page-loading { display: flex; justify-content: center; padding: 80px 0; position: relative; min-height: 120px; }

.notice {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 16px; margin-bottom: 16px; border-radius: 12px; font-size: 14px;
}
.notice .e-icons { margin-top: 2px; }
.notice-info { background: #eef6ff; color: #1e40af; }
.notice-warning { background: #fff7e6; color: #92400e; }
.notice-danger { background: #fef2f2; color: #991b1b; }
.issue-check-list { margin: 6px 0 8px; padding-left: 18px; }
.issue-check-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
    position: relative; overflow: hidden;
}
.kpi-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--msm-gradient); }
.kpi-label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 28px; font-weight: 800; }
/* A text instead of a number (an account name, a date): smaller, on one line with an ellipsis (the full text is the
   tooltip), as tall as a number so the cards of a row stay aligned */
.kpi-value.kpi-text {
    font-size: 17px; font-weight: 700; line-height: 34px; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-value.warning { color: var(--warning-text); }
.kpi-value.success { color: var(--success-text); }
.kpi-value.danger { color: var(--danger); }
/* A card that opens its detail (KpiCard OnClick): pointer, lift on hover, chevron button in the corner (keyboard trigger) */
.kpi-card.kpi-clickable { cursor: pointer; padding-right: 44px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.kpi-card.kpi-clickable:hover, .kpi-card.kpi-clickable:focus-within {
    transform: translateY(-2px); border-color: var(--msm-violet); box-shadow: 0 10px 28px rgba(15, 23, 42, .1);
}
.kpi-detail { position: absolute; top: 12px; right: 10px; }
.e-btn.kpi-detail-btn, .e-btn.kpi-detail-btn:hover, .e-btn.kpi-detail-btn:focus, .e-btn.kpi-detail-btn:active {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; min-width: 26px; padding: 0; border-radius: 50%;
    border: 1px solid var(--border); border-image: none; box-shadow: none;
    background: var(--surface); color: var(--text-muted); line-height: 1;
}
.e-btn.kpi-detail-btn .e-btn-icon { font-size: 13px; width: auto; margin: 0; line-height: 1; }
.kpi-card.kpi-clickable:hover .e-btn.kpi-detail-btn, .e-btn.kpi-detail-btn:focus-visible {
    color: #fff; background: var(--msm-violet); border-color: var(--msm-violet);
}
.e-btn.kpi-detail-btn:focus-visible { outline: 2px solid var(--msm-violet); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .kpi-card.kpi-clickable, .kpi-card.kpi-clickable:hover, .kpi-card.kpi-clickable:focus-within { transition: none; transform: none; }
}

/* ---------- Fiscal entities (company / natural person): switch, KPI blocks, badges ---------- */
.entity-switch { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entity-switch-label { color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.entity-switch-notice { flex-basis: 100%; margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.entity-switch .e-btn-group { box-shadow: none; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.entity-switch .e-btn-group .e-btn.entity-option, .entity-switch .e-btn-group .e-btn.entity-option:focus,
.entity-switch .e-btn-group .e-btn.entity-option:active {
    display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border: none; border-image: none; border-radius: 0;
    box-shadow: none; background: var(--surface); color: var(--text-muted); font-size: 13px; font-weight: 700;
    letter-spacing: normal; text-transform: none; line-height: normal;
}
.entity-switch .e-btn-group .e-btn.entity-option + .e-btn.entity-option { border-left: 1px solid var(--border); }
.entity-switch .e-btn-group .e-btn.entity-option:hover { color: var(--msm-violet); background: #f6f4fb; }
.entity-switch .e-btn-group .e-btn.entity-option.e-active,
.entity-switch .e-btn-group .e-btn.entity-option.e-active:hover { background: var(--msm-violet); color: #fff; }
.entity-switch .e-btn-group .e-btn.entity-option.person.e-active { background: #0284c7; }
.entity-switch .e-btn-group .e-btn.entity-option:disabled { opacity: .6; cursor: progress; }
.entity-switch .e-btn.entity-option.e-active .entity-dot { background: #fff; }
.entity-compare-icon { font-size: 14px; }
.entity-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--msm-violet); flex: 0 0 8px; }
.entity-dot.person { background: #0284c7; }
.entity-badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.entity-kpis.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.entity-kpis.compare .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.entity-kpis.compare .entity-kpi-block { border: 1px dashed var(--border); border-radius: var(--radius); padding: 10px; }
.entity-kpis.compare .entity-kpi-block.company { border-top: 3px solid var(--msm-violet); }
.entity-kpis.compare .entity-kpi-block.person { border-top: 3px solid #0284c7; }
.entity-kpi-title { margin: 2px 4px 10px; font-size: 14px; }
@media (min-width: 1200px) { .kpi-row.kpi-five { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
/* Six cards: three per row on laptops, one row on wide screens (two per row on phones, as every KPI row) */
@media (min-width: 992px) { .kpi-row.kpi-six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1500px) { .kpi-row.kpi-six { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* Three parts that go together (A, B and C = A + B) on one row */
@media (min-width: 760px) { .kpi-row.kpi-three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 759px) { .kpi-row.kpi-three { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Badges & buttons ---------- */
.status-badge {
    display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.status-success { background: #d1fae5; color: #047857; }
.status-info { background: #dbeafe; color: #1d4ed8; }
.status-warning { background: #fef3c7; color: #b45309; }
.status-danger { background: #fee2e2; color: #b91c1c; }
.status-neutral { background: #ede9f6; color: var(--msm-violet-dark); }
.status-muted { background: #f1f5f9; color: var(--text-muted); }
/* In a grid with AllowTextWrap a badge longer than its column wraps instead of being cut */
.e-grid.e-wrap .e-rowcell .status-badge, .e-grid .e-gridcontent.e-wrap .e-rowcell .status-badge { white-space: normal; }

/* ---------- Issue rows: severity badge + text (period, details) + action buttons ---------- */
/* One row per issue (contract coverage in grids, dashboard and details). The list is a size container: its own width
   decides the layout, not the screen. Wide: badge, text and actions on one line. Narrow (a phone, a grid cell rendered as a
   card, a side card): the badge (never wrapping) and the text (wrapping between words) first, the period and details
   below the text, the actions on their own row. The text never gets narrower than 10em, so a word is never split. */
.issue-list { container: issues / inline-size; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.issue-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.issue-row > .status-badge { flex: none; white-space: nowrap !important; } /* !important: beats the grids' wrapping badges */
.issue-row > .issue-body, .issue-row > .issue-title { flex: 1 1 0; min-width: min(10em, 100%); overflow-wrap: break-word; word-break: normal; }
/* Text of a dense row: the title, then the period and the details on the same line while they fit */
.issue-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; }
.issue-title { font-weight: 700; max-width: 100%; }
.issue-meta { color: var(--text-muted); font-size: 12px; max-width: 100%; }
.issue-message { flex: 1 0 100%; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; } /* the full text of a dense row, readable without hovering */
.issue-actions { display: flex; flex-wrap: wrap; gap: 4px; flex: none; margin-left: auto; }
@container issues (max-width: 480px) {
    .issue-row { align-items: flex-start; }
    /* Stacked issues: a thin line between two, so each one's actions clearly belong to it */
    .issue-row + .issue-row { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 2px; }
    .issue-body { flex-direction: column; align-items: flex-start; gap: 2px; }
    .issue-actions { flex: 1 1 100%; margin-left: 0; gap: 6px; }
}

.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
/* ---------- Grid tables (tablets, desktops): never wider than their box ---------- */
/* Column widths are shares of the table (GridUi) and texts wrap: amounts and other right-aligned values, and the cells
   marked nowrap (dates), stay on one line; the row actions wrap when their column is narrow */
.e-grid:not(.e-row-responsive) .e-rowcell.e-rightalign, .e-grid:not(.e-row-responsive) .e-rowcell.nowrap { white-space: nowrap; }
/* ...but the lines of a composite value (an amount with its details, one line per entity) wrap between words */
.e-grid:not(.e-row-responsive) .e-rowcell.e-rightalign :is(div, small, .cell-sub) { white-space: normal; }
/* A long code or keyword wraps inside its column instead of running under the next one */
.e-grid.e-wrap:not(.e-row-responsive) .e-rowcell { overflow-wrap: break-word; }
/* A long header word that does not fit splits at a syllable with a hyphen (the page language is on the html element), not at a random letter */
.e-grid .e-headertext { hyphens: auto; }
/* The sort icon takes its room only in the sorted column: elsewhere the 17 px it keeps would break a header word in two */
.e-grid .e-headercell-container > .e-sortfilterdiv:not(.e-ascending):not(.e-descending) { display: none; }
.e-grid:not(.e-row-responsive) .e-rowcell .row-actions { flex-wrap: wrap; }
/* An entity (issuer) name in a narrow column wraps between its words, like the status badges */
.e-grid.e-wrap .e-rowcell .entity-badge, .e-grid .e-gridcontent.e-wrap .e-rowcell .entity-badge { white-space: normal; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--msm-violet); border-color: var(--msm-violet); }
.icon-btn.success:hover { color: var(--success-text); border-color: var(--success); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.link-btn { background: none; border: none; padding: 0; margin-top: 4px; color: var(--link); font-size: 12px; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.e-btn.e-success { background: var(--success); border-color: var(--success); color: #fff; }

/* ---------- SfButton with the app's own looks (row actions, links, filter tabs, menu groups) ---------- */
/* The theme's e-btn adds shadow, gradient border-image, padding and centering: reset them for these classes */
.e-btn.icon-btn, .e-btn.icon-btn:hover, .e-btn.icon-btn:focus, .e-btn.icon-btn:active, .e-btn.icon-btn:disabled {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; min-width: 32px; padding: 0; border-radius: 8px;
    border: 1px solid var(--border); border-image: none; box-shadow: none;
    background: var(--surface); color: var(--text-muted); line-height: 1;
}
.e-btn.icon-btn .e-btn-icon { font-size: 16px; width: auto; margin: 0; line-height: 1; }
.e-btn.icon-btn:hover { color: var(--msm-violet); border-color: var(--msm-violet); }
.e-btn.icon-btn.success:hover { color: var(--success-text); border-color: var(--success); }
.e-btn.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.e-btn.icon-btn:focus-visible { outline: 2px solid var(--msm-violet); outline-offset: 1px; }
.e-btn.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.e-btn.link-btn, .e-btn.link-btn:hover, .e-btn.link-btn:focus, .e-btn.link-btn:active, .e-btn.link-btn:disabled {
    background: none; border: none; border-image: none; border-radius: 0; box-shadow: none;
    min-width: 0; height: auto; padding: 0; margin-top: 4px; line-height: normal; letter-spacing: normal;
    color: var(--link); font-size: 12px; font-weight: 600;
}
.e-btn.link-btn:hover, .e-btn.link-btn:focus-visible { text-decoration: underline; }
.e-btn.link-btn:disabled { opacity: .6; text-decoration: none; }
.e-btn.filter-tab, .e-btn.filter-tab:focus, .e-btn.filter-tab:active {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
    border: 1px solid var(--border); border-image: none; box-shadow: none;
    background: var(--surface); color: var(--text-muted);
    font-size: 13px; font-weight: 700; line-height: normal; letter-spacing: normal;
}
.e-btn.filter-tab:hover { color: var(--msm-violet); border-color: var(--msm-violet); border-image: none; background: var(--surface); box-shadow: none; }
.e-btn.filter-tab.active, .e-btn.filter-tab.active:hover, .e-btn.filter-tab.active:focus { background: var(--msm-violet); border-color: var(--msm-violet); color: #fff; }
.e-btn.nav-group, .e-btn.nav-group:focus, .e-btn.nav-group:active {
    display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%;
    padding: 10px 12px; border: none; border-image: none; border-radius: 10px; box-shadow: none; background: none;
    color: rgba(230, 233, 242, .85); font-size: inherit; font-weight: 500; line-height: normal; letter-spacing: normal; text-align: left;
}
.e-btn.nav-group:hover { background: rgba(255, 255, 255, .07); color: #fff; box-shadow: none; border-image: none; }
.e-btn.nav-group:focus-visible { box-shadow: none; outline: 2px solid var(--msm-cyan-light); outline-offset: 2px; }

/* ---------- Busy state (BusyButton, BusyOverlay, InlineSpinner) ---------- */
@keyframes msm-fade-in { from { opacity: 0; } }
/* SfSpinner covers its container by default: InlineSpinner gives it a box of its own next to the text */
.inline-spinner { position: relative; display: inline-block; flex-shrink: 0; vertical-align: middle; }
.inline-spinner .e-spinner-pane, .inline-spinner .e-spinner-pane .e-spinner-inner { z-index: auto; }
/* In a button it takes the text color (white on a primary button) and sits where the icon was */
.e-btn .inline-spinner .e-spinner-pane .e-spinner-inner .e-spin-material3 { stroke: currentColor; }
.e-btn .inline-spinner { margin: -2px 8px 0 -4px; }
.e-btn.icon-btn .inline-spinner { margin: 0; }
.btn-busy, .btn-busy:disabled { cursor: progress; }
/* The running action keeps its color: it is working, not unavailable */
.e-btn.e-primary.btn-busy:disabled { background: rgb(var(--color-sf-primary)); border-color: rgb(var(--color-sf-primary)); border-image: none; color: #fff; opacity: .85; }
.e-btn.icon-btn.btn-busy:disabled { opacity: 1; cursor: progress; color: var(--msm-violet); }
.busy-host { position: relative; }
.busy-host[aria-busy="true"] { min-height: 140px; }
.busy-overlay {
    position: absolute; inset: 0; z-index: 10; box-sizing: border-box;
    display: flex; justify-content: center; align-items: flex-start; padding: 40px 16px;
    background: rgba(244, 246, 251, .72); border-radius: var(--radius); cursor: progress;
    animation: msm-fade-in .15s ease both;
}
.busy-overlay-box {
    position: sticky; top: 90px;
    display: inline-flex; align-items: center; gap: 12px; max-width: 560px;
    padding: 14px 20px; border-radius: 12px; border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow); font-weight: 600; color: var(--text);
}
.busy-overlay-text { display: flex; flex-direction: column; gap: 2px; }
.busy-overlay-text small { font-weight: 500; color: var(--text-muted); }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state h2 { margin: 12px 0 6px; font-size: 20px; }
.empty-state p { color: var(--text-muted); max-width: 520px; margin: 0 auto 18px; }
.empty-state-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 64px; height: 64px; border-radius: 18px; font-size: 26px;
    background: #ede9f6; color: var(--msm-violet);
}
.empty-state-icon.success { background: #d1fae5; color: var(--success-text); }
.empty-state-icon.danger { background: #fee2e2; color: var(--danger); }

/* ---------- Timesheet: monthly entry ---------- */
.month-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 16px; flex-wrap: wrap; }
.month-label { font-size: 18px; font-weight: 800; min-width: 170px; text-align: center; }
.toolbar-spacer { flex: 1; }
.supplier-picker { width: 280px; }

.timesheet-card { overflow: hidden; }
/* The month as one table per week (MonthlyEntry): placement, 7 days, week total; never wider than the card. In a narrow
   box (a phone) the placement takes its own line above the 7 days and the total */
/* Month on one row when the card fits placement + 31 compact days + total (about 1440 px: a 1920 window with the menu open,
   1680 with it closed); otherwise the weeks. The card is the size container, so the menu open or closed counts */
.timesheet-layout { container: timesheet-card / inline-size; }
.timesheet-grid.timesheet-month { display: none; }
.timesheet-grid.timesheet-month .col-placement { width: 190px; }
.timesheet-grid.timesheet-month .col-total { width: 52px; }
.timesheet-grid.timesheet-month .col-day { padding: 6px 1px; }
.timesheet-month .e-input-group.e-control-wrapper.hours-input { width: 34px !important; min-width: 34px !important; }
@container timesheet-card (min-width: 1440px) {
    .timesheet-grid.timesheet-month { display: table; }
    .timesheet-layout > .timesheet-weeks { display: none; }
}
.timesheet-weeks { container: timesheet / inline-size; display: flex; flex-direction: column; gap: 14px; padding-bottom: 4px; }
.timesheet-grid { border-collapse: separate; border-spacing: 0; width: 100%; table-layout: fixed; font-size: 13px; }
.timesheet-grid th, .timesheet-grid td { border-bottom: 1px solid var(--border); text-align: center; padding: 6px 2px; }
.timesheet-grid thead th { background: #f8f9fc; font-weight: 700; color: var(--text-muted); }
.timesheet-grid .col-placement {
    width: 260px; text-align: left; padding: 8px 12px; background: var(--surface);
    border-right: 1px solid var(--border); overflow-wrap: break-word;
}
.timesheet-grid thead .col-placement, .timesheet-grid tfoot .col-placement { background: #f8f9fc; }
.placement-month { font-size: 12px; font-weight: 700; color: var(--text); margin-top: 2px; }
.timesheet-grid .out { background: repeating-linear-gradient(135deg, transparent 0 6px, #f3f4f8 6px 8px); }
@container timesheet (max-width: 640px) {
    .timesheet-grid, .timesheet-grid > thead, .timesheet-grid > tbody, .timesheet-grid > tfoot { display: block; }
    .timesheet-grid tr { display: flex; flex-wrap: wrap; }
    .timesheet-grid th, .timesheet-grid td { flex: 1 1 0; min-width: 0; box-sizing: border-box; }
    .timesheet-grid .col-placement { flex: 0 0 100%; width: auto; border-right: none; }
    .timesheet-grid thead .col-placement { display: none; }
    .timesheet-grid .col-total { min-width: 0; }
}
.placement-client { font-weight: 700; color: var(--text); }
.placement-name { color: var(--text-muted); font-size: 12px; }
.timesheet-grid .col-day { min-width: 0; }
.day-name { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.day-number { display: block; font-size: 14px; color: var(--text); }
.timesheet-grid .weekend { background: #f3f4f8; }
.timesheet-grid .holiday { background: #fdf2f8; }
.timesheet-grid thead .holiday .day-number { color: #be185d; }
.timesheet-grid thead .today { box-shadow: inset 0 -3px 0 var(--msm-cyan); }
.timesheet-grid .col-total { width: 64px; font-weight: 800; background: #f8f9fc; }
.timesheet-grid tfoot td { font-weight: 700; background: #f8f9fc; }
.timesheet-grid tfoot .over { color: var(--danger); }

.hours-input {
    width: 40px; height: 32px; box-sizing: border-box; text-align: center;
    border: 1px solid transparent; border-radius: 8px; background: transparent;
    font: inherit; font-weight: 600; color: var(--text);
    -moz-appearance: textfield;
}
.hours-input::-webkit-outer-spin-button, .hours-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hours-input:hover:not(:disabled) { border-color: var(--border); background: #fff; }
.hours-input:focus { outline: none; border-color: var(--msm-violet); background: #fff; box-shadow: 0 0 0 3px rgba(107, 91, 149, .15); }
.hours-input:disabled { color: var(--text-muted); }

.timesheet-footer { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; padding: 16px; flex-wrap: wrap; }
.notes-field { flex: 1; min-width: 260px; }
.notes-field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.footer-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Timesheet: collaborator months ---------- */
.month-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.month-card { display: block; padding: 16px 18px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.month-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 23, 42, .1); }
.month-card.attention { border-color: #fecaca; }
.month-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.month-card-name { font-weight: 800; }
.month-card-hours { font-size: 30px; font-weight: 800; margin-top: 10px; }
.month-card-hours small { font-size: 14px; color: var(--text-muted); font-weight: 600; }
.month-card-clients { color: var(--text-muted); font-size: 13px; min-height: 18px; }
.month-card-note { margin-top: 8px; font-size: 12px; color: #b91c1c; }

/* ---------- Module pages: lists ---------- */
.page-back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; margin-bottom: 6px; }
.page-back:hover { color: var(--msm-violet); }
.kpi-icon { font-size: 14px; margin-right: 4px; color: var(--msm-violet); }
.kpi-hint { font-size: 12px; color: var(--text-muted); }
.kpi-value.danger { color: var(--danger); }
.kpi-value.info { color: var(--info); }

.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-tab {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
    font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.filter-tab:hover { color: var(--msm-violet); border-color: var(--msm-violet); }
.filter-tab.active { background: var(--msm-violet); border-color: var(--msm-violet); color: #fff; }
.filter-count { background: rgba(100, 116, 139, .14); border-radius: 999px; padding: 0 8px; font-size: 12px; }
.filter-tab.active .filter-count { background: rgba(255, 255, 255, .22); }

.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main a, .cell-main strong { font-weight: 700; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
.cell-main a:hover { color: var(--msm-violet); }
.cell-sub { display: block; font-size: 12px; color: var(--text-muted); }
.avatar-sm {
    width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--msm-gradient); color: #fff; font-weight: 800; font-size: 13px;
}

/* ---------- Module pages: forms & details ---------- */
.form-section { margin-bottom: 16px; }
.form-section-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.form-section-head h2 { margin: 0; font-size: 16px; font-weight: 800; flex: 1; }
.form-section-actions { display: flex; gap: 8px; }
.section-icon {
    width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: #ede9f6; color: var(--msm-violet); font-size: 16px;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; padding: 18px 20px 20px; }
.form-grid.single { grid-template-columns: minmax(0, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field > .form-field-control { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.wide, .detail-field.wide { grid-column: 1 / -1; }
.form-field > label { font-size: 13px; font-weight: 700; color: var(--text); }
.required { color: var(--danger); margin-left: 2px; }
.field-hint { color: var(--text-muted); font-size: 12px; }
.validation-message { color: var(--danger); font-size: 12px; font-weight: 600; }
.form-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.check-field { display: flex; align-items: center; gap: 8px; padding-top: 6px; }

.detail-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.detail-value { font-size: 15px; overflow-wrap: anywhere; }
.detail-empty { color: var(--text-muted); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.detail-hero { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 16px; }
.detail-hero .avatar-lg {
    width: 56px; height: 56px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--msm-gradient); color: #fff; font-weight: 800; font-size: 22px; flex-shrink: 0;
}
.detail-hero h2 { margin: 0; font-size: 20px; }
.detail-hero .detail-meta { color: var(--text-muted); font-size: 14px; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
/* Dialogs: the Width of each SfDialog is the measure for its content, the shared cap (--form-max-width) is the upper limit
   and the screen width the other; the wide detail dialogs (the forecast cards' "Vedi dettaglio") are also never taller than the screen */
.e-dialog { max-width: min(var(--form-max-width), calc(100vw - 24px)); }
.e-dialog.forecast-detail-dialog { max-height: calc(100vh - 32px); }

/* ---------- Dashboard (temporary) ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.quick-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; text-decoration: none; color: inherit; }
.quick-card .e-icons { font-size: 24px; color: var(--msm-violet); }
.quick-card small { color: var(--text-muted); }

/* Dashboard grid: 12 columns on large screens, one column on tablets and phones. Shared (not scoped) so Dashboard,
   DashboardMore and any other page (e.g. BusinessLinesPage) that lays out its widgets the same way can reuse it. */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.span-4, .span-5, .span-6, .span-7, .span-8, .span-12 { min-width: 0; }

@media (max-width: 1199px) {
    .span-4, .span-8 { grid-column: span 12; }
}

@media (max-width: 991px) {
    .span-5, .span-6, .span-7 { grid-column: span 12; }
}

/* A KpiCard wrapped in a link (ActivitySummaryCard, DashboardSummary): the whole card is clickable, with a hover lift and an
   optional StatusBadge pinned to its corner (e.g. "N scadute"). Shared so every dashboard card that links its KPI can reuse it. */
.dash-kpi-link {
    display: block;
    position: relative;
    min-width: 0;
    color: inherit;
    text-decoration: none;
    border-radius: var(--radius);
}

.dash-kpi-link .kpi-card {
    height: 100%;
    box-sizing: border-box;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}

.dash-kpi-link:hover .kpi-card,
.dash-kpi-link:focus-visible .kpi-card {
    transform: translateY(-2px);
    border-color: var(--msm-violet);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .1);
}

.dash-kpi-link:focus-visible {
    outline: 2px solid var(--msm-violet);
    outline-offset: 2px;
}

.dash-kpi-link .status-badge {
    position: absolute;
    top: 12px;
    right: 12px;
}

/* ---------- Public pages ---------- */
.public-hero {
    min-height: 100vh; box-sizing: border-box; padding: 40px 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px;
    background: var(--msm-gradient); color: #fff;
}
.public-hero h1 { font-family: var(--font-title); font-size: clamp(36px, 6vw, 64px); margin: 0; }
.public-hero h1 span { color: #aaecf8; }
.public-hero p { max-width: 560px; font-size: 18px; opacity: .9; margin: 0 0 10px; }
.public-hero .muted { font-size: 13px; opacity: .7; }
.public-logo { width: 160px; background: #fff; border-radius: 16px; padding: 10px; }
.public-btn {
    display: inline-flex; align-items: center; padding: 12px 26px; border-radius: 999px;
    background: #fff; color: var(--msm-violet); font-weight: 700; text-decoration: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.public-btn:hover, .public-btn:focus-visible { background: #f1eefa; outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Blazor error UI ---------- */
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 8px; }

/* Filter / period bar above a list: the filters on one row (label + control), wrapping on narrow screens.
   Pages size their controls with CssClass (e.g. .filter-date, .period-year) in their own .razor.css. */
.period-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 16px;
}

.period-bar > label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Syncfusion writes width:100% inline on its inputs: in a filter bar each control is capped (pages narrow it with
   max-width on their CssClass) so the filters stay on one row */
.period-bar > .e-input-group,
.period-bar > .e-control-wrapper {
    flex: 0 1 auto;
    max-width: 260px;
}

/* ---------- Responsive (tablets, phones: iPhone 17 Pro = 402 x 874 CSS px) ---------- */
/* iOS: no font inflation in landscape; the shell fills the visible viewport (dvh: without the Safari toolbars) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.app-shell { min-height: 100dvh; }
.app-sidebar { height: 100dvh; }
/* viewport-fit=cover (App.razor): header, menu and content keep clear of the notch / Dynamic Island and the home indicator */
.app-header {
    padding-top: env(safe-area-inset-top);
    padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right));
}
.app-sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); box-sizing: border-box; }
.app-content { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
#blazor-error-ui { padding-bottom: calc(.7rem + env(safe-area-inset-bottom)); }

@media (max-width: 991px) {
    /* Off-canvas sidebar on tablets/phones: hidden (and out of the tab order) until opened, no shadow over the page */
    .app-shell, .app-shell.collapsed { --sidebar-w: min(280px, 86vw); }
    .app-shell.collapsed .nav-text { display: inline; }
    .app-sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%); visibility: hidden;
        transition: transform .2s ease, visibility 0s linear .2s;
        padding-left: env(safe-area-inset-left);
    }
    .app-shell.mobile-open .app-sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .app-shell.mobile-open .app-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 25; }
    .app-sidebar .nav-item, .app-sidebar .e-btn.nav-group { min-height: 44px; box-sizing: border-box; }
    .toggle-desktop { display: none !important; }
    .toggle-mobile { display: inline-flex !important; }
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-content {
        padding: 16px max(16px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }
    .app-header-title { display: none; }
    .app-header { gap: 4px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
    .header-icon-btn.e-btn { width: 44px; height: 44px; min-width: 44px; }
    /* Header: the avatar alone opens the user menu (its first item is the name); the language stays a compact "IT" */
    .user-avatar { display: none; }
    .header-user.e-btn, .header-user.e-btn:hover, .header-user.e-btn:focus, .header-user.e-btn:active {
        display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
        width: 44px; height: 44px; min-width: 44px; padding: 0; border-radius: 50%;
        font-size: 0; line-height: 0; background: transparent; box-shadow: none;
    }
    .header-user.e-btn::before {
        content: attr(data-initials); display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: 50%; background: var(--msm-gradient); color: #fff;
        font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: 0;
    }
    .header-user.e-btn:focus-visible::before { outline: 2px solid var(--msm-violet); outline-offset: 2px; }
    .header-user.e-btn .e-caret { display: none; }
    .header-lang.e-btn { min-width: 44px; height: 44px; padding: 0 8px; box-shadow: none; }
    .supplier-picker { width: 100%; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .detail-layout { grid-template-columns: minmax(0, 1fr); }
    /* Filter bars: label + control pairs, two pairs per row (phones: one, below) */
    .period-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px 12px; }
    .period-bar > .e-input-group, .period-bar > .e-control-wrapper { width: 100% !important; max-width: none !important; min-width: 0; }
    .period-bar > :not(label):not(.e-input-group):not(.e-control-wrapper) { grid-column: 1 / -1; }
    /* Dialogs never wider or taller than the screen */
    .e-dialog { max-width: calc(100vw - 16px) !important; max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; }
}

/* Grids with the rows rendered vertically (phones, GridUi): a column marked GridUi.WideCell (a list of issues with their
   actions) takes the whole width of the row card, its name above the content instead of next to it */
.e-grid.e-row-responsive .e-gridcontent td.e-rowcell.cell-wide[data-cell] { padding-left: 12px; padding-top: 31px; }
.e-grid.e-row-responsive .e-gridcontent td.e-rowcell.cell-wide[data-cell]::before { left: 12px; top: 7px; width: calc(100% - 24px); }
/* A badge in a row card never shrinks next to a text or a button (a column of letters): it wraps between its words only
   when it is wider than the cell */
.e-grid.e-row-responsive .e-gridcontent td.e-rowcell .status-badge { flex-shrink: 0; overflow-wrap: normal; max-width: 100%; box-sizing: border-box; }

/* Touch screens: every control at least 44 px, inputs at 16 px (iOS zooms the page on a smaller input) */
@media (max-width: 991px) and (pointer: coarse), (max-width: 600px) {
    .e-input-group input.e-input, .e-input-group.e-control-wrapper input.e-input, .e-float-input input,
    .e-input-group textarea.e-input, .e-input-group.e-control-wrapper textarea.e-input, input.e-input, textarea.e-input,
    .e-multiselect .e-dropdownbase input, .e-grid .e-toolbar .e-search-wrapper input, .hours-input { font-size: 16px !important; }
    .app-main .e-input-group:not(.e-multi-line-input) input.e-input,
    .app-main .e-input-group.e-control-wrapper:not(.e-multi-line-input) input.e-input { min-height: 36px; }
    .app-main .e-btn:not(.e-link):not(.link-btn):not(.kpi-detail-btn):not(.e-caret),
    .e-dialog .e-footer-content .e-btn { min-height: 44px; }
    .e-btn.icon-btn, .e-btn.icon-btn:hover, .e-btn.icon-btn:focus, .e-btn.icon-btn:active, .e-btn.icon-btn:disabled,
    .icon-btn { width: 44px; height: 44px; min-width: 44px; }
    .e-btn.filter-tab, .e-btn.filter-tab:focus, .e-btn.filter-tab:active { min-height: 44px; padding: 8px 14px; }
    .e-btn.link-btn { min-height: 32px; display: inline-flex; align-items: center; }
    .e-checkbox-wrapper, .e-radio-wrapper, .e-switch-wrapper { min-height: 32px; }
    .e-dropdown-popup ul .e-item, .e-popup .e-list-item { min-height: 44px; display: flex; align-items: center; }
    .page-back { min-height: 44px; }
    .app-main a.e-btn { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
    .app-main .e-btn.e-icon-btn:not(.kpi-detail-btn) { min-width: 44px; }
    .e-toolbar .e-toolbar-item .e-tbar-btn.e-btn { min-width: 44px !important; min-height: 44px; }
    a.icon-btn, .icon-btn { min-width: 44px !important; min-height: 44px !important; }
    .e-grid .e-rowcell a[href], .detail-value a[href], .cell-main a[href], .dash-card-body li a[href], .dash-card-body .dash-link,
    a.coverage-link, a.coverage-all { display: inline-flex; align-items: center; min-height: 44px; }
    /* The coverage issues' pill actions (contract and placement details) */
    a.coverage-action, .e-btn.coverage-action { min-height: 44px; box-sizing: border-box; }
    .e-pager .e-numericitem, .e-pager .e-icons.e-pager-default, .e-pager .e-pagercontainer .e-icons { min-width: 44px; min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; }
}

/* Phones */
@media (max-width: 600px) {
    /* A long unbroken text (an IBAN, an e-mail, a file name, notes with a URL) wraps instead of widening the page */
    .app-content {
        padding: 12px max(12px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
        overflow-wrap: break-word;
    }
    /* Title on its own row, then the actions (entity switch first) left-aligned and wrapping */
    .page-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
    .page-header h1 { font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
    .page-subtitle { font-size: 14px; }
    .page-actions { justify-content: flex-start; margin-left: 0; width: 100%; gap: 8px; }
    .page-actions > .e-btn, .page-actions > a { white-space: normal; max-width: 100%; }
    /* Entity switch: the label on its row, the three choices sharing the full width */
    .entity-switch { display: flex; width: 100%; gap: 6px; }
    .entity-switch-label { flex: 1 1 100%; }
    .entity-switch .e-btn-group { display: flex; flex: 1 1 0; min-width: 0; }
    .entity-switch .e-btn-group .e-btn.entity-option, .entity-switch .e-btn-group .e-btn.entity-option:focus,
    .entity-switch .e-btn-group .e-btn.entity-option:active {
        flex: 1 1 0; min-width: 0; min-height: 44px; justify-content: center; padding: 6px 6px; gap: 5px;
        font-size: 12.5px; line-height: 1.2; white-space: normal; text-align: center;
    }
    /* KPI cards: two per row, the figures shrink with the screen and never get cut */
    .kpi-row { gap: 10px; }
    .kpi-card { padding: 12px; gap: 4px; }
    .kpi-card.kpi-clickable { padding-right: 36px; }
    .kpi-detail { top: 8px; right: 6px; }
    .kpi-label { font-size: 12px; }
    .kpi-value { font-size: clamp(17px, 5vw, 26px); line-height: 1.2; overflow-wrap: anywhere; }
    .kpi-value.kpi-text { font-size: 15px; line-height: 26px; }
    .kpi-hint { font-size: 11px; overflow-wrap: anywhere; }
    .entity-kpis.compare { gap: 10px; }
    .entity-kpis.compare .entity-kpi-block { padding: 8px 6px; }
    .entity-kpis.compare .kpi-row { gap: 8px; }
    /* Filter bars: one label + control per row, the control as wide as the card */
    .period-bar { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 10px; padding: 12px; }
    .period-bar > .e-input-group, .period-bar > .e-control-wrapper { width: 100% !important; max-width: none !important; min-width: 0; }
    .period-bar > :not(label):not(.e-input-group):not(.e-control-wrapper) { grid-column: 1 / -1; }
    .period-bar > label + .e-input-group, .period-bar > label + .e-control-wrapper { grid-column: 2; }
    .month-toolbar { padding: 10px 12px; }
    .month-label { min-width: 0; font-size: 16px; }
    /* Forms and details */
    .form-grid { padding: 14px 12px 16px; gap: 14px; }
    .form-section-head { padding: 12px; flex-wrap: wrap; }
    .form-section-actions { flex-wrap: wrap; }
    .form-footer { flex-wrap: wrap; }
    .detail-hero { padding: 14px 12px; gap: 12px; flex-wrap: wrap; }
    .detail-hero h2 { font-size: 18px; overflow-wrap: anywhere; }
    .notice { padding: 10px 12px; }
    .notice > span:not(.e-icons) { min-width: 0; overflow-wrap: anywhere; }
    .empty-state { padding: 36px 12px; }
    .busy-overlay { padding: 24px 8px; }
    .busy-overlay-box { max-width: 100%; padding: 12px 14px; }
    /* Grids with the rows rendered vertically (Syncfusion adaptive UI on phones, GridUi.Adaptive): every value left-aligned
       next to its column name, compact cells, one card per row */
    .e-grid.e-row-responsive .e-gridcontent td.e-rowcell[data-cell] {
        padding-top: 7px; padding-bottom: 7px; padding-left: 40%; text-align: left !important; overflow-wrap: anywhere;
        white-space: normal; text-overflow: clip;
    }
    .e-grid.e-row-responsive .e-gridcontent td.e-rowcell[data-cell]::before {
        top: 7px; left: 12px; width: calc(40% - 20px); color: var(--text-muted); font-size: 12px; font-weight: 600; text-align: left;
    }
    .e-grid.e-row-responsive .e-gridcontent tr.e-row { border-bottom: 6px solid var(--bg); }
    .e-grid.e-row-responsive .e-gridcontent .row-actions { justify-content: flex-start; flex-wrap: wrap; }
    /* Grid toolbars: icons only, the search takes the rest of the row */
    .e-grid .e-toolbar .e-toolbar-item .e-tbar-btn-text { display: none; }
    .e-grid .e-toolbar .e-toolbar-item.e-search-wrapper, .e-grid .e-toolbar .e-toolbar-item .e-search-wrapper { max-width: 100%; }
    .e-grid .e-toolbar .e-search-wrapper .e-input-group { width: min(220px, calc(100vw - 150px)) !important; }
    /* Dialogs: almost the full screen */
    .e-dialog:not(.e-dlg-modal-small) { width: calc(100vw - 16px) !important; }
    .e-dialog .e-dlg-header-content, .e-dialog .e-dlg-content, .e-dialog .e-footer-content { padding-left: 14px; padding-right: 14px; }
    .e-dialog .e-footer-content { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
    .e-dialog .e-footer-content .e-btn { margin-left: 0 !important; }
    /* Toasts inside the screen */
    .e-toast-container.e-toast-top-right { right: max(8px, env(safe-area-inset-right)) !important; top: calc(8px + env(safe-area-inset-top)) !important; left: 8px !important; }
    .e-toast-container .e-toast { width: auto !important; max-width: 100%; }
}

/* A numeric box that refused an edit because Syncfusion has not initialised it yet (numeric-input.js): dimmed, busy cursor, same size */
.e-numeric.e-input-group input.e-numerictextbox[aria-busy="true"],
input.e-numerictextbox[aria-busy="true"] {
    opacity: .55;
    cursor: progress;
}
