/* DNS Portal — stile applicazione (nessuna dipendenza esterna, compatibile con CSP 'self') */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e5ea;
    --text: #1d2330;
    --muted: #687083;
    --primary: #2f5bea;
    --primary-hover: #2449c4;
    --primary-soft: #e8eeff;
    --ok: #1a7f4b;
    --ok-soft: #e3f5eb;
    --warn: #9a6100;
    --warn-soft: #fff3d6;
    --err: #c0352b;
    --err-soft: #fde8e6;
    --info: #1f6fb2;
    --info-soft: #e4f0fb;
    --sidebar: #141a28;
    --sidebar-text: #c9cfdc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f131b;
        --surface: #171c27;
        --surface-2: #1e2431;
        --border: #2a3142;
        --text: #e4e7ee;
        --muted: #949cb0;
        --primary: #5b82ff;
        --primary-hover: #7898ff;
        --primary-soft: #1d2a4d;
        --ok: #4ccb87;
        --ok-soft: #14301f;
        --warn: #e8b04a;
        --warn-soft: #33280f;
        --err: #ff6b5e;
        --err-soft: #3a1a17;
        --info: #5fb0f0;
        --info-soft: #132a3d;
        --sidebar: #0b0e15;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: .1rem 0 .3rem; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
pre { overflow: auto; }
[hidden] { display: none !important; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .55rem; padding: 1.2rem 1.25rem; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--primary); font-size: 1.1rem; }
.nav { display: flex; flex-direction: column; padding: .25rem .6rem; flex: 1; }
.nav a { color: var(--sidebar-text); padding: .5rem .75rem; border-radius: 7px; font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(91, 130, 255, .18); color: #fff; }
.nav-section { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: #6f788c; padding: 1rem .75rem .35rem; }
.sidebar-foot { padding: 1rem 1.1rem; border-top: 1px solid rgba(255, 255, 255, .07); display: flex; flex-direction: column; gap: .6rem; }
.who { display: flex; flex-direction: column; }
.who strong { color: #fff; font-size: .92rem; }
.sidebar .btn-ghost { color: var(--sidebar-text); border-color: rgba(255, 255, 255, .15); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: .65rem 1.75rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.menu-toggle { display: none; }
.content { padding: 1.5rem 1.75rem 3rem; max-width: 1280px; width: 100%; }

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

/* ---------- card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-danger { border-color: color-mix(in srgb, var(--err) 35%, var(--border)); }
.card-ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .grid-2 { margin-top: 1.25rem; }
.grid-2 { margin-bottom: 1.25rem; }

/* ---------- stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat-label { color: var(--muted); font-size: .8rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-err { color: var(--err); }

/* ---------- domini cliente */
.domain-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.domain-card { color: var(--text); display: flex; flex-direction: column; gap: .5rem; margin: 0; }
.domain-card:hover { border-color: var(--primary); text-decoration: none; }
.domain-name { font-weight: 700; font-size: 1.05rem; word-break: break-all; }
.domain-meta { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- tabelle */
.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .6rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-compact td { padding: .4rem .6rem; }
.records .value { max-width: 520px; }
.row-warn { background: var(--warn-soft); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; overflow-wrap: anywhere; }
.center { text-align: center; }
.type { display: inline-block; font-family: var(--mono); font-size: .78rem; font-weight: 700; padding: .12rem .45rem; border-radius: 5px; background: var(--surface-2); min-width: 3.2em; text-align: center; }
.type-a, .type-aaaa { background: var(--primary-soft); color: var(--primary); }
.type-cname { background: var(--info-soft); color: var(--info); }
.type-mx { background: var(--ok-soft); color: var(--ok); }
.type-txt { background: var(--warn-soft); color: var(--warn); }
.type-ns, .type-soa { background: var(--surface-2); color: var(--muted); }
.type-caa, .type-tlsa, .type-srv { background: var(--err-soft); color: var(--err); }

/* ---------- badge / chip */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .14rem .5rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-err { background: var(--err-soft); color: var(--err); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-muted { background: var(--surface-2); color: var(--muted); }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { font-size: .8rem; padding: .2rem .65rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- form */
.stack { display: flex; flex-direction: column; gap: .85rem; }
.stack.narrow { max-width: 420px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0; border: 0; padding: 0; min-width: 0; }
.field label, legend { font-weight: 600; font-size: .88rem; }
legend { margin-bottom: .35rem; }
input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; min-width: 0; max-width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 0; border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
.input-sm { width: 120px; }
.hint { color: var(--muted); font-size: .82rem; margin: .2rem 0 0; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; cursor: pointer; }
.check-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; display: flex; flex-direction: column; gap: .3rem; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.suffix { background: var(--surface-2); border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; padding: .5rem .65rem; color: var(--muted); font-family: var(--mono); font-size: .85rem; white-space: nowrap; max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
.code-input { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .25em; text-align: center; max-width: 12rem; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1 1 240px; }
.bulk-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; padding: .25rem 0 .9rem; border-bottom: 1px solid var(--border); margin-bottom: .5rem; }
.row { display: flex; gap: .6rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
.actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.actions form { margin: 0; }
.mt { margin-top: 1rem; }

/* ---------- bottoni */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
    padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
    text-decoration: none; white-space: nowrap; background: var(--surface-2); color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); filter: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--err) 40%, var(--border)); color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); }
.btn-sm { padding: .32rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ---------- alert */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.otp-box { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.otp-grid { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; }
.otp-grid code { font-size: 1rem; user-select: all; }

/* ---------- varie */
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.empty { color: var(--muted); text-align: center; padding: 1.25rem .5rem; margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.2rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .86rem; }
.kv dd { margin: 0; word-break: break-word; }
.notes { background: var(--surface-2); padding: .65rem .8rem; border-radius: 8px; font-size: .9rem; }
.list { list-style: none; margin: 0 0 1rem; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .65rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
details { margin-top: .5rem; }
details > summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: .35rem 0; }
details[open] > summary { margin-bottom: .6rem; }
.pre-small, .json { background: var(--surface-2); border-radius: 8px; padding: .75rem; font-family: var(--mono); font-size: .8rem; max-height: 520px; white-space: pre-wrap; word-break: break-all; }
.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.checks li { display: flex; gap: .55rem; align-items: baseline; }
.check-icon { font-weight: 700; width: 1.1rem; }
.checks .ok .check-icon { color: var(--ok); }
.checks .ko .check-icon { color: var(--err); }
.diag-actions { display: flex; flex-direction: column; gap: .9rem; }
.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
.secret-box { display: flex; gap: .6rem; align-items: center; margin: .5rem 0; flex-wrap: wrap; }
.secret { font-size: 1.05rem; letter-spacing: .06em; padding: .4rem .6rem; user-select: all; }
.diff { list-style: none; padding: 0; margin: 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.diff li { padding: .35rem .7rem; font-size: .84rem; border-bottom: 1px solid var(--border); word-break: break-all; }
.diff li:last-child { border-bottom: 0; }
.diff-add li { background: var(--ok-soft); }
.diff-add li::before { content: "+ "; color: var(--ok); font-weight: 700; }
.diff-del li { background: var(--err-soft); }
.diff-del li::before { content: "− "; color: var(--err); font-weight: 700; }
.diff-upd li { background: var(--info-soft); }
.pager { display: flex; gap: .3rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager .current { padding: .3rem .65rem; border-radius: 6px; border: 1px solid var(--border); font-size: .85rem; }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .muted { margin-left: .5rem; }

/* ---------- auth */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; }
.auth-wrap { width: 100%; max-width: 410px; }
.auth-brand { text-align: center; font-weight: 700; font-size: 1.25rem; margin-bottom: 1rem; }
.auth-card { padding: 1.75rem; }
.auth-title { font-size: 1.3rem; margin-bottom: 1rem; }
.error-page { text-align: center; padding: 1rem 0; }
.error-code { font-size: 3rem; font-weight: 800; color: var(--muted); line-height: 1; }

/* ---------- responsive */
@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
    .menu-toggle { display: inline-flex; }
    .grid-2 { grid-template-columns: 1fr; }
    .content { padding: 1.1rem 1rem 3rem; }
    .topbar { padding: .6rem 1rem; }
}
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: .1rem; }
    .kv dd { margin-bottom: .5rem; }
    h1 { font-size: 1.3rem; }
}
