/* Gemeinsame Basis aller Oberflaechen (Dashboard).
   Wird von jedem Template ueber <link rel="stylesheet" href="/static/css/base.css">
   eingebunden. Seitenspezifische Regeln bleiben im jeweiligen <style>-Block. */

:root {
  --bg: #0c0d10;
  --card: #14171d;
  --text: #e9edf4;
  --muted: #98a2b3;
  --line: #2a303a;
  --blue: #ffbf00;
  --green: #1f9d4d;
  --red: #d13b3b;
  --orange: #e08b1e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at 20% 10%, #202430 0%, var(--bg) 48%);
  color: var(--text);
}

.wrap { width: 100%; max-width: none; margin: 0 auto; padding: 18px 24px; }

.glass {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px #00000033;
}

.header { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 48px; border-radius: 8px; }

.nav { margin-top: 12px; padding: 10px 16px; display: flex; gap: 16px; align-items: center; position: relative; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a.active { color: var(--text); }

.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 1rem;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nav-dropdown-btn:hover, .nav-dropdown-btn.active { color: var(--text); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 170px;
  background: #141922;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 10px 30px #00000088;
  z-index: 1000;
  flex-direction: column;
  gap: 4px;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  display: flex;
}
.nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-dropdown-menu a:hover {
  background: #202735;
  color: var(--text);
}
.nav-dropdown-menu a.active {
  background: #263143;
  color: #fff;
  font-weight: 600;
}

.subtabs { margin-top: 10px; padding: 8px 10px; display: flex; gap: 8px; }
.subtabs a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: .85rem;
  background: #101319;
}
.subtabs a.active { background: var(--blue); color: #111; border-color: transparent; }

.card { margin-top: 12px; padding: 14px; }

.muted { color: var(--muted); }
.helper { color: var(--muted); font-size: .84rem; }
.mono { font-family: Consolas, monospace; }

/* Entscheidung der Firewall je Zeile: Zugelassen | Blockiert.
   Das ist die beobachtete Entscheidung der Firewall, nicht die manuelle
   Sperreinstellung (Sperrstatus) aus der Blocklist-Verwaltung. */
.verdict { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.verdict .v-allowed { color: var(--green); }
.verdict .v-blocked { color: var(--red); }
.verdict .v-sep { color: var(--muted); }
.verdict .v-none { color: var(--muted); }

/* Fusszeile mit der Version der laufenden Anwendung. */
.app-footer {
  margin-top: 22px;
  padding: 10px 2px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
  display: flex;
  justify-content: flex-end;
}
.app-footer-version { letter-spacing: .01em; }

input:not([type="checkbox"]), select, textarea, button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #0f131a;
  color: var(--text);
}
input:not([type="checkbox"]), select, textarea { width: 100%; }
textarea { resize: vertical; line-height: 1.45; }

/* Kopfleisten-Steuerelemente bleiben kompakt (Auswahl, Buttons). */
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls input, .controls select, .controls button {
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 12px;
  background: #101319;
  color: var(--text);
  font-size: .9rem;
}
.controls button { background: var(--blue); color: #111; border: none; cursor: pointer; }

button {
  background: var(--blue);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary { background: #1f2733; color: var(--text); border: 1px solid #334156; }
.btn-secondary:hover { background: #263142; }
.btn-danger { background: #c93434; }

.status { color: var(--muted); margin-top: 8px; }

/* Hinweis oben am Bildschirm (Toast) */
.toast-area {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: grid;
  gap: 8px;
  width: min(680px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #8a6a20;
  background: #241d10;
  color: #ffd479;
  box-shadow: 0 10px 30px #0009;
  font-size: .86rem;
  pointer-events: auto;
  animation: toast-ein .25s ease;
}
.toast.crit { border-color: #8a3a3a; background: #241010; color: #f0a3a3; }
.toast .toast-icon { font-size: 1.05rem; line-height: 1.2; }
.toast .toast-body { display: grid; gap: 3px; }
.toast .toast-title { font-weight: 700; }
.toast ul { margin: 0; padding-left: 18px; }
.toast .toast-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: inherit;
  opacity: .7;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  width: auto;
}
.toast .toast-close:hover { opacity: 1; }
@keyframes toast-ein {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #262d39; padding: 10px 6px; text-align: left; font-size: .9rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .sort-arrow { color: var(--blue); margin-left: 3px; }

.pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #3a475b;
  font-size: .78rem;
  color: #c6d4e7;
}
.pill-new { border-color: #3d693d; color: #9fe49f; margin-left: 6px; }

.empty { padding: 14px; color: var(--muted); }

/* Tooltip: zeigt den vollstaendigen Text beim Mouseover. */
.tip-text { position: relative; cursor: help; border-bottom: 1px dotted var(--muted); }
.tip-text::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 40;
  display: none;
  max-width: 420px;
  min-width: 180px;
  padding: 8px 10px;
  border: 1px solid #3a4659;
  border-radius: 8px;
  background: #121722;
  color: var(--text);
  font-size: .82rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: 0 10px 24px #00000066;
}
.tip-text:hover::after { display: block; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #2c3646;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: #0b0e14cc;
  backdrop-filter: blur(1px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.loading-overlay.show { display: flex; }
.loading-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #121722;
  border: 1px solid #2a3342;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
}

/* Gespeichert-Meldung (im gleichen Stil wie .loading-box) */
.save-toast-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: none;
  background: transparent;
}
.save-toast-overlay.show {
  display: flex;
  animation: saveToastFade .15s ease-out;
}
.save-toast-box {
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  min-width: 140px;
  justify-content: center;
}
.save-toast-icon {
  color: #22c55e;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@keyframes saveToastFade {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Kontomenue oben rechts */
.user-menu { position: relative; }
.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  background: #101319;
  color: var(--text);
  font-family: inherit;
  font-size: .88rem;
  line-height: 1.2;
  cursor: pointer;
}
.user-menu-trigger:hover { background: #161d28; border-color: #3a4659; }
.user-menu-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-caret { color: var(--muted); font-size: .8rem; line-height: 1; }

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #2a3350;
  color: #dbe5f5;
  font-family: inherit;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.user-avatar-lg { width: 38px; height: 38px; font-size: .9rem; }

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  min-width: 260px;
  padding: 6px;
  border: 1px solid #2f3845;
  border-radius: 14px;
  background: #121722;
  box-shadow: 0 16px 38px #00000073;
  display: none;
}
.user-menu.open .user-menu-panel { display: block; }

.user-menu-head { display: flex; align-items: center; gap: 11px; padding: 10px 10px 12px; }
.user-menu-id { display: grid; gap: 2px; min-width: 0; }
.user-menu-id strong { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu-id span { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-menu-sep { height: 1px; background: #262d39; margin: 4px 6px; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: .88rem;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.user-menu-item:hover { background: #1b2230; }
.user-menu-icon { width: 18px; text-align: center; color: var(--muted); font-size: .95rem; }
.user-menu-item-danger { color: #ff8080; }
.user-menu-item-danger:hover { background: #2a1616; }
.user-menu-item-danger .user-menu-icon { color: #ff8080; }
.user-menu-form { margin: 0; }
