
:root {
    --color-primary: #2f6f9e;
    --color-primary-dark: #1d4a6d;
    --color-primary-light: #eaf2f7;
    --color-navy: #17283b;

    --color-bg: #f6f7f9;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;

    --color-text: #111827;
    --color-text-muted: #6b7280;

    --color-success: #15803d;
    --color-success-bg: #e9f7ee;
    --color-success-border: #bfe6cc;

    --color-danger: #b91c1c;
    --color-danger-bg: #fdecec;
    --color-danger-border: #f3c5c5;

    --color-warning: #92650a;
    --color-warning-bg: #fdf3dc;
    --color-warning-border: #f3dfa8;

    --sidebar-width: 260px;
    --topbar-height: 68px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    --card-border: #dfe4ea;
    --card-radius: 16px;
    --card-shadow: 0 4px 18px rgba(23, 40, 59, 0.06);
    --control-height: 36px;
    --control-font-size: 0.85rem;
    --control-padding-y: 0.375rem;
    --control-padding-x: 0.75rem;
    --badge-height: 28px;
    --badge-font-size: 0.78rem;
    --badge-padding-x: 0.75rem;
    --button-height: var(--control-height);
    --table-row-height: 56px;
    --dashboard-tile-min-height: 120px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-primary);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
    box-sizing: border-box;
}

.sidebar-brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex-shrink: 0;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.sidebar-brand-mark svg {
    width: 18px;
    height: 18px;
}

.sidebar-brand-mark img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    object-fit: contain;
    object-position: left center;
}

.app-sidebar .sidebar-brand.sidebar-brand-logo {
    padding-top: 0.5rem;
    padding-right: 1.25rem;
    padding-bottom: 0.5rem;
    padding-left: 1rem;
}

.sidebar-brand-logo .sidebar-brand-mark {
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.sidebar-brand-logo .sidebar-brand-mark img {
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: contain;
}

.app-sidebar-utente .sidebar-brand-logo .sidebar-brand-mark {
    justify-content: flex-start;
}

.app-sidebar-utente .sidebar-brand-logo .sidebar-brand-mark img {
    max-width: 180px;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.sidebar-brand-text .sidebar-brand-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
}

.sidebar-brand-text .sidebar-brand-subtitle {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.app-sidebar nav {
    flex-grow: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-sidebar .nav-section-label {
    padding: 0.5rem 0.6rem 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
}

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

.app-sidebar .nav-link-custom svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}

.app-sidebar .nav-link-custom:hover {
    background-color: var(--color-bg);
    color: var(--color-text);
}

.app-sidebar .nav-link-custom.active {
    background-color: var(--color-primary-light);
    color: var(--color-primary);
}

.app-sidebar .nav-link-custom.active svg {
    opacity: 1;
}

.app-sidebar .nav-divider {
    margin: 0.75rem 0.6rem;
    border-top: 1px solid var(--color-border);
}

.app-content {
    flex-grow: 1;
    min-width: 0;
}

.app-content-inner {
    padding: 2rem;
}

.app-sidebar-toggle,
.app-sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    .app-layout {
        display: block;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1040;
        width: min(280px, 85vw);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow-md);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .app-sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        margin-right: auto;
        padding: 0;
        border: 0;
        border-radius: var(--radius-sm);
        background: transparent;
        color: var(--color-text-muted);
    }

    .app-sidebar-toggle:hover {
        background: var(--color-primary-light);
        color: var(--color-primary);
    }

    .app-sidebar-toggle svg {
        width: 22px;
        height: 22px;
        fill: none;
        stroke: currentColor;
        stroke-width: 2;
        stroke-linecap: round;
    }

    .app-sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1030;
        border: 0;
        background: rgba(17, 24, 39, 0.42);
    }

    .app-sidebar-backdrop.is-visible {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .app-content-inner {
        padding: 1.25rem;
    }
}

/* ---------- Topbar ---------- */

.app-topbar {
    height: var(--topbar-height);
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 2.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-topbar-icon-button,
.app-topbar-user-trigger {
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
}

.app-topbar-icon-button {
    position: relative;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.app-topbar-icon-button:hover,
.app-topbar-user-trigger:hover,
.app-topbar-user-trigger[aria-expanded="true"] {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.app-topbar-icon-button svg,
.app-topbar-user-chevron,
.app-topbar-user-menu .dropdown-item svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-topbar-icon-button svg {
    width: 20px;
    height: 20px;
}

.app-topbar-analysis-badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border: 2px solid var(--color-surface);
    border-radius: 999px;
    background: var(--color-primary);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.app-topbar-user-trigger {
    padding: 0.25rem 0.4rem;
}

.app-topbar-user-chevron {
    width: 16px;
    height: 16px;
}

.app-topbar-user-menu {
    min-width: 190px;
    margin-top: 0.45rem;
    padding: 0.4rem;
    border-color: var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
}

.app-topbar-user-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border-radius: 6px;
    font-size: 0.88rem;
}

.app-topbar-user-menu .dropdown-item svg {
    width: 18px;
    height: 18px;
}

.app-topbar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.app-topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    text-align: right;
}

.app-topbar-user-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--color-text);
}

.app-topbar-user-role {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

.app-topbar-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.app-topbar-profile-button {
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.app-topbar-profile-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-topbar-profile-button:hover {
    background: var(--color-primary);
    color: #ffffff;
}

@media (max-width: 768px) {
    .app-topbar {
        padding: 0 2rem;
    }

    .app-topbar-user-info {
        display: none;
    }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h3,
.page-header h1 {
    margin-bottom: 0.15rem;
    font-weight: 700;
    font-size: 1.4rem;
}

.page-header .page-subtitle {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.dashboard-analysis-filter {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.dashboard-analysis-filter-icon {
    display: grid;
    place-items: center;
    width: var(--control-height);
    height: var(--control-height);
    flex: 0 0 var(--control-height);
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.dashboard-analysis-filter-icon svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* ============================================================
   CARDS
   ============================================================ */

.card,
.dashboard-stat-card,
.metric-tile,
.chip-nav-card,
.login-card-body,
.output-card {
    background: var(--color-surface);
    border: 1px solid var(--card-border);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
}

.card > .card-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--card-border);
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    padding: 1.25rem;
}

.card > .card-footer {
    background: #f7f9fb;
    border-top: 1px solid var(--card-border);
    border-radius: 0 0 var(--card-radius) var(--card-radius);
    padding: 1.25rem;
}

.card-header h5, .output-table-toolbar h5 { margin: 0 0 0.3rem; font-size: 1rem; font-weight: 600; }
.card-header p { margin: 0; color: var(--color-text-muted); font-size: 0.85rem; }
.card > .page-card-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}
.page-card-header h3 {
    margin-bottom: 0.25rem;
    font-size: 1.4rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.page-card-header .page-subtitle, .page-card-header p { font-size: 0.9rem; }
.page-card-body { padding: 1.5rem; min-width: 0; }
.settings-accordion { --bs-accordion-border-color: var(--color-border); --bs-accordion-btn-focus-box-shadow: none; --bs-accordion-active-bg: #f7f9fb; --bs-accordion-active-color: var(--color-text); }
.settings-accordion .accordion-button { align-items: center; gap: 1rem; padding: 1.15rem 1rem; color: var(--color-text); transition: background-color 0.15s ease; }
.settings-accordion .accordion-button:hover { background: #f7f9fb; }
.settings-accordion .accordion-button:not(.collapsed) { box-shadow: none; }
.settings-accordion .accordion-button:not(.collapsed) .settings-accordion-title { color: var(--color-primary); }
.settings-accordion .accordion-button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.settings-accordion-heading { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; min-width: 0; }
.settings-accordion-title { font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.settings-accordion-description, .settings-accordion-date { color: var(--color-text-muted); font-size: 0.85rem; line-height: 1.5; font-weight: 400; }
.settings-accordion-date { white-space: nowrap; }
.settings-accordion .accordion-button::after { margin-left: 0; flex-shrink: 0; }
.settings-accordion .accordion-body { padding: 0.5rem 1rem 1.25rem; background: #f7f9fb; }
.settings-accordion .soglia-valore { line-height: 1.65; resize: vertical; }
.alert-mapping-filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 767px) { .alert-mapping-filters { grid-template-columns: 1fr; } }
@media (max-width: 767px) {
    .settings-accordion .accordion-button { flex-wrap: wrap; gap: 0.75rem; }
    .settings-accordion-heading { flex-basis: calc(100% - 2rem); }
}
@media (max-width: 767px) {
    .card > .page-card-header, .page-card-body { padding: 1rem; }
}
.card.p-4 > .section-title:first-child,
.card.p-4 > h5:first-child,
.card.p-4 > .d-flex:first-child:has(h5),
.card.dashboard-panel > .dashboard-panel-header:first-child {
    margin: -1.5rem -1.5rem 1.25rem;
    padding: 1.25rem;
    border-bottom: 1px solid var(--card-border);
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    background: var(--color-surface);
}
.card.dashboard-panel { padding: 1.5rem; }

.card.shadow-sm {
    box-shadow: var(--card-shadow) !important;
}

.badge.bg-danger {
    background-color: #e35d6a !important;
}

/* ============================================================
   BOTTONI
   ============================================================ */

/* ============================================================
   DASHBOARD
   ============================================================ */

.dashboard-stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.dashboard-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.dashboard-stat-card::after,
.metric-tile::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--stat-accent, var(--color-primary)); }
.dashboard-stat-card-blue, .metric-tile-blue { --stat-accent: #2563eb; }
.dashboard-stat-card-violet, .metric-tile-violet { --stat-accent: #7c3aed; }
.dashboard-stat-card-amber, .metric-tile-amber { --stat-accent: #d79a1e; }
.dashboard-stat-card-green, .metric-tile-green { --stat-accent: var(--color-success); }
.dashboard-stat-card-red, .metric-tile-red { --stat-accent: var(--color-danger); }
.dashboard-stat-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }

.dashboard-stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 12px;
}

.dashboard-stat-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dashboard-stat-icon-blue { background: #e9f3ff; color: #2563eb; }
.dashboard-stat-icon-violet { background: #f1edff; color: #7c3aed; }
.dashboard-stat-icon-amber { background: var(--color-warning-bg); color: var(--color-warning); }
.dashboard-stat-icon-green { background: var(--color-success-bg); color: var(--color-success); }
.dashboard-stat-icon-cyan { background: #e6f8fb; color: #087f8c; }
.dashboard-stat-icon-rose { background: #fff0f5; color: #d6336c; }

.dashboard-stat-label { color: var(--color-text-muted); font-size: 0.84rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.035em; }
.dashboard-stat-value { color: var(--color-text); font-size: 2rem; line-height: 1.15; font-weight: 750; }
.dashboard-stat-description { margin-top: 0.3rem; color: var(--color-text-muted); font-size: 0.81rem; }

.dashboard-panel { padding: 1.4rem; }

.dashboard-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-panel-header h5, .dashboard-panel-header h2 { margin: 0 0 0.2rem; font-size: 1.06rem; font-weight: 700; }
.dashboard-panel-header p { margin: 0; color: var(--color-text-muted); font-size: 0.86rem; }
.dashboard-percentage { color: var(--color-primary); font-size: 1.6rem; font-weight: 700; }

.dashboard-progress { height: 10px; overflow: hidden; background: var(--color-bg); border-radius: 999px; }
.dashboard-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--color-primary), #55a2d5); border-radius: inherit; }

.dashboard-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; color: var(--color-text-muted); font-size: 0.8rem; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 0.4rem; border-radius: 50%; }
.legend-dot-success { background: var(--color-success); }
.legend-dot-warning { background: #d79a1e; }

.dashboard-panel-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
    margin-top: auto;
    padding-top: 1.5rem;
    font-size: 0.82rem;
    font-weight: 650;
    text-decoration: none;
    transition: color 0.15s ease, gap 0.15s ease;
}
.dashboard-panel-link:hover { gap: 0.65rem; color: var(--color-primary-dark); }
.dashboard-panel-header .dashboard-panel-link { padding-top: 0; }
.dashboard-empty { padding: 2rem 0; color: var(--color-text-muted); text-align: center; font-size: 0.85rem; }

.dashboard-feature-card { display: flex; flex-direction: row; gap: 1rem; align-items: flex-start; }
.dashboard-feature-icon { width: 48px; height: 48px; display: grid; place-items: center; flex-shrink: 0; border-radius: 13px; }
.dashboard-feature-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dashboard-feature-content { flex: 1; min-width: 0; }
.dashboard-feature-eyebrow { display: block; margin-bottom: 0.3rem; color: var(--color-text-muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.dashboard-feature-content strong { display: block; margin-bottom: 0.35rem; font-size: 1.1rem; }
.dashboard-feature-content p { margin-bottom: 1rem; color: var(--color-text-muted); font-size: 0.82rem; }
.dashboard-quick-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.dashboard-page { max-width: 1600px; }
.dashboard-welcome { display: flex; min-height: 190px; align-items: center; justify-content: space-between; gap: 2rem; margin-bottom: 1.25rem; padding: 2.25rem 1.75rem; border: 1px solid #d6e3ec; border-radius: var(--card-radius); background: linear-gradient(120deg, #f9fcfe 0%, #edf5fa 100%); }
.dashboard-welcome h1 { margin: 0.2rem 0 0.35rem; color: var(--color-navy); font-size: clamp(1.45rem, 2vw, 2rem); font-weight: 750; }
.dashboard-welcome p { margin: 0; color: var(--color-text-muted); font-size: 0.94rem; }
.dashboard-eyebrow { color: var(--color-primary); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }

.dashboard-chart { position: relative; display: flex; align-items: flex-end; gap: clamp(0.75rem, 3vw, 2.25rem); min-height: 270px; padding: 0.75rem 1rem 0; border-bottom: 1px solid #cfd7df; background: repeating-linear-gradient(to bottom, transparent 0, transparent calc(25% - 1px), #e9edf1 calc(25% - 1px), #e9edf1 25%); }
.dashboard-chart-column { position: relative; z-index: 1; display: flex; flex: 1; min-width: 28px; height: 250px; flex-direction: column; align-items: center; }
.dashboard-chart-value { height: 22px; margin-bottom: 0.35rem; color: #526174; font-size: 0.76rem; font-weight: 700; }
.dashboard-chart-track { display: flex; width: min(52px, 76%); flex: 1; align-items: flex-end; }
.dashboard-chart-track span { display: block; width: 100%; min-height: 4px; border-radius: 3px 3px 0 0; background: var(--color-primary); transition: background-color 0.15s ease; }
.dashboard-chart-column:hover .dashboard-chart-track span { background: var(--color-primary-dark); }
.dashboard-chart-label { padding-top: 0.65rem; color: #526174; font-size: 0.78rem; font-weight: 600; }

.dashboard-donut-row { display: flex; align-items: center; justify-content: space-around; gap: 1.5rem; min-height: 250px; }
.dashboard-donut { display: grid; width: 145px; height: 145px; flex: 0 0 145px; place-items: center; border-radius: 50%; background: conic-gradient(var(--color-success) calc(var(--dashboard-progress) * 1%), #edf0f3 0); }
.dashboard-donut::before { content: ""; width: 105px; height: 105px; border-radius: 50%; background: var(--color-surface); grid-area: 1 / 1; }
.dashboard-donut > div { z-index: 1; display: flex; grid-area: 1 / 1; flex-direction: column; align-items: center; }
.dashboard-donut strong { color: var(--color-navy); font-size: 1.55rem; }
.dashboard-donut span { color: var(--color-text-muted); font-size: 0.67rem; }
.dashboard-status-breakdown { min-width: 145px; }
.dashboard-status-breakdown > div { display: flex; justify-content: space-between; gap: 1.5rem; padding: 0.65rem 0; border-bottom: 1px solid var(--color-border); font-size: 0.84rem; }
.dashboard-status-breakdown > div:last-child { border-bottom: 0; }
.dashboard-status-breakdown > div:nth-child(2) { border-bottom: 0; }
.dashboard-status-breakdown span { color: var(--color-text-muted); }
.dashboard-status-breakdown .dashboard-status-total { margin-top: 0.2rem; border-top: 1px solid var(--color-border); border-bottom: 0; color: var(--color-navy); font-weight: 700; }
.dashboard-status-breakdown .dashboard-status-total span { color: var(--color-navy); }


.dashboard-users-table { margin: 0; overflow: hidden; }
.dashboard-users-table-head, .dashboard-users-table-row { display: grid; grid-template-columns: minmax(125px, 0.75fr) minmax(180px, 1.1fr) minmax(240px, 1.55fr) minmax(100px, 0.65fr) minmax(130px, 0.8fr); align-items: center; gap: 1rem; }
.dashboard-users-table-head { min-height: 46px; padding: 0 1rem; border-bottom: 1px solid var(--color-border); background: #f6f8fa; color: #526174; font-size: 0.72rem; font-weight: 400; letter-spacing: 0.04em; text-transform: uppercase; }
.dashboard-users-table-head span { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.dashboard-users-table-head i { color: #c9d0d7; font-size: 0.65rem; font-style: normal; }
.dashboard-users-table-row { min-height: 56px; padding: 0.55rem 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-text); font-size: 0.86rem; text-decoration: none; transition: background 0.15s ease; }
.dashboard-users-table-row:last-child { border-bottom: 0; }
.dashboard-users-table-row:hover { background: #f7fafc; }
.dashboard-users-table-row:hover .dashboard-users-name { color: var(--color-primary); }
.dashboard-users-name, .dashboard-users-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-users-id { font-variant-numeric: tabular-nums; }
.dashboard-users-email, .dashboard-users-date { color: var(--color-text-muted); font-size: 0.81rem; }
.dashboard-users-table-row em { color: var(--color-text); font-size: 0.81rem; font-style: normal; font-weight: 400; text-transform: uppercase; }

@media (max-width: 767px) {
    .dashboard-welcome { min-height: 0; align-items: flex-start; flex-direction: column; padding: 1.5rem 1.25rem; }
    .dashboard-donut-row { flex-wrap: wrap; }
    .dashboard-users-table { overflow-x: auto; }
    .dashboard-users-table-head, .dashboard-users-table-row { min-width: 850px; }
    .dashboard-chart { gap: 0.4rem; }
}

.output-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.output-card { position: relative; display: flex; flex-direction: column; min-height: 120px; padding: 1rem; color: var(--color-text); text-decoration: none; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.output-card:hover { border-color: var(--color-primary); box-shadow: var(--card-shadow); color: var(--color-text); transform: translateY(-2px); }
.output-card strong { padding-right: 2rem; font-size: 0.88rem; }
.output-card small { margin-top: 0.4rem; color: var(--color-text-muted); font-size: 0.76rem; line-height: 1.45; }
.output-card-icon { position: absolute; top: 0.85rem; right: 0.9rem; color: var(--color-primary); font-weight: 700; }
.csv-status-table td:first-child { min-width: 210px; }
.csv-status-table td:nth-child(3) { min-width: 260px; }

.output-dataset-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.output-dataset-link { padding: 0.65rem 1rem; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-muted); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.output-dataset-link:hover, .output-dataset-link.active { color: var(--color-primary); border-color: var(--color-primary); background: #eef5fa; }
.output-table-toolbar, .output-table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.25rem; }
.output-table-toolbar { border-bottom: 1px solid var(--color-border); }
.output-table-footer { border-top: 1px solid var(--color-border); background: var(--color-surface); margin-top: 0.75rem; padding: 1rem 0 0; font-size: 0.85rem; }
.output-table-toolbar .form-select { width: auto; }
.output-details-cell { white-space: nowrap; }
.output-record-modal .modal-header { border-bottom: 1px solid var(--color-border); padding: 1.5rem; }
.output-record-modal .modal-body { padding: 1.5rem; background: var(--color-surface); }
.output-record-modal .modal-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
.output-record-modal .modal-header p { font-size: 0.9rem; }
.output-record-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.output-record-fields dt { color: var(--color-text-muted); font-size: var(--control-font-size); font-weight: 400; }
.output-record-fields dd { margin: 0.4rem 0 0; }
.output-record-fields .form-control[readonly] { background: #f7f9fb; font-weight: 400; }
@media (max-width: 767px) {
    .output-table-toolbar { padding: 1rem; }
    .output-table-toolbar form { flex-wrap: wrap; }
    .output-table-footer nav { flex-wrap: wrap; }
    .output-dataset-link { flex: 1 1 auto; text-align: center; }
}
@media (max-width: 420px) {
    .output-record-fields { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .output-grid { grid-template-columns: 1fr; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: var(--button-height);
    box-sizing: border-box;
    white-space: nowrap;
    border-radius: 10px;
    font-weight: 600;
    font-size: var(--control-font-size);
    line-height: 1.5;
    padding: 0 0.9rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--color-primary);
    --bs-btn-border-color: var(--color-primary);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--color-primary-dark);
    --bs-btn-hover-border-color: var(--color-primary-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--color-primary-dark);
    --bs-btn-active-border-color: var(--color-primary-dark);
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: var(--color-primary);
    --bs-btn-disabled-border-color: var(--color-primary);
    background: linear-gradient(135deg, #347eae, var(--color-primary));
    border-color: var(--color-primary);
    box-shadow: 0 3px 8px rgba(47, 111, 158, 0.2);
    color: #ffffff;
}

.btn-brand:hover,
.btn-brand:focus {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    border-color: var(--color-primary-dark);
    box-shadow: 0 6px 14px rgba(29, 74, 109, 0.22);
    color: #ffffff;
    transform: translateY(-1px);
}

.btn:active { box-shadow: none !important; transform: translateY(0) !important; }
.btn:focus-visible { outline: 3px solid rgba(47, 111, 158, 0.2); outline-offset: 2px; }

.login-card button[name="loginButton"] { margin-bottom: 15px; }

.btn-secondary {
    --bs-btn-color: #526174;
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--card-border);
    --bs-btn-hover-color: var(--color-text);
    --bs-btn-hover-bg: #f3f5f7;
    --bs-btn-hover-border-color: #b8c3cf;
    --bs-btn-active-color: var(--color-text);
    --bs-btn-active-bg: #e9edf1;
    --bs-btn-active-border-color: #b8c3cf;
    --bs-btn-disabled-color: #97a2b0;
    --bs-btn-disabled-bg: #f7f9fb;
    --bs-btn-disabled-border-color: var(--card-border);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
/* ============================================================
   FORM
   ============================================================ */

.form-control,
.form-select,
div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border-radius: var(--radius-sm);
    border-color: var(--color-border);
    font-size: var(--control-font-size);
    line-height: 1.5;
    padding: var(--control-padding-y) var(--control-padding-x);
    min-height: var(--control-height);
}

input.form-control, select.form-control, .form-select { height: var(--control-height); }
.form-select { padding-right: 2.25rem; }
.form-control::file-selector-button { padding: var(--control-padding-y) var(--control-padding-x); margin: calc(-1 * var(--control-padding-y)) calc(-1 * var(--control-padding-x)); margin-inline-end: var(--control-padding-x); }
.form-check-input { width: 18px; height: 18px; }

.form-control:focus,
.form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 0.2rem var(--color-primary-light);
}

.form-control.is-invalid {
    border-color: var(--color-danger);
}

label.fw-bold {
    font-size: 0.85rem;
    font-weight: 600 !important;
    color: var(--color-text);
}

/* ============================================================
   TABELLE / DATATABLES
   ============================================================ */

.table {
    --bs-table-color: var(--color-text);
    --bs-table-bg: var(--color-surface);
    --bs-table-border-color: #edf0f3;
    --bs-table-hover-bg: #f3f7fa;
    color: var(--color-text);
    font-size: 0.9rem;
    width: 100% !important;
    margin: 0;
}

.table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    color: #526174;
    background: #f7f9fb;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
    padding: 0.9rem 1rem;
    white-space: nowrap;
}

.table tbody td,
.table tbody th {
    box-sizing: border-box;
    font-weight: 400;
    padding: 0.55rem 1rem;
    border-color: #edf0f3;
    vertical-align: middle;
}

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

.table tbody tr {
    height: var(--table-row-height);
    transition: background-color 0.15s ease;
}

.table > tbody > tr:hover > * {
    --bs-table-bg-state: #f3f7fa;
}

.table-card {
    overflow: hidden;
}

.table-card .table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table-card .dataTables_wrapper {
    width: 100%;
    padding: 1.15rem 1.25rem 1rem;
}

.table-card > .table-responsive .table thead th:first-child,
.table-card > .table-responsive .table tbody td:first-child {
    padding-left: 1.25rem;
}

.table-card > .table-responsive .table thead th:last-child,
.table-card > .table-responsive .table tbody td:last-child {
    padding-right: 1.25rem;
}

.table-card > .dashboard-empty {
    padding: 2.5rem 1.25rem;
}

.table-card > .text-muted {
    padding: 0 1.25rem 1rem;
}

div.dataTables_wrapper div.dataTables_filter input,
div.dataTables_wrapper div.dataTables_length select {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background-color: var(--color-surface);
}

div.dataTables_wrapper div.dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0;
    white-space: nowrap;
}

div.dataTables_wrapper div.dataTables_length select {
    width: auto;
    min-width: 76px;
    height: var(--control-height);
    margin: 0;
    padding: var(--control-padding-y) 2.25rem var(--control-padding-y) var(--control-padding-x);
    color: var(--color-text);
    font-weight: 600;
    cursor: pointer;
}

div.dataTables_wrapper div.dataTables_filter input:focus,
div.dataTables_wrapper div.dataTables_length select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

div.dataTables_wrapper div.dataTables_info,
div.dataTables_wrapper div.dataTables_filter,
div.dataTables_wrapper div.dataTables_length {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important;
    border: 1px solid transparent !important;
    margin-left: 0.15rem;
    color: var(--color-text-muted) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--color-primary-light) !important;
    border-color: var(--color-primary-light) !important;
    color: var(--color-primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--color-bg) !important;
    color: var(--color-text) !important;
}

.table-card .dataTables_paginate .pagination { gap: 0.35rem; }
.table-card .dataTables_paginate .page-link { display: inline-flex; align-items: center; justify-content: center; height: var(--button-height); box-sizing: border-box; border: 1px solid var(--color-border); border-radius: 8px !important; background: #fff; color: var(--color-text-muted); font-size: var(--control-font-size); padding: 0 0.8rem; box-shadow: none; }
.table-card .dataTables_paginate .page-item.active .page-link { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.table-card .dataTables_paginate .page-item.disabled .page-link { background: #f7f9fb; color: #97a2b0; border-color: #edf0f3; }
.table-card .dataTables_paginate .page-link:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--color-primary-light); }
.table-card .dataTables_paginate .page-link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.table-record-name { color: var(--color-text); }
.table tbody strong, .table tbody b, .table tbody .table-record-name { font-weight: 400; }
.table-card .dataTables_wrapper > .row:first-child { padding-bottom: 0.9rem; }
.table-card .dataTables_wrapper > .row:last-child { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--color-border); }
.table .table-actions { text-align: right; white-space: nowrap; }
.table-responsive { width: 100%; overflow-x: auto; }

@media (max-width: 768px) {
    .table-card .dataTables_wrapper {
        padding: 1rem;
    }

    .table thead th {
        padding: 0.75rem;
    }

    .table tbody td,
    .table tbody th {
        padding: 0.55rem 0.75rem;
    }
}

/* ============================================================
   BADGE
   ============================================================ */

.badge,
.analysis-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--badge-height);
    box-sizing: border-box;
    font-weight: 600;
    font-size: var(--badge-font-size);
    line-height: 1;
    letter-spacing: 0;
    padding: 0 var(--badge-padding-x);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.badge.bg-success {
    background-color: var(--color-success-bg) !important;
    color: var(--color-success) !important;
    border: 1px solid var(--color-success-border);
}

.badge.bg-warning {
    background-color: var(--color-warning-bg) !important;
    color: var(--color-warning) !important;
    border: 1px solid var(--color-warning-border);
}

.analysis-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(23, 40, 59, 0.06);
    color: var(--color-text-muted);
}

.analysis-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d79a1e;
    box-shadow: 0 0 0 3px var(--color-warning-bg);
}

.analysis-status.analysis-detail-status {
    height: var(--button-height);
    font-size: var(--control-font-size);
    padding-inline: 0.9rem;
}

.analysis-status-progress {
    border-color: var(--color-warning-border);
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.analysis-status-complete .analysis-status-dot {
    background: var(--color-success);
    box-shadow: 0 0 0 3px var(--color-success-bg);
}

.analysis-status-complete {
    border-color: var(--color-success-border);
    background: var(--color-success-bg);
    color: var(--color-success);
}

/* ============================================================
   MODALI
   ============================================================ */

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.modal-content h3 {
    font-size: 1.15rem;
    font-weight: 700;
}

#modaleProfilo .form-control[readonly] {
    background: #f7f9fb;
    color: var(--color-text-muted);
}

/* ============================================================
   MESSAGGI FLASH
   ============================================================ */

.flash-message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: flash-in 0.2s ease-out;
}

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

.flash-message.flash-success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.flash-message.flash-error {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-border);
}

/* ============================================================
   LOGIN
   ============================================================ */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--color-bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1.15rem;
    margin-bottom: 1.75rem;
}

.login-brand img {
    display: block;
    width: min(100%, 260px);
    height: auto;
}


.login-card-body .card-body {
    padding: 2rem;
}

.login-card h1 {
    margin: 0 0 0.45rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.login-subtitle,
.login-footer {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.login-subtitle {
    margin-bottom: 1.75rem;
}

.login-forgot-link {
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
}

.login-forgot-link:hover {
    text-decoration: underline;
}

.login-footer {
    margin: 1.25rem 0 0;
    text-align: center;
}

/* ============================================================
   VISTE UTENTE — grafici e riepiloghi
   ============================================================ */

.chart-box {
    position: relative;
    width: 100%;
    height: 320px;
}

.chart-box-lg {
    height: 380px;
}

.chart-box-sm {
    height: 220px;
}

.dashboard-summary-row .metric-tile,
.dashboard-shortcut-row .chip-nav-card {
    min-height: var(--dashboard-tile-min-height);
}

.metric-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 1.1rem 1.3rem;
    height: 100%;
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.metric-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.metric-tile-label {
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.metric-tile-value {
    color: var(--color-text);
    font-size: 2rem;
    line-height: 1.2;
    font-weight: 700;
}

.metric-tile-sub {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-top: 0.2rem;
}

/* Dettaglio fornitore: indicatori interni piatti, senza card annidate. */
.supplier-metric-value {
    display: flex;
    align-items: center;
    min-height: 2.4rem;
    font-size: 1.15rem;
}

.supplier-detail-card { overflow: hidden; }
.supplier-detail-pane { padding: 1.5rem; }

.supplier-detail-card .metric-tile {
    border: 0;
    box-shadow: none;
}

.supplier-detail-card .metric-tile-green { background: #f0fdf4; }
.supplier-detail-card .metric-tile-violet { background: #faf5ff; }
.supplier-detail-card .metric-tile-amber { background: #fffbeb; }
.supplier-detail-card .metric-tile-red { background: #fef2f2; }

.supplier-detail-card .metric-tile:hover {
    transform: none;
    box-shadow: none;
}

.supplier-detail-panel {
    padding: 1.25rem;
    border-radius: 12px;
    background: var(--color-surface);
}

.supplier-detail-panel .supplier-risk-stat { background: #f5f9ff; }
.supplier-detail-panel .supplier-risk-stat-danger { background: #fef2f2; }
.supplier-detail-panel .supplier-risk-stat-warning { background: #fffbeb; }
.supplier-detail-panel .supplier-risk-stat-success { background: #f0fdf4; }

.supplier-summary,
.supplier-profile-chart {
    min-width: 0;
    padding: 0.5rem;
}

.supplier-summary-table th,
.supplier-summary-table td {
    padding: 0.12rem 0.6rem;
    border-bottom-color: #edf0f3;
    line-height: 1.25;
    vertical-align: middle;
}

.supplier-summary-table th {
    width: 42%;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.supplier-summary-table td {
    color: var(--color-text);
    font-size: 0.95rem;
    text-align: right;
}

.supplier-summary-table thead th:last-child { text-align: right; }
.supplier-summary-table thead th {
    padding-top: 1.2rem;
    padding-bottom: 1.2rem;
    line-height: 1.25;
}
.supplier-summary-table tr:last-child > * { border-bottom: 0; }

.supplier-profile-chart {
    display: flex;
    flex-direction: column;
}

.supplier-profile-chart-box {
    flex: 1;
    height: auto;
    min-height: 380px;
}

.supplier-profile-chart-caption {
    margin: 0.5rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.supplier-history-chart {
    height: clamp(370px, 48vh, 480px);
}

.supplier-history-table-wrap {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
}

.supplier-history-view-label {
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 400;
}

.supplier-history-view-select { max-width: 280px; }
.supplier-history-view { margin-top: 1.25rem; }

.supplier-history-table thead th {
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    background: #f7f9fb;
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 600;
}

.supplier-history-table tbody td {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    font-size: 0.88rem;
}

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

.insights-card { overflow: hidden; }
.insights-pane { padding: 1.5rem; }
.insights-tabs { flex-wrap: wrap; }

.insights-card .metric-tile {
    border: 0;
    background: #f7f9fb;
    box-shadow: none;
}

.insights-card .metric-tile::after { display: none; }
.insights-card .metric-tile:hover { transform: none; box-shadow: none; }

.insights-chart-panel {
    min-width: 0;
    padding: 0.5rem;
}

.insights-filter-label {
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 400;
}

.insights-filter-select { max-width: 340px; }
.insights-archetype-chart { height: 700px; }
.insights-evolution-chart { height: clamp(380px, 52vh, 500px); }
.insights-risk-chart { height: clamp(380px, 46vh, 440px); }
.insights-vendor-chart { height: clamp(350px, 42vh, 400px); }
.insights-comparison-chart { height: clamp(380px, 48vh, 460px); }
.insights-outlier-chart { height: clamp(380px, 48vh, 460px); }
.insights-archetype-view { margin-top: 1.25rem; }

.insights-archetype-table-wrap {
    min-height: 520px;
    overflow-x: auto;
}

#tabellaArchetipi_wrapper {
    padding-right: 0;
    padding-left: 0;
}

.insights-overview-table-wrap {
    width: 100%;
    overflow-x: auto;
}

.insights-overview-table thead th:nth-child(1) { width: 24%; }
.insights-overview-table thead th:nth-child(2) { width: 51%; }
.insights-overview-table thead th:nth-child(3) { width: 25%; }

.insights-overview-table tbody td:first-child {
    color: var(--color-text-muted);
    font-size: 0.84rem;
    font-weight: 600;
    text-align: left;
}

.insights-overview-table tbody th {
    width: auto;
    color: var(--color-text);
    font-weight: 500;
}

.insights-overview-table tbody td:last-child {
    font-weight: 600;
    white-space: nowrap;
}

.insights-archetype-table thead th {
    padding-top: 0.8rem;
    padding-bottom: 0.8rem;
    background: #f7f9fb;
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 600;
}

.insights-archetype-table tbody td { font-size: 0.88rem; }

.insights-chart-description {
    margin: 0.5rem 0 0.75rem;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
    text-align: left;
}

.insights-archetype-description { margin-top: 0; }

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

.supplier-risk-card {
    display: flex;
    flex-direction: column;
}

.supplier-risk-card .supplier-risk-grid {
    flex: 1;
    grid-template-rows: repeat(2, minmax(112px, 1fr));
}

.supplier-risk-stat {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 112px;
    padding: 1rem 1rem 1rem 1.15rem;
    overflow: hidden;
    border-radius: 12px;
    background: #f7f9fb;
}

.supplier-risk-stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--color-primary);
}

.supplier-risk-stat-danger::before { background: var(--color-danger); }
.supplier-risk-stat-warning::before { background: #d79a1e; }
.supplier-risk-stat-success::before { background: var(--color-success); }

.supplier-risk-stat > span {
    color: var(--color-text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.supplier-risk-stat > strong {
    margin: 0.2rem 0 0.1rem;
    color: var(--color-text);
    font-size: 1.65rem;
    line-height: 1.2;
}

.supplier-risk-stat > strong small {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.supplier-risk-stat > small {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

.supplier-risk-stat > .supplier-risk-badge {
    display: flex;
    align-items: center;
    min-height: 2rem;
    font-size: 1rem;
}

.supplier-mitigators {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.supplier-mitigators span {
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: #edf7f1;
    color: #237347;
    font-size: 0.74rem;
    font-weight: 600;
}

.supplier-view-tabs {
    gap: 0.35rem;
    margin-bottom: 0;
    border-bottom: 0;
}

.supplier-view-card { overflow: hidden; }

.supplier-tabs-header {
    padding: 1.35rem 1.25rem 0.65rem 1.25rem;
    border-bottom: 0;
    background: var(--color-surface);
}

.supplier-view-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--button-height);
    box-sizing: border-box;
    padding: 0 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    font-weight: 600;
}

.supplier-view-tabs .nav-link:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.supplier-view-tabs .nav-link:not(.active) {
    border-color: #edf0f3;
    background: #f7f9fb;
}

.supplier-view-tabs .nav-link:not(.active):hover {
    border-color: #dbe8f1;
    background: var(--color-primary-light);
}

.supplier-view-tabs .nav-link.active {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.supplier-view-content > .tab-pane { min-height: 1px; }
.supplier-ranking-pane { padding: 1.5rem; }
.supplier-ranking-pane > .form-label {
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 400;
    line-height: 1.5;
}
.supplier-ranking-select { max-width: 300px; }
.supplier-ranking-chart { min-height: 320px; }
.buyer-ranking-select { max-width: 340px; }
.buyer-hhi-chart { height: 460px; }
.buyer-winners-chart { min-height: 320px; }
.buyer-filter-label, .buyer-chart-note {
    color: var(--color-text-muted);
    font-size: var(--control-font-size);
    font-weight: 400;
}
.buyer-chart-note { margin: 0 0 1rem; }

.compare-suppliers-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
}

.compare-suppliers-selector {
    padding: 1.15rem;
    border-radius: 12px;
    background: #f7f9fb;
}

.compare-suppliers-list {
    max-height: 340px;
    padding: 0.55rem 0.65rem;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
}

.compare-suppliers-list .form-check {
    margin: 0;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #edf0f3;
}

.compare-suppliers-list .form-check:last-child { border-bottom: 0; }
.compare-suppliers-list .form-check-label { color: var(--color-text); }

.compare-suppliers-result {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0;
}

.compare-suppliers-chart {
    flex: 1;
    height: 100%;
    min-height: 420px;
}

.compare-suppliers-empty {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    border: 1px dashed var(--color-border);
    border-radius: 12px;
    background: #fafbfc;
    color: var(--color-text-muted);
    text-align: center;
}

.compare-suppliers-empty span { font-size: 0.95rem; font-weight: 600; }
.compare-suppliers-empty small { margin-top: 0.25rem; }

.compare-suppliers-empty .compare-suppliers-empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 0.85rem;
    border-radius: 14px;
    background: #eef1f4;
    color: #98a2ad;
}

.compare-suppliers-empty-icon svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 991px) {
    .compare-suppliers-layout { grid-template-columns: 1fr; }
    .compare-suppliers-result { padding-bottom: 0; }
    .compare-suppliers-empty { min-height: 320px; }
}

@media (max-width: 575px) {
    .supplier-risk-grid { grid-template-columns: 1fr; }
    .supplier-risk-card .supplier-risk-grid { grid-template-rows: none; }
    .supplier-risk-stat { min-height: 96px; }
}

.severity-bar {
    position: relative;
    width: 100%;
    min-width: 90px;
    height: 8px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}

.severity-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--color-primary);
}

.severity-bar.is-alert span {
    background: var(--color-danger);
}

.severity-bar-marker {
    position: absolute;
    top: -2px;
    bottom: -2px;
    width: 2px;
    background: var(--color-text);
    opacity: 0.55;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.section-title h5 {
    margin: 0 0 0.15rem;
    font-weight: 700;
}

.section-title p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

.chip-nav-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.2rem 1.3rem;
    height: 100%;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.chip-nav-card:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
}

.chip-nav-icon {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.chip-nav-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chip-nav-card strong {
    display: block;
    color: var(--color-text);
    font-size: 0.98rem;
}

.chip-nav-card p {
    margin: 0.1rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
}
