/* ═══════════════════════════════════════════════════════════════
   assets/style.css  –  L'Eredità dell'Onore
   Tema: Art Deco Military Archive
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts: Cinzel (titoli) + Cormorant Garamond (corpo) + JetBrains Mono (dati) */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
    /* Palette */
    --bg:            #0a0906;
    --surface:       #13110d;
    --surface-2:     #1c1912;
    --surface-3:     #252118;
    --surface-4:     #2e2a1e;
    --border:        #332e20;
    --border-gold:   #5a4e26;
    --gold:          #c9a84c;
    --gold-light:    #e8c96a;
    --gold-bright:   #f5dfa0;
    --gold-dim:      #8b7035;
    --gold-muted:    #4a3e1a;
    --bronze:        #9b6f3a;
    --bronze-light:  #ffc585;
    --text:          #e8e0cc;
    --text-dim:      #a09070;
    --text-muted:    #5a5040;
    --danger:        #7a2020;
    --danger-light:  #b03030;
    --danger-bg:     #2a0f0f;
    --success:       #2e5c32;
    --success-light: #4a8a50;
    --success-bg:    #0f1f10;
    --warning:       #7a5c10;
    --warning-light: #c9a84c;
    --warning-bg:    #1f1800;
    --info:          #1a3a5c;
    --info-light:    #4a7aac;
    --info-bg:       #0a1520;

    /* Typography */
    --font-display: 'Cinzel', 'Trajan Pro', serif;
    --font-body:    'Arial', 'Palatino Linotype', Georgia, serif;
    --font-mono:    'JetBrains Mono', 'Courier New', monospace;

    /* Spacing */
    --sidebar-w: 260px;
    --radius:    4px;
    --radius-lg: 8px;

    /* Transitions */
    --t-fast:   150ms ease;
    --t-normal: 250ms ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 22px; scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.2;
    min-height: 100vh;
    /* Texture noise sottile */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(201,168,76,0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(155,111,58,0.04) 0%, transparent 50%);
}

a { color: var(--gold); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--gold-light); }

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--gold-light);
    line-height: 1.2;
}

/* ── Layout principale ──────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border-gold);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    /* Nascosta di default: traslata fuori schermo a sinistra */
    transform: translateX(-100%);
    transition: transform 320ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 320ms ease;
    /* Decorazione linea dorata verticale */
    box-shadow: none;
}

/* Sidebar visibile: attivata da JS quando il mouse si avvicina al bordo */
.sidebar--visible {
    transform: translateX(0);
    box-shadow: inset -3px 0 0 0 var(--gold-muted),
                4px 0 30px rgba(0,0,0,0.8);
}

/* Striscia sensibile al bordo sinistro (trigger invisibile) */
.sidebar-trigger {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 18px;
    z-index: 199;
    cursor: e-resize;
    /* Sottile indicatore visivo: linea dorata semitrasparente */
    background: linear-gradient(to right,
        rgba(201,168,76,0.18) 0%,
        rgba(201,168,76,0.04) 60%,
        transparent 100%);
    transition: background 200ms ease;
}

.sidebar-trigger:hover {
    background: linear-gradient(to right,
        rgba(201,168,76,0.35) 0%,
        rgba(201,168,76,0.08) 70%,
        transparent 100%);
}

/* Overlay scuro semitrasparente dietro la sidebar aperta */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 198;
    backdrop-filter: blur(1px);
    transition: opacity 320ms ease;
    opacity: 0;
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}

.sidebar__brand {
    padding: 1.5rem 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-gold);
    background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
}

.sidebar__medal-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--gold-dim);
    border-radius: 50%;
    font-size: 1.1rem;
    color: var(--gold);
    background: var(--surface-3);
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(201,168,76,0.2);
}

.sidebar__title { flex: 1; min-width: 0; }

.sidebar__app-name {
    display: block;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--gold-light);
    text-transform: uppercase;
    line-height: 1.2;
}

.sidebar__app-sub {
    display: block;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

.sidebar__nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.sidebar__section-label {
    font-family: var(--font-display);
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.5rem 0.5rem 0.3rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--t-fast);
    border: 1px solid transparent;
    position: relative;
}

.nav-item:hover {
    color: var(--gold-light);
    background: var(--surface-3);
    border-color: var(--border);
}

.nav-item.active {
    color: var(--gold-light);
    background: var(--surface-3);
    border-color: var(--border-gold);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 2px;
    background: var(--gold);
    border-radius: 2px;
}

.nav-item--sub { padding-left: 1.5rem; font-size: 0.85rem; }
.nav-item__icon { font-size: 0.85rem; opacity: 0.7; flex-shrink: 0; }
.nav-item.active .nav-item__icon { opacity: 1; }

.nav-item--logout:hover {
    color: var(--danger-light);
    border-color: var(--danger);
    background: var(--danger-bg);
}

.sidebar__footer {
    padding: 0.75rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    text-align: center;
    letter-spacing: 0.1em;
}

/* ── Main content ───────────────────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: 0;
    min-height: 100vh;
    padding-left: 18px;
    min-width: 0;            /* FIX scrollbar: impedisce espansione oltre il viewport */
    overflow-x: hidden;
}

.main-content__inner {
    padding: 2rem 2.5rem;
    max-width: 1400px;
    width: 100%;
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-gold);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header__titles { flex: 1; }

.page-header__eyebrow {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: 0.25rem;
}

.page-header__title {
    font-size: 1.5rem;
    color: var(--gold-bright);
    /* Decorazione Art Deco: linee laterali */
    position: relative;
    padding-left: 1rem;
}

.page-header__title::before {
    content: '';
    position: absolute;
    left: 0; top: 15%; bottom: 15%;
    width: 3px;
    background: linear-gradient(to bottom, transparent, var(--gold), transparent);
}

.page-header__subtitle {
    font-family: var(--font-body);
    font-style: italic;
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.page-header__actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Bottoni ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    border: 4px solid;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--t-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gold-muted);
    border-color: var(--gold-dim);
    color: var(--gold-bright);
}
.btn-primary:hover {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold-bright);
    box-shadow: 0 0 12px rgba(201,168,76,0.2);
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-gold);
    color: var(--text-dim);
}
.btn-secondary:hover {
    border-color: var(--gold-dim);
    color: var(--gold-light);
    background: var(--surface-3);
}

.btn-danger {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger-light);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger-light);
}

.btn-sm { padding: 0.65rem 0.65rem; font-size: 0.85rem; }
.btn-icon { padding: 0.35rem 0.5rem; font-size: 0.8rem; }

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    border-left: 3px solid;
    margin-bottom: 1.5rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flash__icon { font-size: 1rem; flex-shrink: 0; }
.flash--success { background: var(--success-bg); border-color: var(--success-light); color: #7acc80; }
.flash--error   { background: var(--danger-bg);  border-color: var(--danger-light);  color: #cc7070; }
.flash--warning { background: var(--warning-bg); border-color: var(--warning-light); color: var(--gold-light); }
.flash--info    { background: var(--info-bg);    border-color: var(--info-light);    color: #70a0cc; }

/* ── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    width: 100%;
    min-width: 0;
}

/* Decorazione Art Deco: bordo angolare dorato */
.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent 0%, var(--gold-muted) 30%, var(--gold-dim) 50%, var(--gold-muted) 70%, transparent 100%);
}

.card__header {
    padding: 1rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card__title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
}

.card__body { padding: 1.5rem; }

/* ── Dashboard stats ────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: border-color var(--t-normal);
}

.stat-card:hover { border-color: var(--border-gold); }

.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--gold-muted), transparent);
}

.stat-card__value {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--gold-light);
    line-height: 1;
    margin-bottom: 0.4rem;
}

.stat-card__label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.stat-card__icon {
    position: absolute;
    top: 1rem; right: 1.25rem;
    font-size: 2rem;
    opacity: 0.08;
    color: var(--gold);
}

/* ── Tabelle dati ───────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: 0.9rem;
}

table.data-table thead {
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 1;
}

table.data-table th {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold-dim);
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-gold);
    white-space: normal;         /* permette ritorno a capo */
    word-break: normal;          /* va a capo SOLO agli spazi, MAI a metà parola */
    overflow-wrap: break-word;   /* solo per stringhe senza spazi (es. codici) */
    line-height: 1.35;
    vertical-align: bottom;      /* titoli allineati in basso per uniformità */
}

table.data-table th a {
    color: var(--gold-dim);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
table.data-table th a:hover { color: var(--gold-light); }

table.data-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

table.data-table tbody tr:hover td {
    background: var(--surface-2);
}

table.data-table tbody tr:last-child td {
    border-bottom: none;
}

.td-mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.td-actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* Badges tipologia / periodo */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.12rem;
    text-transform: uppercase;
    white-space: normal;         /* permette ritorno a capo */
    word-break: normal;          /* va a capo SOLO agli spazi, MAI a metà parola */
    overflow-wrap: break-word;   /* solo per stringhe senza spazi */
    line-height: 1.5;
    border: 2px solid;
}
/* ── Per ripristinare i badge su una sola riga (nessun ritorno a capo):
   sostituire le tre righe sopra (white-space, word-break, overflow-wrap)
   con: white-space: nowrap;
   ────────────────────────────────────────────────────────────────── */

.badge-gold   { color: var(--gold);         border-color: var(--gold-muted);  background: rgba(201,168,76,0.08);  }
.badge-bronze { color: var(--bronze-light);  border-color: var(--bronze);      background: rgba(155,111,58,0.08);  }
.badge-dim    { color: var(--bronze-light);   border-color: var(--bronze);      background: transparent;            }

/* ── Filtri / Ricerca ───────────────────────────────────────── */
.filter-bar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 2.5rem;
    margin-bottom: 1.5rem;
}

.filter-bar__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    align-items: end;
}

.filter-bar__actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    padding-top: 1.5rem;
}

/* ── Form ───────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem 1.5rem;
}

.form-grid--wide { grid-template-columns: 1fr; }
.form-grid--2    { grid-template-columns: repeat(2, 1fr); }
.form-grid--3    { grid-template-columns: repeat(3, 1fr); }

.form-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.form-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--gold-muted) 40%, transparent);
}

.form-section__title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Decorazione ornamentale titolo sezione */
.form-section__title::before,
.form-section__title::after {
    content: ' ✦ ';
    color: var(--gold-muted);
    font-size: 0.55rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }

.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
.form-group.span-full { grid-column: 1 / -1; }

label {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-dim);
}

label .required { color: var(--gold); margin-left: 0.2rem; }

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    padding: 0.55rem 0.85rem;
    width: 100%;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    appearance: none;
    -webkit-appearance: none;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--gold-dim);
    box-shadow: 0 0 0 2px rgba(201,168,76,0.12);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); font-style: italic; }

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238b7035'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
    cursor: pointer;
}

select option { background: var(--surface-3); color: var(--text); }

textarea { min-height: 90px; resize: vertical; line-height: 1.5; }

.form-hint {
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-footer {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Radio / Checkbox personalizzati */
.radio-group {
    display: flex;
    gap: 1rem;
    padding-top: 0.25rem;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.9rem;
    letter-spacing: 0;
    text-transform: none;
    font-family: var(--font-body);
    color: var(--text);
}

.radio-group input[type="radio"] {
    width: 16px; height: 16px;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    accent-color: var(--gold);
}

/* ── Detail view (scheda medaglia) ──────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.detail-item { display: flex; flex-direction: column; gap: 0.25rem; }

.detail-item__label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.detail-item__value {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    line-height: 1.4;
}

.detail-item__value--highlight {
    color: var(--gold-light);
    font-weight: 600;
}

.detail-item__value--note {
    font-style: italic;
    color: var(--text-dim);
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px; height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 0 0.6rem;
    color: var(--text-dim);
    transition: all var(--t-fast);
    background: var(--surface);
}

.pagination a:hover {
    border-color: var(--gold-dim);
    color: var(--gold-light);
    background: var(--surface-3);
}

.pagination .active {
    background: var(--gold-muted);
    border-color: var(--gold-dim);
    color: var(--gold-bright);
    font-weight: 600;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(201,168,76,0.06) 0%, transparent 60%),
        var(--bg);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 3rem 2.5rem;
    background: var(--surface);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

/* Bordo decorativo Art Deco */
.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--gold-dim), var(--gold), var(--gold-dim), transparent);
}

.login-box::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--gold-muted), transparent);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-emblem {
    font-size: 2.5rem;
    color: var(--gold-dim);
    display: block;
    margin-bottom: 1rem;
    letter-spacing: 0.3em;
}

.login-header h1 {
    text-align: center;
    font-size: 2.1rem;
    color: var(--gold-light);
    margin-bottom: 0.25rem;
    letter-spacing: 0.15em;
}

.login-header p {
    font-style: italic;
    color: var(--text-muted);
    font-size: 1.85rem;
}

/* Separatore Art Deco */
.deco-separator {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.3em;
    margin: 1.5rem 0;
    position: relative;
}

.deco-separator::before, .deco-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-gold));
}

.deco-separator::before { left: 0; }
.deco-separator::after  { right: 0; background: linear-gradient(to left, transparent, var(--border-gold)); }

/* ── Dialog di conferma ─────────────────────────────────────── */
.confirm-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.confirm-overlay.open { display: flex; }

.confirm-box {
    background: var(--surface);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-box h3 {
    font-size: 1rem;
    color: var(--danger-light);
    margin-bottom: 0.75rem;
}

.confirm-box p {
    color: var(--text-dim);
    font-size: 1.9rem;
    margin-bottom: 1.5rem;
}

.confirm-box__actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    :root { --sidebar-w: 220px; }
    .main-content__inner { padding: 1.5rem; }
    .form-grid--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    /* Su mobile la sidebar è già un overlay, nessuna modifica extra necessaria */
    .main-content { padding-left: 12px; }
    .main-content__inner { padding: 1rem; }
    .form-grid, .form-grid--2, .form-grid--3 { grid-template-columns: 1fr; }
    .form-group.span-2, .form-group.span-3 { grid-column: span 1; }
    .sidebar-trigger { width: 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   TABELLE COMPATTE – ELENCO MEDAGLIE
   Queste regole controllano la visualizzazione dell'elenco medaglie
   nel Cruscotto e nell'Archivio completo.

   ┌─────────────────────────────────────────────────────────────┐
   │  PERSONALIZZAZIONE LARGHEZZE COLONNE                        │
   │  Modifica i valori "width" delle classi .col-* qui sotto.   │
   │  La tabella usa table-layout: fixed, quindi la larghezza    │
   │  di ogni colonna è esattamente quella dichiarata.           │
   │  Il testo va a capo agli spazi se non ci sta in una riga.   │
   │                                                             │
   │  Colonna          Classe CSS      Larghezza attuale         │
   │  ─────────────── ─────────────── ─────────────────          │
   │  Numero (Serie–ID) .col-id        65px                      │
   │  Tipologia         .col-tipo      100px                     │
   │  Descrizione       .col-desc      260px                     │
   │  Modello/Variante  .col-modello   185px                     │
   │  Periodo           .col-periodo   165px                     │
   │  Materiale         .col-materiale 120px                     │
   │  Incisore          .col-incisore  170px                     │
   │  Azioni (pulsanti) .col-azioni    96px  ← non modificare    │
   └─────────────────────────────────────────────────────────────┘
   ═══════════════════════════════════════════════════════════════ */

/* Attiva larghezze fisse: il browser rispetta i width dichiarati */
table.data-table.data-table--compact {
    table-layout: fixed;
    width: 100%;
}

/* Intestazioni compatte */
table.data-table.data-table--compact th {
    padding: 0.45rem 0.55rem;
    font-size: 0.70rem;
    vertical-align: bottom;
    word-break: normal;        /* mai a metà parola */
    overflow-wrap: break-word; /* solo per stringhe senza spazi */
    white-space: normal;
    line-height: 1.3;
}

/* Celle compatte */
table.data-table.data-table--compact td {
    padding: 0.35rem 0.55rem;
    font-size: 0.9rem;
    line-height: 1.3;
    vertical-align: top;
    white-space: normal;
    word-break: normal;        /* mai a metà parola */
    overflow-wrap: break-word; /* solo per stringhe senza spazi */
}

/* Badge dentro la tabella compatta */
table.data-table.data-table--compact .badge {
    font-size: 0.75rem;
    padding: 0.1rem 0.35rem;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: normal;
}

/* Pulsanti azioni: dimensione ridotta */
table.data-table.data-table--compact .btn-icon {
    padding: 0.22rem 0.38rem;
    font-size: 0.68rem;
}

/* ── Larghezze fisse delle colonne ──────────────────────────────
   QUESTE SONO LE RIGHE DA MODIFICARE PER PERSONALIZZARE
   LA LARGHEZZA DI OGNI SINGOLA COLONNA.
   ──────────────────────────────────────────────────────────── */
.col-id        { width:  60px; }   /* Numero (Serie–ID)    */
.col-tipo      { width: 130px; }   /* Tipologia            */
.col-desc      { width: 200px; }   /* Descrizione          */
.col-modello   { width: 150px; }   /* Modello / Variante   */
.col-periodo   { width: 150px; }   /* Periodo storico      */
.col-materiale { width: 130px; }   /* Materiale            */
.col-incisore  { width: 100px; }   /* Incisore             */
.col-azioni    { width:  96px; white-space: nowrap; }  /* Pulsanti — non modificare il white-space */

/* Celle testo: wrapping normale (mai troncamento con "…") */
table.data-table.data-table--compact .td-truncate {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    overflow: visible;
}

/* ── Scrollbar orizzontale sticky (generata da script.js) ───────
   Rimane ancorata al bordo inferiore del viewport durante lo
   scorrimento verticale. Mostrata solo quando serve. */
.scroll-sticky-bar {
    position: sticky;
    bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    height: 14px;
    z-index: 50;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-top-color: var(--border-gold);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    margin-top: 2px;
    display: none;
}

.scroll-sticky-bar__inner {
    height: 1px; /* larghezza impostata da JS */
}

/* ── Selettore righe per pagina (in basso a destra) ─────────── */
.table-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.table-controls__label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.table-controls select {
    width: auto;
    padding: 0.3rem 1.8rem 0.3rem 0.65rem;
    font-size: 0.75rem;
    border-color: var(--border-gold);
    color: var(--gold-light);
    background-color: var(--surface-3);
}

/* ── Bottone Duplica ─────────────────────────────────────────── */
.btn-duplicate {
    background: rgba(155,111,58,0.15);
    border-color: var(--bronze);
    color: var(--bronze-light);
}
.btn-duplicate:hover {
    background: var(--bronze);
    border-color: var(--bronze-light);
    color: #fff;
    box-shadow: 0 0 10px rgba(155,111,58,0.3);
}

/* ═══════════════════════════════════════════════════════════════
   GALLERIA FOTO – SCHEDA MEDAGLIA
   ═══════════════════════════════════════════════════════════════ */

/* Layout a due colonne: info sinistra + galleria destra */
.scheda-top {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.25rem;
    align-items: start;
    margin-bottom: 1.25rem;
}

/* Colonna sinistra: le due card si impilano */
.scheda-top__info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

/* ── Pannello galleria ───────────────────────────────────────── */
.foto-gallery {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    /* Altezza uguale alle due card affiancate — si adatta al contenuto */
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

/* Bordo decorativo Art Deco in cima */
.foto-gallery::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(to right,
        transparent, var(--gold-muted) 30%,
        var(--gold-dim) 50%,
        var(--gold-muted) 70%, transparent);
    z-index: 2;
}

/* Intestazione con titolo e pulsante upload */
.foto-gallery__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem 0.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    flex-shrink: 0;
}

.foto-gallery__title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
}

/* Pulsante upload: piccolo, icona, tondo */
.foto-gallery__upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-gold);
    background: transparent;
    color: var(--gold-dim);
    font-size: 1rem;
    cursor: pointer;
    transition: all var(--t-fast);
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}

.foto-gallery__upload-btn:hover {
    background: var(--gold-muted);
    border-color: var(--gold);
    color: var(--gold-bright);
    box-shadow: 0 0 8px rgba(201,168,76,0.25);
}

/* Area immagine: occupa tutto lo spazio disponibile */
.foto-gallery__frame {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    min-height: 260px;
    cursor: pointer;
    outline: none; /* focus gestito via JS senza outline visivo */
}

/* Immagine corrente */
.foto-gallery__img {
    display: block;
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    object-fit: contain;
    border: none;
    transition: opacity 200ms ease;
}

.foto-gallery__img.is-loading {
    opacity: 0;
}

/* Stato vuoto: sfondo trasparente = uguale alla pagina */
.foto-gallery__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.85rem;
    padding: 1.5rem;
    text-align: center;
    width: 100%;
    height: 100%;
}

.foto-gallery__empty-icon {
    font-size: 2.5rem;
    opacity: 0.15;
    line-height: 1;
}

/* Pulsanti prev / next — a scomparsa */
.foto-gallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-gold);
    background: rgba(10, 9, 6, 0.75);
    color: var(--gold);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* Nascosti di default */
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease, background 150ms ease,
                transform 200ms ease;
    z-index: 3;
    backdrop-filter: blur(4px);
    line-height: 1;
    padding: 0;
}

.foto-gallery__nav--prev { left: 8px; }
.foto-gallery__nav--next { right: 8px; }

/* Appaiono al passaggio del mouse sul frame */
.foto-gallery__frame:hover .foto-gallery__nav,
.foto-gallery__frame:focus .foto-gallery__nav {
    opacity: 1;
    pointer-events: auto;
}

.foto-gallery__nav:hover {
    background: var(--gold-muted);
    border-color: var(--gold);
    color: var(--gold-bright);
    transform: translateY(-50%) scale(1.1);
}

/* Contatore immagini (es. "2 / 5") */
.foto-gallery__counter {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    background: rgba(10,9,6,0.6);
    padding: 0.15rem 0.5rem;
    border-radius: 2px;
    letter-spacing: 0.08em;
    pointer-events: none;
    z-index: 3;
}

/* Nome file immagine corrente */
.foto-gallery__filename {
    padding: 0.3rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

/* Responsive: su schermi stretti le colonne si impilano */
@media (max-width: 860px) {
    .scheda-top {
        grid-template-columns: 1fr;
    }
    .foto-gallery {
        min-height: 260px;
    }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-gold   { color: var(--gold-light); }
.text-dim    { color: var(--text-dim); }
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger-light); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.italic      { font-style: italic; }
.mono        { font-family: var(--font-mono); font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}
.empty-state__icon { font-size: 2.5rem; opacity: 0.3; margin-bottom: 0.75rem; }
.empty-state p { font-style: italic; }
