/* blicence: stile comune di gestione e portale */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #687385;
  --border: #dde2ea;
  --primary: #0b5cad;
  --primary-hover: #094a8c;
  --danger: #b42318;
  --ok-bg: #e7f5ec;   --ok-fg: #1d6b3a;
  --err-bg: #fdecec;  --err-fg: #9b1c1c;
  --info-bg: #e8f1fb; --info-fg: #164a7e;
  --free: #8a5a00;    --free-bg: #fff4dc;
  --active: #1d6b3a;  --active-bg: #e7f5ec;
  --revoked: #9b1c1c; --revoked-bg: #fdecec;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b2129; --text: #e4e8ee; --muted: #9aa5b5; --border: #2d3540;
    --primary: #4b9be8; --primary-hover: #6aaef0; --danger: #f07167;
    --ok-bg: #173323; --ok-fg: #8ee0ad; --err-bg: #3a1a1a; --err-fg: #f5a3a3; --info-bg: #172a40; --info-fg: #a9cdf5;
    --free: #f2c46b; --free-bg: #3a2e12; --active: #8ee0ad; --active-bg: #173323; --revoked: #f5a3a3; --revoked-bg: #3a1a1a;
  }
}
* { 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, sans-serif; }
a { color: var(--primary); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
.card h2:first-child, .titlebar h2 { margin-top: 0; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.wrap { overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* Barra in alto */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
          background: var(--surface); border-bottom: 1px solid var(--border); padding: .6rem 1rem; }
.brand { font-weight: 600; font-size: 1.1rem; white-space: nowrap; }
.brand .logo { color: var(--primary); }
.brand small { color: var(--muted); font-weight: 400; margin-left: .3rem; }
.mainnav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
.mainnav a { padding: .35rem .7rem; border-radius: var(--radius); text-decoration: none; color: var(--text); }
.mainnav a:hover { background: var(--bg); }
.mainnav a.active { background: var(--primary); color: #fff; }
.userbox { display: flex; align-items: center; gap: .9rem; margin-left: auto; }
.userbox small { color: var(--muted); }

.container { max-width: 1180px; margin: 0 auto; padding: 1.5rem 16px 2rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem 16px 2rem; }

/* Blocchi */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1.1rem 1.25rem; margin: 0 0 1.25rem; }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.25rem; }
.columns > .card { margin: 0; }
.titlebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.titlebar h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }

/* Messaggi */
.alert { padding: .7rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-error { background: var(--err-bg); color: var(--err-fg); }
.alert-info { background: var(--info-bg); color: var(--info-fg); }

/* Moduli */
.form { display: grid; gap: .85rem; }
.form.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
label { display: grid; gap: .3rem; font-weight: 500; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
                          border-radius: 6px; padding: .5rem .6rem; width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
input.otp { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filters input[type="search"] { flex: 1 1 260px; width: auto; }
.filters select { width: auto; }
form.inline { display: inline; }

.btn { font: inherit; display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; text-decoration: none;
       padding: .5rem 1rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .2rem .55rem; font-size: .85rem; }
.btn.done { border-color: var(--active); color: var(--active); }
.btn.busy { opacity: .6; pointer-events: none; }
button.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; text-decoration: underline; }

/* Tabelle */
.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); margin-bottom: 1.25rem; }
@media (max-width: 900px) { .grid { display: block; overflow-x: auto; } }
.grid th, .grid td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
.grid tbody tr:last-child td { border-bottom: 0; }

/* Dati */
.props { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 .5rem; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .35rem 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child { border-bottom: 0; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge-free { color: var(--free); background: var(--free-bg); }
.badge-active { color: var(--active); background: var(--active-bg); }
.badge-revoked { color: var(--revoked); background: var(--revoked-bg); }
.badge-pending { color: var(--free); background: var(--free-bg); }

/* Colonna computer su tre righe: data e ora, nome, identificativo */
.computer-cell { line-height: 1.35; }
.computer-cell > span { display: block; }
.computer-cell .cid { font-size: .8rem; color: var(--muted); word-break: break-all; }
/* Riga della disattivazione in corso, sotto la licenza */
tr.pending-row td { background: var(--free-bg); border-top: 0; }
tr.pending-row .pending-note { display: block; font-size: .8rem; color: var(--free); max-width: 36rem; }
.notice-pending { padding: .6rem .8rem; border-radius: var(--radius); background: var(--free-bg); color: var(--free); font-size: .9rem; }

code.key { font-weight: 600; letter-spacing: .03em; }
.licence.revoked { opacity: .7; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
        color: var(--muted); text-decoration: none; }
.stat .num { display: block; font-size: 1.8rem; font-weight: 600; color: var(--text); }
a.stat:hover { border-color: var(--primary); }

/* Logo, CSS, lingue, righe delle licenze */
.brand { display: flex; align-items: center; gap: .5rem; }
.logo-img { height: 26px; width: auto; display: block; }
.logo-preview { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.logo-preview img { max-height: 60px; max-width: 240px; background: var(--bg); padding: .4rem; border-radius: 6px; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
input.narrow-input { width: 6rem; }
.langs { margin: 0; }
.langs select { width: auto; padding: .25rem .5rem; font-size: .9rem; }
.licence-rows td, .file-rows td { vertical-align: middle; }
.file-rows td:last-child { text-align: right; width: 1%; }
.licence-rows .keycell { white-space: nowrap; }
.licence-rows .keycell code { margin-right: .5rem; }
.product-block h2 { margin-bottom: .5rem; }
.translations td textarea { min-height: 2.4rem; }

@media (max-width: 720px) {
  .form.two-col, .form.three-col { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .userbox { margin-left: 0; }
  .container { padding-top: 1rem; }
}
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin: 1.5rem 0 1rem; }
.tabs a { padding: .45rem .9rem; text-decoration: none; border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; margin-bottom: -1px; }
.tabs a.active { border-color: var(--border); background: var(--surface); font-weight: 600; }
.flag { display: inline-block; vertical-align: middle; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
h1 .flag { width: 30px; height: 20px; }
.table-scroll { overflow-x: auto; }
.texts-grid th.lang-col { white-space: nowrap; min-width: 16rem; }
.texts-grid th.lang-col.inactive { opacity: .65; }
.texts-grid .var-col { min-width: 14rem; max-width: 22rem; }
.texts-grid textarea { width: 100%; min-height: 2.4rem; resize: vertical; }
.badge.area-portal, .badge.area-admin { font-size: .7rem; padding: .05rem .4rem; margin-left: .3rem; background: var(--bg); color: var(--muted); }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; margin: .75rem 0; }
.pager span.muted { margin-right: .6rem; }
.pager a, .pager .current { min-width: 2rem; text-align: center; padding: .2rem .5rem; border-radius: 4px; text-decoration: none; border: 1px solid var(--border); }
.pager .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0; z-index: 1; }

/* Finestra di conferma (revoca della licenza dal portale) */
.confirm-dialog { max-width: 34rem; width: calc(100% - 32px); border: 1px solid var(--border); border-radius: var(--radius);
                  background: var(--surface); color: var(--text); padding: 1.25rem 1.5rem; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.confirm-dialog::backdrop { background: rgba(10, 14, 20, .55); }
.confirm-dialog h2 { margin: 0 0 .8rem; font-size: 1.2rem; }
.confirm-dialog p { margin: 0 0 .75rem; line-height: 1.5; }
.confirm-dialog .confirm-note { padding: .6rem .8rem; border-radius: 6px; background: var(--free-bg); color: var(--free); font-weight: 600; }
.confirm-buttons { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.cid-full { font-size: .8rem; word-break: break-all; }
