:root {
  --bg: #0f1420;
  --surface: #1a2130;
  --surface-2: #232c3d;
  --border: #2e3952;
  --text: #e6ebf5;
  --muted: #93a0b8;
  --primary: #3b82f6;
  --primary-hover: #2f6fd6;
  --danger: #ef4444;
  --danger-hover: #d93838;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
#search { min-width: 220px; }

.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #2b3647; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.status {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.status.ok { background: #10331f; color: #86efac; border: 1px solid #1f5c38; }
.status.err { background: #3a1a1a; color: #fca5a5; border: 1px solid #6b2a2a; }
.status.info { background: #16263f; color: #93c5fd; border: 1px solid #244a73; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:hover { background: var(--surface-2); }
.actions-cell { white-space: nowrap; display: flex; gap: 6px; }
.actions-cell .btn { padding: 5px 10px; font-size: 13px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-box.small { max-width: 420px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.icon-btn {
  background: none; border: none; color: var(--muted);
  font-size: 24px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { color: var(--text); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}
.field label .pk-badge {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.field label .req { color: var(--danger); margin-left: 3px; }
.field input, .field textarea, .field select { width: 100%; }
.field textarea { min-height: 70px; resize: vertical; font-family: inherit; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.empty { text-align: center; padding: 40px; color: var(--muted); }
.spinner { text-align: center; padding: 30px; color: var(--muted); }
