:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --sidebar: #111827;
  --sidebar-hover: #1f2937;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green-bg: #dcfce7;
  --green-fg: #166534;
  --amber-bg: #fef3c7;
  --amber-fg: #92400e;
  --red-bg: #fee2e2;
  --red-fg: #991b1b;
  --gray-bg: #f3f4f6;
  --gray-fg: #374151;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  background: var(--sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  padding: 18px 18px 14px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid #1f2937;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand span.tag {
  font-size: 11px;
  font-weight: 600;
  background: #1f2937;
  color: #93c5fd;
  padding: 2px 7px;
  border-radius: 4px;
}
.nav { padding: 12px 10px; flex: 1; }
.nav a {
  display: block;
  padding: 9px 12px;
  color: #d1d5db;
  text-decoration: none;
  border-radius: 6px;
  margin-bottom: 3px;
  font-weight: 500;
}
.nav a:hover, .nav a.active { background: var(--sidebar-hover); color: #fff; }
.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid #1f2937;
  font-size: 12px;
  color: #9ca3af;
}
.sidebar-foot form { margin-top: 8px; }

.main { flex: 1; padding: 24px 28px; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); background: #f9fafb; white-space: nowrap; }
tr:hover td { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green-fg); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge-red { background: var(--red-bg); color: var(--red-fg); }
.badge-gray { background: var(--gray-bg); color: var(--gray-fg); }
.badge-blue { background: #dbeafe; color: #1e40af; }

.svc-list { display: flex; flex-wrap: wrap; gap: 4px; max-width: 240px; }
.svc-chip {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
textarea { min-height: 70px; font-family: inherit; }

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
  cursor: pointer;
}
.check-field input { width: auto; margin: 0; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab-btn {
  padding: 8px 13px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.flash-success { background: var(--green-bg); color: var(--green-fg); }
.flash-danger { background: var(--red-bg); color: var(--red-fg); }
.flash-warning { background: var(--amber-bg); color: var(--amber-fg); }
.flash-info { background: #dbeafe; color: #1e40af; }

pre.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
  margin: 8px 0;
}
.muted { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

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