@import url('https://fonts.googleapis.com/css2?family=Commissioner:wght@300;400;500&family=Source+Code+Pro:wght@400&family=Sarabun:wght@300;400;600&display=swap');

:root {
    --magenta:    #0D5F75;
    --magenta2:   #0a4d60;
    --cyan:       #C1CBE8;
    --cyan2:      #666b84;
    --dark:       #171b33;
    --grey:       #666b84;
    --light:      #e8ecf7;
    --white:      #ffffff;
    --border:     #e4e4ec;
    --shadow:     0 2px 20px rgba(0,0,0,0.07);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.12);
    --radius:     4px;
    --radius-sm:  6px;
    --font:          'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-title:    'Commissioner', 'Sarabun', -apple-system, sans-serif;
    --font-subtitle: 'Source Code Pro', 'Courier New', monospace;
    --green:      #0D5F75;
    --green-bg:   #e8ecf7;
    --green-text: #0D5F75;
    --yellow:     #b00020;
    --yellow-bg:  #C1CBE8;
    --yellow-text:#b00020;
    --red:        #FF8500;
    --red-bg:     #fff3e0;
    --red-text:   #FF8500;
    --grey-dot:   #666b84;
    --grey-bg:    #f4f4f8;
    --grey-text:  #4b4d68;
}
/* ─── COMMISSIONER: titoli e CTA ───────────────────────────────────── */
h1, h2, h3, h4, h5, h6,
.hero-title, .hero-label,
.section-title, .card-title, .modal-title,
.sw-stat-num, .site-stat-card h3,
.btn-primary, .btn-update, .btn-ping, .btn-save-profile,
.btn-ai-toggle, .form-btn, .btn-login, .btn-register {
    font-family: var(--font-title);
}
/* ─── SOURCE CODE PRO: sottotitoli ─────────────────────────────────── */
.hero-sublabel, .section-subtitle, .card-subtitle, p.sub {
    font-family: var(--font-subtitle);
    font-weight: 400;
}


* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 15px;
    font-weight: 300;
    background: #f0f0f4;
    color: var(--dark);
    min-height: 100vh;
}

/* ─── NAVBAR ─────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.navbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    height: 100%;
    padding: 0 32px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}
.navbar-left   { display: flex; align-items: center; gap: 12px; }
.navbar-center { display: flex; align-items: center; gap: 4px; justify-content: center; }
.navbar-right  { display: flex; align-items: center; justify-content: flex-end; gap: 10px; position: relative; }

.navbar-logo {
    display: flex; align-items: center;
    cursor: pointer; padding: 4px 0;
}
.navbar-logo img { height: 26px; object-fit: contain; }

.navbar-badge {
    background: #C1CBE8; color: var(--magenta);
    font-size: 11px; font-weight: 700;
    padding: 3px 10px; border-radius: 20px; letter-spacing: .02em;
}

/* nav items */
.nav-item {
    background: none; border: none; cursor: pointer;
    font-family: var(--font); font-size: 15px; font-weight: 600;
    color: #4b5563; padding: 8px 18px; border-radius: 24px;
    transition: all .15s; white-space: nowrap;
}
.nav-item:hover  { background: #f4f4f8; color: #374151; }
.nav-item.active { background: #FF8500; color: white; font-weight: 600; }

/* utente pill destra */
.navbar-user-pill {
    display: flex; align-items: center; gap: 9px;
    cursor: pointer; padding: 4px 9px 4px 4px;
    border-radius: 40px; transition: background .15s;
    user-select: none;
    background: #fff; border: 1.5px solid #e4e8f0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.navbar-user-pill:hover { background: #f9fafc; }

.navbar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: #C1CBE8; color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
    overflow: hidden;
}
.navbar-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.navbar-user-text  { display: flex; flex-direction: column; }
.navbar-user-name  { font-size: 12px; font-weight: 400; color: #0D5F75; line-height: 1.2; }
.navbar-user-sub   { font-size: 10px; color: #C1CBE8; font-weight: 400; }

/* dropdown utente */
.user-dropdown {
    position: absolute; top: calc(100% + 10px); right: 0;
    background: var(--white); border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.13); border: 1px solid var(--border);
    min-width: 240px; z-index: 300; overflow: hidden;
}
.user-dropdown-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 18px;
}
.user-dropdown-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: #C1CBE8; color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700; flex-shrink: 0; overflow: hidden;
}
.user-dropdown-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-dropdown-name  { font-size: 14px; font-weight: 700; color: var(--dark); }
.user-dropdown-email { font-size: 12px; color: var(--grey); margin-top: 1px; }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 0; }
.user-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; background: none; border: none; cursor: pointer;
    font-family: var(--font); font-size: 14px; font-weight: 300;
    color: var(--dark); padding: 12px 18px; text-align: left;
    transition: background .12s;
}
.user-dropdown-item:hover { background: #f8f8fc; }
.user-dropdown-item.logout { color: var(--magenta); }
.user-dropdown-item.logout:hover { background: #e8ecf7; }

/* modal profilo */
.profile-avatar-section {
    display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.profile-avatar-preview {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--magenta); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.btn-upload {
    display: inline-block; cursor: pointer;
    background: none; border: 1.5px solid var(--border);
    color: var(--grey-text); font-size: 12px; font-weight: 600;
    font-family: var(--font); padding: 6px 14px; border-radius: 8px;
    transition: all .15s;
}
.btn-upload:hover { border-color: var(--cyan); color: var(--magenta); }
.profile-field { margin-bottom: 14px; }
.profile-label { display: block; font-size: 11px; font-weight: 700; color: var(--grey); margin-bottom: 5px; }
.profile-input {
    width: 100%; box-sizing: border-box;
    border: 1.5px solid var(--border); border-radius: 4px;
    padding: 9px 12px; font-family: var(--font); font-size: 14px; color: var(--dark);
    outline: none; transition: border-color .15s; background: var(--white);
}
.profile-input:focus { border-color: var(--magenta); }
textarea.profile-input { resize: vertical; }
.profile-actions { margin-top: 20px; }
.btn-save-profile {
    width: 100%; background: var(--magenta); color: white; border: none;
    border-radius: 6px; padding: 11px; font-family: var(--font);
    font-size: 14px; font-weight: 700; cursor: pointer; transition: opacity .15s;
}
.btn-save-profile:hover { opacity: .88; }

/* ─── INFO / LEGENDA MODAL ───────────────────────────────────────────────── */
.info-overlay {
    position: fixed; inset: 0;
    background: rgba(24,24,52,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.info-card {
    background: var(--white); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto;
}
.info-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 0;
    font-size: 16px; font-weight: 800; color: var(--dark);
}
.info-close {
    background: none; border: none; font-size: 16px; cursor: pointer;
    color: var(--grey); padding: 4px 8px; border-radius: 6px;
}
.info-close:hover { background: #f0f0f4; }
.info-card-body { padding: 16px 24px 24px; }
.info-section-title {
    font-size: 11px; font-weight: 700; color: var(--grey);
    letter-spacing: .04em; margin: 16px 0 10px;
}
.info-section-title:first-child { margin-top: 0; }
.info-row {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid #f4f4f8;
    font-size: 14px; color: var(--text);
}
.info-row:last-child { border-bottom: none; }
.info-divider { height: 1px; background: #eef0f6; margin: 8px 0; }
.info-text { font-size: 14px; color: var(--text); line-height: 1.6; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 32px;
}

/* ─── HERO ───────────────────────────────────────────────────────────────── */
.hero {
    background: var(--magenta);
    border-radius: var(--radius);
    padding: 44px 44px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    color: white;
}
.hero::before {
    content: ''; position: absolute;
    right: -40px; top: -60px;
    width: 260px; height: 260px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}
.hero::after {
    content: ''; position: absolute;
    right: 120px; bottom: -100px;
    width: 340px; height: 340px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
}
.hero-label  {
    font-size: 13px; font-weight: 700;
    opacity: .9; margin-bottom: 4px;
}
.hero-sublabel {
    font-size: 12px; font-weight: 500;
    opacity: .7; margin-bottom: 14px; letter-spacing: .02em;
}
.hero-title  { font-size: 38px; font-weight: 800; line-height: 1.1; }

/* ─── STAT CARDS (KPI) ───────────────────────────────────────────────────── */
.sw-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.sw-stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 26px 28px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 18px;
    transition: box-shadow .15s;
}
.sw-stat-card:hover { box-shadow: var(--shadow-lg); }
.sw-stat-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: white;
    flex-shrink: 0;
}
.sw-stat-text { display: flex; flex-direction: column; justify-content: center; }
.sw-stat-num   { font-size: 36px; font-weight: 800; line-height: 1; color: var(--dark); }
.sw-stat-label { font-size: 12px; color: var(--grey); font-weight: 500; margin-top: 5px; }

/* ─── SECTION TITLE ──────────────────────────────────────────────────────── */
.section-title { font-size: 15px; font-weight: 600; color: var(--grey); margin-bottom: 16px; }

/* ─── CARD ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 20px;
}
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid #ececf2;
    background: #fafafa;
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; }

/* ─── TABLE ──────────────────────────────────────────────────────────────── */
table.sites-table { width: 100%; border-collapse: collapse; overflow: visible; }
table.sites-table th {
    text-align: left; padding: 12px 14px;
    font-size: 13px; font-weight: 700; color: #999;
    background: #fafafa; border-bottom: 1px solid var(--border);
    white-space: nowrap; position: relative; overflow: visible;
}
table.sites-table td { padding: 13px 14px; font-size: 14px; border-bottom: 1px solid #f4f4f8; }
table.sites-table tr:last-child td { border-bottom: none; }
table.sites-table tbody tr { transition: background .12s; }
table.sites-table tbody tr:hover td { background: #e8ecf7; }
.site-name-cell { font-weight: 600; font-size: 15px; }
.th-center { text-align: center !important; }
.td-center { text-align: center; }
.tip-q { display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;border-radius:50%;background:#EFEF14;color:#0D5F75;font-size:10px;font-weight:800;cursor:help;margin-left:5px;position:relative;vertical-align:middle;flex-shrink:0;border:2px solid #EFEF14;box-shadow:0 0 0 2px rgba(239,239,20,.25); }

/* ─── PSE TOGGLE ─────────────────────────────────────────────────────────── */
.pse-toggle { position:relative; display:inline-block; width:44px; height:24px; }
.pse-toggle input { opacity:0; width:0; height:0; }
.pse-slider { position:absolute; cursor:pointer; inset:0; background:#cbd5e1; border-radius:24px; transition:.2s; }
.pse-slider:before { content:""; position:absolute; height:18px; width:18px; left:3px; bottom:3px; background:white; border-radius:50%; transition:.2s; }
.pse-toggle input:checked + .pse-slider { background:var(--magenta); }
.pse-toggle input:checked + .pse-slider:before { transform:translateX(20px); }

/* ─── BTN PING ───────────────────────────────────────────────────────────── */
.btn-ping {
    background: transparent; border: 1.5px solid var(--border);
    color: var(--dark); font-family: var(--font);
    font-size: 12px; font-weight: 700;
    padding: 7px 14px; border-radius: 4px; cursor: pointer;
    transition: all .15s; white-space: nowrap;
}
.btn-ping:hover    { background: var(--cyan); border-color: var(--cyan); color: var(--magenta); }
.btn-ping:disabled { opacity: .5; cursor: default; }
.btn-ai-toggle     { background: white !important; border-color: #e4e4ec !important; color: #C1CBE8 !important; }
.btn-ai-toggle:hover { background: var(--cyan) !important; border-color: var(--cyan) !important; color: var(--magenta) !important; }

/* ─── BTN UPDATE ─────────────────────────────────────────────────────────── */
.btn-update {
    background: var(--magenta); border: none; color: white;
    font-family: var(--font); font-size: 12px; font-weight: 700;
    padding: 7px 16px; border-radius: 6px; cursor: pointer;
    transition: all .15s; white-space: nowrap; margin-left: auto;
}
.btn-update:hover    { background: var(--cyan); color: var(--magenta); }
.btn-update:disabled { opacity: .5; cursor: default; }
.btn-scan-ch:hover   { background: var(--cyan) !important; color: var(--magenta) !important; }
.btn-save-ch:hover   { border-color: var(--cyan) !important; color: var(--magenta) !important; background: #e8ecf7 !important; }
#btn-stato-sync-all:hover { background: var(--cyan) !important; color: var(--magenta) !important; }

/* ─── DOT ────────────────────────────────────────────────────────────────── */
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.green  { background: #35364f;         box-shadow: 0 0 0 4px rgba(53,54,79,.15); }
.dot.yellow { background: #C1CBE8;         box-shadow: 0 0 0 4px rgba(13,95,117,.10); }
.dot.red    { background: #b00020;        box-shadow: 0 0 0 4px rgba(176,0,32,.15); }
.dot.grey   { background: var(--grey-dot); }

/* ─── SITE STAT CARDS ────────────────────────────────────────────────────── */
.site-stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.05);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow .15s, transform .1s;
}
.site-stat-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.11); transform: translateY(-1px); }
.site-stat-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.site-stat-nums {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
}
.site-stat-num-cell {
    padding: 22px 20px; text-align: center;
}
.site-stat-num-cell:not(:last-child) { border-right: 1px solid var(--border); }
.site-big-num { font-size: 42px; font-weight: 800; line-height: 1; }
.site-big-lbl { font-size: 10px; font-weight: 700; letter-spacing: .07em; color: var(--grey); text-transform: uppercase; margin-top: 8px; }

/* ─── EMPTY / LOADING ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--grey); }
.empty-icon  { font-size: 40px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: #aaa; }
.loading     { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--grey); font-size: 14px; gap: 12px; }
.spinner     { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--magenta); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── LOGIN ──────────────────────────────────────────────────────────────── */
.login-page  { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--light); }
.login-card  { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 44px 40px; width: 100%; max-width: 400px; text-align: center; }
.login-logo  { margin-bottom: 28px; }
.login-logo img { height: 38px; }
.login-title { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--grey); margin-bottom: 32px; }
.form-group  { margin-bottom: 16px; text-align: left; }
.form-label  { font-size: 12px; font-weight: 700; margin-bottom: 6px; display: block; }
.form-input  {
    width: 100%; padding: 13px 16px;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-family: var(--font); font-size: 14px; color: var(--dark);
    outline: none; transition: border-color .15s;
    background: #fafafa;
}
.form-input:focus { border-color: var(--magenta); background: white; }
.btn-primary {
    width: 100%; background: var(--magenta); color: white; border: none;
    padding: 14px 20px; border-radius: 6px; font-family: var(--font);
    font-size: 14px; font-weight: 700; cursor: pointer;
    transition: background .15s; margin-top: 10px;
}
.btn-primary:hover    { background: var(--cyan); color: var(--magenta); }
.btn-primary:disabled { opacity: .6; cursor: default; }

/* ─── LOGIN ESTESO ───────────────────────────────────────────────────────── */
.login-msg { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.login-msg-success { background: #e6f9f0; color: #1a7a4a; }
.login-msg-error   { background: var(--red-bg); color: var(--red-text); }
.btn-link  { background: none; border: none; color: var(--magenta); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; }
.btn-link:hover { text-decoration: underline; }
.login-divider { position: relative; text-align: center; margin: 20px 0; }
.login-divider::before { content:''; position:absolute; inset:50% 0 auto; height:1px; background:var(--border); }
.login-divider span { position: relative; background: var(--white); padding: 0 12px; font-size: 11px; color: var(--grey); letter-spacing: .05em; font-weight: 600; }
.btn-google {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
    background: var(--white); border: 1.5px solid var(--border); border-radius: 10px;
    padding: 13px 20px; font-family: var(--font); font-size: 14px; font-weight: 600;
    color: var(--dark); cursor: pointer; transition: border-color .15s, background .15s;
}
.btn-google:hover { border-color: var(--cyan); background: #e8ecf7; }
.btn-google:disabled { opacity: .6; cursor: default; }
.btn-back {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--white); border: 1.5px solid var(--border);
    color: var(--dark); font-family: var(--font);
    font-size: 13px; font-weight: 700; padding: 9px 18px;
    border-radius: 10px; cursor: pointer;
    transition: all .15s; margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.btn-back:hover { border-color: var(--cyan); color: var(--magenta); background: #e8ecf7; }
.site-url-cell  { font-size: 11px; color: var(--grey); margin-top: 2px; }
.login-register { font-size: 13px; color: var(--grey); margin-top: 18px; }
.login-register a { color: var(--magenta); font-weight: 700; text-decoration: none; }
.login-register a:hover { text-decoration: underline; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sw-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .main { padding: 16px; }
    .hero { padding: 24px; }
    .hero-title { font-size: 26px; }
    .navbar { padding: 0 16px; height: 64px; }
    .sw-stats { grid-template-columns: 1fr 1fr; }
    table.sites-table th, table.sites-table td { padding: 11px 14px; }
}

/* ─── COLOR INPUT ─────────────────────────────────────────────────────────── */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 40px; height: 32px;
    padding: 2px; border: 1.5px solid #e4e4ec;
    border-radius: 6px; cursor: pointer;
    background: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 3px; }
