:root {
    /* Palette Ufficiale SCUDERIAQ (Midnight Navy + Shield Gold + Eagle Eye Red) */
    --bg: #0c1021;
    --surface: #141932;
    --surface-elevated: #1b2242;
    --surface-hover: #232c54;
    --border: #293462;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #f5b82e;
    --primary-hover: #eab308;
    --primary-light: rgba(245, 184, 46, 0.16);
    --accent-red: #dc2626;

    /* Status colors (Dark Mode) */
    --free-bg: rgba(16, 185, 129, 0.14);
    --free-border: rgba(16, 185, 129, 0.45);
    --free-text: #34d399;

    --shared-bg: rgba(245, 184, 46, 0.15);
    --shared-border: rgba(245, 184, 46, 0.48);
    --shared-text: #f5b82e;

    --exclusive-bg: rgba(220, 38, 38, 0.17);
    --exclusive-border: rgba(220, 38, 38, 0.5);
    --exclusive-text: #f87171;

    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 10px 28px rgba(4, 7, 18, 0.72);
    --shadow-lg: 0 20px 48px rgba(4, 7, 18, 0.9);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    color-scheme: dark;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    background-image: radial-gradient(circle at 50% 0%, rgba(245, 184, 46, 0.08), transparent 55%);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 14px;
}

.hidden {
    display: none !important;
}

/* --- COMPACT MOBILE-FIRST TOPBAR (SCUDERIAQ) --- */
.topbar {
    background: rgba(15, 20, 40, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1.5px solid rgba(245, 184, 46, 0.28);
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
    gap: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-logo-wrap {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #171b36;
    border: 1.5px solid rgba(245, 184, 46, 0.75);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 12px rgba(245, 184, 46, 0.22);
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.brand-title {
    font-family: 'Chakra Petch', sans-serif;
    font-style: italic;
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #ffffff;
    line-height: 1.1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.brand-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.storage-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    display: inline-block;
}

.storage-dot.cloud {
    background: #f5b82e;
    box-shadow: 0 0 8px #f5b82e;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.user-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 5px;
    border-radius: 999px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.74rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-pill-name {
    font-size: 0.8rem;
    font-weight: 600;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- MAIN LAYOUT --- */
.app-main {
    padding-top: 14px;
}

/* --- HERO STATO LIVE --- */
.live-hero {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    margin-bottom: 16px;
}

.live-hero.state-free {
    border-color: var(--free-border);
    background: radial-gradient(circle at top right, rgba(16, 185, 129, 0.16), var(--surface) 68%);
}

.live-hero.state-shared {
    border-color: var(--shared-border);
    background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.16), var(--surface) 68%);
}

.live-hero.state-exclusive {
    border-color: var(--exclusive-border);
    background: radial-gradient(circle at top right, rgba(239, 68, 68, 0.18), var(--surface) 68%);
}

.live-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.status-pill.free {
    background: var(--free-bg);
    color: var(--free-text);
    border: 1px solid var(--free-border);
}

.status-pill.shared {
    background: var(--shared-bg);
    color: var(--shared-text);
    border: 1px solid var(--shared-border);
}

.status-pill.exclusive {
    background: var(--exclusive-bg);
    color: var(--exclusive-text);
    border: 1px solid var(--exclusive-border);
}

.pulse-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
    animation: pulseAnim 1.8s infinite;
}

@keyframes pulseAnim {
    0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
    70% { box-shadow: 0 0 0 7px transparent; opacity: 0.85; }
    100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

.next-event-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.live-headline {
    font-size: 1.28rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.live-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.current-occupants {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.occupant-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.occupant-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.occupant-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.occupant-name {
    font-weight: 700;
    font-size: 0.92rem;
}

.occupant-role {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.occupant-time-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    background: #23232e;
    color: var(--text);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.occupant-note {
    font-size: 0.82rem;
    color: #e2e8f0;
    background: #0d0d11;
    padding: 7px 10px;
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.occupant-progress {
    height: 6px;
    background: #272732;
    border-radius: 999px;
    overflow: hidden;
}

.occupant-progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
}

.quick-actions-card {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
}

.quick-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.quick-actions-desc {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* --- BUTTONS (Thumb-Friendly) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 14px;
    min-height: 44px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.86rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-lg {
    min-height: 48px;
    font-size: 0.88rem;
}

.btn-sm {
    padding: 6px 11px;
    min-height: 34px;
    font-size: 0.78rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 6px 11px;
    min-height: 36px;
    background: var(--surface-elevated);
    border-color: var(--border);
    color: var(--text);
}

.btn-primary {
    background: linear-gradient(135deg, #f5b82e, #eab308);
    color: #0c1021;
    font-weight: 800;
    box-shadow: 0 4px 14px rgba(245, 184, 46, 0.25);
}

.btn-checkin {
    background: #10b981;
    color: #042f1e;
    font-weight: 800;
}

.btn-checkout {
    background: #dc2626;
    color: #fff;
    grid-column: span 2;
}

.btn-outline {
    background: var(--surface-elevated);
    border-color: var(--border);
    color: var(--text);
}

.btn-danger-ghost {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    padding: 5px 10px;
    min-height: 32px;
    font-size: 0.75rem;
    border-radius: 8px;
}

/* --- CALENDAR & SWIPEABLE 7-DAY STRIP --- */
.content-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.calendar-card, .side-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.week-strip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.calendar-current-label {
    font-size: 1rem;
    font-weight: 800;
    text-transform: capitalize;
}

.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Horizontal 7-Day Strip (Mobile App Style) */
.day-strip {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.day-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: all 0.15s ease;
}

.day-pill-name {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.day-pill-num {
    font-size: 0.95rem;
    font-weight: 800;
    margin-top: 2px;
    color: var(--text);
}

.day-pill-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: transparent;
    margin-top: 4px;
}

.day-pill.has-bookings .day-pill-dot {
    background: #f5b82e;
}

.day-pill.is-today {
    border-color: var(--primary);
}

.day-pill.selected {
    background: var(--primary);
    border-color: var(--primary);
}

.day-pill.selected .day-pill-name,
.day-pill.selected .day-pill-num {
    color: #0c1021;
}

.day-pill.selected.has-bookings .day-pill-dot {
    background: #0c1021;
}

.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.view-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #0d0d10;
    border: 1px solid var(--border);
    padding: 3px;
    border-radius: 10px;
    flex: 1;
}

.view-tab {
    border: none;
    background: transparent;
    padding: 8px 6px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    text-align: center;
}

.view-tab.active {
    background: var(--surface-elevated);
    color: var(--text);
}

.date-picker-input {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8rem;
    background: var(--surface-elevated);
    color: var(--text);
}

.calendar-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 0.74rem;
    color: var(--text-muted);
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    display: inline-block;
}

.legend-free {
    background: #141419;
    border: 1px dashed #525266;
}

.legend-shared {
    background: var(--shared-bg);
    border: 1px solid #f59e0b;
}

.legend-exclusive {
    background: var(--exclusive-bg);
    border: 1px solid #ef4444;
}

/* --- VISTA GIORNALIERA (TIMELINE) --- */
.day-timeline {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.hour-row {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 8px;
    align-items: stretch;
    min-height: 52px;
}

.hour-label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-muted);
    padding-top: 10px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.hour-slot {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 9px 12px;
    background: #0e0e12;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.hour-slot.clickable:active,
.hour-slot.clickable:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    cursor: pointer;
}

.hour-slot.current-hour {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.08);
}

.now-indicator-tag {
    position: absolute;
    top: -8px;
    right: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 7px;
    border-radius: 999px;
    letter-spacing: 0.04em;
}

.slot-empty-hint {
    font-size: 0.78rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.booking-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    border-radius: 10px;
    font-size: 0.82rem;
    border-left: 4px solid var(--primary);
    background: var(--surface-elevated);
    color: var(--text);
}

.booking-block.mode-shared {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-left: 4px solid #f59e0b;
}

.booking-block.mode-exclusive {
    background: rgba(239, 68, 68, 0.14);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-left: 4px solid #ef4444;
}

.booking-block-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.booking-mode-tag {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    text-transform: uppercase;
}

.booking-mode-tag.shared {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.booking-mode-tag.exclusive {
    background: rgba(239, 68, 68, 0.22);
    color: #f87171;
}

/* --- VISTA SETTIMANALE (Mobile Agenda + Desktop Grid) --- */
.week-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.week-day-col {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #0e0e12;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.week-day-col.is-today {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.06);
}

.week-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.week-day-name {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
}

.week-day-num {
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--text);
}

.week-booking-item {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 0.8rem;
    border-left: 3px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.week-booking-item.exclusive {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.week-booking-time {
    font-weight: 700;
    color: var(--text);
}

.week-booking-user {
    font-weight: 600;
    color: #e2e8f0;
}

.week-booking-note {
    color: var(--text-muted);
    font-size: 0.74rem;
}

.week-add-btn {
    border: 1px dashed var(--border);
    background: transparent;
    border-radius: 8px;
    padding: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

/* --- SIDEBAR --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.side-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.side-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
}

.badge-count {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
}

.day-schedule-list, .team-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-item {
    padding: 10px 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
}

.schedule-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
}

.team-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.team-member-row:last-child {
    border-bottom: none;
}

.online-tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--free-text);
    background: var(--free-bg);
    border: 1px solid var(--free-border);
    padding: 3px 9px;
    border-radius: 999px;
}

/* --- MOBILE BOTTOM NAVIGATION BAR --- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(66px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(16, 16, 20, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    z-index: 60;
}

.mob-nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    cursor: pointer;
    font-family: inherit;
}

.mob-nav-item.active {
    color: var(--primary);
}

.mob-nav-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.mob-nav-label {
    font-size: 0.68rem;
    font-weight: 700;
}

.mob-nav-fab {
    color: #34d399;
}

.mob-fab-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #10b981;
    color: #042f1e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-top: -16px;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
    border: 3px solid var(--bg);
}

/* --- BOTTOM-SHEET MODALS (Mobile First) --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100;
    padding: 0;
}

.modal {
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 22px 22px 0 0;
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: sheetUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.sheet-handle {
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: #3f3f50;
    margin: 10px auto 2px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 800;
}

.modal-close {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-helper {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.modal-footer {
    padding: 14px 20px;
    background: #0d0d10;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #cbd5e1;
}

/* 16px evita lo zoom automatico su iOS Safari e Chrome Mobile */
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="time"] {
    padding: 12px;
    background: #0d0d10;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-family: inherit;
    min-height: 46px;
    color-scheme: dark;
}

input[type="date"],
input[type="time"] {
    color-scheme: dark;
    cursor: pointer;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.color-input {
    width: 100%;
    height: 46px;
    background: #0d0d10;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
    cursor: pointer;
}

.duration-pills {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.duration-pill {
    padding: 11px 8px;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: 10px;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.duration-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-option {
    cursor: pointer;
}

.mode-option input {
    display: none;
}

.mode-box {
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    border-radius: 12px;
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mode-option input:checked + .mode-box {
    border-color: var(--primary);
    background: var(--primary-light);
}

.mode-title {
    font-size: 0.86rem;
    font-weight: 700;
}

.mode-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.quick-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
}

.quick-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    background: var(--surface-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #0d0d10;
    border: 1px solid var(--border);
    padding: 4px;
    border-radius: 10px;
}

.auth-tab {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 9px;
    border-radius: 7px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
}

.auth-tab.active {
    background: var(--surface-elevated);
    color: var(--text);
}

.demo-login-box {
    margin-top: 6px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.demo-login-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.demo-users-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Toast (Sopra la bottom bar su mobile) */
.toast-container {
    position: fixed;
    bottom: 80px;
    left: 14px;
    right: 14px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #18181f;
    border: 1px solid var(--border);
    color: #fff;
    padding: 13px 16px;
    border-radius: 12px;
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.toast.error {
    background: #7f1d1d;
    border-color: #ef4444;
}

.toast.success {
    background: #064e3b;
    border-color: #10b981;
}

/* --- DESKTOP ENHANCEMENTS (>= 900px) --- */
@media (min-width: 900px) {
    body {
        padding-bottom: 48px;
    }

    .container {
        padding: 0 24px;
    }

    .topbar-inner {
        height: 70px;
    }

    .user-pill-name {
        max-width: none;
    }

    .mobile-bottom-nav {
        display: none !important;
    }

    .app-main {
        padding-top: 24px;
    }

    .live-hero {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 340px;
        padding: 26px;
        gap: 24px;
        margin-bottom: 24px;
        align-items: center;
    }

    .live-headline {
        font-size: 1.55rem;
    }

    .quick-actions-card {
        padding: 18px;
    }

    .quick-buttons {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .btn-checkout {
        grid-column: span 1;
    }

    .current-occupants {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }

    .content-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
        gap: 24px;
        align-items: start;
    }

    .calendar-card {
        display: block !important;
        padding: 24px;
    }

    .sidebar {
        display: flex !important;
        flex-direction: column;
        gap: 20px;
    }

    .side-card {
        padding: 20px;
    }

    .view-tabs {
        flex: 0 1 380px;
    }

    .hour-row {
        grid-template-columns: 64px 1fr;
        gap: 12px;
    }

    .week-grid {
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        gap: 10px;
    }

    .week-day-col {
        min-height: 260px;
    }

    .week-day-header {
        flex-direction: column;
        gap: 2px;
    }

    .week-add-btn {
        margin-top: auto;
    }

    .modal-backdrop {
        align-items: center;
        padding: 16px;
    }

    .modal {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
    }

    .sheet-handle {
        display: none;
    }

    .toast-container {
        bottom: 24px;
        left: auto;
        right: 24px;
        width: 360px;
    }
}

/* --- LOCK SCREEN (LOGIN OBBLIGATORIO SCUDERIAQ) --- */
.lock-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    background: radial-gradient(circle at top, rgba(245, 184, 46, 0.16), var(--bg) 62%);
}

.lock-card {
    width: 100%;
    max-width: 440px;
    background: #161c36;
    border: 1.5px solid rgba(245, 184, 46, 0.42);
    border-radius: 22px;
    padding: 24px 22px 26px;
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.85), 0 0 32px rgba(245, 184, 46, 0.08);
}

.lock-brand {
    text-align: center;
    margin-bottom: 20px;
}

.lock-logo-banner {
    width: 100%;
    max-width: 310px;
    margin: 0 auto 10px;
    border-radius: 16px;
    overflow: hidden;
    background: #161c36;
}

.lock-logo-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

.lock-subtitle {
    font-size: 0.83rem;
    font-weight: 600;
    color: #cbd5e1;
    margin-top: 4px;
}

/* Biometric Hero Button on Lock Screen */
.biometric-login-box {
    margin-bottom: 18px;
}

.btn-biometric-hero {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(59, 130, 246, 0.18));
    border: 1.5px solid rgba(16, 185, 129, 0.55);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: all 0.18s ease;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.15);
}

.btn-biometric-hero:hover,
.btn-biometric-hero:active {
    transform: translateY(-1px);
    border-color: #34d399;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(59, 130, 246, 0.24));
}

.bio-fingerprint-icon {
    font-size: 2.1rem;
    line-height: 1;
    flex-shrink: 0;
}

.bio-hero-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bio-hero-title {
    font-size: 0.96rem;
    font-weight: 800;
    color: #34d399;
}

.bio-hero-sub {
    font-size: 0.76rem;
    color: #cbd5e1;
}

.lock-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.74rem;
    margin-top: 16px;
}

.lock-divider::before,
.lock-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.lock-divider span {
    padding: 0 10px;
}

.lock-footer-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 18px;
}

.setup-banner {
    background: rgba(59, 130, 246, 0.14);
    border: 1px solid rgba(59, 130, 246, 0.38);
    border-radius: 12px;
    padding: 12px;
    font-size: 0.8rem;
    color: #dbeafe;
    margin-bottom: 14px;
}

/* Banner invito attivazione impronta dentro l'app */
.bio-enroll-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(59, 130, 246, 0.12));
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.bio-enroll-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bio-enroll-icon {
    font-size: 1.7rem;
}

.bio-enroll-left strong {
    font-size: 0.9rem;
    display: block;
}

.bio-enroll-left p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Admin Team Management Styles */
.side-card-sub {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.role-badge-admin {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
    margin-left: 5px;
    text-transform: uppercase;
}

.bio-badge-mini {
    display: inline-block;
    font-size: 0.68rem;
    color: #34d399;
    margin-left: 4px;
}

.admin-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    cursor: pointer;
}

.admin-checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
}

.admin-delete-zone {
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

/* Preset Orari (Mattina / Pomeriggio / Tutto il giorno) */
.preset-slots {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.preset-slot-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 9px 6px;
    border-radius: 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.preset-slot-btn span {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
}

.preset-slot-btn:hover,
.preset-slot-btn:active {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Controlli Sessione Attiva (Check-out + Prolunga +30m / +1h) */
.active-session-controls {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.extend-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.btn-edit-ghost {
    background: rgba(59, 130, 246, 0.14);
    color: #60a5fa;
    padding: 5px 10px;
    min-height: 32px;
    font-size: 0.75rem;
    border-radius: 8px;
}

.btn-edit-ghost:hover {
    background: rgba(59, 130, 246, 0.25);
}

/* Selettore Compagni Taggati (Chi c'è con te?) */
.companions-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.companion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px 6px 6px;
    border-radius: 999px;
    background: var(--surface-elevated);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
    user-select: none;
}

.companion-chip.selected {
    background: var(--primary-light);
    border-color: var(--primary);
    color: #fff;
}

.companion-chip .avatar {
    width: 22px;
    height: 22px;
    font-size: 0.62rem;
}

.chip-altro {
    border-style: dashed;
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.45);
}

.companions-inline-badges {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.companion-mini-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 4px;
    border-radius: 999px;
    background: #23232e;
    border: 1px solid var(--border);
    font-size: 0.73rem;
    font-weight: 600;
    color: #e2e8f0;
}

/* Fasce orarie passate non prenotabili */
.hour-slot.past-slot {
    opacity: 0.45;
    background: #0a0a0d;
    border-style: dotted;
    cursor: not-allowed;
}

.week-day-col.past-day {
    opacity: 0.6;
}

/* Pannello Impostazioni (Settings Modal) */
.settings-section {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.settings-section-title {
    font-size: 0.88rem;
    font-weight: 800;
    color: var(--text);
}

.settings-section-desc {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.settings-bio-actions {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bio-status-pill {
    font-size: 0.7rem;
    font-weight: 800;
    padding: 3px 9px;
    border-radius: 999px;
    background: #272732;
    color: var(--text-muted);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.bio-status-pill.active {
    background: var(--free-bg);
    color: var(--free-text);
    border-color: var(--free-border);
}

.random-pass-input {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em;
    color: #f5b82e !important;
}

/* --- FIX RESPONSIVE MOBILE E ANTI-OVERFLOW --- */
html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.form-group,
.form-row > *,
.form-group input {
    min-width: 0;
    width: 100%;
    max-width: 100%;
}

.booking-block {
    flex-wrap: wrap;
}

@media (max-width: 640px) {
    .topbar-inner {
        height: 58px;
        gap: 6px;
    }

    .brand {
        gap: 8px;
    }

    .brand-logo-wrap {
        width: 38px;
        height: 38px;
    }

    .brand-title {
        font-size: 1.04rem;
    }

    .brand-meta {
        font-size: 0.68rem;
        gap: 4px;
    }

    .topbar-right {
        gap: 5px;
    }

    .topbar-bio-quick {
        display: none !important;
    }

    .user-pill-btn {
        padding: 3px 8px 3px 4px;
        gap: 5px;
    }

    .user-pill-name {
        max-width: 72px;
        font-size: 0.75rem;
    }

    .role-badge-admin {
        display: none;
    }

    .quick-buttons {
        grid-template-columns: 1fr;
    }

    .btn-checkout {
        grid-column: span 1;
    }

    .calendar-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .view-tabs {
        width: 100%;
    }

    .date-picker-input {
        width: 100%;
        min-height: 40px;
    }

    .week-strip-header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .preset-slots {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .preset-slot-btn {
        flex-direction: row;
        justify-content: space-between;
        padding: 10px 14px;
    }

    .settings-section .form-row,
    #adminUserForm .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: 88dvh;
    }
}

/* --- BLOCCHI PROPORZIONALI UNIFICATI CALENDARIO --- */
.date-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.proportional-row {
    align-items: stretch;
}

.proportional-label {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    padding: 8px 0;
    color: var(--text);
}

.proportional-label .prop-arrow {
    font-size: 0.65rem;
    color: var(--primary);
    opacity: 0.7;
    padding-right: 4px;
}

.proportional-label .prop-end {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.proportional-slot {
    border-style: solid;
    border-color: rgba(245, 184, 46, 0.22);
    background: rgba(20, 20, 26, 0.9);
    justify-content: flex-start;
    padding: 8px 10px;
}

.proportional-booking {
    cursor: pointer;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
    padding: 11px 13px;
}

.proportional-booking:hover,
.proportional-booking:active {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    border-color: rgba(245, 184, 46, 0.55);
}

.booking-tap-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}

.proportional-booking:hover .booking-tap-cta {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.parallel-book-btn {
    margin-top: 2px;
    width: 100%;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px dashed rgba(245, 184, 46, 0.35);
    background: rgba(245, 184, 46, 0.05);
    color: #fbbf24;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.parallel-book-btn:hover,
.parallel-book-btn:active {
    background: rgba(245, 184, 46, 0.14);
    border-color: var(--primary);
}
