:root {
    --primary: #2c5282;
    --secondary: #3182ce;
    --bg: #f7fafc;
    --surface: #ffffff;
    --text: #2d3748;
    --danger: #e53e3e;
    --warning: #dd6b20;
    --success: #38a169;
    --border: #e2e8f0;
    --indirect-color: #805ad5;
    --admin-color: #d69e2e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    flex: 1;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background: var(--surface);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.brand h1 {
    font-size: 1.5rem;
    color: var(--primary);
    font-weight: 700;
}


/* Tabs */
.nav-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #718096;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab-btn i {
    margin-right: 8px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
}

.card {
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* Inputs */
.input-grid {
    display: grid;
    gap: 12px;
}

.input-wrapper {
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.input-wrapper label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: #4a5568;
}

.input-wrapper input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-weight: 600;
}

.rate-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #edf2f7;
    color: #718096;
    float: right;
}

/* Controls */
.date-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    align-items: center;
}

.btn-nav {
    padding: 10px;
    background: #edf2f7;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text);
}

.btn-nav:hover {
    background: #e2e8f0;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: background 0.3s;
}

.btn-primary:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

/* Balance / Allowance Box */
.balance-box {
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.balance-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.balance-row.final {
    border-top: 1px solid #bee3f8;
    padding-top: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: #2b6cb0;
}

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-day-header {
    text-align: center;
    font-weight: 600;
    padding: 10px;
}

.calendar-day {
    min-height: 120px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover {
    border-color: var(--secondary);
    transform: translateY(-2px);
}

.day-breakdown {
    font-size: 0.7rem;
    margin-top: 6px;
}

.break-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

/* Alerts */
.alert-box {
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.85rem;
    display: none;
    border-left: 4px solid;
}

.alert-danger {
    background: #fff5f5;
    border-color: #c53030;
    color: #c53030;
}

.alert-warning {
    background: #fffaf0;
    border-color: #dd6b20;
    color: #c05621;
}

/* Reports Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th,
.data-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f7fafc;
}

/* Guide Tab Specifics */
.guide-content {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.6;
}

.guide-content h2 {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 5px;
    margin-top: 30px;
}

.guide-content h3 {
    color: var(--secondary);
    margin-top: 20px;
}

.guide-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.guide-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.guide-content th,
.guide-content td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

.guide-content th {
    background: #f0f4f8;
}

/* Controls */
.history-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-control {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #cbd5e0;
    cursor: pointer;
    font-size: 0.9rem;
    background: white;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.btn-control:hover {
    background: #f7fafc;
}

.btn-backup {
    color: #2f855a;
    border-color: #9ae6b4;
    background: #f0fff4;
}

.btn-restore {
    color: #c05621;
    border-color: #fbd38d;
    background: #fffaf0;
}

/* Print Settings */
@media print {
    @page {
        size: A4;
        margin: 15mm;
    }

    body {
        background: white;
        font-size: 12pt;
    }

    .nav-tabs,
    .btn-primary,
    .history-controls,
    .input-column,
    .app-container>header {
        display: none !important;
    }

    .app-container {
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    .dashboard-grid {
        display: block;
    }

    .analytics-column {
        width: 100%;
    }

    .card {
        border: none;
        box-shadow: none;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    #guide.active {
        display: block !important;
    }

    .guide-content h2 {
        page-break-before: always;
    }

    .guide-content h2:first-of-type {
        page-break-before: avoid;
    }

    #history.active #print-section {
        display: block !important;
    }
}