:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #d9e1ee;
  --text: #142033;
  --sub: #5c6b83;
  --primary: #1257e5;
  --danger: #c92a2a;
  --soft: #eef3ff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #f7fbff, #eef4fb 50%, #e9f0fa);
}

.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.login-card h1 { margin-top: 0; font-size: 22px; }

label {
  display: block;
  margin: 10px 0 6px;
  color: var(--sub);
  font-size: 13px;
}

input, textarea, select, button {
  width: 100%;
  border-radius: 8px;
  font-size: 14px;
}

input, textarea, select {
  border: 1px solid var(--line);
  padding: 8px 10px;
  background: #fff;
}

input.field-error, textarea.field-error, select.field-error {
  border-color: #d9485f;
  background: #fff4f6;
}

button {
  margin-top: 10px;
  border: 0;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger { background: var(--danger); }
button.secondary { background: #7b8798; }
button.small { width: auto; margin-top: 0; padding: 5px 9px; font-size: 12px; }

.msg { min-height: 20px; color: var(--danger); }
.hint { color: var(--sub); font-size: 12px; }
.inline-note { color: var(--sub); font-size: 12px; display: inline-flex; align-items: center; }

.app-wrap { min-height: 100vh; }

.app-header {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}
.app-header .sub { margin-left: 8px; color: var(--sub); font-size: 13px; }
.app-header button { width: auto; margin-top: 0; margin-left: 8px; }

.guard {
  margin: 12px;
  padding: 12px;
  border: 1px solid #ffd5d5;
  border-radius: 10px;
  background: #fff5f5;
}
.guard h2 { margin-top: 0; font-size: 18px; }

.app-main {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 56px);
}

.side {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 12px;
}

.menu {
  width: 100%;
  text-align: left;
  margin-top: 0;
  margin-bottom: 8px;
  background: #eef3ff;
  color: #1743a5;
}
.menu.active {
  background: var(--primary);
  color: #fff;
}

.content { padding: 12px; }

.tab {
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.tab.active { display: block; }

.row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }

.row button { margin-top: 0; }
h2, h3 { margin-top: 0; }

.editor {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px dashed #b8c7e6;
  border-radius: 10px;
  background: #f8fbff;
}


table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
th, td {
  border: 1px solid var(--line);
  padding: 8px;
  font-size: 13px;
  text-align: left;
}
th { background: #f5f8ff; }
td .small { margin-right: 6px; }

.cell-sub {
  margin-top: 4px;
  color: var(--sub);
  font-size: 12px;
}

pre {
  margin-top: 12px;
  background: #0f172a;
  color: #dbe7ff;
  border-radius: 8px;
  padding: 10px;
  min-height: 80px;
  overflow: auto;
}

pre.output-error {
  background: #3b0d17;
  color: #ffd9df;
}

pre.output-success {
  background: #0f2a1f;
  color: #d8ffea;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #f6f9ff);
  padding: 12px;
}

.stat-card span {
  display: block;
  color: var(--sub);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 22px;
  color: #14377d;
}

@media (max-width: 1200px) {
  .row, .row-3, .row-4, .row-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-main { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .row, .row-3, .row-4, .row-5 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}
