/* ============================================================
   Calcolatore Valore Chiamata
   Skin: Factos (factosholding.com)
   (nero-carbone #0F1115, testo #EAEAEA, oro #D4AF37, Manrope + Playfair,
    dark glass cards). Structure/markup unchanged from original.
   ============================================================ */
:root {
    --bg-color: #0F1115;
    --ink: #13151A;
    --fg: #EAEAEA;
    --fg-2: rgba(234, 234, 234, 0.78);
    --fg-3: rgba(234, 234, 234, 0.55);
    --fg-dim: rgba(234, 234, 234, 0.32);

    --text-color: #EAEAEA;
    --text-muted: rgba(234, 234, 234, 0.55);

    --teal: oklch(0.84 0.125 91);
    --teal-bright: oklch(0.93 0.085 92);
    --teal-wash: oklch(0.84 0.125 91 / 0.16);
    --teal-strong: oklch(0.84 0.125 91 / 0.55);

    --primary-color: oklch(0.84 0.125 91);
    --primary-light: oklch(0.84 0.125 91 / 0.16);
    --accent-color: oklch(0.84 0.125 91);
    --success-color: oklch(0.84 0.125 91);

    --rule-dark: rgba(234, 234, 234, 0.12);
    --rule-dark-strong: rgba(234, 234, 234, 0.24);

    --card-bg: rgba(15, 17, 21, 0.5);
    --card-border: rgba(234, 234, 234, 0.14);
    --card-border-2: rgba(234, 234, 234, 0.30);
    --card-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.55);

    --font-family: "Manrope", ui-sans-serif, system-ui, sans-serif;
    --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

/* Cosmic background — fixed, deep, glowing (pure CSS, no extra markup) */
body::before {
    content: "";
    position: fixed;
    inset: -6%;
    pointer-events: none;
    z-index: -4;
    background:
        radial-gradient(ellipse 56vw 44vh at 50% 56%, oklch(0.84 0.125 91 / 0.28), transparent 60%),
        radial-gradient(ellipse 40vw 34vh at 50% 50%, oklch(0.62 0.11 62 / 0.24), transparent 62%),
        radial-gradient(ellipse 62vw 54vh at 18% 14%, oklch(0.84 0.125 91 / 0.36), transparent 58%),
        radial-gradient(ellipse 54vw 48vh at 80% 6%, oklch(0.62 0.11 62 / 0.38), transparent 58%),
        radial-gradient(ellipse 72vw 56vh at 55% 108%, oklch(0.84 0.125 91 / 0.3), transparent 58%),
        radial-gradient(ellipse 48vw 42vh at 90% 72%, oklch(0.72 0.09 70 / 0.26), transparent 58%),
        radial-gradient(ellipse 36vw 30vh at 8% 88%, oklch(0.84 0.125 91 / 0.22), transparent 60%);
    filter: blur(96px);
}

.background-gradient {
    display: none;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem 4rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    height: 40px;
    width: auto;
    /* render the (dark) logo mark in cream on the dark theme */
    filter: brightness(0) invert(1);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg);
    letter-spacing: -0.01em;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--rule-dark);
    color: var(--fg-3);
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--teal);
    border-color: var(--teal-strong);
    background: var(--teal-wash);
}

/* Main Container - 3 Column Layout (KPI | card | Target) */
.container {
    flex: 1;
    display: grid;
    grid-template-columns: 230px minmax(360px, 540px) 320px;
    gap: 2.5rem;
    justify-content: center;
    align-items: start;
    padding: 2rem 3rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebars */
.kpi-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 2rem;
}

.kpi-sidebar.left {
    align-items: flex-end;
}

.kpi-sidebar.right {
    align-items: flex-start;
}

/* KPI Cards — dark glass */
.kpi-card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--rule-dark);
    border-radius: 18px;
    padding: 1.25rem;
    width: 100%;
    max-width: 220px;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: var(--card-shadow);
}

.kpi-card:hover {
    transform: translateY(-3px);
    border-color: var(--rule-dark-strong);
    background: rgba(15, 17, 21, 0.7);
    box-shadow: 0 22px 48px -22px rgba(0, 0, 0, 0.6);
}

/* Circular Chart */
.kpi-chart-wrapper {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 100%;
}

.circle-bg {
    fill: none;
    stroke: rgba(234, 234, 234, 0.12);
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    animation: progress 1s ease-out forwards;
    transition: stroke-dasharray 0.5s ease;
}

@keyframes progress {
    0% {
        stroke-dasharray: 0 100;
    }
}

.circular-chart.primary .circle {
    stroke: var(--teal);
    filter: drop-shadow(0 0 3px oklch(0.84 0.125 91 / 0.5));
}

.circular-chart.success .circle {
    stroke: var(--success-color);
}

.percentage {
    fill: var(--fg);
    font-family: var(--font-family);
    font-weight: bold;
    font-size: 0.75rem;
    text-anchor: middle;
}

/* Quality Bar */
.quality-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(234, 234, 234, 0.12);
    border-radius: 10px;
    margin: 0.5rem 0;
    overflow: hidden;
}

.quality-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--teal-strong), var(--teal));
    border-radius: 10px;
    box-shadow: 0 0 8px oklch(0.84 0.125 91 / 0.45);
    transition: width 0.5s ease, background-color 0.3s ease;
}

.full-width {
    width: 100%;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.kpi-value-small {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fg);
}

.kpi-trend-small {
    font-size: 0.75rem;
    color: var(--fg-3);
}

.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--teal-wash);
    color: var(--teal);
    padding: 0.75rem;
    border-radius: 14px;
    width: 42px;
    height: 42px;
}

.kpi-content {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg);
    line-height: 1.2;
}

.kpi-trend {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.1rem;
}

.kpi-trend.positive {
    color: var(--teal);
}

.kpi-trend.negative {
    color: #F98D8D;
}

.kpi-trend.neutral {
    color: var(--fg-3);
}

/* Central Card — dark glass */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--rule-dark);
    border-radius: 22px;
    padding: 3rem;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    position: relative;
}

.card:hover {
    transform: translateY(-5px);
    border-color: var(--rule-dark-strong);
    box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.6);
}

.card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}

/* Mode Switch */
.mode-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(234, 234, 234, 0.04);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    border: 1px solid var(--rule-dark);
}

.mode-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg-3);
    transition: color 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.mode-label:hover {
    color: var(--fg);
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(234, 234, 234, 0.16);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: #EAEAEA;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

input:checked+.slider {
    background-color: var(--teal);
    box-shadow: 0 0 10px oklch(0.84 0.125 91 / 0.5);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--teal);
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.mode-switch-wrapper.active-standard .mode-label:first-child {
    color: var(--fg);
}

.mode-switch-wrapper.active-highticket .mode-label:last-child {
    color: var(--teal);
}

.badge {
    display: none;
}

/* Company Type Toggle */
.company-type-toggle {
    margin-bottom: 2.5rem;
    background: rgba(234, 234, 234, 0.04);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--rule-dark);
}

.toggle-label {
    font-size: 0.95rem;
    color: var(--fg-2);
    font-weight: 500;
}

.toggle-wrapper {
    position: relative;
}

.toggle-checkbox {
    display: none;
}

.toggle-btn {
    display: flex;
    background: rgba(234, 234, 234, 0.06);
    border-radius: 12px;
    padding: 4px;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--rule-dark);
}

.toggle-option {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 2;
    transition: color 0.3s ease;
    color: var(--fg-3);
}

.toggle-btn::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: var(--teal);
    border-radius: 8px;
    box-shadow: 0 0 10px oklch(0.84 0.125 91 / 0.4);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.toggle-checkbox:checked+.toggle-btn::before {
    transform: translateX(100%);
}

.toggle-checkbox:not(:checked)+.toggle-btn .normal {
    color: #0F1115;
}

.toggle-checkbox:checked+.toggle-btn .big {
    color: #0F1115;
}

/* Inputs */
.input-group {
    margin-bottom: 2rem;
}

.input-group label {
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--fg-3);
    margin-bottom: 0.75rem;
}

.helper-text {
    font-size: 0.95rem;
    color: var(--fg-3);
    margin-top: 0.5rem;
    font-weight: 600;
}

.row {
    display: flex;
    gap: 1.5rem;
}

.half {
    flex: 1;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    background: rgba(234, 234, 234, 0.05);
    border: 1px solid var(--rule-dark);
    color: var(--fg);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: var(--font-family);
    font-weight: 500;
    transition: all 0.2s ease;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--teal);
    background: rgba(234, 234, 234, 0.08);
    box-shadow: 0 0 0 3px var(--teal-wash);
}

.number-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.number-input-wrapper input {
    padding-right: 3rem;
}

.currency,
.percent {
    position: absolute;
    right: 1.25rem;
    color: var(--fg-3);
    pointer-events: none;
    font-weight: 500;
}

/* Range Slider */
.range-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(234, 234, 234, 0.16);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0F1115;
    border: 2px solid var(--teal);
    cursor: pointer;
    box-shadow: 0 0 10px oklch(0.84 0.125 91 / 0.45);
    transition: transform 0.2s ease;
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #0F1115;
    border: 2px solid var(--teal);
    cursor: pointer;
    box-shadow: 0 0 10px oklch(0.84 0.125 91 / 0.45);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Divider */
.divider {
    height: 1px;
    background: var(--rule-dark);
    margin: 2.5rem 0;
    margin-top: auto;
}

/* Results */
.results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-item .label {
    color: var(--fg-3);
    font-size: 0.95rem;
    font-weight: 500;
}

.result-item .value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}

.result-item.highlight .value {
    color: var(--teal);
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 18px oklch(0.84 0.125 91 / 0.4);
}

.result-item.sub-item .label {
    font-size: 0.95rem;
}

.result-item.sub-item .value {
    font-size: 1.5rem;
    color: var(--fg-3);
}

.hidden {
    display: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 9, 12, 0.66);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    background: #0F1115;
    border: 1px solid var(--rule-dark);
    border-radius: 22px;
    padding: 0;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--rule-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fg);
}

.modal-body {
    padding: 2rem;
}

.config-section {
    margin-bottom: 2rem;
}

.config-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--fg-3);
    margin-bottom: 1rem;
    font-weight: 600;
}

.help-text {
    font-size: 0.95rem;
    color: var(--fg-3);
    margin-top: 0.5rem;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--rule-dark);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: rgba(234, 234, 234, 0.03);
    border-radius: 0 0 22px 22px;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
    font-size: 0.95rem;
}

.btn.secondary {
    background: transparent;
    color: var(--fg-2);
    border: 1px solid var(--rule-dark);
}

.btn.secondary:hover {
    color: var(--fg);
    background: rgba(234, 234, 234, 0.06);
    border-color: var(--rule-dark-strong);
}

.btn.primary {
    background: var(--teal);
    color: #0F1115;
}

.btn.primary:hover {
    background: var(--teal-bright);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -6px oklch(0.84 0.125 91 / 0.55);
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
        padding: 2rem;
        max-width: 620px;
    }

    /* left KPIs are decoration → hide; keep the Target selector, stacked below */
    .kpi-sidebar.left {
        display: none;
    }

    .kpi-sidebar.right {
        padding-top: 0;
        align-items: stretch;
    }

    .target-panel {
        max-width: 100%;
    }

    .card {
        padding: 2rem;
        width: 100%;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 2rem;
    }

    .container {
        padding: 1rem;
    }
}

/* ============================================================
   Target segmentation panel (right column)
   ============================================================ */
.target-panel {
    width: 100%;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--rule-dark);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.target-head {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--rule-dark);
    text-align: center;
}

.target-eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 600;
    color: var(--teal);
    margin-bottom: 0.55rem;
}

.target-count {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fg);
    line-height: 1;
    letter-spacing: -0.5px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px oklch(0.84 0.125 91 / 0.28);
}

.target-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--fg-3);
    margin-top: 0.3rem;
}

.target-meta {
    font-size: 0.75rem;
    color: var(--fg-2);
    margin-top: 0.55rem;
}

.target-meta span {
    color: var(--teal);
    font-weight: 700;
}

.target-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--rule-dark);
}

.target-btn {
    flex: 1;
    padding: 0.45rem;
    font-family: var(--font-family);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-2);
    background: rgba(234, 234, 234, 0.04);
    border: 1px solid var(--rule-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.target-btn:hover {
    color: var(--teal);
    border-color: var(--teal-strong);
    background: var(--teal-wash);
}

.target-list {
    max-height: 462px;
    overflow-y: auto;
    padding: 0.5rem;
}

.target-list::-webkit-scrollbar {
    width: 8px;
}

.target-list::-webkit-scrollbar-thumb {
    background: rgba(234, 234, 234, 0.16);
    border-radius: 8px;
}

.tg-mrow {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.55rem;
    border-radius: 10px;
}

.tg-mrow:hover {
    background: rgba(234, 234, 234, 0.03);
}

.tg-mname {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg);
    line-height: 1.2;
    cursor: pointer;
}

.tg-mcount {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--teal);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tg-mcount.tg-dim {
    color: var(--fg-dim);
}

.tg-exp {
    background: none;
    border: none;
    color: var(--fg-3);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.15rem 0.2rem;
    line-height: 1;
    transition: transform 0.2s ease, color 0.2s ease;
}

.tg-exp.open {
    transform: rotate(180deg);
    color: var(--teal);
}

.tg-subs {
    padding: 0.1rem 0.2rem 0.5rem;
}

.tg-srow {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem 0.3rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
}

.tg-srow:hover {
    background: rgba(234, 234, 234, 0.03);
}

.tg-sname {
    font-size: 0.75rem;
    color: var(--fg-2);
    line-height: 1.25;
}

.tg-scount {
    font-size: 0.75rem;
    color: var(--fg-3);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tg-mcheck,
.tg-scheck {
    accent-color: var(--teal);
    width: 15px;
    height: 15px;
    cursor: pointer;
    flex-shrink: 0;
}


