/* ==========================================
   AdminPanel — CSS
   Dark Sidebar + Light Content (Forge style)
   ========================================== */

:root {
    /* Sidebar */
    --sb-bg:          #0f1117;
    --sb-border:      rgba(255,255,255,.06);
    --sb-text:        #8b92a5;
    --sb-text-hover:  #e2e8f0;
    --sb-active-bg:   rgba(59,130,246,.15);
    --sb-active-text: #60a5fa;
    --sb-width:       240px;

    /* Content */
    --bg:             #f8fafc;
    --surface:        #ffffff;
    --border:         #e2e8f0;
    --text:           #1e293b;
    --text-muted:     #64748b;
    --text-sm:        0.8125rem;

    /* Accent */
    --accent:         #3b82f6;
    --accent-hover:   #2563eb;
    --danger:         #ef4444;
    --success:        #10b981;
    --warning:        #f59e0b;
    --purple:         #8b5cf6;

    /* Misc */
    --radius:         8px;
    --radius-lg:      12px;
    --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 12px rgba(0,0,0,.1);
    --topbar-h:       56px;
    --font:           'DM Sans', system-ui, sans-serif;
    --font-mono:      'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* =====================
   LAYOUT
   ===================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
    width: var(--sb-width);
    background: var(--sb-bg);
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.logo-text {
    font-weight: 600;
    font-size: .95rem;
    color: #e2e8f0;
    letter-spacing: -.01em;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--sb-text);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color .15s;
}
.sidebar-toggle:hover { color: var(--sb-text-hover); }

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sb-border); border-radius: 2px; }

.nav-section-label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #3d4455;
    padding: 4px 10px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--sb-text);
    font-size: .875rem;
    font-weight: 450;
    position: relative;
    transition: background .15s, color .15s;
    cursor: pointer;
    margin-bottom: 1px;
}

.nav-item:hover {
    background: rgba(255,255,255,.05);
    color: var(--sb-text-hover);
}

.nav-item.active {
    background: var(--sb-active-bg);
    color: var(--sb-active-text);
}

.nav-indicator {
    width: 3px; height: 16px;
    background: var(--accent);
    border-radius: 2px;
    position: absolute;
    right: 0;
}

.nav-icon { flex-shrink: 0; opacity: .75; }
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item-danger { color: #f87171 !important; }
.nav-item-danger:hover { background: rgba(239,68,68,.1) !important; }

/* Sidebar user */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-top: 1px solid var(--sb-border);
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: .8rem;
    font-weight: 600;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: .825rem;
    font-weight: 500;
    color: #c8d0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: .7rem;
    color: #3d4455;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* =====================
   MAIN WRAPPER
   ===================== */
.main-wrapper {
    flex: 1;
    margin-left: var(--sb-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* =====================
   TOPBAR
   ===================== */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8125rem;
    color: var(--text-muted);
}
.breadcrumb-item.active { color: var(--text); font-weight: 500; }
.breadcrumb-sep { color: var(--border); }

.topbar-time {
    font-family: var(--font-mono);
    font-size: .75rem;
    color: var(--text-muted);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
}

/* =====================
   CONTENT
   ===================== */
.content {
    flex: 1;
    padding: 28px 28px;
    max-width: 1400px;
    width: 100%;
}

.app-footer {
    padding: 16px 28px;
    font-size: .75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* =====================
   PAGE HEADER
   ===================== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -.02em;
    color: var(--text);
}

.page-subtitle {
    font-size: .875rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* =====================
   CARDS
   ===================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
}

.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* =====================
   STATS GRID
   ===================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}

.stat-body { flex: 1; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--text);
}

.stat-label {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.stat-trend {
    font-size: .75rem;
    color: var(--text-muted);
    padding: 3px 8px;
    background: var(--bg);
    border-radius: 20px;
    align-self: flex-start;
}
.stat-trend.up { color: var(--success); background: rgba(16,185,129,.08); }

/* =====================
   DASHBOARD GRID
   ===================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
}

/* =====================
   TABLE
   ===================== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.table thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

.table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
}

.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }

/* =====================
   USER CELL
   ===================== */
.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: .7rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

/* =====================
   BADGES
   ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.badge-success { background: rgba(16,185,129,.1);  color: #059669; }
.badge-danger  { background: rgba(239,68,68,.1);   color: #dc2626; }
.badge-warning { background: rgba(245,158,11,.1);  color: #d97706; }
.badge-blue    { background: rgba(59,130,246,.1);  color: #2563eb; }
.badge-purple  { background: rgba(139,92,246,.1);  color: #7c3aed; }

/* =====================
   BUTTONS
   ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger-ghost {
    background: transparent;
    color: var(--danger);
    border-color: transparent;
}
.btn-danger-ghost:hover { background: rgba(239,68,68,.08); }

.btn-sm { padding: 5px 11px; font-size: .8125rem; }

/* =====================
   ALERTS
   ===================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 20px;
    border: 1px solid;
}

.alert-danger  { background: rgba(239,68,68,.06);  border-color: rgba(239,68,68,.2);  color: #b91c1c; }
.alert-success { background: rgba(16,185,129,.06); border-color: rgba(16,185,129,.2); color: #047857; }
.alert-warning { background: rgba(245,158,11,.06); border-color: rgba(245,158,11,.2); color: #b45309; }

/* =====================
   FORMS
   ===================== */
.form-group {
    margin-bottom: 16px;
    flex: 1;
    min-width: 0;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-group label {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
/* Eccezione: label che contiene il toggle non deve essere block */
.form-group label.toggle {
    display: inline-flex !important;
    margin-bottom: 0;
    font-weight: 400;
    font-size: .875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .875rem;
    color: var(--text);
    background: white;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.required { color: var(--danger); }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* Toggle */
.toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin-bottom: 0 !important;
    font-weight: 400 !important;
    font-size: .875rem !important;
    color: var(--text) !important;
}
.toggle input { display: none; }
.toggle-slider {
    width: 40px; height: 22px;
    background: var(--border);
    border-radius: 20px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
    display: inline-block;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s;
}
.toggle input:checked ~ .toggle-slider { background: var(--success); }
.toggle input:checked ~ .toggle-slider::after { transform: translateX(18px); }
.toggle-label {
    font-size: .875rem;
    color: var(--text);
    font-weight: 400;
    line-height: 1.4;
}

/* =====================
   SEARCH
   ===================== */
.search-form { display: flex; }
.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}
.search-wrapper input {
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .8125rem;
    width: 260px;
    outline: none;
    transition: border-color .15s;
}
.search-wrapper input:focus { border-color: var(--accent); }
.search-clear {
    position: absolute;
    right: 8px;
    color: var(--text-muted);
    font-size: .75rem;
    cursor: pointer;
}
.search-clear:hover { color: var(--text); }

/* =====================
   PAGINATION
   ===================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px;
    border-top: 1px solid var(--border);
}

.page-btn {
    min-width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    font-size: .8125rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all .15s;
    padding: 0 8px;
}
.page-btn:hover { background: var(--bg); color: var(--text); }
.page-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* =====================
   ACTION BUTTONS
   ===================== */
.action-buttons {
    display: flex;
    justify-content: flex-start;
    gap: 4px;
}

/* =====================
   INFO LIST (Dashboard)
   ===================== */
.info-list { display: flex; flex-direction: column; gap: 0; }
.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
}
.info-item:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-size: .8125rem; }

/* =====================
   EMPTY STATE
   ===================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.empty-state svg { opacity: .3; }
.empty-state p { font-size: .9375rem; }

/* =====================
   OVERLAY (mobile)
   ===================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
    backdrop-filter: blur(2px);
}

/* =====================
   AUTH LAYOUT
   ===================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1117;
}

.auth-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(59,130,246,.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59,130,246,.03) 1px, transparent 1px);
    background-size: 40px 40px;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 24px 16px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: #161b27;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 24px 64px rgba(0,0,0,.4);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.login-logo svg { border-radius: 8px; }
.login-logo span { font-weight: 700; font-size: 1.1rem; color: #e2e8f0; }

.login-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #f1f5f9;
    letter-spacing: -.02em;
}

.login-subtitle {
    color: #64748b;
    font-size: .875rem;
    margin-top: 4px;
    margin-bottom: 24px;
}

.login-form .form-group { margin-bottom: 16px; }
.login-form label {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 6px;
}

.input-wrapper { position: relative; }
.input-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #475569;
    pointer-events: none;
}

.login-form input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: #0f1117;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: var(--font);
    font-size: .9rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.login-form input::placeholder { color: #334155; }

.login-form input:focus {
    border-color: rgba(59,130,246,.5);
    box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.btn-login {
    width: 100%;
    padding: 11px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: .9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}
.btn-login:hover { background: var(--accent-hover); }
.btn-login:active { transform: scale(.99); }

.login-footer {
    text-align: center;
    font-size: .75rem;
    color: #334155;
    margin-top: 24px;
}

.login-card .alert {
    font-size: .8125rem;
    padding: 10px 14px;
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.show { display: block; }

    .main-wrapper { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .search-wrapper input { width: 200px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* =====================
   MODAL
   ===================== */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,17,23,.65);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn .15s ease;
}
.modal-backdrop.open {
    display: flex;
}

@keyframes fadeIn {
    from { opacity:0; }
    to   { opacity:1; }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 24px 64px rgba(0,0,0,.18);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp .2s ease;
}

.modal.modal-lg { max-width: 720px; }

@keyframes slideUp {
    from { transform: translateY(20px); opacity:0; }
    to   { transform: translateY(0);    opacity:1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-info-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(59,130,246,.06);
    border: 1px solid rgba(59,130,246,.18);
    border-radius: var(--radius);
    font-size: .8125rem;
    color: #2563eb;
    margin-bottom: 14px;
}

.modal-info-warning {
    background: rgba(245,158,11,.06);
    border-color: rgba(245,158,11,.2);
    color: #b45309;
}

/* Readonly grid in modal */
.readonly-grid {
    display: flex;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 4px;
}
.readonly-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.readonly-label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    font-weight: 600;
}
.readonly-value {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--text);
}

/* =====================
   FILTER BAR
   ===================== */
.filter-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
}

.filter-group input,
.filter-group select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .8125rem;
    color: var(--text);
    background: white;
    outline: none;
    transition: border-color .15s;
    appearance: none;
}
.filter-group input:focus,
.filter-group select:focus { border-color: var(--accent); }

.filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* =====================
   BOVINI TABLE EXTRAS
   ===================== */
.table-bovini { min-width: 900px; }
.table-bovini td { white-space: nowrap; }

.mono { font-family: var(--font-mono); }

.lotto-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    background: rgba(16,185,129,.1);
    color: #047857;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 600;
}

.colpi-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
}

/* Textarea in forms */
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .875rem;
    color: var(--text);
    background: white;
    outline: none;
    transition: border-color .15s;
}
.form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

/* =====================
   FILTER BAR ORIZZONTALE
   ===================== */
.filter-bar-h {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.filter-form-h {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
}

.filter-field label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-field input,
.filter-field select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .8125rem;
    color: var(--text);
    background: white;
    outline: none;
    height: 34px;
    transition: border-color .15s;
    appearance: none;
}
.filter-field input:focus,
.filter-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.1); }

.filter-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    padding-right: 24px;
}

.filter-sep {
    color: var(--text-muted);
    padding-bottom: 6px;
    font-size: .9rem;
}

.filter-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    padding-bottom: 1px;
}

/* =====================
   FORM PAGINA SEPARATA
   ===================== */
.form-page {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 900px;
}

.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.form-cols-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.form-info-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 9px 13px;
    background: rgba(59,130,246,.05);
    border: 1px solid rgba(59,130,246,.15);
    border-radius: var(--radius);
    font-size: .8125rem;
    color: #2563eb;
    margin-bottom: 14px;
}

.form-info-box svg { flex-shrink: 0; margin-top: 1px; }

.field-hint {
    display: block;
    font-size: .7rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.field-readonly {
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--text);
    font-weight: 600;
}

.form-actions-page {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

/* =====================
   BOVINI EXTRAS
   ===================== */
.table-scroll { overflow-x: auto; }
.table-bovini { min-width: 1400px; }
.table-bovini td { white-space: nowrap; padding: 9px 12px; }
.table-bovini th { padding: 9px 12px; }

.eta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    background: rgba(245,158,11,.1);
    color: #b45309;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .75rem;
    font-weight: 600;
}

/* Responsive form */
@media (max-width: 768px) {
    .form-cols-3, .form-cols-4 { grid-template-columns: 1fr; }
    .filter-form-h { flex-direction: column; align-items: stretch; }
    .filter-field { min-width: auto; }
    .filter-sep { display: none; }
}

/* =====================
   SELECT WITH INLINE LINK
   ===================== */
.select-with-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-with-link select {
    flex: 1;
    min-width: 0;
}

.select-new-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(59,130,246,.08);
    color: var(--accent);
    border: 1px solid rgba(59,130,246,.25);
    border-radius: var(--radius);
    font-size: .75rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
    text-decoration: none;
    height: 34px;
}
.select-new-link:hover {
    background: rgba(59,130,246,.15);
    border-color: var(--accent);
}

/* =====================
   PRINT BUTTON
   ===================== */
.btn-print-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .8125rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn-print-inline:hover {
    background: var(--surface);
    color: var(--text);
    border-color: #94a3b8;
}

/* =====================
   COLONNA AZIONI A SINISTRA
   ===================== */
td.td-actions {
    width: 120px;
    white-space: nowrap;
    padding: 8px 10px;
}

/* action-buttons: see above */

/* Bottone elimina — colore rosso chiaro di default, rosso pieno on hover */
.btn-danger-ghost {
    color: #ef4444;
    border-color: transparent;
    background: transparent;
}
.btn-danger-ghost:hover {
    background: rgba(239,68,68,.1);
    border-color: rgba(239,68,68,.25);
}
