/* Iron Horse Vineyard Dashboard Styles */
/* Brand Colors from Emergent Connext Guidelines */

:root {
    /* Primary Brand Colors */
    --brand-green: #6b8e23;          /* Olive Green - Primary */
    --brand-blue: #2a7ca0;           /* Blue - Primary */
    --brand-brown: #40351e;          /* Dark Brown - Primary */

    /* Secondary Brand Colors */
    --brand-cream: #f9eddc;          /* Cream - Secondary */
    --brand-gold: #ba7c2b;           /* Gold - Secondary */
    --brand-burgundy: #440008;       /* Dark Red/Burgundy - Secondary */

    /* Functional Colors */
    --status-online: #6b8e23;        /* Green = sensor functioning/online */
    --status-warning: #ba7c2b;       /* Gold = data alert (out of range) */
    --status-critical: #440008;      /* Burgundy = critical data alert */
    --status-offline: #999999;       /* Gray = sensor offline */

    /* UI Colors */
    --bg-dark: #40351e;              /* Dark brown background */
    --bg-sidebar: #2d2518;           /* Darker brown sidebar */
    --bg-card: #f9eddc;              /* Cream card background */
    --bg-input: #352d1c;             /* Input background */
    --text-light: #f9eddc;           /* Cream text - for dark backgrounds */
    --text-card: #2a7ca0;            /* Blue text - for cards/boxes */
    --text-white: #ffffff;           /* White text */
    --text-muted: #c5b89a;           /* Muted cream text */
    --border-color: #5a4d36;         /* Brown border */

    /* Chart Colors */
    --chart-1: #6b8e23;              /* Olive Green */
    --chart-2: #2a7ca0;              /* Blue */
    --chart-3: #ba7c2b;              /* Gold */
    --chart-4: #7cb342;              /* Light Green */
    --chart-5: #5c9dc4;              /* Light Blue */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--brand-brown) 100%);
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
}

.login-logos {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.logo {
    max-height: 50px;
    max-width: 120px;
    object-fit: contain;
}

.logo-divider {
    color: var(--text-muted);
    font-size: 24px;
}

.login-card h1 {
    text-align: center;
    color: var(--brand-blue);
    margin-bottom: 8px;
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: var(--brand-blue);
    margin-bottom: 30px;
}

.error-message {
    background: rgba(68, 0, 8, 0.3);
    border: 1px solid var(--brand-burgundy);
    color: #ff6b6b;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    text-align: center;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--brand-blue);
    font-size: 14px;
}

.login-form input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-white);
    font-size: 16px;
    transition: border-color 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--brand-green);
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--brand-green);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-login:hover {
    background: #5a7a1e;
}

.login-footer {
    margin-top: 30px;
    text-align: center;
    color: var(--brand-blue);
    font-size: 12px;
}

/* OAuth Buttons */
.oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-google {
    background: #ffffff;
    color: #444444;
    border: 1px solid #dadce0;
}

.btn-google:hover {
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn-microsoft {
    background: #ffffff;
    color: #5e5e5e;
    border: 1px solid #8c8c8c;
}

.btn-microsoft:hover {
    background: #f3f3f3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.login-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--brand-blue);
    font-size: 13px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.login-divider span {
    padding: 0 15px;
    opacity: 0.7;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.dashboard-header {
    background: var(--brand-blue);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 40px;
    object-fit: contain;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
}

.header-logo.iron-horse {
    height: 45px;
    background: white;
    padding: 4px 8px;
    border-radius: 4px;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-white);
}

.header-subtitle {
    font-size: 12px;
    opacity: 0.9;
    color: var(--brand-cream);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    color: var(--brand-cream);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Dashboard Content */
.dashboard-content {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    align-self: flex-start;
    max-height: 100vh;
    overflow-y: auto;
}

.sidebar-nav {
    padding: 15px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(249, 237, 220, 0.05);
    color: var(--text-light);
}

.nav-item.active {
    background: rgba(107, 142, 35, 0.2);
    color: var(--brand-green);
    border-left-color: var(--brand-green);
}

.nav-icon {
    width: 24px;
    margin-right: 12px;
    font-size: 18px;
    text-align: center;
    display: inline-block;
}

.sidebar-footer {
    padding: 20px;
}

.export-section h2 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.date-range,
.date-range-vertical {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.date-label {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 4px;
}

.date-input {
    width: 100%;
    padding: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-white);
    font-size: 12px;
    box-sizing: border-box;
}

.date-range span {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.btn-export {
    width: 100%;
    padding: 10px;
    background: var(--brand-blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-export:hover {
    background: #237a94;
}

/* Main Panel */
.main-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--bg-dark);
}

/* Alert Banner */
.alert-banner {
    background: rgba(186, 124, 43, 0.2);
    border: 1px solid var(--brand-gold);
    border-radius: 6px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    color: var(--brand-gold);
}

.alert-banner.hidden {
    display: none;
}

.alert-banner.critical {
    background: rgba(68, 0, 8, 0.3);
    border-color: var(--brand-burgundy);
    color: #ff6b6b;
}

.alert-icon {
    font-size: 20px;
}

.btn-small {
    margin-left: auto;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 4px;
    color: inherit;
    cursor: pointer;
    font-size: 12px;
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--brand-cream);
}

/* Soil page Moisture / Temperature / EC section headers */
.soil-section-header {
    font-size: 18px;
    font-weight: 600;
    color: var(--brand-cream);
    margin: 25px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

/* Soil page Soiltech Beacons / Sensoterra sub-headers */
.soil-subsection-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Sensor Status — inline rename UI */
.sensor-name-display {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
.sensor-name-display > div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sensor-name-original {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}
.sensor-name-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.rename-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.rename-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,0.15);
    border-top-color: var(--brand-blue);
    border-radius: 50%;
    animation: readings-spin 0.9s linear infinite;
    vertical-align: middle;
}
.rename-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
}
.rename-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-card); }
.rename-input {
    border: 1px solid var(--brand-blue);
    background: var(--bg-card);
    color: var(--text-card);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    min-width: 180px;
}
.rename-save-btn, .rename-cancel-btn {
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.rename-save-btn   { background: var(--status-online); color: white; }
.rename-cancel-btn { background: rgba(255,255,255,0.1); color: var(--text-card); }

/* Reading spinner inside time-selector */
.readings-spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,0.15);
    border-top-color: var(--brand-blue);
    border-radius: 50%;
    animation: readings-spin 0.9s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}
@keyframes readings-spin { to { transform: rotate(360deg); } }

.time-selector {
    display: flex;
    gap: 8px;
}

.time-btn {
    padding: 8px 16px;
    background: var(--brand-cream);
    border: 1px solid var(--brand-blue);
    border-radius: 4px;
    color: var(--brand-blue);
    cursor: pointer;
    transition: all 0.2s;
}

.time-btn:hover {
    border-color: var(--brand-green);
    background: var(--brand-cream);
    color: var(--brand-green);
}

.time-btn.active {
    background: var(--brand-green);
    border-color: var(--brand-green);
    color: white;
}

/* View Sections */
.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

/* Sensor Cards */
.sensor-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

@media (max-width: 1100px) {
    .sensor-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .sensor-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
    .sensor-cards { grid-template-columns: 1fr; }
}

.sensor-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid var(--status-online);
    min-width: 0;       /* lets grid children shrink + ellipsis work */
    overflow: hidden;   /* nothing escapes the card */
}

.sensor-card.alert {
    border-left-color: var(--status-warning);
}

.sensor-card.critical-alert {
    border-left-color: var(--status-critical);
}

.sensor-card.offline {
    border-left-color: var(--status-offline);
    opacity: 0.7;
}

.sensor-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 8px;
    min-width: 0;
}

.sensor-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-card);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.sensor-status {
    flex-shrink: 0;    /* badge keeps full size; name truncates instead */
}

.sensor-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(107, 142, 35, 0.2);
    color: var(--status-online);
}

.sensor-status.alert {
    background: rgba(186, 124, 43, 0.2);
    color: var(--brand-gold);
}

.sensor-status.critical-alert {
    background: rgba(68, 0, 8, 0.3);
    color: #ff6b6b;
}

.sensor-status.offline {
    background: rgba(153, 153, 153, 0.2);
    color: var(--status-offline);
}

.sensor-readings {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.reading {
    text-align: center;
}

/* Temperature color coding */
.temp-frost {
    color: #1e40af !important; /* Deep blue for freezing */
}

.temp-cold {
    color: #3b82f6 !important; /* Blue for near-freezing */
}

.temp-hot {
    color: #dc2626 !important; /* Red for hot */
}

.reading-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-card);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reading-label {
    font-size: 10px;
    color: var(--text-card);
    margin-top: 2px;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sensor-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(42, 124, 160, 0.2);
    font-size: 11px;
    color: var(--text-card);
    opacity: 0.7;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.chart-container {
    background: var(--brand-cream);
    border-radius: 8px;
    padding: 16px;
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--brand-blue);
}

.chart {
    height: 300px;
    position: relative;
}

.chart.large {
    height: 400px;
}

/* Plotly modebar styling */
.js-plotly-plot .modebar {
    background: rgba(249, 237, 220, 0.9) !important;
    border-radius: 4px;
    padding: 2px 4px;
}

.js-plotly-plot .modebar-btn {
    color: var(--brand-blue) !important;
}

.js-plotly-plot .modebar-btn:hover {
    color: var(--brand-green) !important;
}

.js-plotly-plot .modebar-btn.active {
    color: var(--brand-green) !important;
}

/* Sensor Select */
.sensor-select {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--text-card);
    border-radius: 4px;
    color: var(--text-card);
    font-size: 14px;
    cursor: pointer;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-card);
}

.stat-label {
    font-size: 12px;
    color: var(--text-card);
    margin-top: 4px;
    opacity: 0.7;
}

.stat-sensor {
    font-size: 11px;
    color: var(--text-card);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(42, 124, 160, 0.2);
    opacity: 0.7;
}

/* Map */
.map-container {
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
}

.map-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-card);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.online {
    background: var(--status-online);
}

.legend-dot.alert {
    background: var(--status-warning);
}

.legend-dot.critical {
    background: var(--status-critical);
}

.legend-dot.offline {
    background: var(--status-offline);
}

/* Map Layer Toggle */
.map-layer-toggle {
    display: flex !important;
    background: var(--bg-card) !important;
    border-radius: 6px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    z-index: 1000 !important;
}

.leaflet-top.leaflet-right .map-layer-toggle {
    margin-top: 10px;
    margin-right: 10px;
}

.map-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: none;
    color: var(--text-card);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.map-toggle-btn:first-child {
    border-right: 1px solid rgba(42, 124, 160, 0.2);
}

.map-toggle-btn:hover {
    background: rgba(42, 124, 160, 0.1);
}

.map-toggle-btn.active {
    background: var(--brand-blue);
    color: white;
}

.map-toggle-btn .toggle-icon {
    font-size: 16px;
}

.map-toggle-btn .toggle-label {
    font-weight: 500;
}

/* Labels overlay toggle (satellite labels on/off) */
.map-labels-toggle {
    background: var(--bg-card) !important;
    border-radius: 6px !important;
    padding: 6px 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    z-index: 1000 !important;
}

.leaflet-top.leaflet-right .map-labels-toggle {
    margin-top: 6px;
    margin-right: 10px;
}

.map-labels-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-card);
    cursor: pointer;
    user-select: none;
}

.map-labels-label input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

/* Center-map (fit-to-bounds) button */
.map-center-btn {
    background: var(--bg-card) !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
    z-index: 1000 !important;
}

.leaflet-top.leaflet-left .map-center-btn {
    margin-top: 10px;
    margin-left: 10px;
}

.map-center-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg-card);
    border: none;
    color: var(--text-card);
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.map-center-button:hover {
    background: rgba(42, 124, 160, 0.1);
}

/* Alerts List */
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid var(--status-warning);
}

.alert-item.critical {
    border-left-color: var(--status-critical);
}

.alert-item.advisory {
    border-left-color: var(--brand-blue);
}

.alert-severity {
    font-size: 24px;
}

.alert-content {
    flex: 1;
}

.alert-message {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-card);
}

.alert-details {
    font-size: 13px;
    color: var(--text-card);
    opacity: 0.7;
}

.no-alerts {
    text-align: center;
    padding: 40px;
    color: var(--text-card);
}

.no-alerts-icon {
    font-size: 48px;
    margin-bottom: 12px;
    color: var(--brand-green);
}

.alerts-list .alert-item {
    background: var(--bg-card);
}

/* Thresholds */
.thresholds-section {
    margin-top: 30px;
}

.thresholds-section h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--brand-cream);
}

.thresholds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.threshold-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
}

.threshold-card h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text-card);
}

.threshold-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: var(--text-card);
    opacity: 0.8;
}

.threshold-value {
    color: var(--text-card);
    font-weight: 500;
    opacity: 1;
}

/* Custom Leaflet Popup - Override default white background */
.leaflet-popup-content-wrapper,
.leaflet-container .leaflet-popup-content-wrapper {
    background: #f9eddc !important;
    color: #2a7ca0 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.leaflet-popup-tip,
.leaflet-container .leaflet-popup-tip {
    background: #f9eddc !important;
}

.leaflet-popup-close-button,
.leaflet-container .leaflet-popup-close-button {
    color: #2a7ca0 !important;
}

.leaflet-popup-close-button:hover,
.leaflet-container .leaflet-popup-close-button:hover {
    color: #40351e !important;
}

.sensor-popup {
    min-width: 180px;
    color: #2a7ca0;
}

.sensor-popup h4 {
    margin-bottom: 8px;
    font-size: 14px;
    color: #2a7ca0;
}

.sensor-popup .popup-readings {
    display: grid;
    gap: 4px;
    font-size: 12px;
    color: #2a7ca0;
}

.sensor-popup .popup-reading {
    display: flex;
    justify-content: space-between;
}

.sensor-popup .popup-reading span {
    color: #2a7ca0;
    opacity: 0.7;
}

.sensor-popup .popup-reading strong {
    color: #2a7ca0;
}

.sensor-popup .popup-status {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(42, 124, 160, 0.2);
    font-size: 11px;
    color: #2a7ca0;
    opacity: 0.7;
}

/* Sensor Status View */
.status-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.status-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.status-card-count {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-card);
    line-height: 1;
}

.status-card-count.online {
    color: var(--status-online);
}

.status-card-count.stale {
    color: var(--brand-gold);
}

.status-card-count.offline {
    color: var(--status-offline);
}

.status-card-label {
    font-size: 14px;
    color: var(--text-card);
    margin-top: 8px;
    opacity: 0.8;
}

.diagnostics-section,
.pipeline-section,
.troubleshooting-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.diagnostics-section h3,
.pipeline-section h3,
.troubleshooting-section h3 {
    color: var(--text-card);
    font-size: 18px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(42, 124, 160, 0.2);
}

.diagnostics-table-container {
    overflow-x: auto;
}

.diagnostics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.diagnostics-table th,
.diagnostics-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(42, 124, 160, 0.1);
}

.diagnostics-table th {
    background: rgba(42, 124, 160, 0.1);
    color: var(--text-card);
    font-weight: 600;
}

.diagnostics-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.diagnostics-table th.sortable:hover {
    background: rgba(42, 124, 160, 0.2);
}

.diagnostics-table th.sortable.sorted {
    background: rgba(42, 124, 160, 0.25);
}

.diagnostics-table th .sort-indicator {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.85;
    min-width: 10px;
}

.diagnostics-table td {
    color: var(--text-card);
}

.diagnostics-table tr:hover {
    background: rgba(42, 124, 160, 0.05);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.online {
    background: rgba(107, 142, 35, 0.2);
    color: var(--status-online);
}

.status-badge.stale {
    background: rgba(186, 124, 43, 0.2);
    color: var(--brand-gold);
}

.status-badge.offline {
    background: rgba(153, 153, 153, 0.2);
    color: var(--status-offline);
}

.pipeline-info {
    display: grid;
    gap: 12px;
}

.pipeline-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(42, 124, 160, 0.1);
}

.pipeline-item:last-child {
    border-bottom: none;
}

.pipeline-label {
    color: var(--text-card);
    font-weight: 500;
}

.pipeline-value {
    color: var(--text-card);
    opacity: 0.8;
}

.troubleshooting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.troubleshooting-card {
    background: rgba(42, 124, 160, 0.05);
    border-radius: 6px;
    padding: 15px;
    border-left: 3px solid var(--brand-blue);
}

.troubleshooting-card h4 {
    color: var(--text-card);
    font-size: 14px;
    margin-bottom: 10px;
}

.troubleshooting-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.troubleshooting-card li {
    color: var(--text-card);
    font-size: 13px;
    padding: 5px 0;
    padding-left: 15px;
    position: relative;
    opacity: 0.85;
}

.troubleshooting-card li::before {
    content: "\2022";
    color: var(--brand-blue);
    position: absolute;
    left: 0;
}

/* Known Issues Section */
.known-issues-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.known-issues-section h3 {
    color: var(--status-critical);
    margin-bottom: 15px;
    font-size: 18px;
}

.known-issues-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.issue-item {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid var(--status-warning);
}

.issue-item.critical {
    border-left-color: var(--status-critical);
}

.issue-item.warning {
    border-left-color: var(--status-warning);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.issue-sensor {
    font-weight: 600;
    color: var(--brand-blue);
    font-size: 15px;
}

.issue-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.issue-badge.critical {
    background: var(--status-critical);
    color: white;
}

.issue-badge.warning {
    background: var(--status-warning);
    color: white;
}

.issue-details p {
    color: var(--text-card);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 5px;
}

.issue-details p:last-child {
    margin-bottom: 0;
}

.issues-note {
    margin-top: 15px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        position: static;
        max-height: none;
        overflow-y: visible;
        align-self: auto;
    }

    .sidebar-nav {
        display: flex;
        padding: 0;
    }

    .nav-item {
        flex-direction: column;
        padding: 12px 16px;
        border-left: none;
        border-bottom: 3px solid transparent;
        font-size: 12px;
    }

    .nav-item.active {
        border-bottom-color: var(--brand-green);
    }

    .nav-icon {
        margin-right: 0;
        margin-bottom: 4px;
    }

    .sidebar-footer {
        display: none;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .header-title h1 {
        font-size: 16px;
    }

    .header-subtitle {
        display: none;
    }
}

/* ===========================================
   Ask Rip Chat Styles
   =========================================== */

.nav-icon-img {
    vertical-align: middle;
    margin-right: 4px;
}

.rip-intro {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.rip-welcome h3 {
    margin: 0 0 4px 0;
    color: var(--text-card);
    font-size: 18px;
}

.rip-welcome p {
    margin: 0;
    color: var(--text-card);
    opacity: 0.8;
    font-size: 14px;
}

.rip-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-action-btn {
    background: var(--bg-card);
    color: var(--text-card);
    border: 1px solid rgba(42, 124, 160, 0.3);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--brand-green);
    color: white;
    border-color: var(--brand-green);
}

.rip-chat-container {
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.rip-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
}

.rip-messages:empty::before {
    content: "Start a conversation with Rip...";
    display: block;
    text-align: center;
    color: var(--text-card);
    opacity: 0.5;
    padding-top: 180px;
    font-size: 14px;
}

.rip-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.rip-message.user-message {
    flex-direction: row-reverse;
}

.rip-message .message-content {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 70%;
    word-wrap: break-word;
}

.rip-message.user-message .message-content {
    background: var(--brand-blue);
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.rip-message.rip-response .message-content {
    background: #e8e8e8;
    color: var(--brand-brown);
    border-radius: 18px 18px 18px 4px;
    max-width: 80%;
}

/* Markdown rendered inside Rip's bubble — tighten spacing so it reads like chat */
.rip-message.rip-response .message-content > *:first-child { margin-top: 0; }
.rip-message.rip-response .message-content > *:last-child  { margin-bottom: 0; }
.rip-message.rip-response .message-content p { margin: 6px 0; }
.rip-message.rip-response .message-content h1,
.rip-message.rip-response .message-content h2,
.rip-message.rip-response .message-content h3 {
    margin: 10px 0 4px;
    font-size: 14px;
    font-weight: 700;
}
.rip-message.rip-response .message-content ul,
.rip-message.rip-response .message-content ol {
    margin: 6px 0;
    padding-left: 20px;
}
.rip-message.rip-response .message-content li { margin: 2px 0; }
.rip-message.rip-response .message-content code {
    background: rgba(0,0,0,0.08);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12.5px;
}
.rip-message.rip-response .message-content pre {
    background: rgba(0,0,0,0.08);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}
.rip-message.rip-response .message-content pre code {
    background: transparent;
    padding: 0;
}
.rip-message.rip-response .message-content strong { font-weight: 700; }

.typing-indicator {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #e8e8e8;
    border-radius: 18px 18px 18px 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--brand-blue);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.rip-input-container {
    display: flex;
    gap: 12px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: 12px;
}

.rip-input {
    flex: 1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    color: var(--brand-brown);
}

.rip-input:focus {
    outline: none;
    border-color: var(--brand-blue);
}

.rip-send-btn {
    background: var(--brand-green);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    min-width: 80px;
    transition: background 0.2s;
}

.rip-send-btn:hover {
    background: #5a7a1e;
}

.rip-send-btn:disabled {
    background: var(--brand-blue);
    opacity: 0.5;
    cursor: not-allowed;
}

.rip-status-bar {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-card);
    opacity: 0.6;
}

/* Password Login Form */
.login-form {
    margin-bottom: 20px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    background: white;
    color: var(--brand-brown);
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(42, 124, 160, 0.2);
}

/* ===========================================================================
   Harborview supplement — fills classes the app.js markup uses that the base
   Iron Horse stylesheet didn't define. Uses the same brand variables so the
   look matches. (Harborview build 2026-06-17)
   =========================================================================== */
.sensor-status.online { background: var(--status-online); color: #fff; }
.sensor-status.offline { background: var(--status-offline); color: #fff; }
.status-card-count.online { color: var(--status-online); }
.status-card-count.alert { color: var(--status-warning); }
.status-card-count.critical { color: var(--status-critical); }
.status-card-count.offline { color: var(--status-offline); }

/* Alert severity badges (Alerts view) */
.alert-badge {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; color: #fff; margin-right: 10px;
}
.alert-badge.critical { background: var(--status-critical); }
.alert-badge.warning { background: var(--status-warning); }

/* Empty-chart placeholder */
.chart-empty {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; color: var(--text-muted); font-style: italic;
}

/* Diagnostics rename control + monospace EUI */
.btn-rename {
    background: none; border: none; cursor: pointer; color: var(--brand-blue);
    font-size: 0.95rem; padding: 0 4px;
}
.btn-rename:hover { color: var(--brand-gold); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.diagnostics-table th.sortable { cursor: pointer; user-select: none; }
