/* ===== Portale Studio Riba & Lerda — tema navy + oro (come home originale) ===== */
:root {
    color-scheme: light;             /* UI chiara: niente rese scure illeggibili */
    --navy: #2d3f55;
    --navy-dark: #24334a;
    --gold: #b8924a;
    --gold-dark: #9e7a3a;
    --ink: #333;
    --muted: #888;
    --bg: #ebebeb;
    --line: #e2e6ea;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
}

/* Campi form sempre leggibili in qualsiasi tema */
input, select, textarea {
    background: #fff; color: var(--ink);
    border: 1px solid #9aa7b8; border-radius: 6px;
    font-size: .95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); border-color: var(--navy); }

/* ===== Shell / header (stile home originale) ===== */
.page-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; }
.site-header {
    background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.1);
    display: flex; align-items: stretch; overflow: hidden;
    width: 94%; max-width: 1200px; margin: 32px auto 0; border-radius: 10px;
}
.header-left { background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 20px 28px; min-width: 150px; }
.header-left img { height: 58px; width: auto; }
.header-right { padding: 20px 28px; display: flex; flex-direction: column; justify-content: center; flex: 1; }
.header-right h1 { font-size: 1.45rem; font-weight: 700; color: var(--navy); }
.header-right p { font-size: .85rem; color: #999; margin-top: 4px; }
.header-user { display: flex; align-items: center; gap: 10px; padding: 0 22px; }
.user-avatar { width: 38px; height: 38px; background: var(--gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .82rem; font-weight: 700; color: #fff; }
.user-name { font-size: .82rem; color: #666; margin-bottom: 3px; }
.btn-logout { display: inline-block; background: none; border: 1px solid #ddd; border-radius: 6px; padding: 4px 12px; font-size: .75rem; color: #999; cursor: pointer; text-decoration: none; transition: all .2s; }
.btn-logout:hover { border-color: var(--gold); color: var(--gold); }

.content { width: 94%; max-width: 1200px; margin: 28px auto 10px; }
.page-hero { text-align: center; margin: 1.4rem 0 1rem; }
.hero-icon { font-size: 2.5rem; line-height: 1; }
.page-hero h1 { font-size: 1.95rem; margin: .35rem 0 0; }
.hero-sub { color: var(--muted); font-size: .9rem; margin-top: .25rem; }
.actions-row { display: flex; justify-content: flex-end; margin-bottom: .5rem; }
.content h1 { color: var(--navy); font-size: 1.5rem; margin-bottom: .3rem; }
.site-footer { margin-top: auto; padding: 22px; color: var(--navy); font-size: .9rem; font-weight: 600; text-align: center; border-top: 1px solid #e3e7ec; }
.login-footer { margin-top: 1.2rem; color: #fff; font-size: .9rem; font-weight: 600; text-align: center; opacity: .9; }
.subtitle { color: var(--muted); margin-bottom: 1rem; }
.back-link { color: var(--gold-dark); text-decoration: none; font-size: .85rem; display: inline-block; margin-bottom: .6rem; }
.back-link:hover { text-decoration: underline; }

/* ===== Griglia card app ===== */
.section-title { margin: 8px 0 18px; color: #888; font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin-bottom: 20px; }
.app-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); text-decoration: none; color: inherit; overflow: hidden; transition: all .22s ease; display: flex; flex-direction: column; }
.app-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.card-top { background: var(--navy); padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.card-icon { font-size: 1.4rem; width: 42px; height: 42px; background: rgba(255,255,255,.1); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.card-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); font-weight: 600; }
.card-title { font-size: .95rem; font-weight: 600; color: #fff; margin-top: 2px; }
.card-body { padding: 16px 20px 20px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.card-desc { font-size: .82rem; color: #888; line-height: 1.5; flex: 1; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-btn { display: inline-block; background: var(--gold); color: #fff; font-size: .78rem; font-weight: 600; padding: 8px 16px; border-radius: 6px; text-align: center; }
.app-card:hover .card-btn { background: var(--gold-dark); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .65rem; font-weight: 700; padding: 5px 11px; border-radius: 20px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.badge.attivo { background: #e8f5e9; color: #2e7d32; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #4caf50; animation: pulse-green 1.8s infinite; }
@keyframes pulse-green { 0% { box-shadow: 0 0 0 0 rgba(76,175,80,.6);} 70% { box-shadow: 0 0 0 7px rgba(76,175,80,0);} 100% { box-shadow: 0 0 0 0 rgba(76,175,80,0);} }
.expo { font-size: .68rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.expo.int { background: #eef1f4; color: #667; }
.expo.ext { background: #f4ecd9; color: var(--gold-dark); }

/* ===== Toolbar / tabella ===== */
.toolbar { display: flex; gap: .6rem; align-items: center; margin: 1rem 0 .8rem; }
.search-input { padding: .55rem .75rem; min-width: 280px; }
.az-bar { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 12px; }
.az { cursor: pointer; padding: 4px 10px; border: 0; border-radius: 6px; font-size: .78rem; font-weight: 600; background: #eef1f4; color: #556; font-family: inherit; }
.az:hover { background: #dde3ea; }
.az.active { background: var(--navy); color: #fff; }
.btn { background: var(--navy); color: #fff; border: 0; padding: .55rem 1rem; border-radius: 6px; cursor: pointer; text-decoration: none; font-size: .9rem; display: inline-block; }
.btn:hover { background: var(--navy-dark); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid #c2ccd6; }
.btn-ghost:hover { background: #f2f5f8; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-gold { background: var(--gold); }
.btn-gold:hover { background: var(--gold-dark); }
.count { color: var(--muted); font-size: .85rem; margin-bottom: .6rem; }
.table-wrap { overflow-x: auto; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); background: #fff; }
table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid thead th { background: var(--navy); color: #fff; font-weight: 600; text-align: left; padding: .7rem .8rem; white-space: nowrap; }
.rep-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 1.2rem; width: 100%; max-width: none; margin-bottom: 14px; }
.rep-card .fin-title { font-size: .95rem; color: var(--navy); font-weight: 700; margin-bottom: .6rem; }
table.grid thead tr.filter-row th { background: #fff; padding: 3px 5px; }
table.grid thead tr.filter-row input { width: 100%; font-size: 11px; padding: 3px 5px; border: 1px solid #ccc; border-radius: 4px; color: var(--ink); }
.rep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .rep-grid { grid-template-columns: 1fr; } }
.stat-sub { font-size: .78rem; color: var(--mut, #6b7480); margin-top: 2px; }
.dpos, .stat-val.dpos { color: #1a7f4b !important; } .dneg, .stat-val.dneg { color: #b4232a !important; }
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { background: #3a4f68; }
table.grid thead th.sort-asc::after { content: " ▲"; font-size: .72em; opacity: .9; }
table.grid thead th.sort-desc::after { content: " ▼"; font-size: .72em; opacity: .9; }
table.grid td { padding: .6rem .8rem; border-bottom: 1px solid #edf0f3; color: var(--ink); white-space: nowrap; }
table.grid tbody tr:nth-child(even) { background: #f8fafb; }
table.grid tbody tr:hover { background: #f0f4f8; }
.cell-empty { color: #c2c8cf; }
.name-cell { font-weight: 600; color: var(--navy); }

/* ===== Pratiche: head, filtri, tabella ===== */
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.head-row h1 { margin-bottom: 0; }
.stato-toggle { display: inline-flex; border: 1px solid #c2ccd6; border-radius: 8px; overflow: hidden; margin: 1rem 0 .2rem; }
.stbtn { border: 0; background: #fff; color: #556; padding: .55rem 1.1rem; font-size: .88rem; font-weight: 600; cursor: pointer; font-family: inherit; border-right: 1px solid #e2e6ea; text-decoration: none; display: inline-block; }
.stbtn:last-child { border-right: 0; }
.stbtn:hover { background: #f2f5f8; }
.stbtn.active { background: var(--navy); color: #fff; }
.filtri { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 .8rem; }
.filtri select, .filtri input[type=date] { padding: .5rem .6rem; }
.flt-date { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td.causale { white-space: normal; max-width: 260px; color: #555; }
.badge.da-fare { background: #fdf0e4; color: #9e6b1f; }
.badge.incompleta { background: #fff6d6; color: #8a6d0f; }
.badge.scaduto { background: #fdecec; color: #b3352f; }

/* ===== Compensazioni ===== */
.row-link { color: var(--navy); text-decoration: none; font-weight: 600; }
.row-link:hover { text-decoration: underline; }
.riga-eliminata { opacity: .55; }
.btn-group { display: flex; gap: .5rem; align-items: center; }
.banner-warn { background: #fff6d6; color: #8a6d0f; border: 1px solid #f0e0a8; border-radius: 8px; padding: .7rem 1rem; margin: .6rem 0; font-size: .9rem; }
.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin: 1rem 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; }
.stat.highlight { background: var(--navy); border-color: var(--navy); }
.stat.highlight .stat-lbl, .stat.highlight .stat-val { color: #fff; }
.stat-lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-val { font-size: 1.1rem; font-weight: 600; color: var(--navy); margin-top: .2rem; }
.sec { font-size: 1.1rem; color: var(--navy); margin: 1.4rem 0 .6rem; }
.note-line { color: #555; font-size: .9rem; }
.add-comp { margin-top: 1.2rem; max-width: none; }
.export-bar { display: flex; align-items: center; gap: .5rem; margin: .6rem 0; flex-wrap: wrap; }
.export-hint { color: var(--muted); font-size: .85rem; margin-right: .2rem; }
.row-actions { display: flex; gap: .4rem; }
table.grid th.chk, table.grid td.chk { width: 34px; text-align: center; }
table.grid td.chk input, table.grid th.chk input { width: 16px; height: 16px; }
table.grid.grid-compact { font-size: .84rem; }
table.grid.grid-compact th, table.grid.grid-compact td { padding: .5rem .55rem; }
table.grid td.causale { white-space: normal; max-width: 220px; color: #555; }

/* ===== Form modifica ===== */
.form-wide { max-width: 980px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.grid2 > *, .grid3 > * { min-width: 0; }
.inline2 { display: flex; gap: .4rem; }
.inline2 input { width: 100%; min-width: 0; }
.hint { color: var(--muted); font-weight: 400; font-size: .72rem; }
.fin-box { background: #faf6ee; border: 1px solid #e8dcc2; border-radius: 8px; padding: .9rem 1rem; margin: .4rem 0 1rem; }
.fin-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-dark); font-weight: 700; margin-bottom: .5rem; }
.readonly { padding: .6rem 0; font-weight: 600; color: var(--navy); }
.form-card textarea, .form-card select { width: 100%; padding: .55rem .7rem; }
.btn-danger { background: #b3352f; }
.btn-danger:hover { background: #8f2a25; }
.del-form { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: 1rem; }


.form-card { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); padding: 1.6rem; max-width: 480px; }
.form-card .field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.1rem; }
.form-card .field label { font-size: .85rem; color: var(--navy); font-weight: 700; }
.form-card .field input { width: 100%; padding: .6rem .7rem; }
.form-card .field-check label { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); }
.form-actions { display: flex; gap: .6rem; margin-top: .3rem; }
.ok-msg { background: #e8f5e9; color: #2e7d32; padding: .5rem .8rem; border-radius: 6px; font-size: .85rem; margin-bottom: .8rem; }
.placeholder { color: var(--muted); background: #fff; border: 1px dashed #cdd6e0; border-radius: 10px; padding: 1.2rem; }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--navy); padding: 1rem; }
.login-card { background: #fff; border-radius: 14px; padding: 2rem 2.2rem 2.2rem; width: 100%; max-width: 390px; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.login-logo { background: var(--navy); border-radius: 10px; padding: 16px; display: inline-flex; margin-bottom: 1rem; }
.login-logo img { height: 60px; }
.login-card h1 { font-size: 1.3rem; color: var(--navy); margin-bottom: 1.4rem; }
.login-card .field { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .3rem; text-align: left; }
.login-card label { font-size: .82rem; color: #556; font-weight: 600; }
.login-card input { padding: .6rem .7rem; width: 100%; }
.login-card .field-check { display: flex; flex-direction: row; align-items: center; gap: .5rem; margin-bottom: 1rem; text-align: left; }
.login-card .field-check input { width: auto; padding: 0; }
.login-card .field-check label { font-weight: 500; color: #556; cursor: pointer; }
.btn-login { width: 100%; margin-top: .5rem; background: var(--gold); color: #fff; border: 0; padding: .7rem; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn-login:hover { background: var(--gold-dark); }
.login-ok { background: #e8f6ee; color: #1f7a42; padding: .55rem .8rem; border-radius: 8px; font-size: .85rem; margin-bottom: .9rem; text-align: left; }
.login-note { font-size: .82rem; color: #556; text-align: left; margin-bottom: 1rem; }
.login-link { margin-top: 1rem; font-size: .85rem; }
.login-link a { color: var(--navy); }
.login-error { background: #fdecec; color: #b32121; padding: .55rem .8rem; border-radius: 8px; font-size: .85rem; margin-bottom: .6rem; text-align: left; }

/* ===== Blazor base ===== */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; font-size: .8rem; }
#blazor-error-ui { background: #ffe8e8; color: #b32121; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Anagrafica: modifica inline in tabella (celle sempre editabili) */
.nowrap { white-space: nowrap; }
.cell-in { width: 100%; min-width: 56px; font-size: 12px; padding: 3px 5px; border: 1px solid #ccc; border-radius: 4px; color: var(--ink); background: #fff; }
.cell-in:focus { border-color: var(--gold, #b8924a); outline: none; }
.cell-cod { font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; }
.stato-cell { text-align: center; font-weight: 700; color: #1a7f4b; white-space: nowrap; }
.login-wrap > div { width: 100%; max-width: 390px; }

/* ===== Home: preferiti ===== */
.fav-section { background: #f6efdf; border: 1px solid #e3d2a8; border-radius: 12px; padding: 18px 18px 6px; margin-bottom: 22px; }
.fav-section .section-title { color: var(--gold-dark); margin-top: 0; }
.section-title .count { font-weight: 700; color: var(--gold-dark); }
.fav-hint { font-size: .78rem; color: var(--muted); margin: -6px 0 14px; }
.app-wrap { position: relative; display: flex; flex-direction: column; min-width: 0; transition: transform .22s ease; }
.app-wrap:hover { transform: translateY(-4px); }
.app-wrap > .app-card { flex: 1; }
.app-wrap > .app-card:hover { transform: none; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.app-wrap .card-top { padding-right: 58px; }
.app-wrap.is-fav .card-top { padding-left: 34px; }
.app-wrap .star { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 8px; border: 0; background: rgba(255,255,255,.1); color: #c5cbd3; font-size: 1.25rem; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s, transform .15s; }
.app-wrap .star:hover:not(:disabled) { background: rgba(255,255,255,.22); color: #f0d48a; transform: scale(1.08); }
.app-wrap .star[aria-pressed="true"] { color: #f5c94a; background: rgba(255,255,255,.16); }
.app-wrap .star:disabled { cursor: not-allowed; opacity: .55; }
.app-wrap .star:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.app-wrap .order { position: absolute; top: 0; left: 0; z-index: 1; background: var(--gold); color: #fff; font-size: .7rem; font-weight: 700; padding: 3px 9px 3px 8px; border-radius: 10px 0 8px 0; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .fav-section { padding-inline: 12px; } }
@media (prefers-reduced-motion: reduce) { .app-wrap, .app-wrap .star { transition: none; } .app-wrap:hover { transform: none; } }

/* riga dei totali in fondo agli elenchi (Reporting) */
table.grid tr.tot-row td { background: #eef1f4; color: var(--navy); font-weight: 700; border-top: 2px solid var(--navy); border-bottom: 0; }

/* ===== Testata del portale su cellulare (≤ 760px): compatta, utente su una riga propria ===== */
@media (max-width: 760px) {
    .site-header { flex-wrap: wrap; width: 96%; margin-top: 12px; }
    .header-left { padding: 10px 14px; min-width: 0; }
    .header-left img { height: 38px; }
    .header-right { padding: 10px 14px; flex: 1 1 0; min-width: 0; }
    .header-right h1 { font-size: 1rem; line-height: 1.25; }
    .header-right p { font-size: .75rem; margin-top: 2px; }
    .header-user { width: 100%; padding: 8px 14px; border-top: 1px solid #eef1f4; gap: 8px; }
    .user-avatar { width: 30px; height: 30px; font-size: .72rem; }
    .content { width: 96%; margin-top: 14px; }
}
