:root {
    /* Layout */
    --sidebar-width: 260px;

    /* Backgrounds */
    --bg-sidebar: #0f172a;
    /* Deep navy */
    --bg-main: #f3f6f9;
    /* Light grey-blue for content */
    --bg-card: #ffffff;
    /* Pure white for cards */

    /* Typography */
    --text-primary: #1a2332;
    /* Charcoal, headings, values */
    --text-secondary: #64748b;
    /* Slate grey, labels, timestamps */
    --text-muted: #94a3b8;
    /* Very light grey for inactive sidebar */

    /* Sidebar Accents */
    --sidebar-active-bg: rgba(255, 255, 255, 0.08);
    /* Faint white highlight */
    --sidebar-active-border: #ffffff;
    /* White left bar */

    /* Card Ribbons */
    --ribbon-blue: #3b82f6;
    /* Blue ribbon / chart */
    --ribbon-green: #10b981;
    /* Green ribbon */
    --ribbon-red: #ef4444;
    /* Red ribbon */

    /* Pill Badges */
    --pill-up-bg: #dcfce7;
    --pill-up-text: #16a34a;
    --pill-up-dot: #22c55e;

    --pill-down-bg: #fee2e2;
    --pill-down-text: #dc2626;
    --pill-down-dot: #ef4444;

    /* Other */
    --btn-primary: #2563eb;
    --border-light: #e2e8f0;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

/* -----------------------------
   GRID LAYOUT
----------------------------- */
.grand-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* -----------------------------
   LEFT SIDEBAR
----------------------------- */
.sidebar {
    background-color: var(--bg-sidebar);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    border-right: 1px solid #1e293b;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 24px 20px 20px;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 12px;
}

.sidebar-brand h2 {
    font-size: 1.1rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    /* default invisible */
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-icon {
    width: 20px;
    text-align: center;
    margin-right: 12px;
    font-size: 1rem;
}

.nav-item:hover {
    color: #e2e8f0;
}

.nav-item.active {
    background-color: var(--sidebar-active-bg);
    color: #ffffff;
    border-left: 3px solid var(--sidebar-active-border);
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px 24px;
    border-top: 1px solid #1e293b;
}

.sidebar-footer .nav-item {
    padding: 8px 0;
    margin-bottom: 16px;
}

.system-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.system-stats span {
    color: #cbd5e1;
    font-weight: 600;
}

/* -----------------------------
   MAIN CONTENT AREA
----------------------------- */
.main-content {
    grid-column: 2;
    padding: 1.5rem 2.5rem;
}

.top-breadcrumb {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.top-breadcrumb i {
    margin-right: 8px;
    font-size: 0.75rem;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.role-pill {
    background: #e0e7ff;
    color: #3730a3;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* -----------------------------
   RIBBON CARDS (Metrics)
----------------------------- */
.metric-ribbon-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.ribbon-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
    border-left-width: 5px;
    /* RIBBON THICKNESS */
}

.blue-ribbon {
    border-left-color: var(--ribbon-blue);
}

.green-ribbon {
    border-left-color: var(--ribbon-green);
}

.red-ribbon {
    border-left-color: var(--ribbon-red);
}

.card-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 8px;
}

.card-value {
    font-size: 2rem;
    font-weight: 800;
}

.black-text {
    color: var(--text-primary);
}

.blue-text {
    color: var(--ribbon-blue);
}

.green-text {
    color: var(--ribbon-green);
}

/* -----------------------------
   TABLE / LISTINGS 
----------------------------- */
.table-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    margin-bottom: 2rem;
    padding: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h3 {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.clean-table {
    width: 100%;
    border-collapse: collapse;
}

.clean-table th {
    text-align: left;
    padding: 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
}

.clean-table td {
    padding: 1rem 0.8rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid #f8fafc;
}

.clean-table tbody tr:hover {
    background-color: #f8fafc;
}

.v-high {
    color: var(--pill-down-text);
}

.remove-btn {
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.remove-btn:hover {
    color: var(--pill-down-text);
    text-decoration: underline;
}

/* -----------------------------
   LED STATUS PILLS (The new look)
----------------------------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.pill-up {
    background: var(--pill-up-bg);
    color: var(--pill-up-text);
}

.pill-up .status-indicator {
    background: var(--pill-up-dot);
    box-shadow: 0 0 4px var(--pill-up-dot);
}

.pill-down {
    background: var(--pill-down-bg);
    color: var(--pill-down-text);
}

.pill-down .status-indicator {
    background: var(--pill-down-dot);
    box-shadow: 0 0 4px var(--pill-down-dot);
}

/* -----------------------------
   CHARTS & CONTROLS
----------------------------- */
.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    padding: 1.5rem;
    margin-bottom: 3rem;
}

.chart-wrapper {
    height: 300px;
    width: 100%;
}

.compact-select {
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: white;
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    outline: none;
}

/* Refresh Live Pulse */
.refresh-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 700;
}

.live-pulse {
    width: 8px;
    height: 8px;
    background: var(--ribbon-green);
    border-radius: 50%;
    position: relative;
}

.live-pulse::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid var(--ribbon-green);
    opacity: 0.5;
    animation: ping-pulse 1.5s infinite;
}

@keyframes ping-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.refresh-svg {
    color: var(--ribbon-green);
}

/* Inputs and Buttons */
.minimal-input {
    width: 100%;
    padding: 1rem 1.5rem;
    border: 2px solid #cbd5e1;
    /* Darker border */
    border-radius: 12px;
    font-size: 1rem;
    color: #0f172a;
    /* Deep navy text */
    background: #ffffff;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* Subtle shadow */
}

.minimal-input::placeholder {
    color: #475569;
    /* Much darker placeholder for readability */
    opacity: 0.8;
    font-weight: 500;
}

.input-limit {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff !important;
    font-size: 0.85rem !important;
    background: #1e293b;
    /* Dark navy background */
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.minimal-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15), 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: white;
}

.btn-primary {
    background: var(--btn-primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* Admin Only Logic */
.admin-only {
    display: none !important;
}

.is-admin .admin-only {
    display: flex !important;
}

.is-admin table .admin-only {
    display: table-cell !important;
}

.hidden {
    display: none !important;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--pill-down-bg);
    color: var(--pill-down-text);
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 700;
    z-index: 1000;
    box-shadow: var(--shadow-soft);
    border: 1px solid #fecaca;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-box {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 12px;
    width: 360px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal-field {
    margin-bottom: 1rem;
}

.modal-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
}

.modal-field input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    outline: none;
    font-family: inherit;
}

.modal-field input:focus {
    border-color: var(--btn-primary);
}

.btn-cancel {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
    font-family: inherit;
}

.btn-cancel:hover {
    background: #f8fafc;
}

.login-error {
    font-size: 0.8rem;
    color: var(--pill-down-text);
    background: var(--pill-down-bg);
    padding: 6px;
    border-radius: 4px;
    text-align: center;
}

/* -----------------------------
   DIAGNOSTIC STATUS LEDS
----------------------------- */
.status-led {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.led-green {
    background-color: #22c55e;
    box-shadow: 0 0 5px #22c55e;
}

.led-red {
    background-color: #ef4444;
    box-shadow: 0 0 5px #ef4444;
}

.led-orange {
    background-color: #f59e0b;
    box-shadow: 0 0 5px #f59e0b;
}