:root {
    /* Provided Palette */
    --navy-900: #041438;
    --navy-850: #0B214C;

    --blue-700: #0A52AC;
    --blue-650: #04398C;
    --blue-600: #0469D5;
    --blue-500: #0997F1;

    --cyan-400: #24CDFA;

    --steel-600: #324B73;
    --steel-500: #4C648C;

    --white-soft: #F3F7F7;

    --gold-700: #71491B;
    --gold-600: #91560F;
    --gold-200: #E6D5A3;

    --gray-bg: #C1C4CB;
    --gray-200: #D0D3D8;
    --gray-350: #BDC1C7;
    --gray-500: #9BA0AA;
    --gray-650: #707686;
    --gray-750: #5C616F;

    /* Functional Mappings (Dark Navy Theme) */
    --bg-dark: var(--navy-900);
    --card-bg: rgba(11, 33, 76, 0.4);
    /* navy-850 with opacity */
    --card-border: var(--steel-600);
    --text-primary: var(--white-soft);
    --text-secondary: var(--gray-bg);

    --accent-color: var(--cyan-400);
    --primary-btn: var(--blue-600);
    --primary-btn-hover: var(--blue-500);

    --accent-glow: rgba(36, 205, 250, 0.3);
    /* Cyan glow */

    --success-color: #00ff9d;
    --warning-color: var(--gold-200);
    --danger-color: #ff4757;

    --font-outfit: 'Outfit', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-outfit);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Effects */
.background-gradients {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

/* Login Modal */
/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 17, 26, 0.95);
    /* Increased opacity for better blocking */
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Ensure it is on top of everything */
    transition: opacity 0.5s ease;
}

.login-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.login-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 3rem;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-card h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

.input-group input:focus {
    border-color: var(--accent-color);
}

.login-btn,
#refresh-btn {
    background: var(--primary-btn);
    border: none;
    padding: 0.5rem 1.2rem;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(4, 105, 213, 0.3);
    /* Blue-600 shadow */
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

#refresh-btn:hover {
    background: var(--primary-btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(9, 151, 241, 0.4);
    /* Blue-500 shadow */
}

/* Header Controls */
.header-controls {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.date-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    flex-wrap: nowrap;
    /* Keep on one line if possible, or wrap logic below */
}

/* Ensure inputs don't get too small on desktop */
.date-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    font-family: var(--font-outfit);
    width: 130px;
    /* Fixed width for desktop */
}

.text-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--accent-color);
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    margin-right: 0.5rem;
    white-space: nowrap;
    /* Prevent text wrap */
}

.text-btn:hover {
    background: rgba(0, 242, 255, 0.1);
    border-color: var(--accent-color);
}

.date-selector label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-left: 0.5rem;
}

/* Legacy input styles replaced by .date-input class */

#refresh-btn {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
}

.orb-1 {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle at 50% 40%,
            var(--cyan-400) 0%,
            var(--blue-500) 25%,
            var(--blue-600) 55%,
            var(--blue-700) 75%,
            var(--navy-900) 100%);
    top: -20vw;
    left: -20vw;
    animation: float 20s infinite ease-in-out;
    opacity: 0.4;
    filter: blur(60px);
}

.orb-2 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--blue-650), var(--navy-850));
    bottom: -20vw;
    right: -20vw;
    animation: float 25s infinite ease-in-out reverse;
    opacity: 0.3;
    filter: blur(60px);
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px);
    }
}

/* Layout */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--card-border);
    flex-wrap: wrap;
    /* Prevent overlap on medium screens */
    gap: 1rem;
}

.logo-img {
    height: 150px;
    width: auto;
    object-fit: contain;
    /* Removed drop-shadow to prevent 'grey border' artifact */
    transition: transform 0.3s ease;
}

.logo-img:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 8px rgba(36, 205, 250, 0.6));
}

#refresh-btn {
    background: var(--primary-btn);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-family: var(--font-outfit);
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(4, 105, 213, 0.3);
    /* Blue-600 shadow */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--success-color);
    background: rgba(0, 255, 157, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 157, 0.2);
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.4);
    }

    70% {
        opacity: 0.7;
        box-shadow: 0 0 0 10px rgba(0, 255, 157, 0);
    }

    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0);
    }
}

/* Grid */
#restaurant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 2rem;
}

/* Card Styles */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.store-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.store-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stat-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: baseline;
    gap: 0.2rem;
}

.currency-symbol {
    font-size: 1.2rem;
    color: var(--accent-color);
}

.occupancy-container {
    margin-top: 0.5rem;
}

.occupancy-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    position: relative;
}

/* Occupancy Bar */
.occupancy-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #054d35, #0a7d5b);
    /* Darker Green for Contrast */
    width: 0%;
    /* Animated via JS */
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(10, 125, 91, 0.4);
}

.occupancy-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.occupancy-percent {
    color: var(--text-primary);
    font-weight: 700;
}

.occupancy-metrics {
    display: flex;
    gap: 1rem;
}

.metric span {
    color: var(--text-primary);
    font-weight: 600;
}

/* New Table Metrics Highlight */
.table-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.table-metric-box {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.table-metric-box.total-tables {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.table-metric-box.open-tables {
    background: rgba(0, 255, 157, 0.05);
    border-color: rgba(0, 255, 157, 0.2);
}

.table-metric-box.open-tables .metric-value {
    color: #10ac84;
    /* Darker Rich Green to match bars */
}

.table-metric-box .metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.table-metric-box .metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Loading */
.loading-container {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-secondary);
    gap: 1rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--danger-color);
    padding: 2rem;
    background: rgba(255, 0, 85, 0.1);
    border: 1px solid rgba(255, 0, 85, 0.2);
    border-radius: 12px;
}

/* Leaderboard Section */
.leaderboard-section {
    margin-top: 4rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(10px);
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chart-label {
    width: 200px;
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-bar-container {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.05);
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--card-border);
}

.chart-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #054d35, #0a7d5b);
    /* Darker Green Gradient */
    width: 0%;
    /* Animated via JS */
    border-radius: 6px;
    box-shadow: 0 0 15px rgba(10, 125, 91, 0.4);
    position: relative;
}

.chart-value {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    width: 80px;
    /* Fixed width for alignment */
    text-align: right;
}

.chart-value {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    z-index: 2;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .leaderboard-section {
        padding: 1rem;
        margin-top: 2rem;
    }

    .chart-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .chart-label {
        width: 100%;
        text-align: left;
        font-weight: 600;
        margin-bottom: 0.2rem;
    }

    .chart-bar-container {
        width: 100%;
    }

    .section-title {
        font-size: 1.2rem;
    }

    /* General Mobile Layout */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .date-selector {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }

    .date-selector input[type="date"] {
        width: 100%;
        text-align: center;
    }

    .text-btn {
        width: 100%;
        text-align: center;
    }

    #refresh-btn {
        width: 100%;
    }

    .btn-icon {
        display: none;
        /* Hide icon on mobile if needed, or keep */
    }

    #restaurant-grid {
        grid-template-columns: 1fr;
        /* Stack cards */
    }

    .table-metrics-grid {
        grid-template-columns: 1fr 1fr;
        /* Keep 2 cols for metrics */
    }
}