 :root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-solid: #ffffff;
    --text: #172033;
    --muted: #667085;
    --border: #e6ebf2;
    --primary: #4f46e5;
    --primary-2: #06b6d4;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Inter", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(79, 70, 229, 0.20), transparent 34%),
        radial-gradient(circle at top right, rgba(6, 182, 212, 0.16), transparent 30%),
        var(--bg);
}

a {
    color: inherit;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 42px;
}

.topbar,
.card,
.stat-card,
.auth-card,
.table-card,
.link-item,
.empty-state {
    background: var(--surface);
    border: 1px solid rgba(255,255,255,0.75);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.topbar {
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 22px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.topbar h1 {
    font-size: clamp(24px, 4vw, 34px);
    line-height: 1.2;
}

.topbar p,
.text-muted {
    color: var(--muted);
}

.topbar-actions,
.inline-actions,
.link-actions,
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card,
.table-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 18px;
}

.card h2,
.table-card h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

.stat-card {
    border-radius: var(--radius-lg);
    padding: 22px;
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -22px;
    top: -22px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(79,70,229,0.16), rgba(6,182,212,0.14));
}

.stat-card .icon {
    font-size: 30px;
    margin-bottom: 14px;
}

.stat-card .label {
    color: var(--muted);
    font-size: 14px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 800;
    margin-top: 6px;
}

.btn,
button.btn,
.copy-btn {
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.btn:hover,
.copy-btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 12px 24px rgba(79, 70, 229, .25);
}

.btn-secondary {
    color: var(--text);
    background: #eef2ff;
}

.btn-success {
    color: #fff;
    background: var(--success);
}

.btn-warning {
    color: #fff;
    background: var(--warning);
}

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-sm {
    padding: 7px 12px;
    font-size: 12px;
}

.badge,
.vip-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge-vip,
.vip-badge.active,
.badge-active {
    color: #fff;
    background: linear-gradient(135deg, #f97316, #ec4899);
}

.badge-normal,
.vip-badge.inactive,
.badge-inactive {
    color: #667085;
    background: #eef2f7;
}

.alert {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: #ecfdf3;
    color: #027a48;
    border-color: #abefc6;
}

.alert-error {
    background: #fef3f2;
    color: #b42318;
    border-color: #fecdca;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #344054;
    font-weight: 700;
    font-size: 14px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border .2s ease, box-shadow .2s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(960px, 100%);
    border-radius: 30px;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.auth-hero {
    color: #fff;
    padding: 44px;
    background: linear-gradient(135deg, #312e81, #0891b2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 520px;
}

.auth-hero h1 {
    font-size: 36px;
    margin-bottom: 12px;
}

.auth-hero p {
    opacity: .88;
    line-height: 1.8;
}

.auth-body {
    padding: 44px;
    background: #fff;
}

.captcha-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.captcha-img {
    width: 120px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 26px 18px;
    color: #fff;
    background: linear-gradient(180deg, #111827, #312e81);
    overflow-y: auto;
}

.sidebar-header {
    padding: 10px 12px 24px;
}

.sidebar-header h2 {
    font-size: 24px;
    margin-bottom: 6px;
}

.sidebar-header p {
    color: rgba(255,255,255,.72);
    font-size: 14px;
}

.sidebar-menu {
    display: grid;
    gap: 8px;
}

.menu-item {
    color: rgba(255,255,255,.84);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 16px;
    transition: background .2s ease, color .2s ease;
}

.menu-item:hover,
.menu-item.active {
    color: #fff;
    background: rgba(255,255,255,.13);
}

.main-content {
    min-width: 0;
    padding: 28px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #475467;
    font-size: 13px;
    background: #f8fafc;
}

tr:hover td {
    background: #fafcff;
}

.menu-grid,
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.menu-card,
.action-btn {
    text-decoration: none;
    border-radius: var(--radius-md);
    padding: 20px;
    color: var(--text);
    background: linear-gradient(180deg, #fff, #f8fafc);
    border: 1px solid var(--border);
    transition: transform .2s ease, box-shadow .2s ease;
}

.menu-card:hover,
.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .10);
}

.menu-card .icon,
.action-btn .icon {
    display: block;
    font-size: 28px;
    margin-bottom: 10px;
}

.link-item {
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 14px;
}

.link-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.link-code,
.link-url {
    font-family: Consolas, "Courier New", monospace;
}

.link-code {
    color: #fff;
    background: #312e81;
    padding: 5px 10px;
    border-radius: 9px;
    margin-right: 8px;
}

.link-title {
    font-weight: 800;
}

.link-info {
    color: var(--muted);
    margin: 10px 0;
}

.link-url {
    color: var(--text);
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    word-break: break-all;
    margin-top: 6px;
}

.stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin: 12px 0;
    color: var(--muted);
    font-size: 13px;
}

.copy-btn {
    color: #fff;
    background: #0891b2;
}

.empty-state {
    text-align: center;
    border-radius: var(--radius-md);
    padding: 44px 20px;
    color: var(--muted);
}

.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
}

.pagination a {
    padding: 8px 13px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
    text-decoration: none;
}

.pagination a.active,
.pagination a:hover {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

@media (max-width: 920px) {
    .grid-2,
    .grid-3,
    .grid-4,
    .auth-card,
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .auth-hero {
        min-height: auto;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

    .sidebar-menu {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    .topbar,
    .link-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-shell,
    .main-content {
        width: 100%;
        padding: 16px;
    }

    .auth-body,
    .auth-hero,
    .card,
    .table-card {
        padding: 22px;
    }
}
