:root {
  --bg-canvas: hsl(38, 28%, 95%);
  --bg-surface: hsl(36, 36%, 99%);
  --bg-subtle: hsl(36, 22%, 91%);
  --bg-sidebar: hsl(184, 34%, 13%);
  --bg-sidebar-hover: hsl(184, 30%, 19%);
  --text-primary: hsl(195, 28%, 14%);
  --text-secondary: hsl(195, 14%, 38%);
  --text-muted: hsl(195, 10%, 54%);
  --text-on-dark: hsl(40, 33%, 94%);
  --text-on-dark-muted: hsl(182, 16%, 68%);
  --brand-jade: hsl(177, 56%, 24%);
  --brand-jade-hover: hsl(177, 60%, 19%);
  --accent-bronze: hsl(37, 62%, 38%);
  --accent-vermilion: hsl(11, 66%, 44%);
  --status-ok: hsl(154, 54%, 28%);
  --border-hairline: hsl(34, 18%, 84%);
  --border-strong: hsl(34, 18%, 73%);
  --shadow-soft: 0 1px 3px hsla(195, 30%, 12%, 0.05), 0 8px 24px hsla(195, 30%, 12%, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Login Gate */
.auth-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, hsl(36, 38%, 97%), hsl(38, 24%, 90%));
}

.auth-panel {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-soft);
}

.auth-crest {
  font-family: var(--font-serif);
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--accent-bronze);
  margin-bottom: 6px;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-on-dark);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.brand-header {
  padding: 0 10px 22px;
  border-bottom: 1px solid hsla(180, 20%, 80%, 0.12);
  margin-bottom: 18px;
}

.brand-domain {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-on-dark-muted);
  display: block;
  margin-top: 4px;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: hsl(42, 68%, 82%);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-on-dark-muted);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.16s ease, color 0.16s ease;
}

.nav-btn:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-on-dark);
}

.nav-btn.active {
  background: hsl(177, 46%, 24%);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid hsla(180, 20%, 80%, 0.12);
  font-size: 12px;
  color: var(--text-on-dark-muted);
}

/* Main Workspace */
.workspace {
  padding: 32px 40px 56px;
  max-width: 1220px;
  width: 100%;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border-hairline);
}

.topbar h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Summary Strip */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
}

.metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.metric-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Section Panels */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 24px;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-hairline);
}

.panel-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
}

.panel-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Forms & Tuning Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 20px 28px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.field-val {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--brand-jade);
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-jade);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand-jade);
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand-jade);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-jade-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: hsl(36, 20%, 86%);
}

/* Tables & Code */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline);
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--bg-subtle);
}

.code-box {
  background: hsl(195, 24%, 13%);
  color: hsl(42, 35%, 90%);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.65;
}

.toast-bar {
  position: fixed;
  bottom: 24px;
  right: 28px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-sidebar);
  color: #ffffff;
  font-size: 13.5px;
  box-shadow: 0 10px 30px hsla(195, 30%, 10%, 0.25);
  z-index: 100;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .workspace {
    padding: 20px 16px 40px;
  }
}
