:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe3ef;
  --text: #111827;
  --muted: #64748b;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --purple: #7c3aed;
  --shadow: 0 14px 40px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, .10), transparent 34%),
    linear-gradient(320deg, rgba(22, 163, 74, .10), transparent 40%),
    var(--bg);
}
.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--muted); }
.input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 12px;
  outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: rgba(37, 99, 235, .75); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.btn {
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}
.btn.secondary { background: #eef2f7; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.error { color: var(--red); font-size: 13px; min-height: 20px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0f172a;
  color: #e5edf8;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.brand { padding: 4px 6px 12px; border-bottom: 1px solid rgba(226, 232, 240, .16); }
.brand b { display: block; font-size: 18px; }
.brand span { color: #94a3b8; font-size: 12px; }
.nav { display: grid; gap: 7px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 7px;
  color: #cbd5e1;
  background: transparent;
  padding: 10px 11px;
  text-align: left;
}
.nav button.active { background: rgba(37, 99, 235, .98); color: #fff; }
.nav button:hover:not(.active) { background: rgba(148, 163, 184, .13); color: #fff; }
.side-footer { margin-top: auto; display: grid; gap: 8px; color: #94a3b8; font-size: 12px; }
.main { min-width: 0; padding: 20px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.topbar h2 { margin: 0; font-size: 22px; }
.topbar .meta { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar button:disabled { opacity: .65; cursor: progress; }
.toast {
  position: fixed;
  top: 18px;
  right: 20px;
  z-index: 1000;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 14px 34px rgba(15, 23, 42, .16);
}
.toast.error-toast {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.two { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .045);
}
.panel.pad { padding: 16px; }
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.panel-title h3 { margin: 0; font-size: 15px; }
.panel-title span { color: var(--muted); font-size: 12px; }
.kpi { padding: 15px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { margin-top: 8px; font-size: 26px; font-weight: 800; letter-spacing: 0; }
.kpi .sub { margin-top: 6px; color: var(--muted); font-size: 12px; }
.blue { color: var(--blue); }
.green { color: var(--green); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.purple { color: var(--purple); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; background: #fff; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e7edf5; text-align: left; font-size: 13px; white-space: nowrap; }
th { color: #475569; background: #f8fafc; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 700; }
.pill.green { background: #dcfce7; color: #15803d; }
.pill.blue { background: #dbeafe; color: #1d4ed8; }
.pill.amber { background: #fef3c7; color: #b45309; }
.pill.red { background: #fee2e2; color: #b91c1c; }

.bar-list { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 76px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 9px; background: #e8eef6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.iframe-wrap { height: calc(100vh - 96px); overflow: hidden; }
.iframe-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.muted { color: var(--muted); }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.loading { padding: 28px; color: var(--muted); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis, .two, .three, .form-grid { grid-template-columns: 1fr; }
  .main { padding: 14px; }
  .iframe-wrap { height: 72vh; }
}
