:root {
    --bg: #eef3fb;
    --surface: #ffffff;
    --surface-soft: #f6f8fc;
    --surface-strong: #101828;
    --text: #172033;
    --muted: #667085;
    --line: #d8e1ee;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #12a36c;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow: 0 18px 45px rgba(16, 24, 40, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, #f8fbff 0, #eef3fb 42%, #e9f0fa 100%);
}

.admin-page {
    background: #edf3fb;
}

.admin-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    margin-top: 0;
}

.login-card {
    width: min(520px, 100%);
}

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 288px minmax(0, 1fr);
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 24px;
    padding: 20px 24px;
    border-right: 1px solid #cad5e4;
    background: rgba(255, 255, 255, 0.96);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #0f172a;
    font-weight: 900;
}

.admin-menu {
    display: grid;
    align-content: start;
    gap: 8px;
}

.admin-menu button {
    display: flex;
    align-items: center;
    min-height: 48px;
    width: 100%;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    color: #344054;
    background: transparent;
    font-weight: 800;
    text-align: left;
    text-decoration: none;
}

.admin-menu button.active {
    color: #fff;
    background: var(--primary);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.admin-menu button:not(.active):hover {
    background: #eef4ff;
}

.sidebar-footer {
    display: grid;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    color: var(--danger);
    font-weight: 800;
    text-decoration: none;
}

.admin-main {
    display: grid;
    gap: 18px;
    align-content: start;
    padding: 32px 36px 48px;
}

.admin-page-view {
    display: grid;
    gap: 18px;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.admin-header h1 {
    margin-bottom: 4px;
}

.admin-header p {
    margin: 0;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    min-height: 132px;
    display: grid;
    align-content: space-between;
    gap: 12px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
}

.stat-card span {
    color: #52637a;
    font-size: 14px;
    font-weight: 900;
}

.stat-card strong {
    color: #0f766e;
    font-size: 34px;
    line-height: 1;
}

.stat-card small {
    color: var(--muted);
    font-weight: 700;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.table-count {
    margin-left: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.table-count strong {
    color: var(--primary);
}

.admin-message {
    min-height: 24px;
    margin: 0;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    letter-spacing: 0;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: white;
    background: var(--surface-strong);
    font-weight: 900;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 14px;
}

.nav span,
.nav a {
    padding: 8px 10px;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 34px auto;
}

.front-shell {
    display: grid;
    gap: 18px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel-pad { padding: 24px; }

.cdk-console {
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 18px;
}

.console-label {
    display: grid;
    gap: 2px;
    min-width: 92px;
}

.console-label span,
.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0;
}

.console-label strong {
    font-size: 15px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
    gap: 18px;
}

.signal-card {
    display: grid;
    gap: 18px;
    min-height: 300px;
}

.value-empty {
    color: #98a2b3 !important;
}

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

.meta-grid div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.meta-grid span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}

.meta-grid strong {
    font-size: 15px;
}

.rotate-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.rotate-panel p {
    margin: 6px 0 0;
}

.rotate-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.front-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

h1 {
    margin: 0 0 10px;
    font-size: 30px;
    line-height: 1.2;
}

h2 {
    margin: 0;
    font-size: 22px;
}

p {
    color: var(--muted);
    line-height: 1.65;
}

.input-row {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.compact-row {
    margin-top: 0;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
    min-height: 150px;
    resize: vertical;
}

button {
    border: 0;
    border-radius: 8px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    color: white;
    background: var(--primary);
    white-space: nowrap;
}

button:hover { background: var(--primary-dark); }
button:disabled { cursor: not-allowed; opacity: 0.48; }
button.secondary { color: var(--text); background: #e9eef6; }
button.secondary:hover { background: #dbe4ef; }
button.danger { background: var(--danger); }
.wide-button { width: 100%; }

code {
    font-family: "SFMono-Regular", Consolas, monospace;
}

pre {
    margin: 0;
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

pre code {
    white-space: pre;
}

.number {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 34px;
    font-weight: 900;
    word-break: break-all;
}

.code {
    min-height: 74px;
    display: grid;
    place-items: center;
    border: 1px dashed #b7c4d8;
    border-radius: 8px;
    background: var(--surface-soft);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 44px;
    font-weight: 900;
    color: var(--success);
}

.number:not(.value-empty),
.code:not(.value-empty),
.copyable {
    cursor: pointer;
}

.number:not(.value-empty):hover,
.code:not(.value-empty):hover,
.copyable:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.status-line {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    color: var(--muted);
    background: var(--surface-soft);
}

.history-box {
    display: grid;
    gap: 8px;
}

.history-title {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.history-list {
    display: grid;
    gap: 8px;
    min-height: 38px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.history-item code {
    color: var(--text);
    font-size: 16px;
    font-weight: 900;
}

.history-item span {
    color: var(--muted);
    font-size: 12px;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

.badge {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    color: var(--primary);
    background: #e8f1ff;
}

.muted-badge {
    color: var(--muted);
    background: #eef2f7;
}

.notice {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a4b00;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

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

th {
    color: var(--muted);
    background: var(--surface-soft);
    font-weight: 800;
}

.toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0;
}

.list-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 14px 0;
}

.list-filters select,
.list-filters input {
    min-height: 38px;
}

.country-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 0 0 14px;
}

.country-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}

.country-stat strong {
    color: var(--text);
}

.stack { display: grid; gap: 14px; }

.footer {
    padding: 8px 16px 28px;
    color: var(--muted);
    text-align: center;
    font-size: 14px;
}

@media (max-width: 860px) {
    .dashboard-grid, .grid { grid-template-columns: 1fr; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-sidebar { position: static; height: auto; }
    .admin-main { padding: 22px 16px 36px; }
    .admin-header { flex-direction: column; }
    .overview-grid, .admin-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; align-items: flex-start; flex-direction: column; justify-content: center; padding-top: 14px; padding-bottom: 14px; }
    .nav { width: 100%; overflow-x: auto; }
    .cdk-console { grid-template-columns: 1fr; }
    .input-row { flex-direction: column; }
    .rotate-panel { align-items: stretch; flex-direction: column; }
    .rotate-actions { justify-content: stretch; }
    .rotate-actions button { flex: 1; }
}
