:root {
  --bg-0: #f5f5f5;
  --bg-1: #ffffff;
  --bg-2: #e8e8e8;
  --panel: #fafafa;
  --panel-2: #f0f0f0;
  --panel-3: #e5e5e5;
  --border: #d0d0d0;
  --text: #212529;
  --muted: #6c757d;
  --accent: #0056b3;
  --accent-2: #dc3545;
  --accent-3: #28a745;
  --danger: #dc3545;
  --mono: "Consolas", "Monaco", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background: #f8f9fa;
  font-size: 14px;
  line-height: 1.5;
}

.page {
  position: relative;
  z-index: 1;
  padding: 20px 20px 40px;
}

.shell {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.banner {
  padding: 24px 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0066cc 0%, #0052a3 100%);
  border: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  color: #ffffff;
}

.banner h1 {
  margin: 0 0 10px 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.banner p {
  margin: 6px 0;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
  font-size: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  border: 1px solid rgba(220, 53, 69, 0.3);
  font-weight: 600;
  font-weight: 600;
}

.card {
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  padding: 28px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 24px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

.info-list {
  display: grid;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
  background: #f8f9fa;
  padding: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.info-list strong {
  color: #333333;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label {
  font-size: 13px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #d0d0d0;
  background: #ffffff;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

input:focus,
textarea:focus {
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: #0066cc;
  color: #ffffff;
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.btn:hover {
  background: #0052a3;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.btn.secondary {
  border-color: transparent;
  background: #6c757d;
  color: #ffffff;
}

.btn.secondary:hover {
  background: #5a6268;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.btn.ghost {
  border-color: #dee2e6;
  background: #ffffff;
  color: #495057;
}

.btn.ghost:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.top-gap {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

.alert {
  padding: 12px 16px;
  border-radius: 4px;
  background: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  font-size: 13px;
  display: none;
}

.alert.show {
  display: block;
}

.portal-grid {
  display: grid;
  gap: 15px;
}

.portal-card {
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

.portal-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
  border-color: #0066cc;
}

.portal-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: var(--text);
  font-weight: 500;
  border-bottom: 2px solid #0056b3;
  padding-bottom: 10px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  position: relative;
}

.terminal .toolbar::before {
  display: none;
}

.terminal .toolbar {
  padding: 12px 16px;
  margin-bottom: 0;
  border-radius: 0;
  border-bottom: 1px solid #14161a;
  background: #282c34;
}

.chip {
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(0, 86, 179, 0.1);
  color: #0056b3;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  border: 1px solid rgba(0, 86, 179, 0.2);
  font-weight: 600;
}

.db-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  border: 1px solid #e0e0e0;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.db-layout > section {
  min-width: 0;
  padding: 20px;
}

.db-list {
  display: grid;
  gap: 0;
  max-height: 520px;
  overflow: auto;
  padding: 0;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
}

.db-list.loading {
  opacity: 0.6;
  pointer-events: none;
}

.db-item {
  padding: 10px 16px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #dee2e6;
  background: transparent;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s ease-in-out;
}

.db-item:hover {
  background: #e9ecef;
  color: #0056b3;
  padding-left: 20px;
}

.output {
  padding: 16px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre;
  min-height: 240px;
  max-height: 600px;
  overflow-x: scroll;
  overflow-y: auto;
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}

.output::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.output::-webkit-scrollbar-track {
  background: #e0e0e0;
  border-radius: 6px;
}

.output::-webkit-scrollbar-thumb {
  background: #adb5bd;
  border-radius: 6px;
  border: 2px solid #e0e0e0;
}

.output::-webkit-scrollbar-thumb:hover {
  background: #868e96;
}

.output::-webkit-scrollbar-corner {
  background: #e0e0e0;
}

.scroll-hint {
  padding: 8px 12px;
  background: #e7f3ff;
  border: 1px solid #b3d9ff;
  border-radius: 4px;
  color: #0056b3;
  font-size: 12px;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 500;
}

.scroll-hint.hidden {
  display: none;
}

.terminal {
  border-radius: 8px;
  border: 1px solid #2d3139;
  background: #1e2127;
  padding: 0;
  font-family: var(--mono);
  font-size: 13px;
  display: grid;
  gap: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.delayed-content {
  transition: opacity 0.3s ease;
}

.delayed-content.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 20;
  transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-card {
  padding: 28px 36px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid #dee2e6;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #e9ecef;
  border-top-color: #0056b3;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 16px;
}

.spinner.small {
  width: 14px;
  height: 14px;
  border-width: 2px;
  margin: 0;
}

.query-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: #666666;
  font-size: 12px;
}

.query-status.hidden {
  display: none;
}

.loading-title {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.loading-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.terminal-output {
  min-height: 380px;
  max-height: 520px;
  overflow-y: auto;
  display: grid;
  gap: 2px;
  padding: 16px;
  background: #1e2127;
  border-radius: 0;
  border: none;
}

.terminal-output::-webkit-scrollbar {
  width: 16px;
}

.terminal-output::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: #666666;
  border: 1px solid #333333;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
  background: #777777;
}

.terminal-line {
  white-space: pre-wrap;
  line-height: 1.5;
  color: #00d000;
}

.motd-header {
  color: #00d000;
  font-weight: normal;
  margin-bottom: 4px;
}

.warning-text {
  color: #ffc107;
  font-weight: normal;
  margin: 6px 0;
}

.system-info {
  color: #00d000;
  font-size: 13px;
  margin: 6px 0;
}

.success-text {
  color: #28a745;
  margin: 6px 0;
}

.error-text {
  color: #dc3545;
}

.command-hint {
  color: #17a2b8;
  font-weight: normal;
}

.prompt {
  color: #00d000;
  font-weight: normal;
}

.terminal-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border-radius: 0;
  border: none;
}

.terminal-input input {
  flex: 1;
  background: transparent;
  border: none;
  color: #00d000;
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}

.terminal-input input::placeholder {
  color: #007000;
}

.terminal-input input:focus {
  animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
  0%, 50% {
    box-shadow: 2px 0 0 0 #10b981;
  }
  51%, 100% {
    box-shadow: none;
  }
}

.terminal-input .btn {
  background: #28a745;
  border: 1px solid transparent;
  color: #ffffff;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.terminal-input .btn:hover {
  background: #218838;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mono {
  font-family: var(--mono);
  background: #f8f9fa;
  padding: 2px 6px;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.footer-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e0e0e0;
  font-size: 11px;
  color: #666666;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .split,
  .db-layout {
    grid-template-columns: 1fr;
  }
  .toolbar {
    align-items: flex-start;
  }
}
