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

:root {
    --bg:       #1e1e1e;
    --panel-bg: #252525;
    --group-bg: #2a2a2a;
    --border:   #3a3a3a;
    --text:     #cccccc;
    --dim:      #888888;
    --accent:   #4488ff;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Menu bar ────────────────────────────────────────────────────── */
#menubar {
    flex-shrink: 0;
    background: #2d2d2d;
    border-bottom: 1px solid #444;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.menu-btns { margin-left: auto; display: flex; gap: 6px; }

/* ── Layout ──────────────────────────────────────────────────────── */
#layout { flex: 1; display: flex; overflow: hidden; }

#left-panel {
    flex-shrink: 0;
    width: 240px;
    background: var(--panel-bg);
    border-right: 1px solid #444;
    padding: 6px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#right-panel {
    flex: 1;
    background: #1a1a1a;
    padding: 8px;
}

#chart-container { width: 100%; height: 100%; position: relative; }

/* ── Status bar ──────────────────────────────────────────────────── */
#statusbar {
    flex-shrink: 0;
    background: #2d2d2d;
    border-top: 1px solid #444;
    padding: 3px 10px;
    font-size: 11px;
    color: var(--dim);
}

/* ── Groups ──────────────────────────────────────────────────────── */
.group {
    background: var(--group-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
}

.group h3 {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #666;
    margin-bottom: 5px;
}

.row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 0;
    cursor: pointer;
    user-select: none;
}
.radio-label:hover { color: #fff; }

/* ── Form controls ───────────────────────────────────────────────── */
select, input[type="number"] {
    background: #333;
    border: 1px solid #555;
    color: var(--text);
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 12px;
    min-width: 0;
}
input[type="number"] { width: 58px; }
select:focus, input:focus {
    outline: 1px solid var(--accent);
    outline-offset: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
button {
    background: #3a3a3a;
    border: 1px solid #555;
    color: var(--text);
    border-radius: 3px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: background 0.1s;
}
button:hover:not(:disabled) { background: #4a4a4a; color: #fff; }
button:disabled { opacity: 0.35; cursor: not-allowed; }

#btn-start { background: #1a4a1a; border-color: #2d7a2d; color: #90ee90; }
#btn-start:hover:not(:disabled) { background: #255025; }
#btn-stop  { background: #4a1a1a; border-color: #7a2d2d; color: #ffaaaa; }
#btn-stop:hover:not(:disabled)  { background: #5a2020; }

.btn-row { display: flex; gap: 5px; }
.btn-row button { flex: 1; }
.btn-full { width: 100%; }

.active-log { background: #4a2800 !important; border-color: #aa5500 !important; color: #ffcc88 !important; }

/* ── Port status ─────────────────────────────────────────────────── */
#port-status { font-size: 11px; color: #666; }
#port-status.connected { color: #00cc66; }

/* ── About modal ─────────────────────────────────────────────────── */
#about-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
#about-overlay.visible { display: flex; }

#about-dialog {
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 24px 28px;
    max-width: 540px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #ccc;
    line-height: 1.55;
}
#about-dialog h2 { color: #fff; margin-bottom: 6px; font-size: 16px; }
#about-dialog hr  { border: none; border-top: 1px solid #444; margin: 10px 0; }
#about-dialog p   { margin-bottom: 8px; font-size: 12px; }
#about-dialog a   { color: #4488ff; }
#about-dialog a:hover { color: #77aaff; }
#about-dialog .warranty { font-size: 11px; color: #999; }
#about-dialog .coffee-link { margin-top: 4px; }
#about-dialog .coffee-link a { font-weight: 600; }
.about-footer { text-align: right; margin-top: 14px; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
#left-panel::-webkit-scrollbar { width: 4px; }
#left-panel::-webkit-scrollbar-track { background: transparent; }
#left-panel::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
