:root {
  color-scheme: dark;
  --bg: #090d14;
  --sidebar: #0c111a;
  --surface: #111925;
  --surface-2: #162130;
  --surface-3: #1b2838;
  --line: #283548;
  --line-soft: rgba(255,255,255,.07);
  --text: #f3f5f7;
  --muted: #8e9bad;
  --gold: #d7aa55;
  --gold-bright: #f0c66e;
  --green: #54c693;
  --red: #e37575;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: "Microsoft YaHei UI", "Microsoft YaHei", sans-serif; }
body { min-width: 1100px; }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 22px 24px; background: linear-gradient(180deg, #0d131d 0%, #090e15 100%); border-right: 1px solid var(--line-soft); }
.brand { display: flex; gap: 13px; align-items: center; padding: 0 8px 30px; border-bottom: 1px solid var(--line-soft); }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; color: #15100a; font: 800 24px/1 serif; border-radius: 11px; background: linear-gradient(145deg, var(--gold-bright), #b47b28); box-shadow: 0 8px 24px rgba(215,170,85,.16); }
.brand strong { display: block; font-size: 18px; letter-spacing: .5px; }
.brand span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; letter-spacing: 2px; }
nav { display: grid; gap: 8px; margin-top: 28px; }
.nav-item { width: 100%; border: 1px solid transparent; background: transparent; padding: 13px 14px; border-radius: 10px; text-align: left; color: #aab4c2; cursor: pointer; transition: .18s ease; }
.nav-item:hover { background: rgba(255,255,255,.035); color: var(--text); }
.nav-item.active { color: var(--gold-bright); border-color: rgba(215,170,85,.2); background: linear-gradient(90deg, rgba(215,170,85,.13), rgba(215,170,85,.03)); }
.nav-icon { display: inline-block; width: 27px; color: var(--gold); }
.sidebar-note { margin-top: auto; display: flex; gap: 11px; align-items: center; padding: 15px; border: 1px solid var(--line-soft); border-radius: 12px; background: rgba(255,255,255,.025); }
.sidebar-note strong, .sidebar-note span { display: block; }
.sidebar-note strong { font-size: 13px; }
.sidebar-note span:last-child { color: var(--muted); font-size: 11px; margin-top: 4px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(84,198,147,.09); }
.logout-form { margin-top: 10px; }
.logout-button { width: 100%; min-height: 38px; border: 1px solid var(--line-soft); border-radius: 10px; color: var(--muted); background: rgba(255,255,255,.025); cursor: pointer; transition: .16s ease; }
.logout-button:hover { color: var(--text); border-color: #3b4a5e; background: #182331; }

.main { min-width: 0; padding: 0 44px 54px; }
.topbar { height: 110px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); }
.eyebrow { margin: 0 0 7px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 2.2px; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 25px; font-weight: 650; letter-spacing: .5px; }
.connection-pill { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #b9c4d1; font-size: 12px; border: 1px solid var(--line-soft); border-radius: 999px; background: rgba(255,255,255,.025); }

.page { display: none; padding-top: 32px; animation: page-in .22s ease; }
.page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.page-intro { display: flex; align-items: end; justify-content: space-between; margin-bottom: 24px; }
.page-intro h2, .hero-card h2 { margin: 0; font-size: 26px; font-weight: 650; }
.page-intro p, .hero-card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.hero-card { display: flex; align-items: center; justify-content: space-between; min-height: 152px; padding: 30px 34px; border: 1px solid rgba(215,170,85,.18); border-radius: 16px; background: radial-gradient(circle at 10% 10%, rgba(215,170,85,.12), transparent 36%), linear-gradient(135deg, #151d28, #101721); box-shadow: var(--shadow); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.metric-card { min-height: 142px; padding: 23px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card span { font-size: 12px; }
.metric-card strong { display: block; margin: 15px 0 7px; font-size: 30px; font-weight: 650; }
.metric-card small { font-size: 11px; }
.metric-card strong.good { color: var(--green); }
.metric-card strong.bad { color: var(--red); }

.panel { border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.13); }
.content-summary { display: flex; justify-content: space-between; align-items: center; padding: 24px 28px; }
.content-summary h3 { margin: 0; font-size: 20px; }
.content-summary > p { max-width: 64%; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.two-column > .panel { padding: 27px; }
.panel-heading { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 26px; }
.panel-heading.compact { margin-bottom: 17px; }
.panel-number { width: 35px; height: 35px; display: grid; place-items: center; color: var(--gold-bright); font-size: 11px; border: 1px solid rgba(215,170,85,.25); border-radius: 10px; background: rgba(215,170,85,.07); }
.panel-heading h3, .list-heading h3 { margin: 0; font-size: 17px; }
.panel-heading p, .list-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.form-stack { display: grid; gap: 15px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
label { display: grid; gap: 8px; color: #b5c0ce; font-size: 12px; }
input, select { width: 100%; height: 42px; padding: 0 13px; color: var(--text); border: 1px solid var(--line); border-radius: 9px; outline: 0; background: #0c131d; transition: .16s ease; }
input:focus, select:focus { border-color: rgba(215,170,85,.7); box-shadow: 0 0 0 3px rgba(215,170,85,.08); }
input::placeholder { color: #596678; }
.button { min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 9px; font-weight: 650; font-size: 12px; cursor: pointer; transition: .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.07); }
.button:disabled { opacity: .38; cursor: not-allowed; }
.button.primary { color: #15100a; background: linear-gradient(135deg, var(--gold-bright), #c9963d); box-shadow: 0 8px 22px rgba(215,170,85,.13); }
.button.secondary { color: #d6dde6; border-color: #3b4a5e; background: #182331; }
.button.danger { color: #ffcaca; border-color: rgba(227,117,117,.35); background: rgba(227,117,117,.1); }
.result-card { min-height: 105px; margin-top: 20px; padding: 18px; border: 1px solid var(--line-soft); border-radius: 10px; background: #0c131c; color: #ccd4de; line-height: 1.8; }
.result-card.empty, .empty-state { color: #657286; }
.result-character { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.divider { height: 1px; margin: 24px 0; background: var(--line-soft); }

.search-panel { padding: 18px 20px; margin-bottom: 16px; }
.search-row { display: grid; grid-template-columns: minmax(280px, 1fr) auto; gap: 12px; align-items: end; }
.character-layout { display: grid; grid-template-columns: minmax(270px, .7fr) minmax(650px, 2fr); gap: 16px; }
.roster-panel, .detail-panel { padding: 22px; min-height: 620px; }
.roster { display: grid; gap: 8px; }
.roster-item { width: 100%; padding: 14px; text-align: left; border: 1px solid var(--line-soft); border-radius: 10px; background: #0d141e; cursor: pointer; }
.roster-item:hover, .roster-item.active { border-color: rgba(215,170,85,.45); background: rgba(215,170,85,.07); }
.roster-item strong, .roster-item span { display: block; }
.roster-item span { margin-top: 6px; color: var(--muted); font-size: 11px; }
.empty-state { display: grid; place-items: center; min-height: 180px; text-align: center; }
.empty-state.large { min-height: 570px; }
.character-header { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 19px; border-bottom: 1px solid var(--line-soft); }
.character-header h3 { margin: 0; font-size: 23px; }
.character-header > div > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.state-badge { padding: 7px 11px; border-radius: 999px; color: var(--green); font-size: 11px; background: rgba(84,198,147,.1); border: 1px solid rgba(84,198,147,.2); }
.state-badge.online { color: #ffc0c0; background: rgba(227,117,117,.1); border-color: rgba(227,117,117,.2); }
.section-title { display: flex; justify-content: space-between; align-items: end; margin: 24px 0 13px; }
.section-title h4 { margin: 0; font-size: 14px; }
.section-title span { color: var(--muted); font-size: 11px; }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.field-grid input { height: 39px; }
.editor-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 19px; }
.editor-actions span { color: var(--muted); font-size: 11px; }
.equipment-grant { margin-top: 25px; padding-top: 2px; border-top: 1px solid var(--line-soft); }
.grant-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }

.shop-toolbar { display: grid; grid-template-columns: minmax(260px, 480px) auto 1fr; gap: 12px; align-items: end; padding: 18px 20px; margin-bottom: 16px; }
.unsaved { justify-self: end; align-self: center; color: var(--gold-bright); font-size: 12px; }
.shop-layout { display: grid; grid-template-columns: minmax(0, 1fr) 112px minmax(0, 1fr); gap: 14px; align-items: stretch; }
.shop-list-panel { min-width: 0; height: 530px; padding: 20px; display: flex; flex-direction: column; }
.list-heading { min-height: 51px; display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.list-heading input { width: 210px; height: 38px; }
.table-wrap { flex: 1; overflow: auto; margin-top: 13px; border: 1px solid var(--line-soft); border-radius: 10px; background: #0a1119; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
thead { position: sticky; top: 0; z-index: 1; background: #1a2635; }
th { color: #b9c4d1; text-align: left; font-weight: 600; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(255,255,255,.035); }
tbody tr.selected { background: rgba(215,170,85,.13); color: #ffe0a1; }
.shop-actions { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.shop-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.shop-footer p { color: var(--muted); font-size: 11px; }

.toast { position: fixed; right: 28px; bottom: 26px; z-index: 20; max-width: 430px; padding: 14px 18px; color: #d9e4ed; border: 1px solid rgba(84,198,147,.27); border-radius: 10px; background: #14231f; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }
.toast.error { color: #ffd2d2; border-color: rgba(227,117,117,.3); background: #2a171b; }
.loading { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 13px; color: #c9d3dd; font-size: 12px; background: rgba(6,9,13,.62); backdrop-filter: blur(2px); }
.loading[hidden] { display: none; }
.spinner { width: 32px; height: 32px; border: 3px solid rgba(255,255,255,.13); border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.login-body { min-width: 0; min-height: 100vh; overflow: hidden; background: radial-gradient(circle at 16% 12%, rgba(215,170,85,.12), transparent 31%), radial-gradient(circle at 88% 82%, rgba(52,86,117,.16), transparent 34%), #080c12; }
.login-body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .28; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 82%); }
.login-shell { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.login-card { width: min(440px, 100%); padding: 34px; border: 1px solid rgba(215,170,85,.18); border-radius: 18px; background: linear-gradient(145deg, rgba(19,28,40,.98), rgba(12,18,27,.98)); box-shadow: 0 30px 90px rgba(0,0,0,.46); }
.login-brand { display: flex; align-items: center; gap: 13px; padding-bottom: 25px; border-bottom: 1px solid var(--line-soft); }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 18px; letter-spacing: .4px; }
.login-brand span { margin-top: 4px; color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.login-copy { padding: 27px 0 22px; }
.login-copy h1 { margin: 0; font-size: 29px; font-weight: 650; }
.login-copy > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-error { margin: 0 0 17px; padding: 11px 13px; border: 1px solid rgba(227,117,117,.3); border-radius: 9px; color: #ffd2d2; background: rgba(227,117,117,.09); font-size: 12px; }
.login-form { display: grid; gap: 16px; }
.login-form input { height: 46px; }
.login-form .button { margin-top: 5px; min-height: 46px; }
.login-footnote { display: flex; justify-content: center; align-items: center; gap: 10px; margin: 24px 0 0; color: #748195; font-size: 11px; }

@media (max-width: 1280px) {
  .main { padding-left: 28px; padding-right: 28px; }
  .field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .character-layout { grid-template-columns: 260px minmax(0, 1fr); }
}
