:root {
  --ink: #f5f1e8;
  --muted: #98958f;
  --panel: rgba(19, 20, 23, .88);
  --panel-strong: #18191d;
  --line: rgba(255, 255, 255, .095);
  --gold: #d8ab55;
  --gold-soft: #f3d393;
  --ember: #b75130;
  --green: #62be8b;
  --red: #df786e;
  --shadow: 0 24px 80px rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #0e0f11; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 12%, rgba(183, 81, 48, .12), transparent 31rem),
    linear-gradient(145deg, #0c0d0f, #131417 56%, #0b0c0e);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  letter-spacing: .01em;
}

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

.ambient {
  position: fixed;
  width: 35rem;
  height: 35rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: .14;
  pointer-events: none;
}

.ambient-one { right: -13rem; top: -15rem; background: var(--ember); }
.ambient-two { left: 25%; bottom: -24rem; background: #826020; }

.eyebrow {
  margin: 0 0 .75rem;
  color: var(--gold);
  font-size: .69rem;
  font-weight: 750;
  letter-spacing: .2em;
}

.brand-mark {
  display: grid;
  width: 4.3rem;
  height: 4.3rem;
  place-items: center;
  border: 1px solid rgba(216, 171, 85, .6);
  color: var(--gold-soft);
  background: linear-gradient(145deg, rgba(216, 171, 85, .15), rgba(183, 81, 48, .08));
  box-shadow: inset 0 0 30px rgba(216, 171, 85, .1);
  font-family: STKaiti, KaiTi, serif;
  font-size: 2.15rem;
}

.brand-mark.small {
  width: 2.65rem;
  height: 2.65rem;
  font-size: 1.35rem;
}

.auth-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(23rem, 34rem) minmax(28rem, 1fr);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2.5rem, 7vw, 7rem);
  border-right: 1px solid var(--line);
  background: rgba(12, 13, 15, .82);
  backdrop-filter: blur(18px);
}

.auth-panel .brand-mark { margin-bottom: 3rem; }

.auth-panel h1 {
  margin: 0;
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(2.9rem, 5vw, 4.9rem);
  font-weight: 500;
  line-height: .98;
}

.auth-panel h1 span { color: var(--gold-soft); }

.auth-copy {
  max-width: 24rem;
  margin: 1.5rem 0 2.4rem;
  color: var(--muted);
  line-height: 1.8;
}

.auth-form, .editor-form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: .55rem;
  color: #c6c2ba;
  font-size: .82rem;
}

input, select, textarea {
  width: 100%;
  min-height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .045);
  padding: .72rem .85rem;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

textarea { min-height: 6.5rem; resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: rgba(216, 171, 85, .75);
  background: rgba(216, 171, 85, .055);
  box-shadow: 0 0 0 3px rgba(216, 171, 85, .08);
}

input[readonly] { color: var(--muted); }

.primary-button, .secondary-button, .text-button {
  border: 0;
  color: inherit;
}

.primary-button {
  display: flex;
  min-height: 3rem;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--gold);
  border-radius: 2px;
  padding: .75rem 1rem;
  color: #15130e;
  background: linear-gradient(135deg, #e6c073, #bd8c3e);
  font-weight: 760;
}

.primary-button:hover { filter: brightness(1.08); }
.primary-button.compact { display: inline-flex; min-height: 2.4rem; gap: 1rem; }

.secondary-button {
  min-height: 2.4rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: .55rem .8rem;
  background: rgba(255, 255, 255, .04);
}

.secondary-button:hover { border-color: rgba(216, 171, 85, .45); }

.text-button {
  padding: 0;
  color: var(--gold-soft);
  background: transparent;
  text-align: left;
}

.form-message {
  min-height: 1.2rem;
  margin: .2rem 0 0;
  color: var(--red);
  font-size: .78rem;
}

.form-message.success { color: var(--green); }

.auth-aside {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(3rem, 8vw, 8rem);
  background:
    linear-gradient(0deg, rgba(10, 11, 13, .93), rgba(10, 11, 13, .2)),
    linear-gradient(120deg, rgba(183, 81, 48, .1), transparent 50%);
}

.aside-index { color: var(--gold); font-size: .72rem; letter-spacing: .22em; }

.auth-aside h2 {
  max-width: 52rem;
  margin: 1rem 0 2.6rem;
  font-family: STKaiti, KaiTi, serif;
  font-size: clamp(2.6rem, 5vw, 5.5rem);
  font-weight: 400;
  line-height: 1.05;
}

.auth-points { display: flex; flex-wrap: wrap; gap: .65rem; }

.auth-points span {
  border: 1px solid var(--line);
  padding: .6rem .8rem;
  color: #c4c0b8;
  background: rgba(0, 0, 0, .2);
  font-size: .78rem;
}

.dashboard {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  grid-template-columns: 15.5rem minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  border-right: 1px solid var(--line);
  padding: 1.4rem;
  background: rgba(12, 13, 15, .9);
  backdrop-filter: blur(20px);
}

.sidebar-brand { display: flex; align-items: center; gap: .85rem; padding: .2rem .1rem 2.5rem; }
.sidebar-brand div:last-child { display: grid; gap: .15rem; }
.sidebar-brand strong { font-size: .92rem; }
.sidebar-brand span { color: var(--muted); font-size: .72rem; }

nav { display: grid; gap: .45rem; }

.nav-item {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: center;
  border: 1px solid transparent;
  padding: .75rem;
  color: #a8a49d;
  background: transparent;
  text-align: left;
}

.nav-item b { color: #69665f; font-size: .65rem; }
.nav-item:hover, .nav-item.active {
  border-color: var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, .045);
}
.nav-item.active b { color: var(--gold); }

.sidebar-foot {
  display: grid;
  gap: .3rem;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 1.3rem .7rem .3rem;
}
.sidebar-foot span { color: var(--muted); font-size: .68rem; }
.sidebar-foot strong { margin-bottom: .45rem; font-size: .9rem; }

.workspace { min-width: 0; padding: 1.7rem clamp(1.3rem, 3vw, 3rem) 4rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.8rem;
}
.topbar h1 { margin: 0; font-family: STKaiti, KaiTi, serif; font-size: 2rem; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #bbb8b1;
  font-size: .76rem;
}
.live-indicator i {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.content-section { animation: reveal .28s ease; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .9rem;
}

.metric-card, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.metric-card {
  display: grid;
  min-height: 9.6rem;
  align-content: space-between;
  padding: 1.1rem;
}
.metric-card > span { color: var(--muted); font-size: .75rem; }
.metric-card strong { font-family: Georgia, serif; font-size: 2.75rem; font-weight: 400; }
.metric-card small { color: #77746e; font-size: .7rem; line-height: 1.5; }
.metric-card.hero-metric { border-color: rgba(216, 171, 85, .34); background: linear-gradient(145deg, rgba(216, 171, 85, .13), var(--panel)); }
.metric-card .time-value { font-family: inherit; font-size: 1.45rem; }

.split-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(19rem, .75fr); gap: .9rem; margin-top: .9rem; }
.panel { padding: 1.25rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
.panel h2 { margin: 0; font-family: STKaiti, KaiTi, serif; font-size: 1.45rem; font-weight: 500; }
.narrow-panel { max-width: 50rem; }

.zone-matrix { display: grid; gap: .55rem; }
.zone-line {
  display: grid;
  grid-template-columns: minmax(8rem, 1.2fr) 1fr auto;
  align-items: center;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding: .85rem .15rem .25rem;
}
.zone-line strong { display: block; font-size: .9rem; }
.zone-line small { color: var(--muted); }

.status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: .35rem;
  border-radius: 999px;
  padding: .28rem .55rem;
  font-size: .68rem;
}
.status::before { content: ""; width: .34rem; height: .34rem; border-radius: 50%; background: currentColor; }
.status.online { color: var(--green); background: rgba(98, 190, 139, .1); }
.status.pending { color: var(--gold-soft); background: rgba(216, 171, 85, .1); }
.status.offline, .status.maintenance, .status.disabled, .status.mismatch { color: var(--red); background: rgba(223, 120, 110, .1); }

.topology { display: grid; gap: 0; margin: 1rem 0 0; padding: 0; list-style: none; }
.topology li { position: relative; display: grid; grid-template-columns: 2rem 1fr; gap: .75rem; min-height: 4.2rem; }
.topology li:not(:last-child)::after { content: ""; position: absolute; left: .73rem; top: 1.35rem; width: 1px; height: 2.4rem; background: var(--line); }
.topology b { color: var(--gold); font-size: .63rem; }
.topology div { display: grid; align-content: start; gap: .25rem; }
.topology strong { font-size: .85rem; }
.topology span { color: var(--muted); font-size: .7rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th { padding: .75rem .65rem; color: #77746e; font-size: .65rem; font-weight: 600; letter-spacing: .08em; text-align: left; }
td { border-top: 1px solid var(--line); padding: .85rem .65rem; vertical-align: top; }
td strong { display: block; margin-bottom: .2rem; }
td small { display: block; color: var(--muted); line-height: 1.5; }
td code { color: var(--gold-soft); overflow-wrap: anywhere; }

.table-action {
  border: 0;
  padding: .25rem .4rem;
  color: var(--gold-soft);
  background: transparent;
  font-size: .72rem;
}

.node-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: .75rem; }
.node-card { border: 1px solid var(--line); padding: 1rem; background: rgba(255, 255, 255, .025); }
.node-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.node-card h3 { margin: 0; font-size: .95rem; }
.node-card code { display: block; margin: .65rem 0; color: var(--muted); font-size: .68rem; overflow-wrap: anywhere; }
.node-meta { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .9rem; }
.node-meta span { display: grid; gap: .2rem; color: var(--muted); font-size: .66rem; }
.node-meta strong { color: var(--ink); font-size: .78rem; }
.node-actions { display: flex; gap: .45rem; margin-top: 1rem; }

.editor-form { margin-top: 1.2rem; }
.editor-form .wide { grid-column: 1 / -1; }
.mail-form { grid-template-columns: 1fr 1fr; }
.mail-attachment-editor { border: 1px solid var(--line); padding: .85rem; }
.attachment-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.attachment-heading div { display: grid; gap: .25rem; }
.attachment-heading small { color: var(--muted); font-size: .7rem; }
.attachment-rows { display: grid; gap: .65rem; margin-top: .8rem; }
.attachment-row { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: .65rem; }
.attachment-row .secondary-button { margin-bottom: 1px; }
.confirm-row { border-left: 2px solid var(--gold); padding: .7rem .8rem; background: rgba(216, 171, 85, .055); }
.mail-result { display: grid; gap: .35rem; margin-top: 1rem; border: 1px solid rgba(98, 190, 139, .3); padding: .9rem; color: var(--ink); background: rgba(98, 190, 139, .06); }
.mail-result span, .mail-result small { color: var(--muted); }
button:disabled { cursor: wait; filter: grayscale(.5); opacity: .65; }
.toggle-row, .toggle-grid label { display: flex; align-items: center; gap: .55rem; }
.toggle-row input, .toggle-grid input { width: auto; min-height: auto; accent-color: var(--gold); }

dialog {
  width: min(52rem, calc(100vw - 2rem));
  border: 1px solid rgba(216, 171, 85, .3);
  padding: 0;
  color: var(--ink);
  background: #141519;
  box-shadow: 0 35px 100px rgba(0, 0, 0, .72);
}
dialog::backdrop { background: rgba(3, 4, 5, .76); backdrop-filter: blur(8px); }
.dialog-card { display: grid; gap: 1rem; padding: 1.35rem; }
.dialog-card > header, .dialog-card > footer { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.dialog-card > footer { border-top: 1px solid var(--line); padding-top: 1rem; }
.dialog-card > footer .form-message { margin-right: auto; }
.dialog-close { border: 0; color: var(--muted); background: transparent; font-size: 1.6rem; }
.compact-dialog { width: min(34rem, calc(100vw - 2rem)); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.editor-grid .wide { grid-column: 1 / -1; }
.toggle-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; border: 1px solid var(--line); padding: .8rem; }
.field-note { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.6; }
.field-note.warning { color: var(--gold-soft); }
.secret-value { display: block; border: 1px solid var(--line); padding: 1rem; color: var(--gold-soft); background: #0b0c0e; overflow-wrap: anywhere; }

.toast {
  position: fixed;
  z-index: 20;
  right: 1.4rem;
  bottom: 1.4rem;
  max-width: 24rem;
  border: 1px solid rgba(216, 171, 85, .35);
  padding: .8rem 1rem;
  color: var(--ink);
  background: #1b1c20;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(.6rem);
  pointer-events: none;
  transition: .2s;
  font-size: .78rem;
}
.toast.visible { opacity: 1; transform: none; }
.empty-state { padding: 1.3rem; color: var(--muted); text-align: center; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .dashboard { grid-template-columns: 5rem minmax(0, 1fr); }
  .sidebar { padding: 1rem .65rem; }
  .sidebar-brand div:last-child, .nav-item:not(.active)::after, .nav-item { font-size: 0; }
  .sidebar-brand { justify-content: center; }
  .nav-item { grid-template-columns: 1fr; place-items: center; }
  .nav-item b { font-size: .7rem; }
  .sidebar-foot strong, .sidebar-foot span { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .dashboard { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-brand, .sidebar-foot { display: none; }
  nav { display: flex; }
  .nav-item { min-width: 3rem; }
  .workspace { padding: 1rem .75rem 3rem; }
  .topbar { align-items: flex-start; }
  .live-indicator { display: none; }
  .metric-grid { grid-template-columns: 1fr; }
  .editor-grid, .toggle-grid, .mail-form, .attachment-row { grid-template-columns: 1fr; }
  .editor-grid .wide { grid-column: auto; }
}
