/* Wave 6 — finestre: page-head, toolbar, form-grid, split, tabs, login */

.page-head{
  display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;
  gap:.75rem 1.25rem;margin:0 0 1rem;
}
.page-head h1{margin:0;font-size:1.35rem;letter-spacing:-.02em}
.page-toolbar{display:flex;flex-wrap:wrap;gap:.4rem;align-items:center}
.page-toolbar .btn,.page-toolbar button{
  font-size:.82rem;padding:.38rem .75rem;border-radius:6px
}
.page-toolbar .btn-ghost{
  background:#fff;color:var(--ink,#0f172a);border:1px solid #cbd5e1
}
html[data-theme="dark"] .page-toolbar .btn-ghost{background:#1e293b;color:#e2e8f0;border-color:#334155}
html.dark .page-toolbar .btn-ghost{background:#1e293b;color:#e2e8f0;border-color:#334155}

.form-panel{display:none;margin-bottom:1rem}
.form-panel.open{display:block}
.form-panel > .card{margin-bottom:0}

/* Form 2 colonne, gruppi */
form.form-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:.65rem 1rem;align-items:end
}
form.form-grid label{display:flex;flex-direction:column;gap:.25rem;margin:0;font-size:.82rem;color:#475569}
form.form-grid label input,form.form-grid label select,form.form-grid label textarea{
  font-size:.92rem;width:100%
}
form.form-grid label.span-2,form.form-grid .span-2,form.form-grid button,
form.form-grid .btn,form.form-grid p{grid-column:1 / -1}
form.form-grid textarea{min-height:4.5rem}
@media(max-width:720px){form.form-grid{grid-template-columns:1fr}}

.form-group{grid-column:1 / -1;display:grid;grid-template-columns:1fr 1fr;gap:.65rem 1rem}
.form-group-title{
  grid-column:1 / -1;font-size:.72rem;font-weight:700;letter-spacing:.08em;
  text-transform:uppercase;color:#64748b;margin:.25rem 0 0;padding-top:.4rem;
  border-top:1px solid #e2e8f0
}
html[data-theme="dark"] .form-group-title{border-color:#334155;color:#94a3b8}
html.dark .form-group-title{border-color:#334155;color:#94a3b8}

/* Split lista / dettaglio */
.split-view{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(260px,.8fr);gap:1rem;align-items:start}
.split-view .split-list{min-width:0}
.split-detail{
  position:sticky;top:.75rem;background:#fff;border:1px solid #e2e8f0;border-radius:10px;
  padding:1rem 1.1rem;min-height:8rem
}
html[data-theme="dark"] .split-detail{background:#1e293b;border-color:#334155}
html.dark .split-detail{background:#1e293b;border-color:#334155}
.split-detail .sd-empty{color:#94a3b8;font-size:.9rem;margin:1.5rem 0}
.split-detail h3{margin:0 0 .6rem;font-size:1.05rem}
.split-detail dl{margin:0;display:grid;grid-template-columns:auto 1fr;gap:.3rem .75rem;font-size:.88rem}
.split-detail dt{color:#64748b;font-weight:600}
.split-detail dd{margin:0}
.split-detail .sd-actions{margin-top:.85rem;display:flex;flex-wrap:wrap;gap:.4rem}
table.tbl tbody tr.split-on, .card table tbody tr.split-on{
  outline:2px solid var(--brand,#0d6efd);outline-offset:-2px;background:#eff6ff
}
html[data-theme="dark"] table tbody tr.split-on{background:#1e3a5f}
html.dark table tbody tr.split-on{background:#1e3a5f}
@media(max-width:900px){.split-view{grid-template-columns:1fr}}

/* Linguette scheda documento */
.page-tabs{margin:0 0 1rem}
.page-tabs-bar{display:flex;flex-wrap:wrap;gap:.15rem;border-bottom:1px solid #e2e8f0;margin-bottom:.75rem}
.page-tabs-bar button{
  background:transparent;border:0;border-bottom:2px solid transparent;
  padding:.5rem .85rem;font-size:.88rem;cursor:pointer;color:#64748b;font-weight:600
}
.page-tabs-bar button.on{color:var(--brand,#0d6efd);border-bottom-color:var(--brand,#0d6efd)}
.page-tab{display:none}
.page-tab.on{display:block}
html[data-theme="dark"] .page-tabs-bar{border-color:#334155}
html.dark .page-tabs-bar{border-color:#334155}

/* Sort header */
th.sortable{cursor:pointer;user-select:none;white-space:nowrap}
th.sortable:hover{color:var(--brand,#0d6efd)}
th.sortable .sort-ico{font-size:.65rem;margin-left:.25rem;opacity:.45}
th.sortable.asc .sort-ico,th.sortable.desc .sort-ico{opacity:1}

/* Login brand */
body:has(.login-wrap){background:linear-gradient(160deg,#0f172a 0%,#1e3a5f 55%,#0d6efd 140%)}
.login-wrap .card{
  border-radius:14px;box-shadow:0 24px 60px rgba(15,23,42,.45);
  border:1px solid rgba(255,255,255,.08)
}
.login-wrap .login-brand{color:#0d6efd}
.login-wrap h1{font-size:1.45rem;letter-spacing:-.03em}
.login-wrap .muted{font-size:.82rem}

.sdata-modal{position:fixed;inset:0;z-index:4000;background:rgba(15,23,42,.45);display:flex;align-items:center;justify-content:center;padding:1rem}
.sdata-modal-card{background:#fff;color:#0f172a;border-radius:10px;padding:1.1rem 1.2rem;max-width:22rem;width:100%;box-shadow:0 18px 50px rgba(15,23,42,.35)}
.sdata-modal-card p{margin:0 0 1rem;font-size:.95rem;line-height:1.4}
.sdata-modal-actions{display:flex;gap:.5rem;justify-content:flex-end}
html.dark .sdata-modal-card{background:#1e293b;color:#e7eef0}

html.dark .flash.ok, html.dark .flash.success, html[data-theme="dark"] .flash.ok { color: #d1fae5; background: #064e3b; border-color: #059669; }
html.dark .empty, html.dark .muted.empty, html.dark .stat-card .muted, html[data-theme="dark"] .empty { color: #cbd5e1; }
html.dark .agenda, html.dark .agenda td, html.dark .cal td, html[data-theme="dark"] .agenda { color: #e2e8f0; }
html.dark .ring, html.dark canvas, html[data-theme="dark"] .kpi-ring { filter: none; }
html.dark body { background: #0f172a; }

html.dark .flash.err, html.dark .flash.error, html[data-theme="dark"] .flash.err {
  color: #fecaca; background: #7f1d1d; border-color: #f87171;
}
html.dark .msg-box, html.dark .wa-preview, html.dark .client-msg, html.dark textarea[name="message"],
html[data-theme="dark"] .msg-box, html[data-theme="dark"] .wa-preview {
  color: #e2e8f0; background: #1e293b;
}
html.dark .btn.tiny, html.dark .btn.small.secondary { min-height: 2rem; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
