:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #687385;
    --border: #dfe4ea;
    --primary: #166534;
    --primary-hover: #14532d;
    --danger: #b42318;
    --warning: #9a5b00;
    --shadow: 0 12px 28px rgba(23, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

code {
    background: #eef2f6;
    border-radius: 4px;
    padding: 2px 6px;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 24px;
    height: 58px;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    color: var(--text);
    font-size: 17px;
    font-weight: 700;
}

.nav {
    align-items: center;
    display: flex;
    gap: 18px;
}

.nav form {
    margin: 0;
}

.link-button {
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px;
}

.section-head {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-head h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0 0 4px;
}

.section-head p {
    color: var(--muted);
    margin: 0;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
    padding: 18px;
}

.panel-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

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

.grid {
    display: grid;
    gap: 22px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

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

th,
td {
    border-bottom: 1px solid var(--border);
    padding: 11px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

tr:last-child td {
    border-bottom: 0;
}

.compact table {
    min-width: 520px;
}

.right {
    text-align: right;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.copy-input {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    max-width: 100%;
    padding: 7px 8px;
    width: 320px;
}

.button {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--primary-hover);
}

.button.danger {
    border-color: #f5c2bd;
    color: var(--danger);
}

.button.warning {
    border-color: #efcf8b;
    color: var(--warning);
}

.button.wide {
    width: 100%;
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.status,
.badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    margin-left: 6px;
    padding: 5px 8px;
}

.status.on {
    background: #e8f6ed;
    color: #166534;
}

.status.off {
    background: #fdecea;
    color: #b42318;
}

.badge {
    background: #edf3ff;
    color: #2450a4;
}

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

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

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.check-row {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    min-height: 66px;
}

.check-row input {
    height: 18px;
    min-height: 18px;
    width: 18px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.subform {
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
    padding-top: 16px;
}

.login-shell {
    display: grid;
    min-height: calc(100vh - 130px);
    place-items: center;
}

.login-box {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 380px;
    padding: 24px;
    width: 100%;
}

.login-box h1 {
    font-size: 22px;
    margin: 0;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.flash,
.error-list {
    border-radius: 8px;
    padding: 11px 13px;
}

.flash.success {
    background: #e8f6ed;
    color: #166534;
}

.flash.error,
.error-list {
    background: #fdecea;
    color: #b42318;
}

.error-list {
    display: grid;
    gap: 4px;
    margin-bottom: 16px;
}

@media (max-width: 820px) {
    .topbar,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
        height: auto;
    }

    .topbar {
        padding: 16px 18px;
    }

    .nav {
        flex-wrap: wrap;
    }

    .page {
        padding: 18px;
    }

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

    .copy-input {
        width: 260px;
    }
}
