:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #172026;
    --muted: #5c6b73;
    --line: #d9e1e5;
    --accent: #0f766e;
    --accent-dark: #0b5f59;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --success-bg: #dcfce7;
    --success-text: #166534;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.4;
}

.topbar {
    background: #172026;
    color: #fff;
    padding: 24px 32px;
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
}

.topbar p {
    margin: 4px 0 0;
    color: #c7d2d8;
}

.layout {
    display: grid;
    gap: 24px;
    padding: 24px 32px 40px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 18px;
}

.firmware-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.full {
    grid-column: 1 / -1;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

button,
.download {
    width: fit-content;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    padding: 10px 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.download:hover {
    background: var(--accent-dark);
}

.alert {
    margin-bottom: 16px;
    border-radius: 6px;
    padding: 10px 12px;
    font-weight: 600;
}

.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.section-heading span,
.empty,
small {
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    border-top: 1px solid var(--line);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td strong,
td small {
    display: block;
}

code {
    display: inline-block;
    max-width: 260px;
    overflow-wrap: anywhere;
    font-size: 12px;
}

@media (max-width: 720px) {
    .topbar,
    .layout {
        padding-left: 16px;
        padding-right: 16px;
    }

    .firmware-form {
        grid-template-columns: 1fr;
    }
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.topnav {
    display: flex;
    gap: 10px;
}

.topnav a {
    color: #dce7eb;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
    font-weight: 700;
}

.topnav a[aria-current="page"] {
    background: #ffffff;
    color: #172026;
}

.warning {
    background: #fef3c7;
    color: #92400e;
}

.secondary-button {
    background: #e4ebef;
    color: #172026;
}

.secondary-button:hover {
    background: #d4dee4;
}

.firmware-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.firmware-option {
    display: grid;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.firmware-option:hover,
.firmware-option.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.firmware-option h3 {
    margin: 0;
    font-size: 16px;
}

.firmware-meta {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 13px;
}

.hash-line {
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
}

.selected-firmware {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    color: var(--muted);
    margin-bottom: 16px;
}

.flash-options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.flash-options select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
    background: #fff;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.progress-shell {
    height: 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    overflow: hidden;
    background: #eef3f5;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--accent);
    transition: width 160ms ease;
}

.status-message {
    margin: 12px 0;
    color: var(--muted);
    font-weight: 700;
}

.console-log {
    min-height: 220px;
    max-height: 340px;
    overflow: auto;
    margin: 0;
    padding: 12px;
    border-radius: 8px;
    background: #101820;
    color: #d7f7ef;
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .flash-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .flash-options {
        grid-template-columns: 1fr;
    }
}
