@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ────────────────────────────────────────────────────────── */
/*  VARIABLES                                                 */
/* ────────────────────────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg:           #06060f;
    --surface:      #0c0c1d;
    --surface-2:    #111126;
    --surface-3:    #16163a;

    /* Borders */
    --border:       rgba(255,255,255,0.055);
    --border-hover: rgba(255,255,255,0.11);
    --border-focus: rgba(124,131,253,0.45);

    /* Accent — violet/indigo */
    --accent:       #818cf8;
    --accent-light: #a5b4fc;
    --accent-dark:  #6366f1;
    --accent-dim:   rgba(129,140,248,0.1);
    --accent-glow:  rgba(129,140,248,0.22);

    /* Text */
    --text:         #eef0f9;
    --text-muted:   #5c6070;
    --text-subtle:  #8b91a8;

    /* Semantic */
    --success:      #34d399;
    --success-dim:  rgba(52,211,153,0.1);
    --warning:      #fbbf24;
    --warning-dim:  rgba(251,191,36,0.1);
    --danger:       #ef4444;
    --danger-dim:   rgba(239,68,68,0.1);
    --orange:       #f97316;
    --orange-dim:   rgba(249,115,22,0.1);
    --info:         #60a5fa;
    --info-dim:     rgba(96,165,250,0.1);

    /* Shape */
    --radius:       12px;
    --radius-sm:    8px;
    --radius-xs:    5px;
    --radius-pill:  999px;

    /* Shadow */
    --shadow:       0 16px 48px rgba(0,0,0,0.55);
    --shadow-sm:    0 4px 16px rgba(0,0,0,0.35);
    --shadow-card:  0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px var(--border);

    /* Sidebar */
    --sidebar-w:    240px;

    /* Transitions */
    --t:            0.18s ease;
    --t-fast:       0.1s ease;
}

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

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Subtle radial glow in top-right */
    background-image:
        radial-gradient(ellipse 70% 50% at 80% -10%, rgba(99,102,241,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 0% 80%, rgba(129,140,248,0.04) 0%, transparent 50%);
    background-attachment: fixed;
}

/* ────────────────────────────────────────────────────────── */
/*  SCROLLBAR                                                 */
/* ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(129,140,248,0.2);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(129,140,248,0.4); }

/* ────────────────────────────────────────────────────────── */
/*  LAYOUT                                                    */
/* ────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

.content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.content main {
    padding: 44px 48px;
    max-width: 1400px;
    width: 100%;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Pages */
.page { display: none; }
.page.active {
    display: flex;
    flex-direction: column;
    gap: 28px;
    animation: fadeUp 0.22s ease both;
}

/* Chat ID nascosto nella tabella utenti */
.chat-id-input {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    width: 90px;
    cursor: default;
    outline: none;
}

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

/* ────────────────────────────────────────────────────────── */
/*  SIDEBAR                                                   */
/* ────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: #07071a;
    border-right: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    padding: 28px 14px 22px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
}

/* ── Logo ─────────────────────────────────────────────────── */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    padding: 0 12px 36px;
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 60%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Diamond icon before logo */
.sidebar-logo::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    border-radius: 3px;
    transform: rotate(45deg);
    -webkit-text-fill-color: initial; /* not text, so no conflict */
}

/* ── Nav ──────────────────────────────────────────────────── */
.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    flex: 1;
    /* hide scrollbar visually */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar nav::-webkit-scrollbar { display: none; }

/* ── Visual group separators (CSS-only, no HTML changes) ──── */
/* Group 1: Dashboard, Utenti                                  */
/* Group 2: Piattaforme → Portali (config)                    */
/* Group 3: Conti → Bilancio (finance)                        */

/* Separator before Piattaforme */
.nav-item[data-page="piattaforme"] {
    margin-top: 20px;
    position: relative;
}
.nav-item[data-page="piattaforme"]::before {
    content: 'GESTIONE';
    position: absolute;
    top: -16px;
    left: 14px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #2e2e50;
    pointer-events: none;
    line-height: 1;
}

/* Separator before Sconti */
.nav-item[data-page="sconti"] {
    margin-top: 20px;
    position: relative;
}
.nav-item[data-page="sconti"]::before {
    content: 'FINANZE';
    position: absolute;
    top: -16px;
    left: 14px;
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #2e2e50;
    pointer-events: none;
    line-height: 1;
}

/* ── Nav item ─────────────────────────────────────────────── */
.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;   /* override button default center */
    gap: 11px;
    padding: 10px 14px;
    border-radius: 9px;
    color: #6b6b90;
    font-size: 0.845rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--t), background var(--t), box-shadow var(--t);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.55;
    transition: opacity var(--t);
}

.nav-item:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text-subtle);
    border-color: transparent;
    box-shadow: none;
}
.nav-item:hover svg { opacity: 0.85; }

/* Active: inset left bar via box-shadow (no ::before conflict) */
.nav-item.active {
    background: rgba(129,140,248,0.08);
    color: var(--accent-light);
    border-color: transparent;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.active svg { opacity: 1; }

/* ── Sidebar sub-filters (conti) ──────────────────────────── */
#sidebar-conti-filters {
    padding: 0 8px 2px;
    margin-top: 1px !important;
}

#sidebar-conti-filters button {
    font-size: 0.76rem !important;
    padding: 5px 14px !important;
    color: #5a5a7a;
    background: transparent;
    border: none;
    justify-content: flex-start;
    box-shadow: none;
    border-radius: 7px;
    letter-spacing: -0.01em;
}

#sidebar-conti-filters button:hover {
    color: var(--text-subtle);
    background: rgba(255,255,255,0.04);
    border-color: transparent;
    box-shadow: none;
}

/* ── Footer ───────────────────────────────────────────────── */
.sidebar-footer {
    margin-top: 12px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

/* Logout button specifico */
#btn-logout {
    color: #5a5a7a;
    font-size: 0.84rem;
    width: 100%;
}
#btn-logout:hover {
    background: rgba(248,113,113,0.06);
    color: var(--danger);
    border-color: transparent;
    box-shadow: none;
}

/* ────────────────────────────────────────────────────────── */
/*  PAGE HEADER                                               */
/* ────────────────────────────────────────────────────────── */
.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 3px;
    line-height: 1.25;
}

.page-subtitle {
    font-size: 0.845rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* ────────────────────────────────────────────────────────── */
/*  SECTION HEADINGS                                          */
/* ────────────────────────────────────────────────────────── */
section h2,
.page > section > h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 14px;
}

section h2::before {
    content: '';
    display: block;
    width: 3px;
    height: 13px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

/* ────────────────────────────────────────────────────────── */
/*  CARDS                                                     */
/* ────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    transition: border-color var(--t), box-shadow var(--t);
    position: relative;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.card h3 {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 14px;
}

.card p {
    font-size: 0.9375rem;
    color: var(--text-subtle);
    line-height: 1.7;
}

.card p strong {
    color: var(--text);
    font-weight: 500;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

/* Accent top-border per ogni stat card (colori per posizione) */
.stats-grid .card:nth-child(1) {
    border-top: 2px solid var(--success);
}
.stats-grid .card:nth-child(2) {
    border-top: 2px solid var(--warning);
}
.stats-grid .card:nth-child(3) {
    border-top: 2px solid var(--orange);
}
.stats-grid .card:nth-child(4) {
    border-top: 2px solid var(--danger);
}

/* Big stat numbers */
.stats-grid .card p[id] {
    font-size: 2.1rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.04em;
    line-height: 1 !important;
}

/* ────────────────────────────────────────────────────────── */
/*  TABLES                                                    */
/* ────────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.875rem;
}

thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-top: 1px solid var(--border);
    transition: background var(--t-fast);
}

tbody tr:first-child { border-top: none; }

tbody tr:hover { background: rgba(129,140,248,0.04); }

tbody td {
    padding: 12px 16px;
    color: var(--text-subtle);
    vertical-align: middle;
}

tbody td:first-child {
    color: var(--text);
    font-weight: 500;
}

.empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Small action buttons inside table cells */
td button {
    font-size: 0.755rem;
    padding: 4px 10px;
    line-height: 1.4;
    border-radius: var(--radius-xs);
}

/* ────────────────────────────────────────────────────────── */
/*  BUTTONS                                                   */
/* ────────────────────────────────────────────────────────── */
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 0.865rem;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--t);
    background: var(--surface-2);
    color: var(--text-subtle);
    border: 1px solid var(--border);
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}

button:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--surface-3);
    box-shadow: none;
}

button:active { transform: scale(0.97); }

/* ── Primary ─────────────────────────────────────────────── */
.btn-primary,
#btn-login,
#btn-register,
.btn-approve,
#btn-confirm-approve {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
    font-weight: 600;
    letter-spacing: -0.01em;
    box-shadow: 0 0 0 1px rgba(129,140,248,0.3), 0 4px 14px rgba(99,102,241,0.3);
}

.btn-primary:hover,
#btn-login:hover,
#btn-register:hover,
.btn-approve:hover,
#btn-confirm-approve:hover {
    background: var(--accent-light);
    border-color: transparent;
    box-shadow: 0 0 0 1px rgba(129,140,248,0.4), 0 6px 20px rgba(99,102,241,0.4);
}

/* ── Ghost / Cancel ──────────────────────────────────────── */
#btn-cancel-approve {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    font-size: 0.82rem;
}

#btn-cancel-approve:hover {
    border-color: rgba(248,113,113,0.3);
    color: var(--danger);
    background: var(--danger-dim);
}

/* ────────────────────────────────────────────────────────── */
/*  BADGES                                                    */
/* ────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-active  {
    background: var(--success-dim);
    color: var(--success);
    border: 1px solid rgba(52,211,153,0.2);
}
.badge-trial   {
    background: var(--accent-dim);
    color: var(--accent-light);
    border: 1px solid rgba(129,140,248,0.2);
}
.badge-expired {
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid rgba(248,113,113,0.2);
}
.badge-pending {
    background: var(--warning-dim);
    color: var(--warning);
    border: 1px solid rgba(251,191,36,0.2);
}
.badge-cancelled {
    background: rgba(100,100,120,0.12);
    color: #6b7280;
    border: 1px solid rgba(100,100,120,0.2);
}

/* ────────────────────────────────────────────────────────── */
/*  FORMS                                                     */
/* ────────────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-subtle);
    letter-spacing: -0.01em;
}

input, select, textarea {
    padding: 9px 13px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.885rem;
    font-family: inherit;
    transition: border-color var(--t), box-shadow var(--t);
    outline: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(129,140,248,0.12);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--border-hover);
}

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

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='%235c6070' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

select option { background: var(--surface-2); }

/* ── Checkbox custom ─────────────────────────────────────── */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px !important;
    height: 16px;
    min-width: 16px;
    background: var(--surface-3);
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background var(--t), border-color var(--t), box-shadow var(--t);
    padding: 0;
}

input[type="checkbox"]:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1.5px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(43deg);
}

/* ── Radio custom ────────────────────────────────────────── */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px !important;
    height: 16px;
    min-width: 16px;
    background: var(--surface-3);
    border: 1.5px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background var(--t), border-color var(--t), box-shadow var(--t);
    padding: 0;
}

input[type="radio"]:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="radio"]:checked {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
}

/* Number spinner */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 0.35;
}

/* ────────────────────────────────────────────────────────── */
/*  LOGIN PAGE                                                */
/* ────────────────────────────────────────────────────────── */
.login-container {
    max-width: 400px;
    margin: 80px auto;
    padding: 0 16px;
}

.login-container .card {
    box-shadow: var(--shadow);
    border-color: rgba(129,140,248,0.12);
}

.login-container h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 28px;
    color: var(--text);
}

#btn-login,
#btn-register {
    width: 100%;
    padding: 10px;
    font-size: 0.9375rem;
    margin-top: 4px;
}

#error-msg {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 12px;
    display: none;
}

/* ────────────────────────────────────────────────────────── */
/*  MODAL                                                     */
/* ────────────────────────────────────────────────────────── */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3,3,12,0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

#modal-overlay .card {
    min-width: 320px;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow);
    border-color: rgba(129,140,248,0.15);
    animation: modalIn 0.2s cubic-bezier(0.34,1.2,0.64,1) both;
}

#modal-overlay h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

/* User edit modal */
#user-edit-modal {
    position: fixed;
    inset: 0;
    background: rgba(3,3,12,0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 16px;
}

#user-edit-modal > .card {
    width: 100%;
    max-width: 680px;
    box-shadow: var(--shadow);
    border-color: rgba(129,140,248,0.15);
    animation: modalIn 0.2s cubic-bezier(0.34,1.2,0.64,1) both;
}

/* Generic fixed modals */
#delete-confirm-modal,
#reject-modal,
#edit-portal-modal {
    position: fixed;
    inset: 0;
    background: rgba(3,3,12,0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

#delete-confirm-modal .card,
#reject-modal .card,
#edit-portal-modal .card {
    animation: modalIn 0.2s cubic-bezier(0.34,1.2,0.64,1) both;
    border-color: rgba(129,140,248,0.12);
    box-shadow: var(--shadow);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(6px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ────────────────────────────────────────────────────────── */
/*  DIVIDER                                                   */
/* ────────────────────────────────────────────────────────── */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ────────────────────────────────────────────────────────── */
/*  MOBILE TOPBAR & BURGER                                    */
/* ────────────────────────────────────────────────────────── */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 54px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    z-index: 60;
    gap: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.mobile-topbar-logo {
    font-size: 0.92rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
    letter-spacing: -0.02em;
}

.burger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: background var(--t);
    box-shadow: none;
}

.burger-btn:hover {
    background: var(--surface-2);
    border-color: transparent;
    box-shadow: none;
    color: var(--text);
}

.burger-btn span {
    display: block;
    width: 20px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: all 0.22s ease;
}

.burger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: 54;
}
.sidebar-overlay.open { display: block; }

/* ────────────────────────────────────────────────────────── */
/*  HEADER (generic)                                          */
/* ────────────────────────────────────────────────────────── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0; z-index: 50;
    backdrop-filter: blur(12px);
}

header h1 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ────────────────────────────────────────────────────────── */
/*  BILANCIO — Specific improvements                          */
/* ────────────────────────────────────────────────────────── */
#page-bilancio .page-header h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* Recurring section box */
#bal-recurring-section {
    border: 1px solid rgba(129,140,248,0.2) !important;
    background: rgba(129,140,248,0.04) !important;
    border-radius: var(--radius-sm) !important;
}

/* Date wrap inside amount form-group */
#bal-date-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}

#bal-date-wrap label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-subtle);
}

/* Balance filter bar */
#bal-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

#bal-search {
    max-width: 220px;
}

/* ────────────────────────────────────────────────────────── */
/*  SUBSCRIPTION CARDS (multi-sub)                           */
/* ────────────────────────────────────────────────────────── */
.sub-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 14px;
    transition: border-color var(--t);
}

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

.sub-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

/* ────────────────────────────────────────────────────────── */
/*  INLINE CODE                                               */
/* ────────────────────────────────────────────────────────── */
code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.82em;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 2px 7px;
    color: var(--accent-light);
}

/* ────────────────────────────────────────────────────────── */
/*  BUTTON VARIANTS                                           */
/* ────────────────────────────────────────────────────────── */

/* Small button (used in tables and sub-cards) */
.btn-small {
    font-size: 0.765rem !important;
    padding: 4px 10px !important;
    border-radius: var(--radius-xs) !important;
    line-height: 1.4;
}

/* Danger */
.btn-danger {
    background: var(--danger-dim) !important;
    color: var(--danger) !important;
    border-color: rgba(248,113,113,0.25) !important;
    font-weight: 600;
}
.btn-danger:hover {
    background: var(--danger) !important;
    color: #fff !important;
    border-color: transparent !important;
}

/* Success */
.btn-success {
    background: var(--success-dim);
    color: var(--success);
    border-color: rgba(52,211,153,0.25);
    font-weight: 600;
}
.btn-success:hover {
    background: var(--success);
    color: #fff;
    border-color: transparent;
}

/* Warning */
.btn-warning {
    background: var(--warning-dim);
    color: var(--warning);
    border-color: rgba(251,191,36,0.25);
    font-weight: 600;
}
.btn-warning:hover {
    background: var(--warning);
    color: #000;
    border-color: transparent;
}

/* Ghost pill (filter buttons) */
.btn-pill {
    border-radius: var(--radius-pill);
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ────────────────────────────────────────────────────────── */
/*  COMPAT: legacy variables referenced in JS                 */
/* ────────────────────────────────────────────────────────── */
:root {
    --card-border: rgba(255,255,255,0.06);
    --surface2:    #111126;    /* alias of --surface-2 (no dash) */
    --accent-glow: rgba(129,140,248,0.22); /* used in some inline styles */
}

/* ────────────────────────────────────────────────────────── */
/*  RESPONSIVE                                                */
/* ────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .content main {
        padding: 32px 28px;
    }
}

@media (max-width: 768px) {
    body { overflow-x: hidden; }

    .mobile-topbar { display: flex; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 55;
    }
    .sidebar.open { transform: translateX(0); }

    .content {
        margin-left: 0;
        padding-top: 54px;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .content main {
        padding: 20px 14px;
        width: 100%;
        max-width: 100%;
    }

    /* Stats: two columns */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    /* Page header row: stack vertically */
    .page.active > div[style*="justify-content:space-between"],
    .page.active > div[style*="justify-content: space-between"] {
        flex-direction: column;
        align-items: flex-start !important;
    }

    /* Tables: horizontal scroll */
    section:not(:has(.responsive-table)) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table:not(.responsive-table) { min-width: 480px; }

    /* Responsive tables: card stacked on mobile */
    .responsive-table thead { display: none; }

    .responsive-table tbody tr {
        display: block;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 4px 12px;
    }

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

    .responsive-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-top: 1px solid var(--border);
        font-size: 0.875rem;
        color: var(--text-subtle);
    }

    .responsive-table tbody tr td:first-child {
        border-top: none;
        color: var(--text);
        font-weight: 600;
    }

    .responsive-table tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--text-muted);
        flex-shrink: 0;
        margin-right: 12px;
    }

    .responsive-table .empty { display: block; text-align: center; }

    /* 2-col form grids → single column */
    .form-grid-2 { grid-template-columns: 1fr; }

    .card { padding: 16px; }

    /* Cred rows */
    #platform-creds-list > div {
        flex-direction: column;
        align-items: flex-start !important;
    }
    #platform-creds-list input {
        max-width: 100% !important;
        width: 100%;
    }

    /* Modal full-width */
    #modal-overlay .card,
    #payment-modal .card,
    #renew-modal .card,
    #reject-modal .card {
        max-width: 96vw;
        width: 96vw;
        padding: 20px 16px;
    }

    /* User edit modal: full width su mobile */
    #user-edit-modal .card {
        max-width: 100%;
        width: 100%;
    }

    /* Touch targets minimi */
    button { min-height: 36px; }

    /* Bottone rinnova full-width su mobile */
    .btn-renew-sub {
        width: 100%;
        justify-content: center;
        padding: 10px 16px !important;
        font-size: 0.875rem !important;
    }

    /* Credenziali piattaforme: stack su mobile */
    .plat-cred-row { flex-wrap: wrap; gap: 10px; }
    .plat-cred-row code { word-break: break-all; max-width: 100%; }

    /* Griglia piani: 1 colonna */
    .cards-grid { grid-template-columns: 1fr; }

    /* Bottoni piani: 2 per riga */
    .plan-interval-btns {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px !important;
    }
    .plan-interval-btns button { width: 100%; }

    /* Page title ridotto su mobile */
    .page-title { font-size: 1.15rem; }
    .page-subtitle { font-size: 0.8rem; }

    /* Admin content padding ridotto su mobile */
    .content main { padding: 20px 14px; }
}

/* Stats-grid: 1 colonna su schermi molto piccoli */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
}
