:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #d5dbe3;
  --line-soft: #e8ecf1;
  --text: #1a2332;
  --muted: #5c6b7e;
  --primary: #1f4b7a;
  --primary-hover: #183a5f;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --side-w: 220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: var(--mono);
  background: var(--line-soft);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.hidden { display: none !important; }

.auth-body { min-height: 100vh; background: #e9edf2; }
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 24px;
}
.auth-panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 40px 36px;
}
.auth-brand .auth-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.auth-brand p { margin: 6px 0 28px; color: var(--muted); font-size: 13px; }
.auth-form { display: grid; gap: 14px; }
.label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 4px;
  padding: 9px 10px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 75, 122, 0.2);
  border-color: var(--primary);
}
textarea { min-height: 80px; resize: vertical; }

.btn-primary, .btn-secondary, .btn-text, .btn-danger {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
}
.btn-primary {
  border: 0;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 14px;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  font-weight: 500;
}
.btn-danger {
  border: 1px solid #f3d1d0;
  background: #fff;
  color: var(--danger);
  padding: 5px 9px;
  font-size: 12px;
}
.btn-text {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  text-align: left;
}
.btn-text:hover { color: var(--danger); }
.auth-error { margin: 0; color: var(--danger); font-size: 13px; }

.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}
.side {
  background: #152033;
  color: #d7dde8;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 4px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 10px;
}
.brand strong {
  display: block;
  font-size: 15px;
  color: #fff;
  line-height: 1.35;
}
.brand span { font-size: 12px; color: #8fa0b8; }
.nav { display: flex; flex-direction: column; padding: 0 10px; gap: 2px; }
.nav button {
  border: 0;
  background: transparent;
  color: #b7c2d3;
  text-align: left;
  padding: 9px 12px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
}
.nav button:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav button.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 600;
}
.side-foot {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  gap: 10px;
}
.status { font-size: 12px; color: #8fa0b8; }
.status.ok { color: #7dcea0; }
.status.warn { color: #e8b86d; }

.main { padding: 24px 28px 48px; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 22px; font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.inline-label select { width: auto; min-width: 140px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 12px;
}
.panel-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}
.panel-bd { padding: 14px; }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px;
}
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { margin-top: 6px; font-size: 22px; font-weight: 700; font-family: var(--mono); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  font-size: 13px;
}
.table th { color: var(--muted); font-weight: 500; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table input { min-width: 120px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 4px;
}
.tag {
  display: inline-block;
  font-size: 12px;
  color: var(--ok);
  border: 1px solid #abefc6;
  background: #ecfdf3;
  padding: 1px 6px;
  border-radius: 3px;
}
.tag.off {
  color: var(--muted);
  border-color: var(--line);
  background: #f8f9fb;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #152033;
  color: #fff;
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  z-index: 30;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border-radius: 6px;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--line);
}
.modal-hd {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-bd { padding: 16px; }
.modal-ft {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.menu-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.menu-checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; }

@media (max-width: 960px) {
  .app, .split, .form-grid { grid-template-columns: 1fr; }
}
