:root {
  --bg: #0b1220;
  --card: #111a2d;
  --text: #e8eefc;
  --muted: #a8b3cf;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #e8232a;
  --danger: #ff6a6a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(1200px 800px at 15% 10%, rgba(232, 35, 42, 0.10), transparent 55%),
              radial-gradient(1000px 700px at 95% 20%, rgba(232, 35, 42, 0.07), transparent 45%),
              var(--bg);
  color: var(--text);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 18px;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.2px;
}

.header__right {
  display: flex;
  gap: 12px;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

.link:hover { text-decoration: underline; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}

.card h2 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.muted {
  color: var(--muted);
  margin: 0 0 12px 0;
  font-size: 13px;
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

input {
  height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  outline: none;
}

input:focus {
  border-color: rgba(106, 166, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(106, 166, 255, 0.12);
}

button {
  height: 34px;
  border: 1px solid var(--border);
  background: rgba(106, 166, 255, 0.18);
  color: var(--text);
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  background: rgba(106, 166, 255, 0.26);
}

.table {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.table tr:last-child td { border-bottom: none; }

.row-actions {
  display: flex;
  gap: 8px;
}

.btn-danger {
  background: rgba(255, 106, 106, 0.18);
}

.btn-danger:hover {
  background: rgba(255, 106, 106, 0.26);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 8px 16px;
  height: auto;
  font-size: 14px;
  margin-bottom: -1px;
}

.tab-btn:hover {
  background: transparent;
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.status-header h2 {
  margin: 0;
}

.status-filter {
  display: flex;
  gap: 12px;
  align-items: center;
}

select {
  height: 34px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1a2540;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

select option {
  background: #1a2540;
  color: #e8eefc;
}

select:focus {
  border-color: rgba(232, 35, 42, 0.55);
}

.status-grid {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  min-width: 140px;
  font-size: 13px;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#toastContainer {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: #1e2d45;
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: #4ade80;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

.toast--error {
  background: #2d1a1a;
  border-color: rgba(255, 106, 106, 0.4);
  color: #ff6a6a;
}

.tab-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-refresh:hover {
  background: rgba(255,255,255,0.13);
}

.btn-refresh svg {
  flex-shrink: 0;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-box {
  background: #131e35;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 820px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 40px);
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 12px 8px;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
}

.modal-tab-btn:hover {
  color: var(--text);
}

.modal-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.modal-panel[hidden] {
  display: none;
}

.modal-panel {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 6px 16px 0;
  flex-shrink: 0;
}

.btn-copy {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.btn-copy:hover {
  background: rgba(255,255,255,0.13);
  color: var(--text);
}

.btn-copy.copied {
  color: #4ade80;
  border-color: #4ade80;
}

.json-pre {
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  font-family: 'Courier New', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #a8e6cf;
  background: rgba(0, 0, 0, 0.3);
  overflow: auto;
  max-height: 52vh;
  white-space: pre;
  word-break: normal;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.btn-download {
  background: rgba(232, 35, 42, 0.15);
  border: 1px solid rgba(232, 35, 42, 0.4);
  color: var(--accent);
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.btn-download:hover {
  background: rgba(232, 35, 42, 0.25);
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.btn-edit {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-edit:hover {
  background: rgba(250, 204, 21, 0.15);
  border-color: rgba(250, 204, 21, 0.4);
  color: #facc15;
}

.btn-ver-json {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-ver-json:hover {
  background: rgba(232, 35, 42, 0.15);
  border-color: rgba(232, 35, 42, 0.4);
  color: var(--accent);
}

.auto-refresh-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.auto-refresh-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

.log-viewer {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.log-line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 3px 6px;
  border-radius: 4px;
  line-height: 1.5;
}

.log-line:hover {
  background: rgba(255, 255, 255, 0.05);
}

.log-time {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 11px;
}

.log-level {
  font-weight: 700;
  width: 46px;
  flex-shrink: 0;
  font-size: 11px;
}

.log-msg {
  color: var(--text);
  flex: 1;
  word-break: break-word;
}

.log-ctx {
  color: rgba(168, 179, 207, 0.6);
  font-size: 11px;
  word-break: break-all;
  flex-shrink: 1;
  max-width: 50%;
}

.log-empty {
  padding: 14px 10px;
  color: var(--muted);
  font-size: 13px;
}

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

.mapeos-auth-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 32, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  min-height: 400px;
}

.mapeos-auth-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.mapeos-auth-box h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.mapeos-auth-box .muted {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

.mapeos-auth-box .form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mapeos-auth-box .form input {
  width: 100%;
}

.mapeos-auth-box .form button[type="submit"] {
  align-self: stretch;
  margin-top: 6px;
}

.mapeos-auth-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}
