:root {
    --bg: #0d0c14;
    --panel: rgba(27, 25, 39, .84);
    --panel-solid: #1b1927;
    --panel-soft: #211f2f;
    --line: rgba(255, 255, 255, .08);
    --line-strong: rgba(255, 255, 255, .14);
    --text: #f7f5ff;
    --muted: #aaa6bc;
    --subtle: #777386;
    --accent: #ff7657;
    --accent-bright: #ff9a68;
    --violet: #8b7cff;
    --green: #50d49b;
    --yellow: #f5c563;
    --red: #ff6b78;
    --shadow: 0 24px 80px rgba(0, 0, 0, .32);
    --radius: 22px;
    --sidebar: 256px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 80% 10%, rgba(101, 77, 180, .12), transparent 34%),
        radial-gradient(circle at 8% 90%, rgba(255, 118, 87, .08), transparent 30%),
        var(--bg);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient {
    position: fixed;
    z-index: 0;
    width: 440px;
    height: 440px;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(100px);
    opacity: .13;
}
.ambient-one { top: -220px; right: 5%; background: var(--violet); }
.ambient-two { bottom: -260px; left: 30%; background: var(--accent); }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    color: white;
    background: linear-gradient(145deg, var(--accent-bright), var(--accent) 55%, #df4d73);
    box-shadow: 0 10px 28px rgba(255, 118, 87, .27);
    font: 800 21px/1 Georgia, serif;
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .02em; font-size: 15px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .18em; }

.login-shell {
    position: relative;
    z-index: 1;
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(440px, 1.1fr) minmax(420px, .9fr);
}
.login-story {
    position: relative;
    display: flex;
    min-height: 100vh;
    padding: clamp(40px, 6vw, 88px);
    overflow: hidden;
    flex-direction: column;
    justify-content: space-between;
    background:
        linear-gradient(150deg, rgba(255,255,255,.04), transparent 34%),
        linear-gradient(145deg, #171421, #0e0d16 72%);
    border-right: 1px solid var(--line);
}
.login-story::before {
    position: absolute;
    width: 560px;
    height: 560px;
    right: -250px;
    bottom: -180px;
    content: "";
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 50%;
    box-shadow: 0 0 0 70px rgba(255,255,255,.018), 0 0 0 140px rgba(255,255,255,.014);
}
.login-story::after {
    position: absolute;
    width: 230px;
    height: 230px;
    right: 15%;
    top: 18%;
    content: "";
    border-radius: 50%;
    background: linear-gradient(145deg, rgba(139,124,255,.3), rgba(255,118,87,.16));
    filter: blur(2px);
    opacity: .55;
}
.brand-large { position: relative; z-index: 2; }
.brand-large .brand-mark { width: 48px; height: 48px; border-radius: 16px; }
.story-copy { position: relative; z-index: 2; max-width: 620px; }
.eyebrow, .page-kicker {
    margin: 0 0 14px;
    color: var(--accent-bright);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .22em;
    text-transform: uppercase;
}
.story-copy h1 {
    margin: 0;
    font-size: clamp(44px, 5.2vw, 76px);
    font-weight: 720;
    line-height: 1.12;
    letter-spacing: -.045em;
}
.story-copy > p:last-child {
    max-width: 540px;
    margin: 28px 0 0;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.9;
}
.story-metrics {
    position: relative;
    z-index: 2;
    display: grid;
    max-width: 600px;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
}
.story-metrics div { padding: 22px 16px 0 0; }
.story-metrics span { color: var(--accent-bright); font: 600 12px/1 ui-monospace, monospace; }
.story-metrics p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.story-footer {
    position: absolute;
    right: 34px;
    bottom: 42px;
    margin: 0;
    color: rgba(255,255,255,.19);
    font-size: 9px;
    letter-spacing: .25em;
    writing-mode: vertical-rl;
}
.login-panel {
    display: grid;
    padding: 40px;
    place-items: center;
}
.login-card { width: min(420px, 100%); }
.login-card h2 { margin: 0; font-size: 34px; letter-spacing: -.035em; }
.form-lead { margin: 12px 0 34px; color: var(--muted); }
.mobile-brand { display: none; margin-bottom: 46px; }

.field { display: grid; gap: 9px; margin: 0 0 20px; color: #d9d6e5; font-size: 13px; font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input, .select-input, .plain-input {
    width: 100%;
    height: 54px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    outline: 0;
    color: var(--text);
    background: rgba(255,255,255,.035);
    transition: border-color .2s, box-shadow .2s, background .2s;
}
.input-wrap input { padding-left: 48px; padding-right: 64px; }
.input-wrap input:focus, .select-input:focus, .plain-input:focus {
    border-color: rgba(255, 140, 102, .7);
    background: rgba(255,255,255,.055);
    box-shadow: 0 0 0 4px rgba(255,118,87,.09);
}
.input-icon {
    position: absolute;
    left: 17px;
    z-index: 1;
    color: var(--subtle);
    font: 700 11px/1 ui-monospace, monospace;
}
.password-toggle {
    position: absolute;
    right: 14px;
    border: 0;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-size: 12px;
}
.form-error {
    margin: -4px 0 18px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 107, 120, .25);
    border-radius: 11px;
    color: #ffb3bb;
    background: rgba(255, 107, 120, .08);
    font-size: 12px;
    line-height: 1.5;
}
.btn {
    display: inline-flex;
    min-height: 42px;
    padding: 0 16px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 680;
    font-size: 13px;
    transition: transform .18s, border-color .18s, background .18s, opacity .18s;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.btn-primary {
    color: #171017;
    background: linear-gradient(135deg, var(--accent-bright), var(--accent));
    box-shadow: 0 12px 34px rgba(255,118,87,.2);
}
.btn-secondary { border-color: var(--line-strong); background: rgba(255,255,255,.045); }
.btn-ghost { border-color: transparent; color: var(--muted); background: transparent; }
.btn-danger { border-color: rgba(255,107,120,.25); color: #ffafb7; background: rgba(255,107,120,.08); }
.btn-block { width: 100%; min-height: 54px; justify-content: space-between; padding: 0 21px; }
.login-help {
    display: flex;
    margin-top: 23px;
    align-items: flex-start;
    gap: 9px;
    color: var(--subtle);
    font-size: 11px;
    line-height: 1.6;
}
.safe-dot { width: 7px; height: 7px; margin-top: 5px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(80,212,155,.08); }

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: var(--sidebar);
    padding: 27px 18px 18px;
    flex-direction: column;
    background: rgba(18, 17, 27, .92);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(22px);
}
.sidebar > .brand { padding: 0 10px 28px; }
.main-nav { display: grid; gap: 5px; }
.nav-item {
    display: flex;
    width: 100%;
    min-height: 48px;
    padding: 0 13px;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-weight: 620;
    font-size: 13px;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.035); }
.nav-item.active {
    color: white;
    border-color: rgba(255,118,87,.16);
    background: linear-gradient(90deg, rgba(255,118,87,.16), rgba(255,118,87,.035));
}
.nav-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 9px;
    color: #c9c4d8;
    background: rgba(255,255,255,.055);
    font-size: 11px;
}
.nav-item.active .nav-icon { color: #1a1114; background: var(--accent-bright); }
.sidebar-footer {
    display: flex;
    margin-top: auto;
    padding: 14px 8px 2px;
    align-items: center;
    gap: 9px;
    border-top: 1px solid var(--line);
}
.sidebar-profile { display: flex; min-width: 0; flex: 1; align-items: center; gap: 10px; }
.sidebar-profile > span:last-child { min-width: 0; }
.sidebar-profile strong, .sidebar-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile strong { font-size: 12px; }
.sidebar-profile small { margin-top: 3px; color: var(--subtle); font-size: 10px; }
.avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255,154,104,.25);
    border-radius: 12px;
    color: var(--accent-bright);
    background: rgba(255,118,87,.1);
    font-size: 12px;
    font-weight: 800;
}
.avatar-button { cursor: pointer; }
.icon-button, .menu-button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--muted);
    background: rgba(255,255,255,.03);
    cursor: pointer;
}
.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 88px;
    padding: 18px clamp(24px, 4vw, 52px);
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(13,12,20,.78);
    backdrop-filter: blur(22px);
}
.page-kicker { margin-bottom: 5px; font-size: 9px; }
.topbar h1 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }
.system-status { display: flex; margin-right: 6px; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.system-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(80,212,155,.08); }
.menu-button { display: none; font-size: 17px; }
.page-content { padding: clamp(24px, 3.5vw, 48px) clamp(22px, 4vw, 52px) 56px; }

.welcome-row { display: flex; margin-bottom: 28px; align-items: flex-end; justify-content: space-between; gap: 20px; }
.welcome-row h2 { margin: 0 0 8px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.035em; }
.welcome-row p { margin: 0; color: var(--muted); font-size: 13px; }
.date-chip { padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.025); font-size: 11px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card, .content-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
    box-shadow: 0 18px 50px rgba(0,0,0,.12);
}
.stat-card { position: relative; min-height: 152px; padding: 22px; overflow: hidden; }
.stat-card::after {
    position: absolute;
    width: 100px;
    height: 100px;
    right: -45px;
    bottom: -55px;
    content: "";
    border: 18px solid currentColor;
    border-radius: 50%;
    opacity: .045;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-badge { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 10px; color: var(--accent-bright); background: rgba(255,118,87,.1); font-size: 11px; }
.stat-value { margin-top: 23px; font-size: 32px; font-weight: 760; letter-spacing: -.04em; }
.stat-foot { margin-top: 7px; color: var(--subtle); font-size: 10px; }
.dashboard-grid { display: grid; margin-top: 16px; grid-template-columns: 1.3fr .7fr; gap: 16px; }
.content-card { padding: 22px; }
.card-head { display: flex; margin-bottom: 21px; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-head p { margin: 6px 0 0; color: var(--subtle); font-size: 11px; }
.status-list { display: grid; gap: 17px; }
.status-row { display: grid; grid-template-columns: 88px 1fr 38px; align-items: center; gap: 12px; }
.status-label { color: var(--muted); font-size: 11px; }
.status-track { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.055); }
.status-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-bright)); }
.status-count { text-align: right; font: 650 11px/1 ui-monospace, monospace; }
.profile-list { display: grid; gap: 15px; }
.profile-item { display: flex; padding-bottom: 13px; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); font-size: 11px; }
.profile-item:last-child { padding-bottom: 0; border: 0; }
.profile-item span { color: var(--subtle); }
.profile-item strong { text-align: right; font-weight: 650; }

.section-head { display: flex; margin-bottom: 22px; align-items: flex-end; justify-content: space-between; gap: 16px; }
.section-head h2 { margin: 0 0 7px; font-size: 25px; letter-spacing: -.03em; }
.section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.search-box { position: relative; min-width: 260px; }
.search-box input { width: 100%; height: 42px; padding: 0 14px 0 36px; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--text); background: rgba(255,255,255,.035); font-size: 12px; }
.search-box::before { position: absolute; left: 13px; top: 13px; content: "⌕"; color: var(--subtle); }
.table-card { overflow: hidden; padding: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 15px 18px; color: var(--subtle); background: rgba(255,255,255,.025); font-size: 10px; font-weight: 650; letter-spacing: .06em; text-align: left; }
td { padding: 17px 18px; border-top: 1px solid var(--line); color: #dcd9e7; font-size: 11px; }
tr:hover td { background: rgba(255,255,255,.018); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.empty-state { padding: 70px 24px; text-align: center; color: var(--subtle); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.status-pill { display: inline-flex; padding: 5px 8px; align-items: center; gap: 5px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.055); font-size: 9px; font-weight: 750; }
.status-pill::before { width: 5px; height: 5px; content: ""; border-radius: 50%; background: currentColor; }
.status-active, .status-paid, .status-success, .status-completed { color: var(--green); background: rgba(80,212,155,.09); }
.status-pending, .status-processing, .status-queued, .status-running { color: var(--yellow); background: rgba(245,197,99,.09); }
.status-disabled, .status-failed, .status-cancelled, .status-paused { color: var(--red); background: rgba(255,107,120,.09); }

.channel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.channel-card { position: relative; padding: 23px; overflow: hidden; }
.channel-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: linear-gradient(var(--accent-bright), var(--violet)); }
.channel-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.channel-top h3 { margin: 0 0 7px; font-size: 17px; }
.channel-code { color: var(--subtle); font: 10px/1.5 ui-monospace, monospace; }
.link-box { display: flex; margin-top: 21px; padding: 11px 12px; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.16); }
.link-box span { min-width: 0; flex: 1; overflow: hidden; color: var(--muted); font: 10px/1.4 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.channel-actions { display: flex; margin-top: 13px; gap: 9px; flex-wrap: wrap; }
.channel-meta { display: flex; margin-top: 18px; padding-top: 15px; gap: 24px; border-top: 1px solid var(--line); color: var(--subtle); font-size: 10px; }

.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.account-hero { display: flex; padding: 28px; align-items: center; gap: 18px; }
.account-avatar { width: 64px; height: 64px; border-radius: 20px; font-size: 20px; }
.account-hero h3 { margin: 0 0 7px; font-size: 20px; }
.account-hero p { margin: 0; color: var(--muted); font-size: 11px; }
.security-panel { padding: 28px; }
.security-item { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.security-item h3 { margin: 0 0 7px; font-size: 14px; }
.security-item p { margin: 0; color: var(--subtle); font-size: 11px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; overflow: hidden; padding: 0; background: var(--line); }
.detail-cell { padding: 22px; background: var(--panel-solid); }
.detail-cell span, .detail-cell strong { display: block; }
.detail-cell span { color: var(--subtle); font-size: 10px; }
.detail-cell strong { margin-top: 8px; font-size: 12px; }

.skeleton { position: relative; overflow: hidden; background: rgba(255,255,255,.05); }
.skeleton::after { position: absolute; inset: 0; content: ""; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); animation: shimmer 1.25s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.loading-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.loading-card { height: 150px; border-radius: var(--radius); }

.toast-stack { position: fixed; z-index: 100; top: 20px; right: 20px; display: grid; width: min(360px, calc(100vw - 40px)); gap: 10px; }
.toast { display: flex; padding: 14px 16px; align-items: flex-start; gap: 10px; border: 1px solid var(--line-strong); border-radius: 13px; background: rgba(28,26,39,.96); box-shadow: var(--shadow); animation: toast-in .2s ease-out; font-size: 12px; line-height: 1.5; }
.toast::before { width: 7px; height: 7px; margin-top: 5px; flex: 0 0 auto; content: ""; border-radius: 50%; background: var(--green); }
.toast.error::before { background: var(--red); }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } }

.app-dialog {
    width: min(520px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    color: var(--text);
    background: #1a1824;
    box-shadow: var(--shadow);
}
.app-dialog::backdrop { background: rgba(5,4,9,.68); backdrop-filter: blur(5px); }
.dialog-body { padding: 26px; }
.dialog-head { display: flex; margin-bottom: 22px; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-head h3 { margin: 0 0 7px; font-size: 19px; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.dialog-close { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 20px; }
.dialog-actions { display: flex; margin-top: 25px; justify-content: flex-end; gap: 10px; }
.dialog-form .field { margin-bottom: 16px; }
.dialog-form .plain-input { height: 48px; }

@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .channel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .login-shell { display: block; }
    .login-story { display: none; }
    .login-panel { min-height: 100vh; padding: 28px; }
    .mobile-brand { display: flex; }
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 19; inset: 0; background: rgba(0,0,0,.55); }
    .workspace { margin-left: 0; }
    .menu-button { display: grid; }
    .topbar { min-height: 76px; padding: 14px 20px; }
    .topbar > div:nth-child(2) { margin-right: auto; }
    .system-status, .topbar .btn-secondary { display: none; }
    .page-content { padding: 24px 18px 46px; }
    .account-grid { grid-template-columns: 1fr; }
}

@media (max-width: 580px) {
    .login-panel { padding: 24px 21px; }
    .login-card h2 { font-size: 29px; }
    .stat-grid, .loading-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
    .stat-card { min-height: 132px; padding: 17px; }
    .stat-value { margin-top: 18px; font-size: 27px; }
    .section-head { align-items: flex-start; flex-direction: column; }
    .toolbar { width: 100%; }
    .search-box { width: 100%; min-width: 0; }
    .welcome-row { align-items: flex-start; flex-direction: column; }
    .date-chip { display: none; }
    .channel-card { padding: 20px; }
    .account-hero { align-items: flex-start; }
    .detail-grid { grid-template-columns: 1fr; }
    .security-item { align-items: flex-start; flex-direction: column; }
    .security-item .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
