:root {
    /* Переменные темной темы (по умолчанию) */
    --bg-dark: #121212;
    --bg-card: #1E1E1E;
    --text-main: #E0E0E0;
    --text-muted: #A0A0A0;
    --duino-yellow: #F4B400;
    --duino-yellow-dim: rgba(244, 180, 0, 0.15);
    --duino-green: #00E676;
    --duino-red: #FF5252;
    --duino-blue: #2196F3; /* ДОБАВЛЕНО */
    --border-color: #333;
    --radius: 12px;
    --header-border: #333;
    --chart-grid: rgba(255,255,255,0.05);
    --table-hover: rgba(255,255,255,0.03);
}

/* Переменные светлой темы */
[data-theme="light"] {
    --bg-dark: #F5F7FA;
    --bg-card: #FFFFFF;
    --text-main: #333333;
    --text-muted: #666666;
    --duino-yellow: #F57F17; 
    --duino-yellow-dim: rgba(245, 127, 23, 0.1);
    --duino-green: #2E7D32;
    --duino-red: #C62828;
    --border-color: #E0E0E0;
    --header-border: #E0E0E0;
    --chart-grid: rgba(0,0,0,0.05);
    --table-hover: rgba(0,0,0,0.02);
}

* { box-sizing: border-box; }

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s, color 0.3s;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--header-border);
}

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

.brand img {
    height: 32px;
    width: auto;
    border-radius: 0;
    background: none;
    padding: 0;
    object-fit: contain;
    box-shadow: none;
    margin-right: 10px;
    border-radius: 4px; 
    transition: filter 0.3s;
}

[data-theme="light"] .brand img { filter: none; /* Оригинальный цвет для светлой темы */ }

h1 {
    margin: 0;
    font-size: 24px;
    color: var(--duino-yellow);
    font-weight: 700;
    letter-spacing: 0.5px;
    white-space: nowrap;
    line-height: 32px;
}

.user-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 500px;
    position: relative;
    align-items: center;
    order: 3; /* Порядок на мобильных */
    width: 100%;
}

.settings-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    order: 2;
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover {
    border-color: var(--duino-blue); /* Синяя подсветка при наведении */
}

.icon-btn:active {
    transform: scale(0.95);
}

input[type="text"] {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 12px 15px 12px 15px;
    border-radius: var(--radius);
    font-size: 15px;
    outline: none;
    transition: 0.3s;
    width: 100%;
}

input[type="text"]:focus {
    border-color: var(--duino-yellow);
    box-shadow: 0 0 0 2px var(--duino-yellow-dim);
}

.input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--duino-yellow);
    pointer-events: none;
    z-index: 2;
}

input[type="text"] { padding-left: 40px; }

button.btn-main {
    background: var(--duino-yellow);
    color: #121212;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

button.btn-main:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

button.btn-main:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

.status-bar {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 20px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #555;
    transition: 0.3s;
}
.dot.active { background-color: var(--duino-green); box-shadow: 0 0 8px var(--duino-yellow); /* Желтое свечение точки статуса */
    }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--duino-yellow);
    opacity: 0.5;
}

.card-icon-wrapper {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: rgba(128,128,128, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--duino-yellow);
}

.card-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.card-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 26px;
    font-weight: 500;
    color: var(--text-main);
}

.card-subtext { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 25px;
    height: 320px;
}

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

.section-title {
    color: var(--duino-yellow);
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    width: 100%;
}

.table-scroll { overflow-x: auto; width: 100%; }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; 
}

th {
    background: rgba(0,0,0,0.2);
    text-align: left;
    padding: 15px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: 'Roboto Mono', monospace;
    font-size: 13px;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: var(--table-hover); }

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
}

.status-online { 
    background: rgba(0, 230, 118, 0.15); 
    color: var(--duino-green); 
    border: 1px solid rgba(0, 230, 118, 0.3);
}

.status-offline { 
    background: rgba(255, 82, 82, 0.15); 
    color: var(--duino-red); 
    border: 1px solid rgba(255, 82, 82, 0.3);
}

.efficiency-bar-bg {
    width: 100%;
    height: 6px;
    background: #333; 
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}

[data-theme="light"] .efficiency-bar-bg { background: #ddd; }

.efficiency-bar-fill {
    height: 100%;
    background: var(--duino-yellow);
    transition: width: 0.5s ease;
}

.error-msg {
    background: rgba(255, 82, 82, 0.1);
    border: 1px solid var(--duino-red);
    color: var(--duino-red);
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    text-align: center;
    display: none;
    font-weight: 500;
}

.footer-stats {
    margin-top: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: none; 
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    border-top: 2px solid var(--duino-yellow);
}

.footer-user { display: flex; align-items: center; gap: 15px; }

.footer-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #F4B400, #FF8F00);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: bold;
    font-size: 22px;
    text-transform: uppercase;
    border: 2px solid #fff;
    object-fit: cover;
    position: relative;
    overflow: hidden;
}

.footer-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.footer-avatar-letter { z-index: 1; }

.footer-info h2 {
    margin: 0;
    font-size: 18px;
    color: var(--duino-yellow);
    line-height: 1.2;
}

.footer-info span {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

.footer-balances {
    display: flex;
    gap: 40px;
    text-align: right;
    align-items: center;
}

.footer-balance-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.footer-balance-item .label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-bottom: 4px;
    font-weight: 700;
}

.footer-balance-item .value {
    font-family: 'Roboto Mono', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

.icon-svg { width: 20px; height: 20px; fill: currentColor; }
.icon-lg { width: 24px; height: 24px; }

@media (max-width: 850px) {
    .stats-grid { grid-template-columns: 1fr; }
    header { flex-direction: column; align-items: stretch; }
    .user-controls { max-width: 100%; width: 100%; order: 3; }
    .settings-controls { width: 100%; justify-content: flex-end; order: 2; margin-bottom: 10px; }
    .footer-stats { flex-direction: column; align-items: flex-start; gap: 15px; }
    .footer-balances { text-align: left; width: 100%; justify-content: flex-start; gap: 30px; margin-top: 10px; }
    .footer-balance-item { align-items: flex-start; }
    .footer-balance-item .label { justify-content: flex-start; }
    .input-icon { display: none; }
    input[type="text"] { padding-left: 15px; }
}
