/* Pannello clienti. Nessuno stile inline (CSP default-src 'self'): tutto qui. */
:root {
    --bg: #f3f5f9; --bg-2: #e9edf5; --panel: #ffffff; --panel-2: #f7f9fc;
    --text: #141a26; --muted: #5b6577; --line: #dfe4ec; --line-strong: #c9d1de;
    --accent: #3b5bfd; --accent-2: #7a3cf5; --accent-soft: #eaeefe; --on-accent: #fff;
    --ok: #138a4b; --ok-soft: #e3f5ea; --warn: #9a5b00; --warn-soft: #fff3dc; --danger: #c8302c; --danger-soft: #fde8e7;
    --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 8px 24px -12px rgb(16 24 40 / .18);
    --radius: 14px;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117; --bg-2: #111827; --panel: #161c26; --panel-2: #1b2230;
        --text: #e7ebf2; --muted: #96a0b2; --line: #263041; --line-strong: #34405a;
        --accent: #7b93ff; --accent-2: #b08cff; --accent-soft: #1d2645; --on-accent: #0b1020;
        --ok: #4ad38a; --ok-soft: #12291d; --warn: #f0b54a; --warn-soft: #2d2311; --danger: #ff7a73; --danger-soft: #2f1517;
        --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px -16px rgb(0 0 0 / .7);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    background: radial-gradient(1200px 400px at 10% -10%, var(--accent-soft), transparent 70%), var(--bg);
    color: var(--text); font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- struttura --- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 16px; padding: 10px 24px;
    background: color-mix(in srgb, var(--panel) 85%, transparent); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.logo { width: 34px; height: 34px; flex: none; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a, .nav button {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 9px;
    color: var(--muted); font: inherit; font-weight: 500; background: none; border: 0; cursor: pointer; margin: 0;
}
.nav a:hover, .nav button:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.nav form { margin: 0; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 32px 24px 48px; flex: 1; }

.site-footer {
    border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px;
}
.site-footer .inner {
    max-width: 1120px; margin: 0 auto; padding: 18px 24px;
    display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
}
.site-footer .domain { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.site-footer .domain .dot { width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

/* --- intestazioni di pagina --- */
.page-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.crumb:hover { color: var(--accent); }
h2 { font-size: 16px; margin: 0 0 4px; letter-spacing: -.01em; }
.section-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

/* --- superfici --- */
.card {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.card-head .icon-tile { margin-right: 4px; }
.card-title { display: flex; gap: 12px; align-items: flex-start; }
.icon-tile {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex: none;
    background: var(--accent-soft); color: var(--accent);
}
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 20px; }

/* --- statistiche --- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 28px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.stat .pip { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.stat.all .pip { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.stat.Active .pip { background: var(--ok); }
.stat.Trial .pip { background: var(--accent); }
.stat.Suspended .pip { background: var(--danger); }

/* --- clienti --- */
.tenants { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tenant {
    display: flex; flex-direction: column; gap: 14px; padding: 20px; color: var(--text);
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.tenant:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--line-strong); }
.tenant .top { display: flex; gap: 12px; align-items: center; }
.tenant .name { font-weight: 650; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.tenant .host { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.tenant .meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; border-top: 1px dashed var(--line); padding-top: 12px; color: var(--muted); font-size: 13px; }
.tenant .badge { margin-left: auto; }

.avatar {
    display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px;
    color: #fff; font-weight: 700; letter-spacing: .02em; background: linear-gradient(135deg, #3b5bfd, #7a3cf5);
}
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.avatar.h1 { background: linear-gradient(135deg, #0ea5a4, #2563eb); }
.avatar.h2 { background: linear-gradient(135deg, #f97316, #db2777); }
.avatar.h3 { background: linear-gradient(135deg, #16a34a, #0d9488); }
.avatar.h4 { background: linear-gradient(135deg, #9333ea, #db2777); }
.avatar.h5 { background: linear-gradient(135deg, #0284c7, #4f46e5); }

.empty { text-align: center; padding: 48px 24px; }
.empty .icon-tile { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px; }
.empty .icon-tile .icon { width: 26px; height: 26px; }
.empty h2 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 460px; margin: 6px auto 20px; }

/* --- stato --- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg-2); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.Active { color: var(--ok); background: var(--ok-soft); }
.badge.Trial { color: var(--accent); background: var(--accent-soft); }
.badge.Suspended { color: var(--danger); background: var(--danger-soft); }

/* --- scheda cliente --- */
.hero { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; }
.hero .title { flex: 1; min-width: 220px; }
.hero h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hero .host { margin-top: 4px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0; margin: 20px 0 0; border-top: 1px solid var(--line); }
.facts div { padding: 14px 16px 0 0; }
.facts dt { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 4px 0 0; overflow-wrap: anywhere; }

.segmented { position: relative; display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg-2); border-radius: 12px; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented label {
    margin: 0; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted);
    display: inline-flex; align-items: center; gap: 6px;
}
.segmented input:checked + label { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- tabelle --- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 0 10px 10px 0; }
td { padding: 12px 10px 12px 0; border-top: 1px solid var(--line); vertical-align: middle; }
td:last-child, th:last-child { padding-right: 0; text-align: right; }
.who { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.who .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.muted { color: var(--muted); }
.revoked td { color: var(--muted); }
.revoked .who { text-decoration: line-through; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg-2); }

/* --- moduli --- */
label { display: block; margin: 0 0 6px; font-weight: 600; font-size: 14px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.fields { display: grid; gap: 0 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
input, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--panel-2); color: var(--text); font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input::placeholder { color: var(--muted); opacity: .8; }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-affix span {
    display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--line-strong); border-left: 0;
    border-radius: 0 10px 10px 0; background: var(--bg-2); color: var(--muted); font-size: 14px; white-space: nowrap;
}
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.error { color: var(--danger); font-size: 13px; margin: 6px 0 0; font-weight: 500; }
.row-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.row-form .field { flex: 1 1 200px; margin: 0; }
.row-form.flush { margin-top: 0; padding-top: 0; border-top: 0; }
.row-form .hint { flex-basis: 100%; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.who + .muted { display: block; font-size: 12px; margin-top: 2px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; cursor: pointer;
    font: inherit; font-weight: 600; line-height: 1.2; color: var(--on-accent);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 6px 16px -8px var(--accent); transition: filter .15s ease, transform .1s ease;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--line-strong); box-shadow: none; }
.btn.secondary:hover { background: var(--bg-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; align-items: center; margin-top: 8px; }

/* --- passi (nuovo cliente) --- */
.step { display: grid; grid-template-columns: 40px 1fr; gap: 16px; }
.step .num {
    display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
    font-weight: 700; color: var(--accent); background: var(--accent-soft);
}

/* --- avvisi e segreti --- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; }
.alert.danger { background: var(--danger-soft); color: var(--danger); }
.secret {
    border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft);
    border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px;
}
.secret .lead { display: flex; gap: 10px; align-items: flex-start; color: var(--warn); font-weight: 600; margin: 0 0 14px; }
.secret .lead span { color: var(--text); font-weight: 500; }
.secrets { display: grid; gap: 10px; margin: 0; }
.secrets > div {
    display: grid; grid-template-columns: minmax(130px, 200px) 1fr auto; gap: 12px; align-items: center;
    padding: 10px 12px; border-radius: 10px; background: var(--panel);
}
.secrets dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.secrets dd { margin: 0; overflow-wrap: anywhere; }
.secrets code { font-size: 14px; user-select: all; }
.copy[data-copied]::after { content: " ✓"; }

/* --- accesso --- */
.auth { flex: 1; display: grid; place-items: center; padding: 32px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 32px; }
.auth .logo { width: 48px; height: 48px; margin-bottom: 16px; }
.auth h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.01em; }
.auth p.sub { margin: 0 0 24px; color: var(--muted); }

@media (max-width: 640px) {
    .topbar { padding: 10px 16px; }
    .brand small { display: none; }
    .nav .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .hero h1 { font-size: 21px; }
    .avatar.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 18px; }
    main { padding: 24px 16px 40px; }
    .card { padding: 18px; }
    .table-wrap { margin: 0 -18px; padding: 0 18px; }
    .page-head h1 { font-size: 24px; }
    .step { grid-template-columns: 1fr; gap: 10px; }
    .secrets > div { grid-template-columns: 1fr auto; }
    .secrets dt { grid-column: 1 / -1; }
    .site-footer .inner { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
