:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #6b7280;
    --border: #dde1e7;
    --primary: #1f4fd8;
    --primary-text: #ffffff;
    --ok: #16803c;
    --ok-bg: #e7f6ec;
    --warn: #a15c00;
    --warn-bg: #fff4e0;
    --error: #b42318;
    --error-bg: #fdecea;
    --radius: 10px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1b1f27;
        --text: #e7e9ee;
        --muted: #9aa3b2;
        --border: #2d333f;
        --primary: #5b8cff;
        --primary-text: #0b0e14;
        --ok: #5fd08a;
        --ok-bg: #12301f;
        --warn: #ffb547;
        --warn-bg: #352610;
        --error: #ff7a6e;
        --error-bg: #3a1714;
    }
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--primary); }
[hidden] { display: none !important; }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; }
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a { text-decoration: none; }
.inline { display: inline; margin: 0; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 16px;
}
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

.btn {
    display: inline-block; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
    background: var(--primary); color: var(--primary-text); font: inherit; font-weight: 600; text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: .9rem; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--error); color: #fff; }
button.link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=search], select {
    display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; font-weight: 400;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.has-error input { border-color: var(--error); }
.error { display: block; color: var(--error); font-weight: 400; margin-top: 3px; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 700; margin-bottom: 8px; color: var(--muted); text-transform: uppercase; font-size: .75rem; letter-spacing: .05em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: 1fr 2fr 1fr 2fr; gap: 0 14px; }
.stack button { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--error-bg); color: var(--error); }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input { flex: 1 1 240px; margin: 0; }
.filters select { width: auto; margin: 0; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { font-size: .8rem; color: var(--muted); font-weight: 600; }
table.list tr:last-child td { border-bottom: 0; }
tr.is-revoked td { opacity: .6; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; }
.badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-revoked { background: var(--error-bg); color: var(--error); }
.badge-pending { background: var(--warn-bg); color: var(--warn); }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.preview { position: sticky; top: 16px; }
.qr-box { background: #fff; border-radius: 8px; padding: 8px; margin: 12px 0; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-box svg .dark { fill: #000; }
.meter-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--ok); transition: width .2s; }
.meter-warn .meter-bar span { background: var(--warn); }
.meter-block .meter-bar span { background: var(--error); }
.meter-text { margin: 6px 0 0; font-size: .9rem; }
.meter-hint { margin: 4px 0 0; font-size: .85rem; }
.meter-hint:empty { display: none; }
.meter-warn .meter-hint { color: var(--warn); }
.meter-block .meter-hint { color: var(--error); }
pre { white-space: pre-wrap; word-break: break-all; font-size: .8rem; background: var(--bg); padding: 10px; border-radius: 8px; }
details summary { cursor: pointer; font-size: .9rem; color: var(--muted); }
.links { font-size: .9rem; margin-bottom: 0; }

.copy-row { display: flex; gap: 8px; margin-bottom: 8px; }
.copy-row input { margin: 0; flex: 1; }
.danger-zone { border-color: var(--error-bg); }
.audit { list-style: none; padding: 0; margin: 0; }
.audit li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.audit li:last-child { border-bottom: 0; }

.bizcard .role { font-weight: 600; margin: 0; }
.bizcard .qr-box { max-width: 280px; margin: 16px auto; }
.contact-list { list-style: none; padding: 0; margin: 0 0 16px; line-height: 2; }

@media (max-width: 820px) {
    .editor { grid-template-columns: 1fr; }
    .preview { position: static; }
}
@media (max-width: 560px) {
    .grid2, .grid4 { grid-template-columns: 1fr; }
    .copy-row { flex-wrap: wrap; }
    .topbar nav { gap: 10px; }
}
.wallet-buttons { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn-wallet { background: #000; color: #fff; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
input[type=color] { display: block; width: 100%; height: 38px; margin-top: 4px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
input[type=file] { display: block; margin-top: 6px; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
label .small { font-weight: 400; display: inline-block; margin-top: 4px; }
.mt { margin-top: 20px; }
.icon-row { display: flex; align-items: center; gap: 10px; }
.icon-row img { border-radius: 9px; }

.pass-mock {
    background: var(--pass-bg); color: var(--pass-fg); border-radius: 14px; padding: 14px 16px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.pass-head { height: 32px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-width: 0; }
.pass-logo { max-height: 32px; max-width: 104px; }
.pass-logotext { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Nome accanto al logo: stessa riga, più piccolo */
.pass-logo:not([hidden]) + .pass-logotext { font-size: 13px; }
.pass-label { color: var(--pass-label); font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pass-primary { font-size: 22px; line-height: 1.2; margin-bottom: 10px; }
.pass-value { font-size: 15px; margin-bottom: 10px; }
.pass-value.small { font-size: 12px; word-break: break-all; }
.pass-aux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pass-qr { background: #fff; color: #999; border-radius: 6px; width: 110px; height: 110px; margin: 8px auto 0; display: grid; place-items: center; font-size: 12px; }

.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.company-tile {
    display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px;
}
.company-swatch {
    background: var(--pass-bg); color: var(--pass-fg); border-radius: 8px; height: 70px; margin-bottom: 6px;
    display: grid; place-items: center; font-weight: 600; padding: 10px;
}
.company-swatch img { max-height: 44px; max-width: 100%; }

.public .bizcard-head { display: flex; align-items: center; gap: 10px; background: var(--pass-bg); color: var(--pass-fg); margin: -20px -20px 16px; padding: 18px 20px; border-radius: var(--radius) var(--radius) 0 0; }
.public .bizcard-head img { max-height: 44px; max-width: 70%; }
.public .bizcard-head .pass-logotext { font-size: 17px; }
.public .bizcard-head img + .pass-logotext { font-size: 15px; }
@media (max-width: 560px) { .grid3 { grid-template-columns: 1fr 1fr 1fr; } }

.photo-field { display: flex; gap: 14px; align-items: flex-start; }
.photo-current { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex: none; }
.pass-main { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.pass-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 4px; flex: none; }
.open-on-phone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.open-on-phone h2 { font-size: 1rem; margin: 0 0 4px; }
.bizcard .small-qr { max-width: 160px; }
