:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #116149;
  --primary-dark: #0a4735;
  --accent: #d89b22;
  --danger: #b42318;
  --success-bg: #e8f6ef;
  --danger-bg: #fff0ee;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(17, 97, 73, 0.14), transparent 42%),
    linear-gradient(315deg, rgba(216, 155, 34, 0.16), transparent 36%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.login-panel h1,
.topbar h1,
.table-title h2,
.api-panel h2,
.modal-card h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  margin-top: 18px;
  font-size: 28px;
}

.login-panel p {
  margin: 10px 0 24px;
  color: var(--muted);
}

.login-form,
#userForm {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 97, 73, 0.12);
}

.primary-btn,
.login-form button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  font-weight: 750;
}

.primary-btn:hover,
.login-form button:hover {
  background: var(--primary-dark);
}

.ghost-btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  font-weight: 650;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
}

.alert {
  margin-bottom: 16px;
  border-radius: 6px;
  padding: 12px;
  font-weight: 650;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: #18212f;
  color: #fff;
  padding: 22px;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.logo-row span {
  display: block;
  margin-top: 2px;
  color: #aeb8c8;
  font-size: 13px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  border-radius: 6px;
  color: #d5dce8;
  padding: 11px 12px;
  text-decoration: none;
  font-weight: 650;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: 30px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.toolbar,
.table-panel,
.api-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
}

.table-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 0;
}

.table-title h2,
.api-panel h2 {
  font-size: 20px;
}

.table-title p,
.api-panel p {
  margin: 4px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  min-width: 820px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.muted,
.empty {
  color: var(--muted);
}

.empty {
  padding: 36px 18px;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.active {
  background: var(--success-bg);
  color: var(--primary);
}

.badge.disabled {
  background: var(--danger-bg);
  color: var(--danger);
}

.actions {
  white-space: nowrap;
}

.actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  margin-right: 6px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.actions button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.actions .danger {
  color: var(--danger);
}

.api-panel {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  margin-top: 18px;
  padding: 18px;
}

pre {
  margin: 0;
  overflow: auto;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  padding: 16px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.55);
}

.modal.open {
  display: grid;
}

.modal-card {
  width: min(680px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

#userForm {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#userForm .full,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  transition: 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .api-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 18px;
  }

  .topbar,
  .table-title {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  #userForm {
    grid-template-columns: 1fr;
  }
}
