/* ===========================================================================
   RAM Reports — Global Stylesheet
   =========================================================================== */

:root {
    --primary-blue: #4472C4;
    --primary-dark: #2E5AA0;
    --teal: #70AD47;
    --orange: #FFC000;
    --bg: #F2F2F2;
    --card-bg: #FFFFFF;
    --text: #404040;
    --text-light: #808080;
    --text-dark: #1e293b;
    --border: #e2e8f0;
    --border-light: #f0f0f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --radius: 6px;
    --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

    /* Category pie colors */
    --cat-1: #4472C4;
    --cat-2: #5B9BD5;
    --cat-3: #70AD47;
    --cat-4: #FFC000;
    --cat-5: #BDD7EE;
    --cat-6: #1F4E79;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ===========================================================================
   Navbar
   =========================================================================== */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    padding: 0 24px;
    height: 56px;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.navbar-logo {
    height: 32px;
    width: auto;
}

.navbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.navbar-center {
    display: flex;
    gap: 4px;
}

.navbar-link {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}

.navbar-link:hover {
    background: var(--bg);
    color: var(--text);
}

.navbar-link.active {
    background: var(--primary-blue);
    color: #fff;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 13px;
    color: var(--text-light);
}

.btn-logout, .btn-login {
    font-size: 13px;
    color: var(--primary-blue);
    text-decoration: none;
    padding: 4px 12px;
    border: 1px solid var(--primary-blue);
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover, .btn-login:hover {
    background: var(--primary-blue);
    color: #fff;
}

/* ===========================================================================
   Tab Bar
   =========================================================================== */

.tab-bar {
    display: flex;
    gap: 0;
    background: var(--card-bg);
    padding: 0 24px;
    border-bottom: 2px solid var(--border);
}

.tab {
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
    font-weight: 600;
}

/* ===========================================================================
   Main Content
   =========================================================================== */

.content {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ===========================================================================
   Dashboard Header
   =========================================================================== */

.dashboard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dashboard-title h1 {
    font-size: 22px;
    font-weight: 400;
}

.title-blue {
    color: var(--primary-blue);
    font-weight: 700;
}

.title-gray {
    color: var(--text-light);
    font-style: italic;
}

.data-freshness {
    font-size: 12px;
    color: var(--text-light);
}

/* ===========================================================================
   KPI Bar
   =========================================================================== */

.kpi-bar {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.kpi-card.kpi-highlight {
    border: 1px solid var(--primary-blue);
    background: #f8faff;
}

.kpi-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.kpi-rule {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.kpi-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

/* ===========================================================================
   Cards
   =========================================================================== */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

/* ===========================================================================
   Dashboard Grid
   =========================================================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 16px;
}

.grid-left, .grid-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.grid-left .card, .grid-right .card {
    margin-bottom: 0;
}

.pie-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ===========================================================================
   Financial Summary Table
   =========================================================================== */

.financial-summary {
    padding: 16px 20px;
}

.fin-table {
    width: 100%;
    border-collapse: collapse;
}

.fin-table td {
    padding: 6px 0;
    font-size: 15px;
}

.fin-label {
    color: var(--text-light);
    width: 40%;
}

.fin-value {
    text-align: right;
    font-weight: 500;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

.fin-noi-row td {
    border-top: 2px solid var(--border);
    padding-top: 8px;
}

/* ===========================================================================
   Chart Containers
   =========================================================================== */

.chart-container {
    position: relative;
    width: 100%;
}

.chart-bar-h {
    height: 300px;
}

.chart-pie {
    height: 220px;
}

.chart-expirations {
    height: 320px;
}

/* ===========================================================================
   Data Table
   =========================================================================== */

.table-wrapper {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    background: var(--primary-blue);
    color: #fff;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid var(--primary-dark);
}

.data-table th:hover {
    background: var(--primary-dark);
}

.data-table th.sort-asc::after { content: " \u25B2"; font-size: 10px; }
.data-table th.sort-desc::after { content: " \u25BC"; font-size: 10px; }

.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}

.data-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.data-table tbody tr:hover {
    background: #eef3ff;
}

.data-table .row-vacant td {
    color: var(--text-light);
    font-style: italic;
}

.text-right {
    text-align: right;
}

.total-row td {
    background: var(--bg);
    border-top: 2px solid var(--border);
    font-size: 13px;
    padding: 8px 12px;
}

.data-table tfoot {
    position: sticky;
    bottom: 0;
}

/* ===========================================================================
   Index / Landing Page
   =========================================================================== */

.index-page {
    max-width: 800px;
    margin: 40px auto;
}

.index-page h1 {
    font-size: 24px;
    margin-bottom: 24px;
    color: var(--text-dark);
}

.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.report-card {
    display: block;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.2s, transform 0.2s;
}

.report-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.report-card-icon {
    color: var(--primary-blue);
    margin-bottom: 12px;
}

.report-card h2 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.report-card p {
    font-size: 14px;
    color: var(--text-light);
}

/* ===========================================================================
   Error Page
   =========================================================================== */

.error-page {
    max-width: 500px;
    margin: 80px auto;
    text-align: center;
}

.error-page h1 {
    font-size: 28px;
    color: var(--text-dark);
    margin-bottom: 12px;
}

.error-page p {
    color: var(--text-light);
    margin-bottom: 8px;
}

.error-detail {
    font-size: 13px;
    color: var(--text-light);
}

.btn-primary {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 24px;
    background: var(--primary-blue);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* ===========================================================================
   Responsive
   =========================================================================== */

@media (max-width: 1200px) {
    .kpi-bar {
        grid-template-columns: repeat(4, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .kpi-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    .pie-row {
        grid-template-columns: 1fr;
    }
    .navbar {
        padding: 0 12px;
    }
    .content {
        padding: 16px 12px;
    }
}
