:root {
  --bg: #080b12;
  --panel: #111621;
  --panel-2: #171d2b;
  --line: #293142;
  --text: #f4f6fa;
  --muted: #8f9aaf;
  --accent: #7c5cff;
  --accent-2: #ae92ff;
  --green: #36d399;
  --red: #ff647c;
  --amber: #ffca5c;
  color-scheme: dark;
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 80% -10%, #21194a 0, transparent 32rem), var(--bg); color: var(--text); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .45rem; color: var(--accent-2); font-size: .72rem; letter-spacing: .13em; font-weight: 800; }

.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 1240px)/2)); border-bottom: 1px solid var(--line); background: rgba(8,11,18,.8); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10; }
.brand, .top-actions { display: flex; align-items: center; gap: 12px; font-weight: 800; }
.top-actions form { margin: 0; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; color: white; font-weight: 900; font-size: 1.5rem; background: linear-gradient(135deg, var(--accent), #4b8dff); box-shadow: 0 14px 38px rgba(124,92,255,.35); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.live-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 5px rgba(54,211,153,.1); }

.shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 80px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 28px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.045em; }
.hero p:last-child { margin: 0; color: var(--muted); max-width: 760px; }
.revision-card { min-width: 190px; padding: 18px 22px; background: linear-gradient(145deg, #1c2434, #121722); border: 1px solid var(--line); border-radius: 18px; }
.revision-card span, .revision-card small { display: block; color: var(--muted); }
.revision-card strong { display: block; color: var(--accent-2); font-size: 2rem; margin: 3px 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(17,22,33,.86); }
.stat span, .stat small { display: block; color: var(--muted); }
.stat strong { display: block; font-size: 1.55rem; margin: 8px 0 4px; }
.stat strong.strategy { font-size: 1.15rem; padding-top: 7px; }

.card { background: linear-gradient(145deg, rgba(23,29,43,.97), rgba(15,20,30,.97)); border: 1px solid var(--line); border-radius: 20px; padding: 24px; margin-bottom: 18px; box-shadow: 0 16px 42px rgba(0,0,0,.18); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.card-head h2 { margin: 0; font-size: 1.25rem; }
.endpoint-card { border-color: rgba(124,92,255,.45); }
.url-box { display: block; padding: 15px 18px; border-radius: 12px; color: #d9ceff; background: #090c13; border: 1px solid #332c56; overflow-wrap: anywhere; }
.hint { margin: 12px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.65; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid.compact { grid-template-columns: repeat(3, 1fr); }
label { display: grid; gap: 7px; color: #b7c0d1; font-size: .85rem; }
input, select, textarea { width: 100%; min-width: 0; padding: 11px 12px; border-radius: 10px; border: 1px solid #343d50; background: #0c111a; color: var(--text); outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,92,255,.14); }
input[readonly] { color: var(--muted); }
textarea { resize: vertical; }

.notice { margin: -2px 0 16px; padding: 12px 14px; border-left: 3px solid var(--accent); background: rgba(124,92,255,.09); color: #c7cede; font-size: .88rem; line-height: 1.55; }
.endpoint-list { display: grid; gap: 10px; }
.endpoint-row { display: grid; grid-template-columns: 22px 30px minmax(120px,.7fr) minmax(260px,1.5fr) 90px 108px 104px; align-items: end; gap: 9px; padding: 13px; border-radius: 14px; background: #0d121b; border: 1px solid #242c3b; }
.endpoint-row label span { font-size: .73rem; color: var(--muted); }
.drag-handle { color: #606b7f; align-self: center; }
.priority { align-self: center; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #1f2640; color: var(--accent-2); font-weight: 800; }
.health-cell { align-self: center; }
.health { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 999px; font-size: .76rem; white-space: nowrap; }
.health.up { color: var(--green); background: rgba(54,211,153,.1); }
.health.down { color: var(--red); background: rgba(255,100,124,.1); }
.health.unknown { color: var(--amber); background: rgba(255,202,92,.09); }
.health.muted-state { color: var(--muted); background: rgba(143,154,175,.08); }
.row-actions { display: flex; gap: 5px; align-self: center; }
.icon-button { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid #333c4e; border-radius: 8px; background: #171d28; color: #ccd3df; }
.icon-button:hover { border-color: var(--accent); color: white; }
.icon-button.danger:hover { border-color: var(--red); color: var(--red); }

.platform-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.platform-card { border: 1px solid #293143; padding: 16px; border-radius: 14px; background: rgba(9,13,21,.55); display: grid; gap: 12px; }
.platform-card h3 { margin: 0; }
.force-select { display: flex; align-items: center; gap: 10px; }
.force-select select { width: 84px; }

.publish-bar { position: sticky; bottom: 14px; z-index: 5; display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 16px; padding: 16px; margin-bottom: 18px; border-radius: 16px; background: rgba(17,22,33,.93); border: 1px solid #44377b; backdrop-filter: blur(18px); box-shadow: 0 18px 42px rgba(0,0,0,.4); }
.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; color: white; background: #202737; font-weight: 700; }
.button.primary { background: linear-gradient(135deg, var(--accent), #596cff); box-shadow: 0 8px 22px rgba(124,92,255,.25); }
.button.ghost { border-color: #343d50; background: #151b27; }
.button:hover { filter: brightness(1.1); }
.button.full { width: 100%; margin-top: 8px; }
.button.tiny { padding: 7px 9px; font-size: .75rem; }
.small-button { padding: 7px 10px; font-size: .78rem; }
.inline-actions { display: flex; gap: 8px; }
.badge { padding: 6px 9px; border-radius: 999px; color: #cfc5ff; background: rgba(124,92,255,.12); font-size: .72rem; font-weight: 800; }
.badge.green { color: var(--green); background: rgba(54,211,153,.1); }

.two-column { display: grid; grid-template-columns: .75fr 1.25fr; gap: 18px; }
.history-list { display: grid; gap: 8px; }
.history-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #262e3e; }
.history-item:last-child { border-bottom: 0; }
.history-item div { display: grid; grid-template-columns: 42px 1fr; gap: 3px 8px; align-items: center; }
.history-item small { grid-column: 2; color: var(--muted); }
.audit-list { display: grid; gap: 6px; font-size: .82rem; }
.audit-list div { display: grid; grid-template-columns: 190px 90px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid #252d3d; }
.audit-list time, .audit-list span { color: var(--muted); }

.flash { padding: 13px 16px; margin-bottom: 16px; border-radius: 11px; border: 1px solid; }
.flash.success { color: #9df0cf; background: rgba(54,211,153,.09); border-color: rgba(54,211,153,.3); }
.flash.error { color: #ffabb9; background: rgba(255,100,124,.09); border-color: rgba(255,100,124,.3); }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 38px; text-align: center; border-radius: 24px; border: 1px solid var(--line); background: linear-gradient(145deg, #171d2b, #0e131d); box-shadow: 0 28px 80px rgba(0,0,0,.45); }
.login-card .brand-mark { margin: 0 auto 20px; }
.login-card h1 { margin: 0 0 8px; }
.login-card .muted { margin: 0 0 24px; }
.login-form { display: grid; gap: 10px; text-align: left; }
.footnote { margin: 24px 0 0; color: #626d82; font-size: .75rem; }

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid.compact { grid-template-columns: repeat(2, 1fr); }
  .endpoint-row { grid-template-columns: 20px 28px 1fr 1.6fr; }
  .endpoint-enabled, .health-cell, .row-actions { grid-column: auto; }
  .endpoint-enabled { grid-column: 3; }
  .health-cell { grid-column: 4; }
  .row-actions { grid-column: 4; justify-self: end; }
}

@media (max-width: 680px) {
  .shell { width: min(100% - 20px, 1240px); padding-top: 24px; }
  .topbar { padding: 0 12px; }
  .hero { align-items: stretch; flex-direction: column; }
  .revision-card { width: 100%; }
  .stats-grid, .form-grid, .form-grid.compact, .platform-grid, .two-column { grid-template-columns: 1fr; }
  .card { padding: 17px; border-radius: 16px; }
  .card-head { align-items: flex-start; }
  .endpoint-row { display: grid; grid-template-columns: 22px 30px 1fr; align-items: center; }
  .endpoint-name, .endpoint-url, .endpoint-enabled { grid-column: 1 / -1; }
  .health-cell { grid-column: 1 / 3; }
  .row-actions { grid-column: 3; }
  .publish-bar { position: static; grid-template-columns: 1fr; }
  .audit-list div { grid-template-columns: 1fr; gap: 3px; }
  .audit-list time, .audit-list strong, .audit-list span { grid-column: 1; }
}
