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

html {
    width: 100%;
    min-height: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: #0f172a !important;
    background: #0f172a;
}

body {
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    width: 100%;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    margin: 0;
    padding: 0;
    background-color: #0f172a !important;
    background: linear-gradient(to bottom, #0f172a 0%, #1e293b 100%) no-repeat fixed;
    background-size: 100% 100%;
    color: #e2e8f0;
    overflow-x: hidden;
    position: relative;
}

/* Aggressive fix for mobile - cover everything with blue */
html::before,
body::before {
    content: '';
    position: fixed;
    top: -200vh;
    left: -50vw;
    right: -50vw;
    width: 200vw;
    height: 200vh;
    background: #0f172a;
    z-index: -999;
}

html::after,
body::after {
    content: '';
    position: fixed;
    bottom: -200vh;
    left: -50vw;
    right: -50vw;
    width: 200vw;
    height: 200vh;
    background: #1e293b;
    z-index: -999;
}

header {
    border-bottom: 1px solid #334155;
    padding: 20px 40px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-left: max(40px, env(safe-area-inset-left));
    padding-right: max(40px, env(safe-area-inset-right));
    background: #0f172a;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 -100vh 0 100vh #0f172a;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b 0%, #eab308 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.pnode-badge {
    background: #334155;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: #94a3b8;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 12px;
    color: #64748b;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px;
    padding-left: max(40px, env(safe-area-inset-left));
    padding-right: max(40px, env(safe-area-inset-right));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.view-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 40px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 8px;
    backdrop-filter: blur(10px);
}

.view-tab {
    flex: 1;
    max-width: 200px;
    background: transparent;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.view-tab:hover {
    color: #e2e8f0;
    background: rgba(51, 65, 85, 0.5);
}

.view-tab.active {
    background: #f59e0b;
    color: #0f172a;
    font-weight: 600;
}

.view-content {
    display: none;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 24px;
    backdrop-filter: blur(10px);
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.clickable {
    cursor: pointer;
}

.stat-card.clickable:hover {
    border-color: #f59e0b;
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.stat-card.clickable:active {
    transform: translateY(0);
}

.stat-label {
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.stat-value-container {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
}

.stat-unit {
    font-size: 14px;
    color: #64748b;
}

.stat-trend {
    font-size: 16px;
    margin-left: 4px;
}

.date-toggle-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.date-toggle {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    padding: 12px 24px;
    border-radius: 8px;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.date-toggle:hover {
    border-color: #f59e0b;
    color: #e2e8f0;
}

.date-toggle.active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #0f172a;
    font-weight: 600;
}

.date-toggle.grayed-out {
    color: #64748b;
    opacity: 0.6;
}

.date-toggle.grayed-out:hover {
    color: #94a3b8;
    opacity: 0.8;
}

.date-toggle.grayed-out.active {
    opacity: 1;
    color: #0f172a;
}

.date-toggle.before-today {
    position: relative;
}

.date-toggle.before-today::after {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #eab308;
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.6);
}

.chart-container {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
}

.chart-title {
    margin: 0 0 24px 0;
    font-size: 18px;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: 0.5px;
}

#main-chart {
    height: 400px !important;
    width: 100% !important;
}

#phase-chart {
    height: 400px !important;
    width: 100% !important;
}

.data-table-container {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 30px;
    backdrop-filter: blur(10px);
    max-height: 600px;
    overflow-y: auto;
}

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

.data-table th {
    background: rgba(51, 65, 85, 0.5);
    padding: 12px;
    text-align: left;
    font-size: 12px;
    color: #94a3b8;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #334155;
}

.data-table th:nth-child(3),
.data-table th:nth-child(4) {
    text-align: center;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #334155;
    font-size: 14px;
}

.data-table tr:hover {
    background: rgba(51, 65, 85, 0.3);
}

.price-cell {
    font-weight: 600;
    color: #f59e0b;
}

.status-box {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-on {
    background: #10b981;
    color: #0f172a;
}

.status-off {
    background: #ef4444;
    color: #ffffff;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-slow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Modal styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    font-size: 20px;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 24px;
    text-align: center;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 12px;
    color: #94a3b8;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.form-input {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 12px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: #e2e8f0;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #f59e0b;
}

.form-input::placeholder {
    color: #64748b;
}

/* Date input styling for dark theme */
.form-input[type="date"] {
    color-scheme: dark;
}

.form-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-button {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-button-primary {
    background: #f59e0b;
    color: #0f172a;
}

.modal-button-primary:hover {
    background: #eab308;
    transform: translateY(-1px);
}

.modal-button-secondary {
    background: #334155;
    color: #e2e8f0;
}

.modal-button-secondary:hover {
    background: #475569;
}

.result-display {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    margin-top: 16px;
}

.result-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.result-value {
    font-size: 24px;
    font-weight: 700;
    color: #f59e0b;
}

/* ============================================
   EXTRACTED INLINE STYLE CLASSES
   ============================================ */

/* --- Semantic color classes --- */
.text-amber   { color: #f59e0b; }
.text-blue    { color: #3b82f6; }
.text-green   { color: #10b981; }
.text-red     { color: #ef4444; }
.text-orange  { color: #f97316; }
.text-purple  { color: #a855f7; }
.text-muted   { color: #64748b; }
.text-slate   { color: #94a3b8; }

/* Highlighted value inside badges/pills */
.highlight-amber { color: #f59e0b; font-weight: 600; }
.highlight-green { color: #10b981; font-weight: 600; }
.highlight-red   { color: #ef4444; font-weight: 600; }

/* --- Layout helpers --- */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-between-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.btn-group {
    display: flex;
    gap: 12px;
}

.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-group-mb {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* --- Section headers (chart / table top bars) --- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

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

/* --- Chart title variants --- */
.chart-title-inline {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: 0.5px;
}

.chart-title-compact {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: 0.5px;
}

/* --- Toolbar button (shared by all header action buttons) --- */
.toolbar-btn {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid #334155;
    padding: 8px 16px;
    border-radius: 6px;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

/* Non-clickable info pill (same look, no cursor) */
.toolbar-badge {
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid #334155;
    padding: 8px 16px;
    border-radius: 6px;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

/* --- Hint / help text --- */
.text-hint {
    font-size: 10px;
    color: #64748b;
}

.form-hint {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

.hint-highlight {
    color: #94a3b8;
}

/* --- Chart wrapper --- */
.chart-wrapper {
    position: relative;
}

.chart-wrapper-md {
    position: relative;
    height: 400px;
}

/* --- No-data overlay (initially hidden; JS shows with style.display) --- */
.no-data-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    display: none;
}

.no-data-text {
    text-align: center;
    color: #94a3b8;
    font-size: 18px;
}

/* --- Breakeven / Difficulty card helpers --- */
.efficiency-info {
    font-size: 10px;
    color: #64748b;
    text-align: right;
}

.difficulty-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.difficulty-info {
    text-align: right;
    font-size: 11px;
    color: #64748b;
}

.difficulty-info div + div {
    margin-top: 2px;
}

/* --- Top-5 Peaks grid & cards --- */
.peaks-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

.peak-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 8px;
    border: 1px solid #334155;
}

.peak-date {
    color: #94a3b8;
    font-size: 12px;
    margin-bottom: 8px;
}

.peak-value {
    color: #ef4444;
    font-weight: 600;
    font-size: 20px;
    margin-bottom: 4px;
}

.peak-status {
    color: #64748b;
    font-size: 10px;
}

/* --- Sensor grid & placeholder --- */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.sensor-placeholder {
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.sensor-placeholder-text {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 12px;
}

/* --- Configuration form layout --- */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 600px;
    margin: 0 auto;
}

.config-section {
    max-width: 600px;
    margin: 0 auto;
}

/* Make select inputs use pointer cursor */
select.form-input {
    cursor: pointer;
}

/* --- Status message areas (initially hidden; JS shows them) --- */
.status-message {
    display: none;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

.status-message-sm {
    display: none;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
}

/* --- Info cards (Current Configuration display) --- */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-card {
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 20px;
}

.info-card-label {
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-card-value {
    font-size: 18px;
    font-weight: 600;
}

/* --- Telegram bot info --- */
.telegram-bot-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #1e293b;
    border-radius: 8px;
    margin: 20px 0;
}

.telegram-qr-code {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    background: #fff;
    padding: 4px;
}

.telegram-bot-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.telegram-bot-label {
    font-size: 13px;
    color: #94a3b8;
}

.telegram-bot-link {
    font-size: 15px;
    font-weight: 600;
    color: #38bdf8;
    text-decoration: none;
    transition: color 0.2s;
}

.telegram-bot-link:hover {
    color: #7dd3fc;
    text-decoration: underline;
}

/* --- Telegram toggle row --- */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 24px;
}

.toggle-label {
    font-size: 14px;
    color: #e2e8f0;
    font-weight: 600;
}

.toggle-description {
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
}

/* Toggle switch - merge inline sizes into existing class */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    margin-left: 16px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.toggle-track {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #334155;
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-knob {
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #94a3b8;
    border-radius: 50%;
    transition: 0.3s;
}

/* --- Form group spacing variants --- */
.form-group-md {
    margin-bottom: 20px;
}

.form-group-lg {
    margin-bottom: 24px;
}

/* --- Modal variants --- */
.modal-content-wide {
    max-width: 800px;
}

.modal-description {
    margin-bottom: 20px;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
}

.modal-scroll-body {
    max-height: 500px;
    overflow-y: auto;
}

.modal-buttons-mt {
    margin-top: 20px;
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    header {
        padding: 16px 20px;
    }
    
    .header-container {
        flex-direction: row;
        gap: 12px;
        align-items: center;
        justify-content: space-between;
    }
    
    .header-left {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    h1 {
        font-size: 22px;
    }
    
    .header-right {
        flex-shrink: 0;
    }
    
    main {
        padding: 20px;
    }
    
    /* ===== VIEW SELECTOR IMPROVEMENTS ===== */
    .view-selector {
        flex-direction: column;
        gap: 0;
        padding: 0;
        background: transparent;
        border: none;
        position: relative;
        margin-bottom: 40px;
    }
    
    .view-tab {
        display: none !important;
        width: 100%;
        max-width: none;
        padding: 14px 20px;
        font-size: 14px;
        border-radius: 8px;
        position: relative;
        background: rgba(15, 23, 42, 0.8);
        border: 1px solid #334155;
        margin-bottom: 4px;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .view-tab.active {
        display: flex !important;
        border-radius: 12px;
        margin-bottom: 8px;
        background: rgba(15, 23, 42, 0.9);
        border: 1px solid #f59e0b;
        box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
        color: #f59e0b;
        font-weight: 600;
    }
    
    .view-tab.active::after {
        content: '▼';
        margin-left: 10px;
        font-size: 12px;
        transition: transform 0.2s;
    }
    
    /* Dropdown menu on mobile */
    .view-selector.menu-open .view-tab {
        display: flex !important;
    }
    
    .view-selector.menu-open .view-tab.active::after {
        content: '▲';
        transform: rotate(180deg);
    }
    
    .view-selector.menu-open .view-tab:not(.active) {
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid #334155;
    }
    
    .view-selector.menu-open .view-tab:not(.active):hover {
        background: rgba(51, 65, 85, 0.8);
        border-color: #f59e0b;
    }
    
    /* ===== STATS GRID IMPROVEMENTS ===== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 30px;
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-label {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    .stat-value {
        font-size: 26px;
    }
    
    .stat-unit {
        font-size: 12px;
    }
    
    /* Fix difficulty adjustment card to match other card sizes */
    .stat-card #difficulty-adj {
        font-size: 26px !important;
    }
    
    /* Hide time estimate in difficulty card on mobile */
    .stat-card #time-estimate {
        display: none;
    }
    
    /* Optimize blocks remaining text */
    .stat-card #blocks-remaining {
        font-size: 10px !important;
    }
    
    /* ===== DATE TOGGLE IMPROVEMENTS ===== */
    .date-toggle-container {
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .date-toggle {
        padding: 10px 16px;
        font-size: 13px;
        flex: 1 1 auto;
        min-width: 120px;
    }
    
    /* ===== CHART CONTAINER IMPROVEMENTS ===== */
    .chart-container {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .chart-title {
        font-size: 15px;
        margin-bottom: 16px;
    }
    
    /* Better chart aspect ratio for mobile */
    #main-chart {
        height: 350px !important;
    }
    
    #load-forecast-chart {
        height: 350px !important;
    }
    
    /* ===== DATA TABLE IMPROVEMENTS ===== */
    .data-table-container {
        padding: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        min-width: 100%;
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 8px;
        font-size: 11px;
        white-space: nowrap;
    }
    
    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        background: rgba(15, 23, 42, 0.95);
        z-index: 10;
    }
    
    .data-table th:first-child {
        background: rgba(51, 65, 85, 0.95);
    }
    
    /* ===== BUTTON GROUP IMPROVEMENTS ===== */
    .chart-container > div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    
    .chart-container > div:first-child > div:last-child {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .chart-container button,
    #refresh-lmp-button,
    #adder-button,
    #refresh-load-button,
    #refresh-sensors-button {
        width: 100%;
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* Data table controls */
    .data-table-container > div:first-child {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start !important;
    }
    
    .data-table-container > div:first-child > div:last-child {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .data-table-container > div:first-child > div:last-child > div,
    .data-table-container button {
        width: 100%;
    }
    
    #machine-count-button,
    #export-csv-button,
    #export-range-button {
        width: 100%;
        text-align: center;
    }
    
    /* Better styling for profit/loss displays */
    .data-table-container > div:first-child > div:last-child > div {
        background: rgba(51, 65, 85, 0.5);
        border: 1px solid #334155;
        padding: 10px 16px;
        border-radius: 6px;
        color: #94a3b8;
        font-family: 'JetBrains Mono', monospace;
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* ===== TOP 5 PEAKS IMPROVEMENTS ===== */
    .peaks-grid {
        display: flex !important;
        flex-direction: column;
        gap: 12px;
    }
    
    .peaks-grid > .peak-card {
        padding: 20px !important;
    }
    
    /* ===== SENSOR LIST IMPROVEMENTS ===== */
    #sensor-list {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    #sensor-list > div {
        padding: 16px !important;
    }
    
    /* Temperature view - zones container (Cold/Hot split) */
    #sensor-list > div[style*="grid-template-columns"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    /* Individual zone cards (Cold and Hot) */
    #sensor-list > div > div {
        padding: 16px !important;
    }
    
    /* Sensor grid inside each zone */
    #sensor-list > div > div > div:last-child {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    /* Average temp display boxes */
    #sensor-list [id^="avg-temp"] {
        font-size: 24px !important;
    }
    
    /* ===== MODAL IMPROVEMENTS ===== */
    .modal-content {
        width: 95%;
        padding: 24px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        font-size: 18px;
    }
    
    .form-input {
        font-size: 16px;
        padding: 12px 16px;
    }
    
    /* ===== CONFIGURATION VIEW IMPROVEMENTS ===== */
    .config-grid {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .config-grid > .info-card {
        padding: 16px !important;
    }
    
    /* Form improvements */
    #config-form,
    #sensorpush-config-form {
        max-width: 100%;
    }
}

/* ===== SMALL MOBILE PHONES (480px and below) ===== */
@media (max-width: 480px) {
    h1 {
        font-size: 20px;
    }
    
    .pnode-badge {
        font-size: 10px;
        padding: 3px 8px;
    }
    
    .status-text {
        font-size: 10px;
    }
    
    main {
        padding: 16px;
    }
    
    .view-tab {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    /* ===== STATS GRID - KEEP 2 COLUMNS ===== */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-label {
        font-size: 10px;
        margin-bottom: 6px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-unit {
        font-size: 11px;
    }
    
    /* Fix difficulty adjustment card */
    .stat-card #difficulty-adj {
        font-size: 24px !important;
    }
    
    .stat-card #blocks-remaining {
        font-size: 9px !important;
    }
    
    /* ===== CHART IMPROVEMENTS ===== */
    .chart-container {
        padding: 16px;
    }
    
    .chart-title {
        font-size: 14px;
    }
    
    #main-chart {
        height: 300px !important;
    }
    
    #load-forecast-chart {
        height: 300px !important;
    }
    
    /* ===== DATE TOGGLES ===== */
    .date-toggle {
        padding: 10px 14px;
        font-size: 12px;
        min-width: 100px;
    }
    
    /* ===== DATA TABLE ===== */
    .data-table-container {
        padding: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 6px;
        font-size: 10px;
    }
    
    .status-box {
        padding: 3px 8px;
        font-size: 10px;
    }
    
    /* ===== BUTTONS ===== */
    .chart-container button,
    .data-table-container button {
        padding: 10px 14px;
        font-size: 12px;
    }
    
    /* ===== MODALS ===== */
    .modal-content {
        padding: 20px;
        width: 96%;
    }
    
    .modal-header {
        font-size: 16px;
        margin-bottom: 20px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-button {
        width: 100%;
        padding: 12px 20px;
    }
    
    .form-input {
        font-size: 16px;
    }
    
    /* ===== PEAKS VIEW ===== */
    .peaks-grid > .peak-card {
        padding: 16px !important;
    }
}

/* ===== LANDSCAPE MOBILE OPTIMIZATION ===== */
@media (max-width: 812px) and (orientation: landscape) {
    header {
        padding: 12px 20px;
    }
    
    .header-container {
        flex-direction: row;
    }
    
    main {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-value {
        font-size: 22px;
    }
    
    .chart-container {
        padding: 16px;
    }
    
    #main-chart,
    #load-forecast-chart {
        height: 280px !important;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Ensure proper touch target sizes (44px minimum per iOS guidelines) */
    .view-tab,
    .date-toggle,
    button,
    .modal-button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better tap feedback */
    .stat-card.clickable {
        -webkit-tap-highlight-color: rgba(245, 158, 11, 0.2);
    }
    
    .view-tab,
    .date-toggle,
    button {
        -webkit-tap-highlight-color: rgba(245, 158, 11, 0.15);
        tap-highlight-color: rgba(245, 158, 11, 0.15);
    }
    
    /* Improve scrolling on touch devices */
    .data-table-container {
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Disable hover effects on touch devices */
    .stat-card:hover,
    .view-tab:hover,
    .date-toggle:hover {
        transform: none;
    }
    
    /* Keep active states for touch */
    .stat-card.clickable:active {
        transform: scale(0.98);
    }
    
    .view-tab:active,
    .date-toggle:active,
    button:active {
        opacity: 0.8;
    }
}

/* ===== ADDITIONAL MOBILE IMPROVEMENTS ===== */
@media (max-width: 768px) {
    /* Improve table scroll indicator */
    .data-table-container::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, rgba(15, 23, 42, 0.8), transparent);
        pointer-events: none;
    }
    
    /* Better last refresh time display */
    #last-refresh-time,
    #load-last-refresh-time {
        font-size: 10px;
    }
    
    /* Hashprice history modal table */
    #hashprice-history-modal .modal-content {
        max-width: 95%;
    }
    
    #hashprice-history-modal .data-table th,
    #hashprice-history-modal .data-table td {
        font-size: 10px;
        padding: 8px 4px;
    }
}

/* ============================================================
   Toggle Switch (Telegram / future toggles)
   ============================================================ */
.toggle-switch {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.toggle-switch:hover #telegram-toggle-slider,
.toggle-switch:hover [id$="-toggle-slider"] {
    opacity: 0.9;
}
