/* Layout e controlli dell'app (sostituiscono i componenti Streamlit) */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; }
body { min-height: 100vh; }
.hidden { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: 'Syne', sans-serif; letter-spacing: -0.02em; margin: 0.6em 0 0.4em; }
h1 { font-size: 2rem; font-weight: 800; } h2 { font-size: 1.4rem; font-weight: 700; } h3 { font-size: 1.1rem; font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.muted { color: var(--text2); } .small { font-size: 0.8rem; }

#app { display: flex; min-height: 100vh; }
#sidebar { width: 310px; flex: 0 0 310px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
#main { flex: 1; min-width: 0; padding: 20px 28px 60px; max-width: 1400px; }
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar { position: static; width: 100%; height: auto; flex: none; }
  #main { padding: 14px; }
}
.lbl { font-size: 0.8rem; color: var(--text2); margin-top: 4px; }
input[type=date], input[type=number], input[type=text], select, textarea {
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
  font-family: 'DM Sans', sans-serif; padding: 8px 10px; width: 100%; color-scheme: dark;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border: none; border-radius: var(--radius-sm);
  font-family: 'Syne', sans-serif; font-weight: 600; font-size: 0.85rem; padding: 10px 16px; width: 100%; cursor: pointer;
  box-shadow: 0 2px 12px rgba(79,142,247,0.3); }
.btn:hover { opacity: .9; } .btn:disabled { opacity: .5; cursor: wait; }
.btn-sec { background: var(--bg3); border: 1px solid var(--border2); box-shadow: none; }
.btn-auto { width: auto; }
.progress { background: var(--bg3); border-radius: 999px; height: 22px; position: relative; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { background: linear-gradient(90deg, var(--accent), var(--accent2)); height: 100%; width: 0%; transition: width .3s; }
.progress-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; }
.sidebar-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 10px; }

.checks { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.checks label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.scroll { max-height: 260px; overflow-y: auto; padding: 6px; background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* expander = <details> */
details.exp { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
details.exp:hover { border-color: var(--border2); }
details.exp > summary { cursor: pointer; padding: 12px 16px; font-weight: 500; list-style: none; }
details.exp > summary::before { content: '▸'; display: inline-block; margin-right: 8px; color: var(--accent); transition: transform .15s; }
details.exp[open] > summary::before { transform: rotate(90deg); }
details.exp > summary::-webkit-details-marker { display: none; }
details.exp > .exp-body { padding: 4px 16px 16px; }
details.exp details.exp { background: var(--bg); }

/* colonne e metriche */
.cols { display: grid; gap: 14px; } .cols-2 { grid-template-columns: 1fr 1fr; } .cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); } .cols-pick { grid-template-columns: 1fr 1.5fr; } .cols-vs { grid-template-columns: 4fr 0.6fr 4fr; align-items: center; }
@media (max-width: 860px) { .cols-2, .cols-3, .cols-4, .cols-pick, .cols-vs { grid-template-columns: 1fr; } }
.metric { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.metric-l { font-size: 0.72rem; color: var(--text2); text-transform: uppercase; letter-spacing: .08em; }
.metric-v { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.metric-d { font-size: .75rem; color: var(--text2); }

/* tabs */
.tabs { display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; margin: 14px 0; flex-wrap: wrap; }
.tab { font-family: 'Syne', sans-serif; font-weight: 600; font-size: .85rem; color: var(--text2); background: transparent; border: none;
  border-radius: var(--radius-sm); padding: 8px 16px; cursor: pointer; }
.tab.attivo { background: var(--accent); color: #fff; box-shadow: var(--glow-blue); }

/* tabelle */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
table.tbl th { background: var(--bg3); text-align: left; padding: 8px 10px; font-weight: 600; color: var(--text2); white-space: nowrap; }
table.tbl td { padding: 7px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
table.tbl tr:hover td { background: rgba(79,142,247,0.05); }
.num { text-align: right; font-family: 'DM Mono', monospace; }

.alert { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0; font-size: .9rem; }
.alert-warn { border-color: rgba(245,158,11,.5); } .alert-err { border-color: rgba(239,68,68,.5); } .alert-ok { border-color: rgba(34,197,94,.5); }
.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; }
textarea.json { height: 360px; font-family: 'DM Mono', monospace; font-size: .75rem; }
.svg-chart { width: 100%; height: 220px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); }
.inline-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.inline-ctl input[type=number] { width: 120px; }
.inline-ctl .btn { width: auto; padding: 8px 14px; }
