:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #15803d;
    --danger: #b91c1c;
    --warning: #b45309;
    --surface: #ffffff;
    --background: #f4f7fb;
    --border: #dbe3ef;
    --text: #172033;
    --muted: #64748b;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(145deg, #eef4ff, #f8fafc);
}
.login-card {
    width: min(420px, 100%);
    padding: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(37, 99, 235, .10);
}
.brand-mark {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: white;
    background: var(--primary);
    font-weight: 800;
    font-size: 20px;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 18px 0 4px; font-size: 26px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); }
label { display: block; margin: 18px 0; font-weight: 600; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    margin-top: 7px;
    padding: 9px 12px;
    color: var(--text);
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    outline: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 0;
    border-radius: 9px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
}
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { color: var(--text); background: #e8eef7; }
.button.danger { color: white; background: var(--danger); }
.button.small { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.button.full { width: 100%; }
.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: white;
    background: #172033;
}
.topbar strong { font-size: 18px; }
.topbar a { color: #dbeafe; text-decoration: none; }
.container { width: min(1320px, calc(100% - 32px)); margin: 24px auto 48px; }
.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stat, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(15, 23, 42, .04);
}
.stat { padding: 18px; }
.stat span { display: block; color: var(--muted); }
.stat strong { display: block; margin-top: 5px; font-size: 28px; }
.panel { margin-top: 18px; padding: 20px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab {
    padding: 10px 18px;
    border-radius: 9px;
    color: var(--muted);
    background: #e8eef7;
    text-decoration: none;
    font-weight: 700;
}
.tab.active { color: white; background: var(--primary); }
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
}
.form-grid label { margin: 0; }
.form-grid .wide { grid-column: span 2; }
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-bottom: 14px;
}
.toolbar label { margin: 0; min-width: 160px; }
.toolbar .search { min-width: 260px; flex: 1; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #e8eef7; }
th { color: var(--muted); background: #f8fafc; font-size: 13px; }
.code { font-family: Consolas, monospace; font-weight: 700; letter-spacing: .3px; }
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge.success { color: #166534; background: #dcfce7; }
.badge.warning { color: #92400e; background: #fef3c7; }
.badge.danger { color: #991b1b; background: #fee2e2; }
.badge.muted { color: #475569; background: #e2e8f0; }
.inline { display: inline; }
.rename-input { min-height: 32px; padding: 4px 8px; font-size: 13px; width: 140px; display: inline-block; }
.rename-form { display: inline-flex; align-items: center; gap: 4px; }
.alert { margin: 14px 0; padding: 12px 14px; border-radius: 9px; }
.alert-success { color: #166534; background: #dcfce7; }
.alert-error { color: #991b1b; background: #fee2e2; }
.empty { padding: 38px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr 1fr; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    .container { width: min(100% - 20px, 1320px); margin-top: 12px; }
    .topbar { padding: 0 14px; }
    .stats, .form-grid { grid-template-columns: 1fr; }
    .form-grid .wide { grid-column: span 1; }
    .panel { padding: 14px; }
    .login-card { padding: 24px; }
}
.firmware-edit-form {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
    min-width: 180px
}

.firmware-edit-form input {
    min-width: 0;
    width: 100%
}
