:root {
    --bg: #eef2f5;
    --surface: #ffffff;
    --text: #20242a;
    --muted: #68717d;
    --line: #d8dde4;
    --focus: #0f766e;
    --focus-dark: #115e59;
    --danger: #b42318;
    --ok: #17663a;
    --soft: #f8fafb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Microsoft YaHei", sans-serif;
    font-size: 14px;
}

button,
input,
select {
    font: inherit;
}

button {
    min-height: 36px;
    border: 1px solid var(--focus);
    border-radius: 6px;
    background: var(--focus);
    color: #fff;
    padding: 0 14px;
    cursor: pointer;
    white-space: nowrap;
}

button.secondary,
.tab {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
}

button:hover {
    filter: brightness(0.96);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.64;
    filter: none;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 30px;
    background: #172126;
    color: #fff;
    border-bottom: 1px solid var(--line);
}

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

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

.top-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-link,
.auth-links a {
    color: inherit;
    text-decoration: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 6px;
    padding: 0 12px;
    color: #fff;
}

#apiBase {
    width: 220px;
}

.shell {
    display: block;
    padding: 22px 30px;
}

.dashboard-shell {
    max-width: 1280px;
    margin: 0 auto;
}

.auth-panel,
.workspace,
.tab-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.auth-panel {
    padding: 18px;
    align-self: start;
}

.workspace {
    min-width: 0;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--soft);
}

.section-title h2 {
    margin: 0;
    font-size: 17px;
}

.tabs {
    display: flex;
    gap: 8px;
    padding: 14px 14px 0;
    border-bottom: 1px solid transparent;
}

.tab {
    color: var(--muted);
}

.tab.active {
    color: #fff;
    background: var(--focus);
    border-color: var(--focus);
}

.tab-panel {
    display: none;
    margin: 14px;
    overflow: hidden;
}

.tab-panel.active {
    display: block;
}

.grid {
    display: grid;
    gap: 14px;
    padding: 20px;
}

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

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

.select-grid {
    padding-top: 0;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-row.inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: end;
}

.city-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

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

input,
select,
output {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    padding: 8px 10px;
}

select[multiple] {
    min-height: 260px;
    padding: 0;
}

select[multiple] option {
    padding: 8px 10px;
    border-bottom: 1px solid #edf0f3;
}

input:focus,
select:focus {
    outline: 2px solid rgba(20, 108, 148, 0.18);
    border-color: var(--focus);
}

.form-actions,
.button-row {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    gap: 10px;
}

.table-wrap {
    padding: 0 18px 18px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    background: #f7f9fb;
}

tbody tr:hover {
    background: #f9fbfc;
}

td.actions {
    width: 170px;
    text-align: right;
}

td.actions button {
    margin-left: 6px;
    min-height: 30px;
    padding: 0 10px;
}

.readonly output {
    display: block;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: none;
    max-width: 420px;
    border-radius: 8px;
    background: #20242a;
    color: #fff;
    padding: 12px 14px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
}

.toast.show {
    display: block;
}

.toast.error {
    background: var(--danger);
}

.toast.ok {
    background: var(--ok);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background: linear-gradient(135deg, #172126 0%, #25353b 52%, #eef2f5 52%, #eef2f5 100%);
}

.auth-card {
    width: min(440px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    padding: 26px;
}

.auth-heading {
    margin-bottom: 22px;
}

.auth-heading h1 {
    margin: 0;
    font-size: 24px;
}

.auth-heading p {
    margin: 8px 0 0;
    color: var(--muted);
}

.wide-btn {
    width: 100%;
    margin-top: 16px;
}

.auth-code-row {
    grid-template-columns: minmax(0, 1fr) auto;
}

.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    color: var(--focus-dark);
}

.email-code-combo {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.email-code-combo input {
    min-width: 0;
}

.email-code-combo button {
    min-width: 112px;
}

.summary-list {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.summary-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.summary-list div:last-child {
    border-bottom: 0;
}

.summary-list span {
    color: var(--muted);
}

.summary-list strong {
    font-weight: 700;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 700;
    background: #e8f5ee;
    color: var(--ok);
}

.status-badge.off {
    background: #f8e8e6;
    color: var(--danger);
}

.empty-row {
    color: var(--muted);
    text-align: center;
    padding: 28px 10px;
}

@media (max-width: 920px) {
    .topbar,
    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

    #apiBase {
        width: 100%;
    }

    .field-row.inline {
        grid-template-columns: 1fr;
    }

    .city-picker {
        grid-template-columns: 1fr;
    }

    .email-code-combo {
        grid-template-columns: 1fr;
    }
}
