* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Inter", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    color: #132039;
    background:
        radial-gradient(circle at 20% 10%, #ecf4ff 0%, #f0f5ff 45%, #f6f2ff 100%);
}

.admin-wrap {
    max-width: 1160px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: 40px;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 9;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 18px;
    background: linear-gradient(130deg, #0e4ca5 0%, #193f83 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(18, 46, 92, 0.22);
}

.top-bar h1 {
    margin: 0;
    font-size: 28px;
}

.top-bar p {
    margin: 6px 0 0;
    opacity: 0.9;
}

.top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.top-actions button {
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    min-width: 84px;
}

h2 {
    margin-top: 0;
}

main {
    display: grid;
    gap: 14px;
}

.card {
    background: #ffffffd9;
    border: 1px solid #d9e3f5;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 16px 40px rgba(22, 37, 66, 0.08);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

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

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

label {
    display: block;
    color: #203151;
    font-size: 14px;
}

input, select, button, pre, textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #c9d8f2;
    background: #f9fbff;
}

input, select, textarea {
    padding: 10px;
    font-size: 14px;
    margin-top: 6px;
}

button {
    width: auto;
    cursor: pointer;
    padding: 10px 14px;
    color: #fff;
    border-color: #1b6dff;
    background: linear-gradient(120deg, #1a6cff, #2a88ff);
    box-shadow: 0 6px 14px rgba(24, 96, 197, 0.22);
}

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

.actions, .panel-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.panel-actions {
    margin-bottom: 12px;
}

.inline-btn {
    width: auto;
    margin-bottom: 10px;
}

.output {
    margin-top: 10px;
    border-radius: 10px;
    padding: 10px;
    border: 1px dashed #bdd4ff;
    background: #f1f6ff;
}

.hidden {
    display: none;
}

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

.metric-card {
    border: 1px solid #d9e5fb;
    background: #fff;
    border-radius: 14px;
    padding: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.metric-card-link {
    color: inherit;
    text-decoration: none;
    display: block;
    width: 100%;
    height: 100%;
}

.metric-card:hover {
    border-color: #8db4ff;
    box-shadow: 0 10px 18px rgba(22, 60, 116, 0.14);
    transform: translateY(-2px);
}

.metric-card h3 {
    margin: 0;
    color: #35527d;
    font-size: 13px;
}

.metric-card p {
    margin: 8px 0 6px;
    font-size: 24px;
    font-weight: 700;
    color: #173a76;
}

.metric-card span {
    color: #596882;
    font-size: 12px;
}

.metric-card-action {
    display: block;
    margin-top: 12px;
    color: #1d5fbf;
    font-size: 12px;
    font-weight: 700;
}

.statistics-page .top-bar {
    align-items: center;
}

.statistics-page main {
    display: grid;
    gap: 16px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #cbdcf8;
    border-radius: 10px;
    background: #fff;
    color: #234c87;
    font-weight: 700;
    text-decoration: none;
}

.statistics-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0;
}

.summary-item {
    border: 1px solid #d9e5fb;
    border-radius: 14px;
    background: linear-gradient(145deg, #ffffff, #f4f8ff);
    padding: 14px;
}

.summary-item span {
    display: block;
    color: #607292;
    font-size: 12px;
}

.summary-item strong {
    display: block;
    margin-top: 6px;
    color: #173a76;
    font-size: 22px;
}

.statistics-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.statistics-toolbar label {
    width: 160px;
}

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

.status-badge.inactive,
.status-badge.failed {
    background: #fff0ed;
    color: #b93828;
}

.statistics-empty {
    padding: 36px 16px;
    text-align: center;
    color: #607292;
}

.card[id] {
    scroll-margin-top: 92px;
}

pre {
    margin: 0;
    padding: 12px;
    border-radius: 12px;
    background: #0b1428;
    color: #e8eefc;
    overflow: auto;
    max-height: 320px;
    font-size: 12px;
    white-space: pre-wrap;
}

.message-list {
    margin-top: 12px;
    display: grid;
    gap: 10px;
}

.mail-item {
    background: #fff;
    border: 1px solid #d6e5ff;
    border-radius: 12px;
    padding: 10px;
}

.mail-item h3 {
    margin: 0 0 8px;
    color: #22406f;
}

.mail-item p {
    margin: 4px 0;
}

.mail-item pre {
    background: #f6f8ff;
    color: #22314a;
    max-height: 180px;
    border: 1px solid #d4e4ff;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 8px;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border: 1px solid #dbe7fb;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
    color: #22324a;
}

th {
    background: #f2f6ff;
    color: #2c4366;
}

td input[type="text"], td input[type="number"] {
    width: 100%;
    min-width: 120px;
}

td button {
    margin-right: 6px;
    margin-bottom: 6px;
}

.muted {
    color: #607292;
}

.error {
    color: #c62828;
}

@media (max-width: 980px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .field-grid {
        grid-template-columns: 1fr;
    }
    .metric-grid {
        grid-template-columns: 1fr;
    }
    .statistics-summary {
        grid-template-columns: 1fr;
    }
}
