/* START GROUP — visual layer. Business forms and navigation keep their structure. */
:root {
  --bg: #101217;
  --body-bg: #101217;
  --surface: #191c23;
  --surface-2: #22262e;
  --surface-3: #14171d;
  --border: #30353f;
  --text: #f2f3f5;
  --muted: #a3abb9;
  --primary: #f5a623;
  --accent-text: #ffc46a;
  --primary-soft: #f5a62317;
  --topbar-bg: #191c23f5;
  --topbar-border: #30353f;
  --nav-bg: #191c23f5;
  --card-shadow: 0 2px 6px #0000000d;
  --shadow: 0 20px 70px #00000050;
  --soft-bg: #ffffff06;
  --table-head-bg: #22262e;
}

:root[data-theme="light"] {
  --bg: #f3f4f6;
  --body-bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #f9fafb;
  --border: #dce0e6;
  --text: #222731;
  --muted: #616b7b;
  --accent-text: #925900;
  --primary-soft: #fff5e2;
  --topbar-bg: #fffffff5;
  --topbar-border: #e1e4e9;
  --nav-bg: #fffffff5;
  --card-shadow: 0 2px 6px #172b4d05;
  --shadow: 0 20px 70px #172b4d24;
  --soft-bg: #22273105;
  --table-head-bg: #f5f6f8;
}

body { line-height: 1.45; -webkit-font-smoothing: antialiased; }
.page { width: min(1240px, 100%); }
.topbar { padding-block: 14px; gap: 12px; }
.brand-heading { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-heading > div { min-width: 0; }
.brand-mark { flex-shrink: 0; border-radius: 11px; }
.eyebrow { color: var(--accent-text); font-size: .65rem; letter-spacing: .11em; font-weight: 750; }
.topbar h1 { font-size: 1.25rem; line-height: 1.25; letter-spacing: -.025em; }
.user-greeting { margin-top: 3px; font-size: .76rem; font-weight: 450; }
.btn, .icon-btn { border-radius: 9px; min-height: 44px; font-weight: 650; }
.btn { font-size: .88rem; }
.btn:hover, .icon-btn:hover { transform: none; background: var(--surface-3); }
.btn.primary:hover { background: #ffb83e; border-color: #ffb83e; }
.btn.success:hover { background: var(--success); filter: brightness(1.1); }
.btn.danger:hover { background: var(--danger); filter: brightness(1.1); }
.btn:disabled { cursor: wait; opacity: .65; }
.btn.small { border-radius: 8px; min-height: 36px; font-size: .8rem; }
.icon-btn { min-height: 38px; width: 38px; min-width: 38px; }
.quick-links { gap: 9px; margin-bottom: 22px; }
.quick-links .btn { min-height: 44px; }
.action-plus { font-size: 1.45rem; line-height: 1; font-weight: 400; }
.metric-card, .card, .panel, .empty-state { border-radius: 12px; }
.panel { padding: 22px; }
.card { gap: 14px; padding: 19px; }
.card h2, .card h3 { font-size: .98rem; line-height: 1.4; }
.card p { font-size: .86rem; line-height: 1.5; }
.card h2 a:hover, .card h3 a:hover { color: var(--accent-text); }
.section-head { margin-bottom: 20px; }
.section-head h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.015em; }
.section-head p { font-size: .8rem; line-height: 1.5; margin-top: 5px; }
.metric-card { padding: 19px; min-height: 135px; }
.metric-card p { font-size: .8rem; font-weight: 550; }
.metric-card strong { font-size: 1.9rem; font-weight: 700; letter-spacing: -.035em; margin-top: 12px; font-variant-numeric: tabular-nums; }
.metric-card span { margin-top: 10px; font-size: .74rem; }
.dashboard .metric-card:nth-child(3) { border-top: 3px solid var(--primary); padding-top: 17px; background: linear-gradient(115deg, var(--primary-soft), transparent), var(--surface); }
.dashboard .metric-card:nth-child(3) strong { color: var(--accent-text); }
.pill { min-height: 25px; font-size: .73rem; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.pill.primary { color: var(--accent-text); }
.type-icon { background: var(--surface-2); border-color: var(--border); border-radius: 8px; box-shadow: none; }
.toolbar { padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; gap: 10px; }
.toolbar-field span { font-weight: 650; letter-spacing: .04em; }
input, select, textarea { min-width: 0; min-height: 44px; border-radius: 8px; font-weight: 450; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
label { font-weight: 600; line-height: 1.4; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); min-height: auto; }
input:disabled, select:disabled { cursor: not-allowed; }
.summary-item { border-radius: 10px; }
.summary-item strong, td, .money-pill { font-variant-numeric: tabular-nums; }
th { font-size: .69rem; font-weight: 650; letter-spacing: .04em; }
td { font-size: .86rem; padding-block: 15px; }
tbody tr:hover { background: var(--soft-bg); }
.table-wrap { border-radius: 10px; }
.modal-backdrop { backdrop-filter: blur(4px); }
.modal-panel { padding: 24px; border-radius: 16px; }
.modal-head { align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.modal-actions { padding-top: 16px; border-top: 1px solid var(--border); }
.modal-actions .btn { min-height: 44px; }
.empty-state { padding: 38px 24px; box-shadow: none; }
.bottom-nav { gap: 4px; }
.bottom-nav a { font-weight: 600; }
.bottom-nav svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.bottom-nav a.active { color: var(--accent-text); }
.bottom-nav a:hover { color: var(--text); background: var(--soft-bg); }
.bottom-nav a.active:hover { color: var(--accent-text); background: var(--primary-soft); }

/* Dashboard: equal overview panels, compact lists, readable amounts. */
.dashboard-overview, .dashboard-performance { margin-top: 22px; gap: 20px; }
.dashboard-chart { display: flex; flex-direction: column; }
.dashboard-chart .bar-chart { flex: 1; align-content: end; grid-template-columns: repeat(var(--bar-count, 6), minmax(0, 1fr)); overflow: visible; gap: 14px; margin-top: 18px; }
.dashboard-chart .bar-track { height: 230px; border: 0; border-radius: 5px; background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--border) calc(25% - 1px), var(--border) 25%); }
.dashboard-chart .bar-track span { left: 18%; right: 18%; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #f5b447, #de911e); }
.dashboard-chart .bar-item strong { font-size: .75rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.dashboard-chart .bar-item small { margin-top: 5px; }
.section-count { display: inline-flex; vertical-align: middle; padding: 2px 7px; margin-left: 5px; border-radius: 6px; background: var(--primary-soft); color: var(--accent-text); font-size: .72rem; font-weight: 650; }
.alert-list { max-height: 324px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; padding-right: 5px; }
.alert-list:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.alert-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.alert-row:first-child { padding-top: 0; }
.alert-row:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-row h3 { margin: 0; font-size: .8rem; line-height: 1.45; font-weight: 650; }
.alert-row h3 a:hover { color: var(--accent-text); }
.alert-row .type-icon { height: 27px; width: 27px; font-size: .9rem; }
.alert-row p { color: var(--muted); font-size: .72rem; margin: 4px 0 0 37px; line-height: 1.4; }
.alert-row .pill { font-size: .68rem; white-space: nowrap; border: 0; }
.alert-row .card-head { gap: 8px; }
.performance-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--border); }
.performance-row:first-child { padding-top: 0; }
.performance-row:last-child { border-bottom: 0; padding-bottom: 0; }
.rank { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); height: 26px; border-radius: 7px; font-size: .75rem; font-variant-numeric: tabular-nums; }
.performance-info h3 { margin: 1px 0 4px; font-size: .84rem; line-height: 1.4; font-weight: 650; overflow-wrap: anywhere; }
.performance-info a:hover { color: var(--accent-text); }
.performance-info p { margin: 0; font-size: .74rem; color: var(--muted); overflow-wrap: anywhere; }
.performance-info .performance-meta { margin-top: 5px; font-size: .68rem; line-height: 1.6; }
.performance-value { text-align: right; }
.performance-value strong { display: block; color: var(--accent-text); font-size: .98rem; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.performance-value span { color: var(--muted); font-size: .65rem; }

/* Reuse the existing brand asset on the sign-in page. */
.login-screen { background: radial-gradient(ellipse at 50% 0, #f5a62312, transparent 65%), var(--bg); }
.login-panel { padding: 36px; border-radius: 20px; border-top: 3px solid var(--primary); }
.login-brand { display: block; margin: 0 0 26px; }
.login-panel .eyebrow { margin-bottom: 7px; }
.login-panel h1 { font-size: 1.55rem; letter-spacing: -.035em; margin-bottom: 0; }
.login-intro { color: var(--muted); font-size: .9rem; margin: 9px 0 28px; }
.login-panel label { margin-bottom: 18px; }
.login-panel .btn { margin-top: 6px; }
.login-panel .form-error:empty { display: none; }

@media (min-width: 980px) {
  .topbar { padding-inline: max(24px, calc((100vw - 1240px) / 2 + 24px)); }
  .page { padding: 26px 24px; }
  .bottom-nav { align-self: stretch; width: 100%; max-width: none; margin: 0; padding: 0 max(24px, calc((100vw - 1240px) / 2 + 24px)); border: 0; border-bottom: 1px solid var(--border); border-radius: 0; gap: 9px; }
  .bottom-nav a { min-width: 0; min-height: 54px; padding: 0 13px; gap: 8px; border-radius: 0; border-bottom: 2px solid transparent; font-size: .78rem; }
  .bottom-nav a.active { border-bottom-color: var(--primary); background: transparent; }
  .bottom-nav a[data-route="nuovo-aggio"] { margin-left: auto; }
  .bottom-nav svg { width: 18px; height: 18px; }
}

@media (min-width: 680px) and (max-width: 979px) {
  .dashboard-overview, .dashboard-performance { grid-template-columns: 1fr; }
}

@media (max-width: 679px) {
  .page { padding: 18px 14px; }
  .topbar { padding: 12px 14px; gap: 9px; }
  .brand-mark { display: none; }
  .topbar h1 { font-size: 1.08rem; }
  .eyebrow { font-size: .58rem; }
  .user-greeting { font-size: .7rem; }
  .topbar > #theme-toggle { padding-inline: 9px; font-size: .72rem; }
  .panel { padding: 18px; }
  .card { padding: 16px; }
  .metric-grid { gap: 10px; }
  .metric-card { padding: 15px; min-height: 128px; }
  .metric-card strong { font-size: 1.6rem; }
  .metric-card p { font-size: .76rem; }
  .metric-card span { font-size: .68rem; }
  .dashboard .metric-card:nth-child(3) { padding-top: 13px; }
  .quick-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
  .quick-links .btn { font-size: .77rem; padding-inline: 8px; }
  .dashboard-overview, .dashboard-performance { margin-top: 18px; gap: 18px; }
  .dashboard-chart .bar-chart { gap: 7px; }
  .dashboard-chart .bar-track { height: 165px; }
  .dashboard-chart .bar-track span { left: 12%; right: 12%; }
  .dashboard-chart .bar-item strong { font-size: .64rem; }
  .dashboard-chart .bar-item small { font-size: .65rem; }
  .performance-row { gap: 9px; grid-template-columns: 23px minmax(0, 1fr) auto; }
  .performance-value strong { font-size: .86rem; }
  .performance-info h3 { font-size: .8rem; }
  .modal-panel { padding: 20px 16px; }
  .toolbar { padding: 12px; }
  .toolbar > select, .toolbar > input { flex-basis: 100%; }
  .toolbar > .toolbar-field { flex: 1 1 calc(50% - 5px); }
  input, select, textarea { font-size: 16px; }
  .bottom-nav a { font-size: .64rem; }
  .bottom-nav { box-shadow: 0 -4px 18px #0000000a; }
}
