:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --primary: #ef4444; /* Red for fire department */
    --primary-hover: #dc2626;
    --secondary: #3b82f6;
    --accent: #f59e0b; /* Orange for warnings */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title i {
    color: var(--primary);
}

.radio-channel {
    background: rgba(239, 68, 68, 0.1);
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.user-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.nav-link:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    transform: translateY(-2px);
}

.time-display {
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.user-display {
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

/* Floating Action Button (Mobile) */
.fab-add-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: transform 0.3s, background 0.3s;
}
.fab-add-btn:active {
    transform: scale(0.9);
}
.fab-add-btn:hover {
    background: var(--primary-hover);
}

@media (max-width: 600px) {
    .desktop-add-btn {
        display: none !important;
    }
    .desktop-text {
        display: none;
    }
    .header-add-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
    }
    .fab-add-btn {
        display: flex;
    }
}

/* Mobile/Tablet Header Optimizations */
@media (max-width: 900px) {
    header {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    .header-title {
        font-size: 1.2rem;
    }
    .user-controls {
        gap: 10px;
        width: 100%;
        justify-content: space-between;
    }
    .radio-channel {
        width: 100%;
        text-align: center;
        order: 3;
    }
    .nav-text, .user-display span {
        display: none;
    }
    .nav-link {
        font-size: 1.2rem;
        padding: 0.5rem;
    }

    /* Mobile Table Cards */
    .table.mobile-cards thead {
        display: none;
    }
    .table.mobile-cards tbody tr {
        display: block;
        background: rgba(255,255,255,0.05);
        margin-bottom: 1rem;
        border-radius: 8px;
        padding: 0.5rem;
        position: relative;
    }
    .table.mobile-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        padding: 0.75rem 0.5rem;
        text-align: right;
    }
    .table.mobile-cards tbody td:last-child {
        border-bottom: none;
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid rgba(255,255,255,0.05);
    }
    .table.mobile-cards tbody td:first-child {
        padding-right: 0.5rem;
    }
    .table.mobile-cards tbody td:last-child::before {
        display: none;
    }
    .table.mobile-cards tbody td::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        text-align: left;
        margin-right: 1rem;
    }
}

/* Layout Grid */
.main-container {
    padding: 1rem;
    flex: 1;
}

@media (min-width: 1024px) {
    .main-container {
        padding: 1rem;
    }
}

.squads-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (min-width: 900px) {
    .squads-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1200px) {
    .squads-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Squad Card */
.squad-card {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.squad-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.squad-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.squad-title input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: bold;
    width: 100%;
    outline: none;
}
.squad-title input::placeholder {
    color: var(--text-muted);
}

.squad-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.meta-input {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0;
    font-size: 0.85rem;
    width: 100%;
    outline: none;
}
.meta-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

/* Timer Display */
.timer-display {
    font-size: 4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(255,255,255,0.1);
    letter-spacing: 2px;
}

.timer-progress {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.timer-bar {
    height: 100%;
    width: 100%;
    background: var(--success);
    transition: width 1s linear, background-color 0.3s;
}

/* Members List */
.members-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.05);
    padding: 0.75rem;
    border-radius: 8px;
}

.add-member-btn {
    background: rgba(59, 130, 246, 0.2);
    color: var(--secondary);
    border: 1px dashed var(--secondary);
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-weight: 600;
}
.add-member-btn:hover {
    background: rgba(59, 130, 246, 0.3);
}

/* Pressure Inputs Grid */
.pressure-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    text-align: center;
}

.pressure-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pressure-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.pressure-input {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    width: 100%;
}
.pressure-input:disabled {
    opacity: 0.5;
}

/* Pressure Modal Keypad */
.pressure-grid-buttons::-webkit-scrollbar {
    width: 6px;
}
.pressure-grid-buttons::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}
.pressure-btn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: white;
    font-size: 1.25rem;
    font-weight: bold;
    padding: 1rem 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.pressure-btn:active {
    transform: scale(0.95);
    background: rgba(59, 130, 246, 0.4);
}

.return-pressure {
    margin-top: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 0.75rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}
.return-value {
    color: var(--accent);
    font-size: 1.2rem;
}

/* Actions */
.squad-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: auto;
}

.btn {
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-start { background: var(--success); color: white; }
.btn-start:hover { background: #059669; }

.btn-mayday { background: var(--danger); color: white; grid-column: 1 / -1; }
.btn-mayday:hover { background: #b91c1c; box-shadow: 0 0 15px rgba(239, 68, 68, 0.5); }

/* Warning States */
.warning-1-3 .timer-bar { background: var(--accent); }
.warning-2-3 .timer-bar { background: var(--danger); }
.warning-end .timer-display { color: var(--danger); animation: pulse 1s infinite; }

.mayday-active {
    animation: mayday-flash 1s infinite;
    border-color: var(--danger);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes mayday-flash {
    0% { background: var(--bg-card); box-shadow: inset 0 0 0px var(--danger); }
    50% { background: rgba(239, 68, 68, 0.2); box-shadow: inset 0 0 20px var(--danger); }
    100% { background: var(--bg-card); box-shadow: inset 0 0 0px var(--danger); }
}

/* Login Overlay */
#login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-box h2 {
    text-align: center;
    color: var(--text-main);
    font-size: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.input-group input {
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
}
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-icon {
    background: transparent;
    color: var(--primary);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}
.btn-icon:hover {
    color: var(--text-main);
    transform: scale(1.1);
    background: rgba(255,255,255,0.1);
}

.mobile-cards td:last-child {
    text-align: right;
}

.btn-login {
    background: var(--primary);
    color: white;
    margin-top: 1rem;
}
.btn-login:hover { background: var(--primary-hover); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 500;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 2rem;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.close-btn {
    background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer;
}
.member-select-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.member-select-item {
    padding: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    cursor: pointer;
}
.member-select-item:hover {
    background: rgba(255,255,255,0.1);
}

.add-squad-card:hover {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.4) !important;
}
.add-squad-card:hover i, .add-squad-card:hover span {
    color: rgba(255,255,255,0.8) !important;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    animation: slideInRight 0.3s ease forwards;
    pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--secondary); }

.toast.hiding {
    animation: fadeOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}
