@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap");

:root {
  --bg: #10151c;
  --bg-elevated: #151c26;
  --panel: #1a2330;
  --panel-2: #202b3a;
  --line: #2c3a4d;
  --text: #edf2f7;
  --muted: #8b9aab;
  --ok: #3ecf8e;
  --warn: #e6a23c;
  --crit: #ef6b6b;
  --accent: #3d8bfd;
  --accent-2: #2f6fed;
  --focus: #7eb6ff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  --radius: 12px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: none;
  line-height: 1.45;
  color-scheme: dark;
}

body.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(16, 21, 28, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(160deg, #3d8bfd 0%, #1f4f9c 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22);
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand .muted {
  margin: 2px 0 0;
  font-size: 0.82rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a, .nav button, button, .btn {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
}

.nav a.active,
.nav a:hover,
.btn:hover,
button:hover {
  background: var(--panel-2);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-2);
  border-color: #2a62d0;
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent); }

.btn-danger {
  background: #3a1f24;
  border-color: #6b3038;
  color: #ffc9c9;
}

.page {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 48px;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-header h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.page-header-compact {
  margin-bottom: 12px;
}

.page-header-meta {
  font-size: 0.82rem;
  max-width: 42%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-fill {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.muted { color: var(--muted); margin: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

@media (max-width: 980px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-header-meta { max-width: 100%; text-align: left; }
}

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .page { width: calc(100% - 24px); }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.card .label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.card .value {
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  line-height: 1.35;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
  box-shadow: none;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #121821;
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.crit { color: var(--crit); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #243145;
  border: 1px solid var(--line);
  font-size: 12px;
}

.pill.muted-pill {
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  vertical-align: middle;
  margin-left: 6px;
}

ul.alerts {
  margin: 0;
  padding-left: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

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

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

label.field span.req { color: var(--warn); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="url"],
input:not([type]),
select,
textarea {
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  width: 100%;
  min-height: 40px;
  box-shadow: none;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* Browser-Autofill oft hell — an Dark-Theme angleichen (Login Benutzername vs Passwort) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--bg-elevated) inset !important;
  transition: background-color 99999s ease-out 0s;
  border: 1px solid var(--line) !important;
}

input::placeholder,
textarea::placeholder {
  color: #6f7f92;
  opacity: 1;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.flash {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #182231;
}

.flash.error {
  border-color: #6b3038;
  background: #2a171b;
  color: #ffc9c9;
}

.flash.ok {
  border-color: #246b4a;
  background: #14261e;
  color: #b7f0d3;
}

.mono { font-family: var(--mono); font-size: 0.86rem; }

.token-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.token-row input { flex: 1; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  margin-top: 4px;
}

/* Login */
body.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, #121821 0%, var(--bg) 42%, var(--bg) 100%);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
}

.login-card .brand {
  margin-bottom: 22px;
}

.login-card .brand h1 {
  font-size: 1.35rem;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 11px 14px;
  margin-top: 4px;
}

.login-hint {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.license-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.9rem;
}

.license-banner.ok { border-color: rgba(62, 207, 142, 0.45); }
.license-banner.warn { border-color: rgba(230, 162, 60, 0.55); }
.license-banner.crit { border-color: rgba(239, 107, 107, 0.55); background: rgba(239, 107, 107, 0.08); }

body.license-locked main.page {
  position: relative;
}
body.license-locked main.page::after {
  content: "Testversion / Lizenz inaktiv — Ansicht möglich, Aktionen gesperrt. Bitte SPEL-Schlüssel unter Lizenz aktivieren.";
  display: block;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid rgba(239, 107, 107, 0.45);
  border-radius: 8px;
  background: rgba(239, 107, 107, 0.08);
  color: var(--text, #e8eef7);
  font-size: 0.92rem;
}
body.license-locked main.page button:disabled,
body.license-locked main.page input:disabled,
body.license-locked main.page select:disabled,
body.license-locked main.page textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.feature-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel-2);
}

.nav {
  flex-wrap: wrap;
}

.field.check {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-direction: row;
}

/* SQL-Admin shell (sidebar + tabs, like desktop SQL-Admin) */
.sql-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
  margin-bottom: 18px;
}

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

.sql-sidebar,
.sql-main {
  margin-top: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 170px);
}

.sql-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sql-db-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sql-db-path {
  font-size: 0.72rem;
  margin: 0 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sql-filter { margin-bottom: 12px; }

.sql-object-group {
  margin-bottom: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sql-object-group h4 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sql-object-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elevated);
  max-height: 220px;
  flex: 1;
}

.sql-object-list li { margin: 0; }

.sql-object-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.86rem;
  cursor: pointer;
}

.sql-object-list li:last-child .sql-object-item { border-bottom: 0; }

.sql-object-item:hover { background: rgba(61, 139, 253, 0.08); }
.sql-object-item.active {
  background: rgba(61, 139, 253, 0.16);
  color: #fff;
}

.sql-object-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.sql-object-rows { font-size: 0.75rem; flex: 0 0 auto; }

.sql-sidebar-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}

.sql-sidebar-actions button { flex: 1; }

.btn-ghost-sm {
  padding: 4px 8px !important;
  min-width: 34px;
  font-size: 0.95rem !important;
}

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

.sql-tab {
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 8px 8px 0 0 !important;
  color: var(--muted) !important;
  padding: 8px 14px !important;
  font-weight: 600;
}

.sql-tab:hover { color: var(--text) !important; background: rgba(255,255,255,0.03) !important; }
.sql-tab.active {
  color: var(--text) !important;
  border-color: var(--line) !important;
  border-bottom-color: var(--panel) !important;
  background: var(--panel-2) !important;
}

.sql-tab-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sql-tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}

.sql-tab-panel.active { display: flex; }

.sql-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.sql-toolbar strong { font-size: 0.95rem; }

.sql-subhead {
  margin: 8px 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.sql-hint { font-size: 0.82rem; }

.db-builder {
  margin-top: 14px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.db-cs-preview {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  line-height: 1.4;
}

.sql-editor {
  width: 100%;
  min-height: 160px;
  font-size: 0.86rem !important;
  line-height: 1.45;
  tab-size: 2;
}

.sql-actions { margin-top: 0; }

.sql-grid {
  flex: 1;
  min-height: 180px;
}

.sql-grid table { min-width: 480px; }

.sql-grid th,
.sql-grid td {
  font-size: 0.84rem;
  padding: 8px 10px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--line);
}

/* Range toggle buttons (Verlauf / Timeline) */
.btn-range.active {
  background: var(--accent-2);
  border-color: #2a62d0;
  color: #fff;
  font-weight: 600;
}

/* Outage / threshold timeline */
ul.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.timeline li {
  position: relative;
  padding: 4px 0 14px 22px;
  border-left: 2px solid var(--line);
  margin-left: 6px;
}

ul.timeline li::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--panel);
}

ul.timeline li.open::before {
  background: var(--crit);
}

ul.timeline li:last-child {
  border-left-color: transparent;
  padding-bottom: 0;
}

/* Theme-konforme Bestätigungsdialoge */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-message {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* --- Demo-only overrides (keep real Enterprise look) --- */
.demo-banner {
  margin: 0 0 16px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #2a4a3a;
  background: rgba(62, 207, 142, 0.08);
  color: #9fe7c4;
  font-size: 0.88rem;
}
.demo-banner strong { color: #c8f5df; }
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ok);
  font-size: 0.82rem;
  font-weight: 600;
}
.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.45);
  animation: ent-live-pulse 1.8s ease-out infinite;
}
@keyframes ent-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(62, 207, 142, 0); }
  100% { box-shadow: 0 0 0 0 rgba(62, 207, 142, 0); }
}
.nav button.nav-link {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
}
.nav button.nav-link.active {
  background: var(--panel-2);
  border-color: #3a4d66;
  color: #fff;
  font-weight: 600;
}
.chart-box {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 210px;
}
.chart-box canvas { display: block; width: 100%; height: 200px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 0 0 8px; font-size: 0.78rem; color: var(--muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sql-editor-demo {
  width: 100%;
  min-height: 280px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 12px 14px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
  box-sizing: border-box;
}

/* Website language toggle on Enterprise demo topbar */
.topbar .lang-toggle {
  margin-left: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.topbar .lang-toggle:hover { border-color: var(--accent); color: var(--accent); }
