* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: #edf1f7; color: #202634; }
a { text-decoration: none; }
code { background: #eef2ff; padding: 2px 6px; border-radius: 4px; }
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 22px; }
.login-card, .card { background: #fff; border-radius: 12px; box-shadow: 0 10px 28px rgba(16,24,40,.08); }
.login-card { width: 100%; max-width: 560px; padding: 28px; }
.login-card-wide { max-width: 760px; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: #1f2937; color: #fff; padding: 24px; }
.sidebar h1 { font-size: 22px; margin-top: 0; margin-bottom: 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.sidebar nav a { color: #dbeafe; padding: 10px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar-box { margin-top: 22px; padding: 12px; background: rgba(255,255,255,.06); border-radius: 10px; }
.sidebar-main-value { font-size: 18px; font-weight: 700; margin: 4px 0; }
.content { flex: 1; padding: 10px; width: 90% !important; }
.page-title { margin-bottom: 16px; }
.card { padding: 10px; margin-bottom: 18px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { text-align: center; }
.big-number { font-size: 34px; font-weight: 700; margin-top: 8px; }
.muted { color: #6b7280; }
.small { font-size: 12px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.btn { display: inline-block; background: #2563eb; color: #fff; border: 0; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { filter: brightness(.95); }
.btn-secondary { background: #475569; }
.btn-danger { background: #dc2626; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.section-title { margin: 14px 0 10px; font-weight: 700; }
.toolbar-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
textarea, input, select { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; margin-top: 6px; margin-bottom: 12px; background: #fff; }
textarea { resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.inline-field { min-width: 180px; flex: 1; }
.inline-field-wide { min-width: 260px; flex: 2; }
.action-field { max-width: 140px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 14px; }
.form-grid-2 { grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); }
.field-block { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; }
.table-wrap { overflow: auto; border: 1px solid #e5e7eb; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e5e7eb; vertical-align: top; text-align: left; }
thead th { background: #eef2ff; position: sticky; top: 0; }
.actions-cell { min-width: 160px; }
.pagination { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.page-link { display: inline-block; min-width: 38px; text-align: center; padding: 9px 11px; border-radius: 8px; background: #e2e8f0; color: #0f172a; }
.page-current { background: #2563eb; color: #fff; }
.page-gap { padding: 0 6px; color: #64748b; }
.sql-preview { white-space: pre-wrap; word-break: break-word; background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow: auto; }
ul { margin-top: 8px; }
@media (max-width: 900px) { .sidebar { width: 100%; } .app-shell { flex-direction: column; } }

.json-cell summary { cursor: pointer; color: #1d4ed8; font-weight: 600; }
.json-cell pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; background: #f8fafc; border: 1px solid #e2e8f0; padding: 10px; border-radius: 8px; max-width: 420px; }
.null-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #64748b; font-size: 12px; font-weight: 700; }


.sql-editor-shell { border: 1px solid #dbe3f0; border-radius: 12px; overflow: hidden; background: #0f172a; }
.sql-editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 10px 12px; background: #111827; border-bottom: 1px solid rgba(255,255,255,.08); }
.sql-editor-toolbar .button-row { margin-top: 0; }
.sql-editor-meta { color: #cbd5e1; font-size: 12px; }
.ace-editor { width: 100%; height: 260px; }
.sql-hidden-textarea { display:none; }
.btn-ghost { background: #1e293b; color: #fff; }
.btn-ghost:hover { filter: brightness(1.08); }
.editor-help { margin-top: 10px; }
.editor-help code { background: #e2e8f0; }
@media (max-width: 700px) { .ace-editor { height: 300px; } }


.sql-card { padding-bottom: 18px; width: 100% !important;}
.sql-card-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:0px; flex-wrap:wrap; }
.sql-card-head h2 { margin-bottom: 4px; }
.no-margin { margin: 0; }
.sql-status-pill { border-radius: 999px; padding: 7px 12px; font-size: 12px; font-weight: 700; background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.sql-status-pill.is-ok { background: #ecfdf5; color: #166534; border-color: #86efac; }
.sql-status-pill.is-warning { background: #fff7ed; color: #9a3412; border-color: #fdba74; }
.sql-admin-look { background: linear-gradient(180deg,#244a7c 0%, #1f3b63 14%, #10233a 14%, #10233a 100%); border-color: #b6c6da; box-shadow: inset 0 1px 0 rgba(255,255,255,.15); }
.sql-toolbar-top { background: linear-gradient(180deg,#dde8f6 0%, #c8d9ee 100%); border-bottom: 1px solid #95afcf; }
.sql-toolbar-top .btn-ghost { background: #eef4fb; color: #12355b; border: 1px solid #aabed8; }
.sql-toolbar-top .btn-ghost:hover { background: #ffffff; }

.sql-editor-info-bar { display:flex; gap:10px; flex-wrap:wrap; align-items:center; padding:8px 12px; background:#edf3fa; border-bottom:1px solid #c8d5e6; color:#274c77; font-size:12px; }
.editor-resizable { resize: vertical; overflow: auto; min-height: 180px; height: 200px; max-height: 35vh; background: #0b1220; }
.editor-resizable.editor-light { background: #ffffff; }
.editor-resizable .ace-editor { height: 100%; }
.ace_editor { line-height: 1.55 !important; }
.ace_gutter { background: rgba(255,255,255,.08) !important; color: #c7d2fe !important; min-width: 52px !important; }

.editor-light .ace_gutter { background: #f3f6fb !important; color: #415a77 !important; }
.ace_gutter-active-line { background: rgba(59,130,246,.18) !important; }
.ace_active-line { background: rgba(59,130,246,.10) !important; }
.ace_marker-layer .ace_selection { background: rgba(56,189,248,.24) !important; }
.button-row-compact { gap: 6px; }
@media (max-width: 700px) {
  .editor-resizable { height: 320px; }
  .sql-editor-info-bar { font-size: 11px; }
}

.sql-fallback-textarea {
  width: 100%;
  min-height: 380px;
  resize: vertical;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  line-height: 1.55;
  background: #0b1220;
  color: #e5eefc;
  border: 1px solid #95afcf;
  border-radius: 0 0 12px 12px;
  padding: 14px;
  margin: 0;
}
.sql-fallback-textarea.light-mode {
  background: #ffffff;
  color: #0f172a;
}
.sql-fallback-textarea.sql-fallback-active {
  display: block;
}
.ace_gutter-cell {
  padding-left: 10px !important;
  padding-right: 10px !important;
  font-weight: 600;
}
.ace_scroller {
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}


.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}
.modal-box {
  width: min(1120px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.32);
  border: 1px solid #dbe3f0;
}
.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg,#f8fbff 0%, #edf3fa 100%);
  border-bottom: 1px solid #dbe3f0;
}
.modal-header h3 {
  margin: 0 0 4px;
}
.modal-body {
  padding: 18px;
}
.modal-close {
  border: 0;
  background: transparent;
  color: #334155;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.modal-close:hover {
  color: #0f172a;
}
.info-block {
  margin-bottom: 18px;
}
.info-block h4 {
  margin: 0 0 8px;
  color: #1f3b63;
}
.info-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  overflow: auto;
}
.info-table-wrap {
  max-height: 340px;
}
.info-table thead th {
  background: #edf3fa;
}

