:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  background: #0f172a;
  color: #f8fafc;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: #94a3b8; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  background: #1e293b;
  padding: 6px 10px;
  border-radius: 999px;
}

.tabs {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.container { max-width: 1120px; margin: 18px auto; padding: 0 14px 48px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card h3 { margin: 0; font-size: 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi-val { font-size: 22px; font-weight: 700; }
.kpi-lbl { font-size: 12px; color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
textarea { resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-ghost { background: transparent; color: var(--primary); padding: 4px 8px; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-L1 { background: #dcfce7; color: #166534; }
.badge-L2 { background: #fef3c7; color: #92400e; }
.badge-L3 { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #e2e8f0; color: #475569; }
.badge-status { background: #eff6ff; color: #1d4ed8; }

.quote {
  background: #f8fafc;
  border-left: 3px solid #94a3b8;
  padding: 8px 12px;
  border-radius: 4px;
  white-space: pre-wrap;
  font-size: 14px;
}
.muted { color: var(--muted); font-size: 13px; margin: 0; }
details { font-size: 13px; color: #334155; }
details summary { cursor: pointer; font-weight: 600; color: var(--primary); }

.kv { font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 12px; word-break: break-all; }

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.modal-body { position: relative; width: 100%; max-width: 520px; z-index: 1; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
}
