:root {
    /* Grass Theme Color System */
    --primary: #1f983e;
    --primary-rgb: 31, 152, 62;
    --primary-dark: #167a30;
    --primary-light: #e8f5ea;

    --text-main: #1a1a1a;
    --text-secondary: #666666;
    --text-light: #999999;

    --bg-body: #f8faf8;
    --bg-surface: #ffffff;
    --border: #e2e8e2;

    /* Semantic Statuses */
    --success: #2e7d32;
    --danger: #d32f2f;
    --warning: #ed6c02;
    --info: #0288d1;

    /* Layout Tokens */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(31, 152, 62, 0.04);
    --shadow-md: 0 10px 30px rgba(31, 152, 62, 0.08);

    /* --- Bootstrap Variables Overrides --- */
    --bs-primary: var(--primary);
    --bs-primary-rgb: var(--primary-rgb);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-dark);
    --bs-success: var(--success);
    --bs-danger: var(--danger);
    --bs-warning: var(--warning);
    --bs-info: var(--info);
    --bs-body-bg: var(--bg-body);
}

/* Base resets & typography */
* {
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    background-color: var(--bs-body-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c3d2c3;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ab49a;
}

/* Bootstrap Button Customizations */
.btn {
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--primary-dark) !important;
    border-color: var(--primary-dark) !important;
    box-shadow: 0 4px 12px rgba(31, 152, 62, 0.2) !important;
}

.btn-danger {
    background-color: var(--danger) !important;
    border-color: var(--danger) !important;
    color: #ffffff !important;
}

/* Site Header */
.site-header {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1020;
}

.header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 72px;
}

.brand {
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 20px;
    color: var(--primary);
    gap: 10px;
    justify-self: start;
}

.main-nav {
    display: flex;
    align-items: center;
    justify-self: center;
}

.header-actions {
    justify-self: end;
}

.nav-list {
    display: flex;
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

/* Main Layout content container */
.content {
    min-height: calc(100vh - 72px);
    padding: 32px 0;
}

/* Cards customization without breaking Bootstrap */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:has(.card-body) {
    padding: 0; /* Keep Bootstrap layout clean */
}

.card:not(:has(.card-body)) {
    padding: 24px; /* Apply padding for raw cards */
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Indicator cards mapping colors */
.indicator-card {
    border-left: 4px solid var(--primary) !important;
}
.indicator-card.alert-card {
    border-left-color: var(--warning) !important;
}
.indicator-card.danger-card {
    border-left-color: var(--danger) !important;
}

.indicator-title {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.indicator-value {
    font-size: 26px;
    font-weight: 800;
    margin: 6px 0;
    color: var(--text-main);
    font-family: var(--font-mono);
    letter-spacing: -0.5px;
}

.indicator-subtitle {
    font-size: 11px;
    color: var(--text-light);
}

/* Metric Cards Layout Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

/* Burn Rate depletion live ticker */
.ticker-container {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #ffffff;
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: 0 4px 20px rgba(31, 152, 62, 0.15);
}

.ticker-value {
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Forms styling integration */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 152, 62, 0.15);
}

/* Responsive clean tables */
.table-responsive {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.table {
    margin-bottom: 0;
    font-size: 14px;
}

.table th {
    background-color: #f4f7f4;
    color: var(--text-secondary);
    font-weight: 700;
    border-bottom: 2px solid var(--border);
    padding: 14px 16px;
}

.table td {
    padding: 14px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

/* Styling alignment for badges */
.badge {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-success {
    background-color: var(--primary-light) !important;
    color: var(--success) !important;
}
.badge-danger {
    background-color: #fde8e8 !important;
    color: var(--danger) !important;
}
.badge-warning {
    background-color: #fdf2e2 !important;
    color: var(--warning) !important;
}
.badge-info {
    background-color: #e6f4ea !important;
    color: var(--info) !important;
}
.badge-neutral {
    background-color: #f1f3f1 !important;
    color: var(--text-secondary) !important;
}

/* System error notifications */
.blazor-error-boundary {
    background: var(--danger);
    padding: 20px;
    color: white;
    border-radius: var(--radius-md);
}

/* --- Responsive & Mobile Adaptations --- */
@media (max-width: 992px) {
    .header-inner {
        height: auto;
        flex-direction: column;
        align-items: center;
        padding: 12px 0;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .content {
        padding: 16px 0;
    }

    /* Swipeable Horizontal Navigation bar for mobile view */
    .main-nav {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }

    .nav-list {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        width: max-content;
    }

    .nav-link {
        padding: 6px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Stack cards grid or display side-by-side in double columns on phone screen */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 20px;
    }

    .card:not(:has(.card-body)) {
        padding: 16px;
    }

    /* Ticker stacking */
    .ticker-container {
        padding: 16px;
        margin-bottom: 20px;
        text-align: center;
    }

    .ticker-info {
        margin-bottom: 12px;
    }

    .ticker-value {
        font-size: 26px;
    }

    /* Shrunk metrics font size on tiny screen to fit */
    .indicator-value {
        font-size: 18px;
    }

    .indicator-title {
        font-size: 11px;
    }

    /* Adjust list groups inside detail cards */
    .list-group-item {
        padding: 12px 0;
    }

    /* Tables min-width cells to support overflow swipe on mobile screens */
    .table td, .table th {
        white-space: nowrap;
        padding: 10px 12px;
    }
    
    /* Make tables swipe indicator visible */
    .table-responsive {
        border-radius: var(--radius-sm);
    }
}

@media (max-width: 576px) {
    /* Full width container layout on micro screen */
    .card-grid {
        grid-template-columns: 1fr;
    }

    /* Centered header triggers */
    .header-actions {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    /* Bootstrap Modals Adaptation */
    .modal-dialog {
        margin: 8px;
        max-width: calc(100% - 16px) !important;
    }

    .modal-content {
        border-radius: var(--radius-sm);
    }
}

/* Blazor Error UI overrides to hide the unhandled error banner by default */
#blazor-error-ui {
    background: #fff3cd;
    color: #664d03;
    border-top: 1px solid #ffe69c;
    bottom: 0;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    display: none;
    left: 0;
    padding: 12px 24px;
    position: fixed;
    width: 100%;
    z-index: 2000;
    font-size: 14px;
    font-weight: 500;
}

#blazor-error-ui a {
    color: #664d03;
    text-decoration: underline;
    font-weight: 600;
    margin: 0 4px;
}

#blazor-error-ui a:hover {
    color: var(--primary-dark);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 24px;
    font-size: 16px;
    font-weight: 700;
}