:root {
  --bg: #0b0d12;
  --surface: #141820;
  --surface-2: #1a2030;
  --border: #252d3d;
  --text: #edf0f7;
  --muted: #7d8aa0;
  --primary: #07c160;
  --primary-glow: rgba(7, 193, 96, 0.25);
  --danger: #ff4d4f;
  --warning: #faad14;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.green-text { color: var(--primary); }
.red-text { color: var(--danger); }
.empty-center { text-align: center; padding: 32px; }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 20%, rgba(7,193,96,0.12), transparent 50%), radial-gradient(ellipse at 70% 80%, rgba(59,130,246,0.1), transparent 50%), var(--bg); }
.login-bg::after { content: ''; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h60v60H0z' fill='none' stroke='%23252d3d' stroke-width='0.5'/%3E%3C/svg%3E"); opacity: 0.4; }
.login-card { position: relative; width: min(400px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 42px 34px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 60px; height: 60px; margin: 0 auto 18px; border-radius: 18px; background: linear-gradient(135deg, var(--primary), #10b981); display: grid; place-items: center; font-size: 30px; font-weight: 700; color: #fff; box-shadow: 0 8px 24px var(--primary-glow); }
.login-card h1 { font-size: 23px; margin-bottom: 6px; }
.login-desc { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.login-card input { width: 100%; padding: 13px 15px; border-radius: 11px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); margin-bottom: 20px; font-size: 14px; outline: none; transition: 0.2s; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 12px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 8px 10px 22px; }
.brand-icon { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #059669); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item { background: none; border: none; color: var(--muted); text-align: left; padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; transition: 0.15s; display: flex; align-items: center; gap: 8px; }
.nav-icon { font-size: 15px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-glow); color: var(--primary); font-weight: 500; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; }
.sidebar-status { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 12px; color: var(--muted); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 var(--primary-glow); } 50% { opacity: 0.7; box-shadow: 0 0 0 6px transparent; } }
.logout-btn { background: none; border: 1px solid var(--border); color: var(--muted); padding: 10px; border-radius: 9px; cursor: pointer; font-size: 13px; margin-top: 8px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h2 { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.badge { font-size: 12px; padding: 5px 12px; border-radius: 20px; background: var(--primary-glow); color: var(--primary); }
.clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.page { display: none; padding: 22px 28px; flex: 1; overflow-y: auto; }
.page.active { display: block; }

/* Hero */
.hero-banner { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px; border-radius: var(--radius); margin-bottom: 20px; background: linear-gradient(135deg, rgba(7,193,96,0.15), rgba(59,130,246,0.08)); border: 1px solid rgba(7,193,96,0.2); flex-wrap: wrap; gap: 16px; }
.hero-banner.warn { background: linear-gradient(135deg, rgba(250,173,20,0.12), rgba(255,77,79,0.06)); border-color: rgba(250,173,20,0.25); }
.hero-banner h3 { font-size: 20px; margin-bottom: 4px; }
.hero-banner p { color: var(--muted); font-size: 14px; }
.hero-metrics { display: flex; gap: 32px; }
.hero-metrics div { text-align: center; }
.hero-metrics strong { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.hero-metrics span { font-size: 12px; color: var(--muted); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stats-grid.mini { grid-template-columns: repeat(4, 1fr); }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; align-items: center; gap: 14px; transition: 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card.mini { flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; }
.stat-card.mini .stat-value { font-size: 22px; }
.stat-icon { font-size: 28px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); }
.grad-green { border-color: rgba(7,193,96,0.2); }
.grad-blue { border-color: rgba(59,130,246,0.2); }
.grad-purple { border-color: rgba(139,92,246,0.2); }
.grad-orange { border-color: rgba(250,173,20,0.2); }
.stat-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.stat-value { font-size: 26px; font-weight: 700; }

/* Charts */
.charts-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
.chart-panel { min-height: 260px; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; max-width: 40px; border-radius: 6px 6px 2px 2px; overflow: hidden; display: flex; flex-direction: column; min-height: 4px; transition: 0.5s; }
.bar-success { background: var(--primary); }
.bar-fail { background: var(--danger); }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 8px; }
.bar-num { font-size: 11px; color: var(--text); font-weight: 600; }
.donut-wrap { position: relative; width: 140px; height: 140px; margin: 10px auto; }
.donut-svg { width: 100%; height: 100%; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center strong { font-size: 28px; }
.donut-center span { font-size: 12px; color: var(--muted); }
.donut-legend { display: flex; justify-content: center; gap: 20px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot.green { background: var(--primary); }
.dot.gray { background: #4a5568; }

/* Flow */
.flow-diagram { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 20px 10px; }
.flow-node { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; text-align: center; font-size: 13px; min-width: 90px; }
.flow-node.highlight { border-color: var(--primary); background: var(--primary-glow); box-shadow: 0 0 20px var(--primary-glow); }
.flow-node small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.flow-arrow { color: var(--muted); font-size: 18px; }

/* Rank */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: center; gap: 12px; }
.rank-no { width: 24px; height: 24px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.rank-body { flex: 1; }
.rank-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #10b981); border-radius: 3px; transition: 0.5s; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline.full { max-height: 600px; overflow-y: auto; }
.tl-item { display: flex; gap: 14px; padding: 12px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 5px; top: 28px; bottom: -4px; width: 2px; background: var(--border); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; z-index: 1; }
.tl-item.success .tl-dot { background: var(--primary); box-shadow: 0 0 8px var(--primary-glow); }
.tl-item.fail .tl-dot { background: var(--danger); }
.tl-body { flex: 1; }
.tl-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.tl-type { font-weight: 500; font-size: 13px; }
.tl-badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.tl-badge.success { background: var(--primary-glow); color: var(--primary); }
.tl-badge.fail { background: rgba(255,77,79,0.15); color: var(--danger); }
.tl-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.tl-detail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.tag { background: var(--surface-2); padding: 2px 8px; border-radius: 6px; font-size: 11px; color: var(--blue); }

/* Domain cards */
.domain-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.domain-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; transition: 0.2s; }
.domain-card.on { border-color: rgba(7,193,96,0.3); }
.domain-card.off { opacity: 0.65; }
.domain-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.dc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dc-status { font-size: 12px; }
.domain-card.on .dc-status { color: var(--primary); }
.domain-card.off .dc-status { color: var(--muted); }
.dc-name { font-size: 14px; margin-bottom: 4px; }
.dc-time { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.dc-actions { display: flex; gap: 8px; }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 10px; }
.pill.on { background: var(--primary-glow); color: var(--primary); }
.pill.off { background: rgba(125,138,160,0.15); color: var(--muted); }

/* Token ring */
.token-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.ring-wrap { position: relative; width: 180px; height: 180px; margin: 20px auto 24px; }
.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-progress { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; transition: 0.8s; stroke-dasharray: 427; stroke-dashoffset: 427; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center strong { font-size: 32px; }
.ring-center span { font-size: 13px; color: var(--muted); }

/* Components */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; margin-bottom: 16px; font-weight: 600; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-header h3 { margin-bottom: 0; }
.panel-actions { display: flex; align-items: center; gap: 12px; }
.view-toggle { display: flex; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.toggle-btn { background: none; border: none; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.toggle-btn.active { background: var(--surface); color: var(--text); }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.info-item span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.info-item code { font-size: 13px; word-break: break-all; }
.btn { padding: 9px 16px; border-radius: 9px; border: none; cursor: pointer; font-size: 13px; font-weight: 500; transition: 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #06a050; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(255,77,79,0.12); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.select-sm { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 24px !important; }
.token-box, .result-box { background: var(--surface-2); border-radius: 10px; padding: 16px; font-size: 13px; }
.token-box code { display: block; word-break: break-all; font-family: Consolas, monospace; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-grid label, .modal-card label { display: block; font-size: 12px; color: var(--muted); }
.form-grid input, .form-grid select, .modal-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; outline: none; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; }
.copy-row input { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.qr-preview { text-align: center; margin-top: 16px; }
.qr-img { border-radius: 10px; background: #fff; padding: 8px; }
.verify-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.verify-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 18px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.verify-icon { font-size: 32px; }

/* Upload zone */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px 20px; text-align: center; transition: 0.2s; cursor: pointer; margin-top: 16px; }
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-glow); }
.upload-icon { font-size: 40px; margin-bottom: 12px; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: inherit; text-decoration: underline; }
.upload-progress { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.upload-progress.ok { color: var(--primary); }
.upload-progress.fail { color: var(--danger); }
.verify-preview { font-size: 11px; color: var(--muted); word-break: break-all; max-width: 100%; }
.verify-actions { display: flex; gap: 6px; margin-top: 4px; }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.settings-form-panel label { display: block; margin-bottom: 16px; font-size: 13px; color: var(--text); font-weight: 500; }
.settings-form-panel input { width: 100%; margin-top: 6px; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 14px; outline: none; }
.settings-form-panel input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.field-hint { display: block; margin-top: 5px; font-size: 12px; color: var(--muted); font-weight: 400; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.test-result { margin-top: 14px; padding: 12px 16px; border-radius: 9px; font-size: 13px; }
.test-result.ok { background: var(--primary-glow); color: var(--primary); border: 1px solid rgba(7,193,96,0.3); }
.test-result.fail { background: rgba(255,77,79,0.1); color: var(--danger); border: 1px solid rgba(255,77,79,0.3); }
.guide-steps { display: flex; flex-direction: column; gap: 18px; }
.guide-step { display: flex; gap: 14px; align-items: flex-start; }
.step-no { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-glow); color: var(--primary); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.guide-step strong { display: block; font-size: 14px; margin-bottom: 4px; }
.guide-step p { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 6px; }
.guide-step code { font-size: 12px; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
.guide-step a { color: var(--primary); }
.copy-box { display: flex; gap: 8px; margin: 8px 0; }
.copy-box input { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 13px; }

/* Modal & Toast */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }
.modal-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 26px; width: min(400px, 92vw); box-shadow: var(--shadow); }
.modal-card h3 { margin-bottom: 20px; }
.modal-card label { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--surface-2); border: 1px solid var(--border); padding: 13px 22px; border-radius: 11px; font-size: 13px; box-shadow: var(--shadow); z-index: 200; }
.toast.success { border-color: var(--primary); }
.toast.error { border-color: var(--danger); }

@media (max-width: 900px) {
  .charts-row, .two-col, .token-layout, .settings-layout { grid-template-columns: 1fr; }
  .stats-grid.mini { grid-template-columns: repeat(2, 1fr); }
  .flow-diagram { gap: 4px; }
  .flow-arrow { display: none; }
}
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .page { padding: 16px; }
  .hero-metrics { gap: 20px; }
}
