:root {
    /* Premium Fintech Palette */
    --primary-color: #0f172a;
    /* Slate 900 */
    --primary-light: #1e293b;
    /* Slate 800 */
    --accent-color: #3b82f6;
    /* Blue 500 */
    --accent-hover: #2563eb;
    /* Blue 600 */

    --success-color: #10b981;
    /* Emerald 500 */
    --warning-color: #f59e0b;
    /* Amber 500 */
    --danger-color: #ef4444;
    /* Red 500 */
    --info-color: #0ea5e9;
    /* Sky 500 */

    --background-color: #f1f5f9;
    /* Slate 100 */
    --surface-color: #ffffff;
    --surface-hover: #f8fafc;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;

    --border-color: #e2e8f0;
    --border-focus: #3b82f6;

    --font-family: 'Inter', sans-serif;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    --sidebar-width: 260px;
    --header-height: 70px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* --- Utilities --- */
.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-primary {
    color: var(--accent-color);
}

/* --- Screens --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--background-color);
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 1;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    transform: scale(0.98);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
    transform: scale(1);
}

/* --- Components --- */
.card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-hover));
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.btn-secondary:hover {
    background-color: var(--surface-hover);
    border-color: var(--text-tertiary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.btn-icon:hover {
    background-color: var(--surface-hover);
    color: var(--accent-color);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

input,
select {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    /* Space for icon */
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
    background-color: var(--surface-color);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

/* --- Loading Screen --- */
#loading-screen {
    background-color: var(--primary-color);
    color: white;
}

.loading-content {
    text-align: center;
}

.logo-mark {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
    animation: pulse 2s infinite;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    margin: 1.5rem auto 0;
    overflow: hidden;
}

.loading-progress {
    width: 50%;
    height: 100%;
    background: var(--accent-color);
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes progress {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(200%);
    }
}

/* --- Setup Screen --- */
.setup-card {
    width: 100%;
    max-width: 500px;
}

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.icon-wrapper {
    width: 60px;
    height: 60px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.info-box {
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.info-item:last-child {
    margin-bottom: 0;
}

.info-item .label {
    color: var(--text-secondary);
}

.info-item .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Dashboard Layout --- */
#game-dashboard {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    background-color: var(--background-color);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 20;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
}

.sidebar-header .logo i {
    color: var(--accent-color);
}

.company-profile {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.03);
    margin: 1rem;
    border-radius: var(--radius-md);
}

.company-profile .avatar {
    width: 40px;
    height: 40px;
    background: var(--accent-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.profile-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    color: white;
}

.status-badge {
    font-size: 0.7rem;
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    transition: all 0.2s;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.turn-display {
    display: flex;
    justify-content: space-between;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.turn-display .value {
    color: white;
    font-weight: 600;
}

.full-width {
    width: 100%;
}

/* Main Content */
.dashboard-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.top-bar {
    height: var(--header-height);
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    flex-shrink: 0;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .icon-box {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

.stat-card .icon-box.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-card .icon-box.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-card .icon-box.info {
    background: rgba(14, 165, 233, 0.1);
    color: var(--info-color);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-info .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
}

.stat-info .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

.detailed-stats h3,
.active-products h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.detailed-stats h3 i,
.active-products h3 i {
    color: var(--text-tertiary);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
}

.stat-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.stat-row.highlight {
    background: rgba(59, 130, 246, 0.05);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: none;
    margin-top: 0.5rem;
    font-weight: 600;
}

/* Products List */
.products-container {
    max-height: 400px;
    overflow-y: auto;
}

.products-list {
    list-style: none;
}

.products-list li {
    background: var(--surface-hover);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.products-list li:last-child {
    margin-bottom: 0;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--accent-color);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 0.5rem;
}

/* Modal */
.modal-overlay {
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    width: 100%;
    max-width: 550px;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-tertiary);
    cursor: pointer;
}

.close-btn:hover {
    color: var(--danger-color);
}

.modal-content form {
    padding: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Game Over */
.game-over-card {
    text-align: center;
    max-width: 400px;
}

.icon-wrapper.large {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
}

.product-info {
    display: flex;
    flex-direction: column;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
}

.product-details {
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

.badge {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.text-secondary {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #game-dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        align-items: center;
        padding: 0.5rem 1rem;
        justify-content: space-between;
    }

    .sidebar-header {
        border: none;
        height: auto;
        padding: 0;
    }

    .sidebar-nav,
    .company-profile,
    .sidebar-footer {
        display: none;
        /* Simplified for mobile for now */
    }

    .dashboard-main {
        height: calc(100vh - 60px);
    }
}

/* Financial Reports Styles */
.financial-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.financial-table th,
.financial-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.financial-table th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.financial-table .text-right {
    text-align: right;
}

.financial-table .section-header td {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    padding-top: 1rem;
}

.financial-table .sub-item td:first-child {
    padding-left: 1.5rem;
    font-size: 0.9em;
}

.financial-table .total-row td {
    border-top: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-primary);
}

.full-width-card {
    grid-column: 1 / -1;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.02);
}
/* Sales & Membership Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.data-table td {
    color: var(--text-primary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Ensure full width cards take full width */
.card.full-width {
    grid-column: 1 / -1;
}

/* Adjust dashboard grid for smaller stats */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

