:root {
  color-scheme: light;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #172033;
  background: #f4f6f8;
  font-synthesis: none;
  --navy: #183b66;
  --navy-dark: #102a49;
  --blue: #1769aa;
  --green: #14855d;
  --line: #d9e0e7;
  --muted: #667085;
  --surface: #ffffff;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f6f8; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #eef3f7 0%, #ffffff 48%, #eaf2f6 100%);
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--navy);
  padding: 34px;
  box-shadow: 0 18px 45px rgba(16, 42, 73, 0.12);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: white;
  font-weight: 750;
  letter-spacing: 0;
  margin-bottom: 24px;
}
.brand-mark.small { width: 38px; height: 38px; margin: 0; font-size: 13px; }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1 { margin: 0; font-size: 26px; letter-spacing: 0; }
h2 { margin: 0; font-size: 19px; }
.muted, .section-heading p { color: var(--muted); line-height: 1.65; }

.form-stack, .field-grid { display: grid; gap: 18px; }
.form-stack { margin-top: 28px; }
label { display: grid; gap: 8px; font-weight: 650; color: #344054; }
label small { font-weight: 400; color: var(--muted); line-height: 1.45; }
input, textarea {
  width: 100%;
  border: 1px solid #cbd5df;
  background: white;
  color: #172033;
  padding: 11px 12px;
  outline: none;
  border-radius: 4px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12); }
textarea { resize: vertical; line-height: 1.5; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 3px; }

.primary-button, .secondary-button, .logout-button, .nav-item, .log-tab {
  border: 0;
  cursor: pointer;
}
.primary-button {
  background: var(--navy);
  color: white;
  padding: 11px 18px;
  font-weight: 700;
  border-radius: 4px;
}
.primary-button:hover { background: var(--navy-dark); }
.secondary-button {
  background: #eef2f6;
  color: #24364b;
  padding: 10px 16px;
  font-weight: 650;
  border: 1px solid #cbd5df;
  border-radius: 4px;
}
.form-error { min-height: 20px; margin: 0; color: #b42318; font-size: 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--navy-dark);
  color: white;
  padding: 24px 18px;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.14); }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { margin-top: 3px; color: #aebdd0; font-size: 12px; }
nav { display: grid; gap: 4px; margin-top: 24px; }
.nav-item { text-align: left; color: #c8d4e1; background: transparent; padding: 12px 13px; border-left: 3px solid transparent; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.08); border-left-color: #57a9e3; }
.logout-button { margin-top: auto; background: transparent; color: #c8d4e1; padding: 11px; border: 1px solid rgba(255,255,255,.18); }

.content { min-width: 0; padding: 30px clamp(20px, 4vw, 56px) 56px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 28px; }
.status-line { color: var(--green); font-weight: 700; font-size: 14px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; background: var(--green); border-radius: 50%; }
.notice { padding: 13px 16px; margin-bottom: 18px; background: #eaf4fb; border-left: 4px solid var(--blue); color: #24435f; line-height: 1.55; }
.section-block { background: white; border: 1px solid var(--line); padding: 24px; margin-bottom: 18px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading p { margin: 6px 0 0; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.action-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 0; background: rgba(244,246,248,.95); }
.save-status { margin: 0 auto 0 0; color: var(--green); font-weight: 650; }
.rule-list { display: grid; border-top: 1px solid var(--line); }
.rule-item { display: grid; grid-template-columns: 28px 1fr; align-items: start; gap: 10px; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.rule-number { color: var(--blue); font-weight: 800; }
.link-button { display: inline-flex; text-decoration: none; white-space: nowrap; }
.backup-info { padding: 14px 16px; background: #f7f9fb; border: 1px solid var(--line); margin-bottom: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #475467; font-size: 13px; }
.ok-text { color: var(--green); font-weight: 700; }
.log-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.log-tab { background: transparent; color: var(--muted); padding: 10px 14px; border-bottom: 3px solid transparent; }
.log-tab.active { color: var(--navy); border-bottom-color: var(--blue); font-weight: 700; }
pre { margin: 0; min-height: 380px; max-height: 62vh; overflow: auto; background: #101923; color: #d7e2ef; padding: 18px; line-height: 1.5; font: 13px/1.55 Consolas, monospace; white-space: pre-wrap; }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px; }
  .sidebar-brand { padding-bottom: 13px; }
  nav { grid-template-columns: repeat(4, 1fr); margin-top: 12px; overflow-x: auto; }
  .nav-item { text-align: center; padding: 10px 7px; border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .nav-item:hover, .nav-item.active { border-left-color: transparent; border-bottom-color: #57a9e3; }
  .logout-button { display: none; }
  .content { padding: 22px 14px 36px; }
  .two-columns { grid-template-columns: 1fr; }
  .section-heading, .topbar { align-items: flex-start; }
  .section-heading { flex-direction: column; }
}
