* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #1f2937;
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.2), transparent 32%),
        linear-gradient(135deg, #eef2ff 0%, #f8fafc 45%, #eff6ff 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.1);
    color: #4338ca;
    font-size: 0.95em;
}

.login-body,
.dashboard-body {
    min-height: 100vh;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel,
.card,
.stat-card {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

.login-panel {
    width: min(460px, 100%);
    padding: 36px;
    border-radius: 28px;
}

.login-badge,
.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(79, 70, 229, 0.1);
    color: #4338ca;
    font-size: 13px;
    font-weight: 600;
}

h1,
h2 {
    margin: 0;
}

.login-panel h1 {
    margin-top: 18px;
    font-size: 34px;
}

.login-title {
    text-align: center;
    margin-top: 0 !important;
}

.muted {
    color: #6b7280;
}

.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label span {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid #dbe4ff;
    background: rgba(255, 255, 255, 0.92);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.14);
    transform: translateY(-1px);
}

button {
    border: 0;
    cursor: pointer;
    font: inherit;
}

.primary-btn,
.ghost-btn,
.mini-btn {
    border-radius: 14px;
    transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover,
.ghost-btn:hover,
.mini-btn:hover {
    transform: translateY(-1px);
}

.primary-btn {
    padding: 14px 18px;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
    box-shadow: 0 16px 30px rgba(79, 70, 229, 0.22);
}

.ghost-btn,
.mini-btn {
    padding: 10px 14px;
    background: #eef2ff;
    color: #3730a3;
}

.danger-btn {
    background: #fee2e2;
    color: #b91c1c;
}

.alert {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    font-size: 14px;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.dashboard-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0 60px;
}

.topbar,
.stats-grid,
.section-heading,
.topbar-actions,
.action-row,
.search-form,
.pagination,
.pagination-links {
    display: flex;
}

.topbar,
.section-heading {
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar {
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin-top: 12px;
    font-size: 36px;
}

.topbar-actions {
    align-items: center;
    gap: 12px;
}

.welcome-text {
    color: #475569;
    font-size: 14px;
}

.stats-grid {
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1 1 220px;
    padding: 24px;
    border-radius: 24px;
}

.stat-card span {
    display: block;
    color: #6b7280;
    margin-bottom: 10px;
}

.stat-card strong {
    font-size: 34px;
    color: #111827;
}

.card {
    padding: 24px;
    border-radius: 28px;
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th,
td {
    padding: 16px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}

th {
    color: #64748b;
    font-weight: 600;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.status-pill.enabled {
    background: #dcfce7;
    color: #166534;
}

.status-pill.disabled {
    background: #fee2e2;
    color: #991b1b;
}

.action-row {
    gap: 8px;
    flex-wrap: wrap;
}

.empty-cell {
    text-align: center;
    color: #6b7280;
    padding: 28px 12px;
}

.list-heading-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.btn-compact {
    padding: 9px 16px;
    font-size: 14px;
}

.list-hint {
    margin: 10px 0 0;
    font-size: 13px;
}

.search-form {
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;
}

.search-form input {
    width: auto;
    min-width: 220px;
    padding: 10px 14px;
    border-radius: 12px;
}

.expire-warning {
    color: #b91c1c;
    font-weight: 600;
}

.pagination {
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
    margin-top: 20px;
}

.pagination-info {
    color: #6b7280;
    font-size: 13px;
    white-space: nowrap;
}

.pagination-links {
    align-items: center;
    gap: 8px;
}

.page-btn {
    padding: 6px 14px;
    border-radius: 10px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
    line-height: 1.6;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.page-btn:hover {
    transform: translateY(-1px);
}

.page-btn-disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.app-dialog {
    width: min(440px, calc(100% - 32px));
    border: none;
    border-radius: 24px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.24);
    animation: dialogPop 0.18s ease;
}

.app-dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
}

.dialog-header {
    padding: 22px 28px;
    background: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
}

.dialog-header h2 {
    font-size: 20px;
    color: #fff;
}

.dialog-header p {
    margin: 6px 0 0;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    min-height: 16px;
}

.dialog-body {
    padding: 24px 28px 4px;
}

.dialog-body label {
    display: block;
}

.dialog-body label + label {
    margin-top: 16px;
}

.dialog-body .field-hint {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 28px 28px;
}

@keyframes dialogPop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .dashboard-shell {
        width: min(100% - 20px, 100%);
        padding-top: 24px;
    }

    .topbar,
    .section-heading,
    .topbar-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-heading-left {
        width: 100%;
    }

    .search-form {
        width: 100%;
        margin-left: 0;
    }

    .search-form input {
        flex: 1 1 auto;
    }

    .login-panel,
    .card,
    .stat-card {
        border-radius: 22px;
    }

    .login-panel {
        padding: 28px;
    }
}
