:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --green: #16a34a;
  --orange: #d97706;
  --red: #dc2626;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: #111827;
  color: #e5e7eb;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.logo { font-size: 1.15rem; font-weight: 700; color: #fff; margin-bottom: 2px; }
.logo-sub { font-size: 0.72rem; color: #9ca3af; margin-bottom: 20px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: #d1d5db;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background .15s;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.side-foot { font-size: 0.72rem; color: #6b7280; margin-top: 20px; }
.main { flex: 1; padding: 20px 28px; max-width: 1200px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 1.5rem; font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }
.userbox strong { font-weight: 600; }
.userbox span { color: var(--muted); }
.flash {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.content { display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.panel h3 { font-size: 1.05rem; margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.metric-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.metric-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.metric-value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.metric-value.orange { color: var(--orange); }
.metric-value.gray { color: var(--muted); }
.metric-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
tr:hover td { background: #fafafa; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.btn {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  transition: all .15s;
}
.btn:hover { background: #f3f4f6; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 0.76rem; }
.ok-bar {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 0.9rem;
}
.err-bar {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  margin: 12px 0;
  font-size: 0.9rem;
}
.flow { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.flow-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  flex: 1;
  min-width: 120px;
}
.flow-item b { display: block; font-size: 0.86rem; }
.flow-item span { font-size: 0.74rem; color: var(--muted); }
.flow-arrow { align-self: center; color: var(--muted); font-size: 1.1rem; }
.steps { display: flex; flex-direction: column; gap: 12px; }
.step {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.step b { display: block; margin-bottom: 4px; }
.step span { font-size: 0.85rem; color: var(--muted); }
ul.plain { list-style: none; display: flex; flex-direction: column; gap: 8px; }
ul.plain li { font-size: 0.88rem; color: #374151; }
code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; font-size: 0.8rem; }

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e3a8a 0%, #111827 60%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px 36px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-logo { font-size: 2rem; margin-bottom: 8px; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.login-card .muted { font-size: 0.85rem; margin-bottom: 16px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.demo-btn {
  width: 100%;
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  color: var(--text);
}
.demo-btn:hover { border-color: var(--primary); background: #eff6ff; }
.demo-btn strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
.demo-btn span { font-size: 0.74rem; color: var(--muted); }
.divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 14px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 0.8rem; color: var(--muted); }
.login-form input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  margin-bottom: 8px;
}
.login-form .btn { margin-top: 4px; }
.small { font-size: 0.78rem; }
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; }
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}