:root {
    --primary: #1976D2;
    --primary-dark: #1565C0;
    --bg: #f8f9fa;
}

html, body {
    background: var(--bg);
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}
body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    font-size: 15px;
}

/* ── TOP BAR ── */
#topbar {
    background: var(--primary);
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
#topbar .app-name { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }
#topbar .offline-badge { background: #f44336; border-radius: 4px; padding: 2px 8px; font-size: .75rem; }
#topbar .online-badge  { background: #4CAF50; border-radius: 4px; padding: 2px 8px; font-size: .75rem; display: none; }

/* ── BOTTOM NAV ── */
#bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
#bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    cursor: pointer;
    color: #757575;
    font-size: .7rem;
    border: none;
    background: none;
    transition: color .2s;
}
#bottom-nav .nav-item.active { color: var(--primary); }
#bottom-nav .nav-item i { font-size: 1.4rem; margin-bottom: 2px; }

/* ── CALENDAR ── */
#calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
}
.cal-day {
    background: #fff;
    min-height: 64px;
    padding: 4px;
    cursor: pointer;
    position: relative;
    transition: background .15s;
}
.cal-day:hover { background: #e3f2fd; }
.cal-day.today { background: #e8f5e9; }
.cal-day.other-month { background: #fafafa; color: #bbb; }
.cal-day .day-num { font-size: .8rem; font-weight: 600; margin-bottom: 2px; }
.cal-bars { display: flex; flex-direction: column; gap: 1px; margin-top: 1px; }
.cal-bar {
    border-radius: 3px;
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    text-align: center;
    line-height: 14px;
    height: 14px;
}
.cal-header-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: #555;
    padding: 4px 0;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

/* ── EVENT CARDS ── */
.event-card {
    border-left: 4px solid;
    border-radius: 6px;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.event-card .card-body { padding: 10px 12px; }
.event-card .insegna { font-weight: 700; font-size: 1rem; }
.event-card .date-range { color: #555; font-size: .85rem; }
.company-badge {
    display: inline-block;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: .75rem;
    color: #fff;
    font-weight: 600;
}
.product-list { font-size: .85rem; color: #444; margin-top: 4px; }

/* ── IMPORT MODAL ── */
.import-step { display: none !important; }
.import-step.active { display: block !important; }
.import-step.active.d-flex { display: flex !important; }
#dropzone {
    border: 2px dashed #90CAF9;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: background .2s, border-color .2s;
    color: #1976D2;
}
#dropzone.dragover { background: #e3f2fd; border-color: var(--primary); }

/* ── SETTINGS ── */
.mapping-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mapping-row label { width: 140px; font-size: .85rem; color: #555; flex-shrink: 0; }
.mapping-row input { width: 70px; }

/* ── ANALYTICS ── */
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.stat-card .stat-num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { color: #555; font-size: .85rem; }

/* ── LOGIN ── */
#login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1976D2 0%, #42A5F5 100%);
}
#login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
#login-card .logo { text-align: center; margin-bottom: 24px; }
#login-card .logo-text { font-size: 1.8rem; font-weight: 700; color: var(--primary); }

/* ── UTILITIES ── */
.spinner-overlay {
    position: fixed; inset: 0;
    background: rgba(255,255,255,.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.page { display: none; }
.page.active { display: block; }

/* ── DESKTOP NAV (topbar links) ── */
.desktop-nav .nav-item {
    color: rgba(255,255,255,.85);
    font-size: .85rem;
    border-color: rgba(255,255,255,.4);
    padding: 4px 10px;
}
.desktop-nav .nav-item:hover { color: #fff; border-color: rgba(255,255,255,.8); background: rgba(255,255,255,.1); }
.desktop-nav .nav-item.active { color: #fff; border-color: #fff; background: rgba(255,255,255,.2); font-weight: 600; }

/* ── DAY MODAL (mobile-optimized) ── */
#dayModal .accordion.accordion-flush { margin: 0 -1rem; }
#dayModal .accordion-button { padding: 10px 1rem; }
#dayModal .accordion-button::after { margin-left: 8px; flex-shrink: 0; }
#dayModal .accordion-body { padding: 8px 1rem; }

@media (min-width: 768px) {
    body { padding-bottom: 0; }
    #bottom-nav { display: none; }
    .desktop-nav { display: flex !important; }
    #calendar-grid { gap: 2px; }
    .cal-day { min-height: 90px; }
}
