/* ============================================
   CANTIERE & FERIE TRACKER — Design System v5
   Top nav, Ore Ferie page, projections
   ============================================ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-active: rgba(255, 255, 255, 0.15);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --cantiere-primary: #f97316;
    --cantiere-light: #fb923c;
    --cantiere-bg: rgba(249, 115, 22, 0.12);
    --cantiere-border: rgba(249, 115, 22, 0.3);
    --cantiere-glow: rgba(249, 115, 22, 0.25);

    --ferie-primary: #06b6d4;
    --ferie-light: #22d3ee;
    --ferie-bg: rgba(6, 182, 212, 0.12);
    --ferie-border: rgba(6, 182, 212, 0.3);
    --ferie-glow: rgba(6, 182, 212, 0.25);

    --permesso-primary: #8b5cf6;
    --permesso-light: #a78bfa;
    --permesso-bg: rgba(139, 92, 246, 0.12);
    --permesso-border: rgba(139, 92, 246, 0.3);
    --permesso-glow: rgba(139, 92, 246, 0.25);

    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.12);
    --warning: #eab308;
    --warning-bg: rgba(234, 179, 8, 0.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(249, 115, 22, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

/* ============================================
   TOP NAV BAR
   ============================================ */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
}

.top-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
}

.nav-logo-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    line-height: 1;
    flex-shrink: 0;
}

.nav-brand {
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--cantiere-light), var(--ferie-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.nav-version {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.nav-tabs {
    display: flex;
    gap: 3px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 3px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.9rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-secondary);
}

.nav-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}

.tab-icon {
    font-size: 0.85rem;
}

/* Page switching */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* ============================================
   NAV ACTIONS (Export / Import)
   ============================================ */
.nav-actions {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.nav-tab-action {
    border: 1px solid var(--border-color);
    background: transparent;
}

.nav-tab-action:hover {
    border-color: var(--border-active);
    background: rgba(255, 255, 255, 0.07);
}

@media (max-width: 520px) {
    .nav-tab-action {
        font-size: 0;
    }

    .nav-tab-action .tab-icon {
        font-size: 0.85rem;
    }
}

/* ============================================
   LAYOUT
   ============================================ */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

/* Sections */
.section {
    margin-top: 1.25rem;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.section-icon {
    font-size: 1rem;
}

.section-subtitle {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    margin-top: -0.3rem;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.section-title-row .section-title {
    margin-bottom: 0;
}

/* Two-column */
.two-col-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
    margin-top: 1.25rem;
}

@media (max-width: 768px) {
    .two-col-section {
        grid-template-columns: 1fr;
    }
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1rem;
    backdrop-filter: blur(20px);
    margin-bottom: 0.5rem;
}

.compact-card {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-lg);
}

.storico-card {
    max-height: 420px;
    overflow-y: auto;
}

/* ============================================
   NAV BUTTONS
   ============================================ */
.gantt-nav {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.nav-btn-sm {
    width: 24px;
    height: 24px;
    font-size: 0.6rem;
}

.nav-label {
    font-size: 0.82rem;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}

.nav-label-sm {
    font-size: 0.78rem;
    min-width: 50px;
}

.compact-nav {
    gap: 0.35rem;
}

/* Gantt text button (Oggi) and Busta Paga buttons */
.nav-btn-text {
    height: var(--control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.7rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.nav-btn-text:hover {
    border-color: var(--cantiere-primary);
    color: var(--cantiere-light);
    background: var(--cantiere-bg);
}

/* Specific alignments for Busta Paga Controls */
.bp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.6rem;
}

.bp-level-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.bp-level-selector .form-label {
    margin-bottom: 0;
}

.gantt-goto {
    position: relative;
}

.gantt-date-input {
    width: 130px;
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
}

/* ============================================
   GANTT
   ============================================ */
.gantt-card {
    padding: 0;
    overflow: hidden;
}

.gantt-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.gantt-table {
    width: 100%;
    border-collapse: collapse;
}

.gantt-month-header-row th {
    padding: 0.35rem 0;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    letter-spacing: 0.3px;
}

.gantt-week-row th {
    padding: 0.2rem 0;
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--cantiere-light);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.2);
}

.gantt-week-row th.gantt-label-col {
    border-left: none;
    box-shadow: none;
}

.gantt-month-header-row th.gantt-label-col,
.gantt-header-row th.gantt-label-col,
.gantt-day-numbers th.gantt-label-col {
    min-width: 120px;
    width: 120px;
    position: sticky;
    left: 0;
    z-index: 4;
    background: var(--bg-secondary);
}

.gantt-header-row th {
    padding: 0.2rem 0;
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    min-width: 22px;
}

.gantt-day-numbers th {
    padding: 0.15rem 0 0.3rem;
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    border-bottom: 1px solid var(--border-active);
    background: var(--bg-secondary);
}

.today-col {
    background: rgba(249, 115, 22, 0.08);
}

.gantt-event-col {
    background: rgba(239, 68, 68, 0.15);
    /* Rosso più visibile */
    border-left: 1px solid rgba(239, 68, 68, 0.2);
    cursor: pointer;
}

th.today-col {
    color: var(--cantiere-light) !important;
    font-weight: 700 !important;
    background: rgba(249, 115, 22, 0.15) !important;
}

.weekend-col {
    background: rgba(255, 255, 255, 0.015);
}

.month-sep {
    border-left: 2px solid var(--border-active) !important;
}

.gantt-row td {
    padding: 0;
    height: 30px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    min-width: 22px;
}

.gantt-row td.gantt-label-cell {
    padding: 0 0.4rem 0 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.7rem;
    font-weight: 500;
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
    min-width: 120px;
    width: 120px;
    border-right: 1px solid var(--border-color);
}

.gantt-label-inner {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.gantt-label-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.gantt-label-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-block {
    display: block;
    position: absolute;
    inset: 2px 1px;
    border-radius: 3px;
    opacity: 0.85;
    transition: opacity var(--transition-fast);
}

.gantt-block:hover {
    opacity: 1;
    z-index: 5;
}

/* ============================================
   FAB
   ============================================ */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cantiere-primary), var(--ferie-primary));
    color: white;
    font-size: 1.6rem;
    font-weight: 300;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.35);
    z-index: 9999;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    transform: translateZ(0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    line-height: 1;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 28px rgba(249, 115, 22, 0.5);
}

/* ============================================
   FORM MODAL / OVERLAY
   ============================================ */
.form-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.form-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.form-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    width: 92%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: transform var(--transition-normal);
}

.form-overlay.show .form-modal {
    transform: translateY(0) scale(1);
}

.form-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.form-modal-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.form-close {
    position: relative;
    z-index: 10;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    pointer-events: auto;
    transition: all var(--transition-fast);
}

.form-close:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: 0.85rem;
}

.form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.optional {
    color: var(--text-muted);
    font-weight: 400;
}

/* Base height for all standard UI controls (buttons, selects, inputs) */
:root {
    --control-height: 36px;
}

.form-input {
    width: 100%;
    height: var(--control-height);
    padding: 0 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.82rem;
    transition: all var(--transition-fast);
    outline: none;
    display: flex;
    align-items: center;
}

.form-input:focus {
    border-color: var(--border-active);
    background: rgba(255, 255, 255, 0.07);
}

.form-input option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.form-hint {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.mt-sm {
    margin-top: 0.5rem;
}

/* Color section */
.color-section {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.color-swatches {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.swatch {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.active {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.color-picker-wrapper {
    position: relative;
    width: 34px;
    height: 26px;
    flex-shrink: 0;
}

.color-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: var(--radius-md);
    background: none;
    opacity: 0;
    z-index: 2;
}

.color-preview {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-active);
    transition: all var(--transition-fast);
}

/* Type Selector */
.type-selector {
    display: flex;
    gap: 0.4rem;
}

.type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem;
    border: 1.5px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.type-btn:hover {
    border-color: var(--border-active);
}

.type-btn.active[data-type="cantiere"] {
    border-color: var(--cantiere-primary);
    background: var(--cantiere-bg);
    color: var(--cantiere-light);
    box-shadow: 0 0 10px var(--cantiere-glow);
}

.type-btn.active[data-type="ferie"] {
    border-color: var(--ferie-primary);
    background: var(--ferie-bg);
    color: var(--ferie-light);
    box-shadow: 0 0 10px var(--ferie-glow);
}

.type-btn.active[data-type="evento"] {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
    box-shadow: 0 0 10px var(--danger-bg);
}

.type-emoji {
    font-size: 0.95rem;
}

/* Period Selector */
.period-selector {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    padding: 2px;
}

.period-btn {
    flex: 1;
    padding: 0.4rem 0.15rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.period-btn:hover {
    color: var(--text-secondary);
}

.period-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Preview */
.preview-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.7rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.85rem;
}

.preview-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.preview-count {
    font-size: 1rem;
    font-weight: 700;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary {
    width: 100%;
    padding: 0.65rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: linear-gradient(135deg, var(--cantiere-primary), var(--ferie-primary));
    color: white;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.15));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.btn-danger {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    background: var(--danger);
    color: white;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover {
    background: #dc2626;
}

/* ============================================
   STORICO
   ============================================ */
.storico-filters {
    display: flex;
    gap: 2px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 2px;
    margin-bottom: 0.5rem;
}

.filter-btn {
    flex: 1;
    padding: 0.35rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.filter-btn:hover {
    color: var(--text-secondary);
}

.filter-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Entry item */
.entry-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.entry-item:last-child {
    border-bottom: none;
}

.entry-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.entry-details {
    flex: 1;
    min-width: 0;
}

.entry-name {
    font-size: 0.78rem;
    font-weight: 600;
}

.entry-dates {
    font-size: 0.68rem;
    color: var(--text-secondary);
}

.entry-meta {
    font-size: 0.62rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entry-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.entry-count-number {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

.entry-count-label {
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.entry-delete {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.entry-delete:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.entry-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.entry-edit {
    width: 26px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.entry-edit:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.4rem;
}

.empty-state p {
    font-size: 0.78rem;
}

/* ============================================
   RIEPILOGO — compact
   ============================================ */
.summary-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.summary-mini {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

.summary-mini.cantiere-accent {
    border-color: var(--cantiere-border);
    box-shadow: 0 2px 12px var(--cantiere-glow);
}

.summary-mini.ferie-accent {
    border-color: var(--ferie-border);
    box-shadow: 0 2px 12px var(--ferie-glow);
}

.mini-icon {
    font-size: 1rem;
}

.mini-value {
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1;
}

.cantiere-accent .mini-value {
    color: var(--cantiere-light);
}

.ferie-accent .mini-value {
    color: var(--ferie-light);
}

.mini-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Monthly breakdown */
.month-row {
    display: grid;
    grid-template-columns: 65px 1fr 1fr;
    align-items: center;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.72rem;
}

.month-row:last-child {
    border-bottom: none;
}

.month-name {
    font-weight: 500;
    color: var(--text-secondary);
}

.month-cantiere,
.month-ferie {
    text-align: center;
    font-weight: 600;
    font-size: 0.75rem;
}

.month-cantiere {
    color: var(--cantiere-light);
}

.month-ferie {
    color: var(--ferie-light);
}

.month-header {
    color: var(--text-muted) !important;
    font-weight: 500 !important;
    font-size: 0.6rem !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.month-zero {
    color: var(--text-muted);
    opacity: 0.3;
}

/* Totals compact */
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    font-size: 0.72rem;
}

.total-row-label {
    color: var(--text-secondary);
}

.total-row-value {
    font-weight: 700;
    font-size: 0.78rem;
}

.total-row-value.cantiere-color {
    color: var(--cantiere-light);
}

.total-row-value.ferie-color {
    color: var(--ferie-light);
}

.total-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.15rem 0;
}

/* ============================================
   ORE FERIE PAGE
   ============================================ */

/* Input grid */
.ore-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
}

@media (max-width: 768px) {
    .ore-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .ore-grid {
        grid-template-columns: 1fr;
    }
}

.ore-input-group {
    min-width: 0;
}

.ore-input-group .form-input {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    padding: 0.6rem;
}

/* Summary cards */
.ore-summary-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

@media (max-width: 600px) {
    .ore-summary-row {
        grid-template-columns: 1fr;
    }
}

.ore-summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1rem;
    backdrop-filter: blur(20px);
    text-align: center;
}

.ore-summary-card.ferie-card {
    border-color: var(--ferie-border);
    box-shadow: 0 2px 16px var(--ferie-glow);
}

.ore-summary-card.permesso-card {
    border-color: var(--permesso-border);
    box-shadow: 0 2px 16px var(--permesso-glow);
}

.ore-summary-card.totale-card {
    border-color: var(--cantiere-border);
    box-shadow: 0 2px 16px var(--cantiere-glow);
}

.ore-summary-header {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.ore-summary-values {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 1rem;
}

.ore-big {
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.ore-big-number {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
}

.ferie-card .ore-big-number {
    color: var(--ferie-light);
}

.permesso-card .ore-big-number {
    color: var(--permesso-light);
}

.totale-card .ore-big-number {
    color: var(--cantiere-light);
}

.ore-big-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.ore-secondary {
    display: flex;
    align-items: baseline;
    gap: 0.15rem;
    opacity: 0.65;
}

.ore-sec-number {
    font-size: 0.95rem;
    font-weight: 700;
}

.ore-sec-unit {
    font-size: 0.55rem;
    color: var(--text-muted);
}

/* Projection table */
.projection-table-wrapper {
    overflow-x: auto;
}

.projection-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.projection-table th {
    padding: 0.5rem 0.4rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--border-active);
    white-space: nowrap;
}

.projection-table td {
    padding: 0.45rem 0.4rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-variant-numeric: tabular-nums;
}

.projection-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.proj-month {
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left !important;
    padding-left: 0.6rem !important;
}

.proj-ferie {
    color: var(--ferie-light);
}

.proj-permesso {
    color: var(--permesso-light);
}

.proj-total {
    font-weight: 700;
}

.proj-limit {
    color: var(--text-muted);
}

.proj-limit.at-limit {
    color: var(--warning);
    background: var(--warning-bg);
    border-radius: 4px;
}

.proj-warning {
    font-weight: 700;
    font-size: 0.72rem;
}

.proj-warning.over {
    color: var(--danger);
}

.proj-warning.ok {
    color: #10b981;
}

/* Semester row highlight */
.semester-row {
    background: rgba(234, 179, 8, 0.04) !important;
}

.semester-row td {
    border-bottom: 2px solid rgba(234, 179, 8, 0.2);
}

/* Current month highlight */
.current-month-row {
    background: rgba(249, 115, 22, 0.05) !important;
}

/* Sub-value (gg) in projection cells */
.proj-gg {
    display: block;
    font-size: 0.58rem;
    opacity: 0.55;
    font-weight: 500;
    line-height: 1.2;
}

/* Auto-calc deducted column */
.proj-deducted {
    color: var(--ferie-light);
    font-weight: 600;
}

.proj-deducted-val {
    display: block;
    font-size: 0.72rem;
}

/* ============================================
   AUTO-CALC TOGGLE
   ============================================ */
.auto-calc-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    color: var(--text-muted);
}

.auto-calc-toggle:hover {
    border-color: var(--border-active);
    color: var(--text-secondary);
}

.auto-calc-toggle.active {
    border-color: var(--ferie-primary);
    background: var(--ferie-bg);
    color: var(--ferie-light);
}

.toggle-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-muted);
    transition: all var(--transition-fast);
    position: relative;
}

.auto-calc-toggle.active .toggle-dot {
    border-color: var(--ferie-primary);
    background: var(--ferie-primary);
}

.toggle-label {
    font-size: 0.68rem;
    font-weight: 600;
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-active);
    color: var(--text-primary);
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-lg);
    font-size: 0.78rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 100;
    opacity: 0;
    transition: all var(--transition-normal);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Export modal */
.export-modal {
    max-width: 360px;
    text-align: left;
}

.export-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.export-modal-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
}

.export-modal .form-group {
    margin-bottom: 1rem;
}

.export-modal .btn-primary {
    margin-top: 0.25rem;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    max-width: 300px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-message {
    font-size: 0.85rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
}

/* ============================================
   BUSTA PAGA PAGE
   ============================================ */
.bp-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.bp-level-selector {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.bp-label {
    margin-bottom: 0;
    white-space: nowrap;
}

.bp-select {
    width: auto;
    min-width: 70px;
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    appearance: auto;
    -webkit-appearance: auto;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.bp-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.bp-settings-btn {
    font-size: 0.72rem !important;
    padding: 0.25rem 0.6rem !important;
}

.bp-month-select {
    width: auto;
    min-width: 60px;
    padding: 0.2rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 600;
    appearance: auto;
    -webkit-appearance: auto;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.bp-month-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.bp-month-nav {
    gap: 0.3rem;
}

/* Day counts */
.bp-counts-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
}

@media (max-width: 600px) {
    .bp-counts-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

.bp-count-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.8rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

.bp-count-item.bp-count-notworked {
    border-color: rgba(234, 179, 8, 0.3);
    box-shadow: 0 2px 12px rgba(234, 179, 8, 0.08);
}

.bp-count-num {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--cantiere-light);
}

.bp-count-notworked .bp-count-num {
    color: var(--warning);
}

.bp-count-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-align: center;
}

/* Summary cards */
.bp-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

@media (max-width: 700px) {
    .bp-summary-grid {
        grid-template-columns: 1fr;
    }
}

.bp-summary-card {
    text-align: center;
}

.bp-total-card {
    border-color: var(--cantiere-border);
    box-shadow: 0 2px 16px var(--cantiere-glow);
}

.bp-card-header {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bp-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.bp-card-row:last-child {
    border-bottom: none;
}

.bp-row-label {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.bp-row-value {
    font-size: 0.85rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bp-highlight {
    color: var(--cantiere-light);
    font-size: 0.95rem;
}

/* Detail table */
.bp-detail-table {
    font-size: 0.78rem;
}

.bp-dt-header {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 2px solid var(--border-active);
    font-weight: 600;
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bp-dt-section {
    padding: 0.5rem 0 0.2rem;
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--cantiere-light);
    border-top: 1px solid var(--border-color);
}

.bp-dt-section:first-of-type {
    border-top: none;
}

.bp-dt-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
}

.bp-dt-row span:last-child {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bp-dt-subtotal {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-weight: 700;
    border-top: 1px dashed var(--border-active);
    border-bottom: 1px solid var(--border-color);
}

.bp-dt-total {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-weight: 800;
    font-size: 0.88rem;
}

.bp-dt-netto {
    color: #10b981;
    font-size: 0.95rem;
}

.bp-formula-note {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.6rem;
    font-style: italic;
}

/* ============================================
   DAY OVERRIDE MODAL
   ============================================ */
.day-worked-modal {
    max-width: 320px;
    padding: 1.25rem;
}

.day-override-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 0.6rem 0;
}

.day-override-row.muted {
    opacity: 0.5;
    pointer-events: none;
}

.day-override-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.day-override-input {
    width: 70px;
    padding: 0.2rem 0.4rem;
    text-align: center;
}

.day-override-note {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    font-style: italic;
    text-align: left;
    line-height: 1.4;
}

/* Activity Cards Grid for Day Worked */
.activity-cards {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
    margin: 1rem 0;
}

.activity-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    aspect-ratio: 1;
}

.activity-card svg {
    width: 24px;
    height: 24px;
}

.activity-card span {
    font-size: 0.65rem;
    font-weight: 600;
    font-family: inherit;
}

.activity-card:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Active State Colors */
.activity-card.active[data-type="worked"] {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
    /* Amber */
    color: #f59e0b;
}

.activity-card.active[data-type="not-worked"] {
    border-color: #94a3b8;
    background: rgba(148, 163, 184, 0.08);
    /* Slate */
    color: #cbd5e1;
}

.activity-card.active[data-type="travel"] {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.08);
    /* Cyan */
    color: #06b6d4;
}

.day-worked-toggle {
    display: flex;
    gap: 0.4rem;
}

.btn-toggle {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-toggle:hover {
    border-color: var(--border-active);
    color: var(--text-secondary);
}

.btn-toggle.active[data-val="true"] {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.btn-toggle.active[data-val="false"] {
    border-color: var(--danger);
    background: var(--danger-bg);
    color: var(--danger);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

/* ============================================
   LEVEL SETTINGS MODAL
   ============================================ */
.level-settings-modal {
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
}

.ls-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--cantiere-light);
    margin-top: 1rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--border-color);
}

.ls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
}

@media (max-width: 480px) {
    .ls-grid {
        grid-template-columns: 1fr;
    }
}

.ls-field .form-input {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.ls-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.2rem;
    justify-content: flex-end;
}

.ls-actions .btn-primary {
    width: auto;
    padding: 0.5rem 1.5rem;
}

/* ============================================
   GANTT — Not Worked & Clickable indicators
   ============================================ */
.gantt-clickable {
    cursor: pointer;
}

.gantt-clickable:hover .gantt-block {
    opacity: 1;
    filter: brightness(1.15);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.gantt-block.gantt-not-worked {
    opacity: 0.35;
    background-image: repeating-linear-gradient(45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.4) 2px,
            rgba(0, 0, 0, 0.4) 4px) !important;
}

.gantt-block.gantt-viaggio {
    opacity: 0.7;
    background-image: repeating-linear-gradient(-45deg,
            transparent,
            transparent 2px,
            rgba(59, 130, 246, 0.3) 2px,
            rgba(59, 130, 246, 0.3) 4px) !important;
}

.gantt-nw-marker {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    color: var(--danger);
    font-weight: 800;
    pointer-events: none;
    z-index: 6;
}

.grafici-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .grafici-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.grafico-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.grafico-card {
    padding: 1.25rem;
}

#page-grafici .chart-container {
    min-height: 300px;
}

#page-grafici canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.chart-canvas-native-hidden {
    display: none !important;
}

.native-chart {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.native-chart svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.native-bg {
    fill: transparent;
}

.native-grid {
    stroke: rgba(148, 163, 184, 0.14);
    stroke-width: 1;
}

.native-axis-line {
    stroke: rgba(148, 163, 184, 0.24);
    stroke-width: 1.4;
}

.native-axis {
    fill: #94a3b8;
    font-size: 12px;
    font-weight: 650;
    font-family: Inter, system-ui, sans-serif;
}

.native-x {
    text-anchor: middle;
}

.native-area-orange {
    fill: rgba(249, 115, 22, 0.12);
}

.native-line-orange {
    fill: none;
    stroke: #f97316;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.native-line-blue {
    fill: none;
    stroke: #3b82f6;
    stroke-width: 2.5;
    stroke-dasharray: 7 7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.native-dot-orange {
    fill: #f97316;
}

.native-dot-blue {
    fill: #3b82f6;
}

.native-bar-green {
    fill: #10b981;
}

.native-value {
    fill: #d1fae5;
    font-size: 12px;
    font-weight: 800;
    text-anchor: middle;
    font-family: Inter, system-ui, sans-serif;
}

.native-legend text {
    fill: #cbd5e1;
    font-size: 12px;
    font-weight: 700;
    font-family: Inter, system-ui, sans-serif;
}

.native-empty {
    fill: #64748b;
    font-size: 16px;
    font-weight: 700;
    text-anchor: middle;
    font-family: Inter, system-ui, sans-serif;
}

@media (max-width: 700px) {
    #page-grafici .chart-container {
        min-height: 280px;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.empty-state,
.empty-state *,
.empty-icon {
    pointer-events: none;
}

/* iPhone definitive PWA fixes */
html {
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior-y: none;
    touch-action: manipulation;
}

.top-nav {
    top: env(safe-area-inset-top);
}

input,
select,
textarea,
button {
    font-size: 16px;
}

.nav-tabs,
.nav-actions {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 520px) {
    .top-nav-inner {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
}

/* Mobile layout polish: keep controls from overlapping on iPhone */
@media (max-width: 700px) {
    .top-nav-inner {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.45rem;
        padding: max(0.5rem, env(safe-area-inset-top)) 0.75rem 0.55rem;
    }

    .nav-logo-container {
        order: 1;
        width: 66px;
        min-width: 66px;
    }

    .nav-actions {
        order: 2;
        flex: 1 1 calc(100% - 76px);
        min-width: 0;
        margin-left: 0;
        justify-content: flex-end;
        overflow: visible;
    }

    .nav-tabs {
        order: 3;
        width: 100%;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar,
    .nav-actions::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        min-height: 36px;
        padding: 0.42rem 0.75rem;
    }

    .nav-tab-action {
        display: none !important;
    }

    .ocf-auth-bar {
        min-width: 0 !important;
        max-width: 100% !important;
        justify-content: flex-end !important;
        gap: 6px !important;
    }

    .ocf-auth-label {
        display: none !important;
    }

    .ocf-auth-select {
        width: min(162px, 48vw) !important;
        max-width: 48vw !important;
        height: 36px !important;
        padding: 0 8px !important;
        font-size: 16px !important;
    }

    .ocf-auth-logout {
        height: 36px !important;
        padding: 0 10px !important;
        font-size: 16px !important;
        flex: 0 0 auto !important;
    }

    .app-container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-bottom: calc(7rem + env(safe-area-inset-bottom));
    }

    .section-title-row {
        align-items: flex-start;
        gap: 0.65rem;
    }

    .section-title-row .gantt-nav {
        width: 100%;
        display: grid;
        grid-template-columns: 34px minmax(130px, 1fr) 34px 64px;
        gap: 0.45rem;
    }

    .section-title-row .gantt-nav .nav-btn,
    .section-title-row .gantt-nav .nav-btn-text {
        width: 100%;
        min-width: 0;
    }

    .section-title-row .gantt-nav .nav-label {
        min-width: 0;
        width: 100%;
        align-self: center;
        white-space: nowrap;
    }

    .gantt-goto {
        display: none;
    }

    .storico-card {
        max-height: 54vh;
    }

    .entry-item {
        gap: 0.55rem;
        padding: 0.65rem 0;
    }

    .entry-name {
        font-size: 0.86rem;
    }

    .entry-dates {
        font-size: 0.74rem;
    }

    .entry-meta {
        font-size: 0.68rem;
    }

    .entry-count {
        padding: 0.24rem 0.48rem;
    }

    .entry-actions {
        gap: 6px;
    }

    .entry-edit,
    .entry-delete {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }

    .fab {
        right: 1rem;
        bottom: calc(5.75rem + env(safe-area-inset-bottom));
        width: 50px;
        height: 50px;
        z-index: 80;
    }
}

@media (max-width: 380px) {
    .nav-logo-container {
        width: 58px;
        min-width: 58px;
    }

    .ocf-auth-select {
        width: min(140px, 46vw) !important;
        max-width: 46vw !important;
    }

    .section-title-row .gantt-nav {
        grid-template-columns: 32px minmax(112px, 1fr) 32px 58px;
    }
}
