
:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --sidebar: #111c31;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text: #172033;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #15803d;
    --danger: #dc2626;
}

* {
    box-sizing: border-box;
}

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

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

button, input {
    font: inherit;
}

button {
    cursor: pointer;
}

h1, h2, h3, h4, p {
    margin: 0;
}

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

.small {
    font-size: 12px;
}

.brand {
    font-size: 21px;
    font-weight: 750;
    letter-spacing: -0.5px;
}

/* 网站整体布局 */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: white;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    color: white;
    margin-bottom: 36px;
}

.brand-subtitle {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    letter-spacing: 2px;
}

.nav-link {
    display: block;
    color: #cbd5e1;
    padding: 12px 14px;
    margin-bottom: 6px;
    border-radius: 8px;
}

.nav-link:hover,
.nav-link.active {
    background: #26344d;
    color: white;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 30px;
}

.sidebar-user {
    padding: 14px 0;
    overflow-wrap: anywhere;
}

.main-panel {
    flex: 1;
    min-width: 0;
    padding: 36px;
}

.content-wrap {
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.7px;
}

.page-header p {
    margin-top: 4px;
    color: var(--muted);
}

/* 卡片和统计数字 */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.025);
}

.card h2 {
    font-size: 17px;
    margin-bottom: 16px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
}

.stat-value {
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -0.8px;
    margin: 9px 0 3px;
    overflow-wrap: anywhere;
}

.stat-unit {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.status {
    display: inline-block;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    white-space: nowrap;
    background: #f1f5f9;
    color: #475569;
}

.status-ok {
    background: #dcfce7;
    color: var(--success);
}

.status-blocked {
    background: #fee2e2;
    color: var(--danger);
}

.traffic-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}

.traffic-number {
    font-size: 28px;
    font-weight: 700;
}

.traffic-progress {
    width: 100%;
    height: 12px;
    margin: 18px 0;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
    appearance: none;
}

.traffic-progress::-webkit-progress-bar {
    background: #e2e8f0;
}

.traffic-progress::-webkit-progress-value {
    background: var(--primary);
    border-radius: 8px;
}

.traffic-progress::-moz-progress-bar {
    background: var(--primary);
    border-radius: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    padding-top: 12px;
}

.detail-value {
    font-weight: 600;
    margin-top: 4px;
}

/* 订阅区域 */

.subscription-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 0;
}

.subscription-item + .subscription-item {
    border-top: 1px solid var(--border);
}

.client-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 12px;
    font-size: 17px;
    font-weight: 700;
}

.client-info {
    flex: 1;
    min-width: 0;
}

.client-info h3 {
    font-size: 15px;
    margin-bottom: 3px;
}

.subscription-field {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.subscription-field input {
    flex: 1;
    width: 100%;
    min-width: 0;
    font-family: monospace;
    font-size: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--primary);
    color: white;
    transition: background 0.15s;
}

.btn:hover {
    background: var(--primary-hover);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #f1f5f9;
    color: var(--text);
}

.btn-logout {
    width: 100%;
    background: #26344d;
    color: #e2e8f0;
}

.btn-block {
    width: 100%;
}

.notice {
    padding: 13px 16px;
    margin-bottom: 20px;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

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

/* 登录与注册 */

.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
    background: #f1f5f9;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 24px;
}

.auth-brand .brand {
    font-size: 30px;
}

.auth-card {
    padding: 32px;
}

.auth-card h1 {
    font-size: 23px;
    margin-bottom: 6px;
}

.auth-description {
    color: var(--muted);
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
}

input:not([type="hidden"]) {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #dbeafe;
}

.form-field {
    margin-bottom: 18px;
}

.helptext {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 7px;
}

.helptext ul {
    margin: 4px 0;
    padding-left: 18px;
}

.errorlist {
    padding: 8px 12px;
    margin: 8px 0;
    list-style: none;
    background: #fef2f2;
    color: var(--danger);
    border-radius: 6px;
    font-size: 12px;
}

.auth-switch {
    margin-top: 22px;
    text-align: center;
    color: var(--muted);
}

/* 手机与平板适配 */

@media (max-width: 1050px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .main-panel {
        padding: 24px;
    }
}

@media (max-width: 700px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 16px;
    }

    .sidebar .brand {
        margin-bottom: 12px;
    }

    .sidebar-bottom {
        padding-top: 8px;
    }

    .sidebar-user {
        padding: 8px 0;
    }

    .main-panel {
        padding: 16px;
    }

    .stat-grid {
        gap: 10px;
    }

    .stat-card,
    .card {
        padding: 16px;
    }

    .stat-value {
        font-size: 22px;
    }

    .page-header h1 {
        font-size: 23px;
    }

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

    .subscription-item {
        align-items: flex-start;
    }

    .subscription-field {
        flex-wrap: wrap;
    }

    .subscription-field input {
        flex-basis: 100%;
    }

    .auth-card {
        padding: 24px;
    }
}


/* =========================================
   Administrator Dashboard
   ========================================= */

.admin-user-card {
    padding: 22px;
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
}

.admin-user-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.admin-user-heading h3 {
    font-size: 18px;
    overflow-wrap: anywhere;
}

.admin-action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.admin-action-row input[type="number"] {
    width: 150px;
}

select {
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: var(--text);
    font: inherit;
}

.admin-action-row select {
    width: auto;
}

.btn-danger {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.btn-danger:hover {
    color: white;
    background: #b91c1c;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

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

.admin-form-grid select {
    width: 100%;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    margin-top: 24px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.admin-table th {
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.admin-table td,
.admin-table th {
    border-bottom: 1px solid var(--border);
    padding: 13px 12px;
    white-space: nowrap;
}

.admin-table td {
    max-width: 300px;
    overflow-wrap: anywhere;
    white-space: normal;
}

.admin-table tbody tr:hover {
    background: #f8fafc;
}

.admin-table .btn {
    padding: 6px 12px;
    font-size: 12px;
}

@media (max-width: 700px) {

    .admin-form-grid {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .admin-user-card {
        padding: 14px;
    }

    .admin-action-row input[type="number"] {
        flex: 1;
        min-width: 100px;
    }

    .admin-action-row select {
        flex: 1;
        min-width: 140px;
    }

}
