/* Modern DBaaS Portal UI override */
:root {
  --portal-bg: #f4f7fb;
  --portal-surface: #ffffff;
  --portal-surface-muted: #f8fafc;
  --portal-border: #e2e8f0;
  --portal-text: #0f172a;
  --portal-muted: #64748b;
  --portal-primary: #2563eb;
  --portal-primary-hover: #1d4ed8;
  --portal-success: #16a34a;
  --portal-warning: #d97706;
  --portal-danger: #dc2626;
  --portal-radius: 14px;
  --portal-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--portal-text);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 30rem),
    var(--portal-bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.container {
  width: min(1600px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.header,
.topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 22px 26px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 18px;
  box-shadow: var(--portal-shadow);
  backdrop-filter: blur(12px);
}

.header h1,
.topBar h2,
.card h2,
.card h3 {
  margin-top: 0;
  color: var(--portal-text);
  letter-spacing: -0.025em;
}

.header p,
.topBar p { margin-bottom: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
}

.card {
  background: var(--portal-surface);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.06);
  padding: 24px;
}

.loginCard {
  width: min(460px, 100%);
  margin: 70px auto 0;
  padding: 32px;
}

.portalLayout {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.leftColumn,
.rightColumn { min-width: 0; }

.rightColumn {
  display: grid;
  gap: 24px;
}

.stickyCard {
  position: sticky;
  top: 24px;
}

.adminDashboard {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dashboardCard {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  padding: 18px;
  background: linear-gradient(145deg, #ffffff, #f8fafc);
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.05);
}

.dashboardCard::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -30px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
}

.dashboardLabel {
  display: block;
  margin-bottom: 14px;
  color: var(--portal-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboardCard strong {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  line-height: 1;
}

label {
  display: block;
  margin: 16px 0 7px;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  color: var(--portal-text);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

button {
  min-height: 42px;
  padding: 10px 15px;
  color: #fff;
  background: var(--portal-primary);
  border: 0;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  background: var(--portal-primary-hover);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
  transform: translateY(-1px);
}

button.secondary {
  color: #334155;
  background: #fff;
  border: 1px solid #cbd5e1;
}

button.secondary:hover {
  color: var(--portal-primary);
  background: #f8fafc;
  border-color: #93c5fd;
  box-shadow: none;
}

.hint,
.muted,
.userInfo {
  color: var(--portal-muted);
}

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

.sectionHeader h2 { margin-bottom: 0; }

.engineSelector {
  display: grid;
  gap: 10px;
}

.engineCard {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-areas:
    "logo name"
    "logo description";
  align-items: center;
  gap: 2px 14px;
  width: 100%;
  min-height: 78px;
  padding: 14px;
  color: var(--portal-text);
  text-align: left;
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 12px;
  box-shadow: none;
}

.engineCard:hover {
  background: #f8fbff;
  border-color: #93c5fd;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
}

.engineCard.selected {
  background: #eff6ff;
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.engineLogo { grid-area: logo; }
.engineName { grid-area: name; font-weight: 800; }
.engineDescription { grid-area: description; color: var(--portal-muted); font-size: 0.84rem; }

.engineLogo.imageLogo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.createFields {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--portal-border);
}

#createButton,
#createUserButton {
  width: 100%;
  margin-top: 20px;
}

.databaseList,
.userList,
.tenantList,
.auditLogList {
  display: grid;
  gap: 12px;
}

.databaseItem,
.userItem,
.tenantItem,
.backupItem,
.statusItem {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.databaseItem:hover,
.userItem:hover,
.tenantItem:hover {
  border-color: #bfdbfe;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.databaseMeta {
  color: var(--portal-muted);
  font-size: 0.9rem;
}

.databaseActions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.databaseActions button,
.actions button {
  min-height: 36px;
  padding: 8px 11px;
  font-size: 0.82rem;
}

.statusBadge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.statusBadge.running,
.statusBadge.ready,
.statusBadge.healthy,
.statusBadge.synced,
.statusBadge.complete,
.statusBadge.succeeded {
  color: #166534;
  background: #dcfce7;
}

.statusBadge.pending,
.statusBadge.progressing,
.statusBadge.warning {
  color: #92400e;
  background: #fef3c7;
}

.statusBadge.failed,
.statusBadge.error,
.statusBadge.degraded,
.statusBadge.notready {
  color: #991b1b;
  background: #fee2e2;
}

.detailsBox,
.tenantDetailsBox {
  margin-top: 14px;
  padding: 16px;
  background: var(--portal-surface-muted);
  border: 1px solid var(--portal-border);
  border-radius: 10px;
}

.auditTableWrapper {
  overflow-x: auto;
  border: 1px solid var(--portal-border);
  border-radius: 10px;
}

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

.auditTable th,
.auditTable td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--portal-border);
  text-align: left;
}

.auditTable th {
  color: #475569;
  background: #f8fafc;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hidden { display: none !important; }

@media (max-width: 1180px) {
  .adminDashboard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .portalLayout { grid-template-columns: 1fr; }
  .stickyCard { position: static; }
}

@media (max-width: 680px) {
  .container { width: min(100% - 22px, 1600px); padding-top: 12px; }
  .header, .topBar { align-items: flex-start; flex-direction: column; padding: 18px; }
  .adminDashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 18px; }
  .sectionHeader { align-items: flex-start; flex-direction: column; }
  .sectionHeader button { width: 100%; }
}
