:root {
  --bg: #080d1b;
  --panel: #111a2b;
  --line: #26344d;
  --text: #f3f7ff;
  --muted: #9bb0d2;
  --muted2: #6f7f9b;
  --blue: #2d6df6;
  --green: #16a34a;
  --shadow: rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #111a33 0, #080d1b 42%, #060915 100%);
  color: var(--text);
  font: 15px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: #9fc1ff; text-decoration: none; }
a:hover { color: #d3e2ff; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 276px;
  padding: 18px;
  border-right: 1px solid #202a3f;
  background: linear-gradient(180deg, rgba(9,14,27,.98), rgba(6,10,20,.98));
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid #202a3f;
}
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2f80ff, #21c45d);
  font-weight: 800;
}
.brand-title { font-size: 18px; font-weight: 800; }
.brand-subtitle { color: #9cb4dd; font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  min-height: 48px;
  padding: 13px 15px;
  border-radius: 14px;
  color: #c6d6f5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-item:hover { background: #121c30; }
.nav-item.active {
  background: var(--green);
  color: white;
  box-shadow: 0 18px 40px rgba(22, 163, 74, .22);
}
.nav-item.disabled { color: var(--muted2); opacity: .72; }
.badge-muted {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #273044;
  color: #aeb8cb;
}
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.user-box {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--muted);
}
.main {
  margin-left: 276px;
  padding: 28px;
  width: calc(100vw - 276px);
  max-width: none;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}
.page-head.compact { max-width: 760px; }
h1 { margin: 0; font-size: 34px; letter-spacing: -.03em; }
h2 { margin: 0 0 14px; font-size: 20px; }
h3 { margin: 0; font-size: 16px; }
p { color: var(--muted); margin: 8px 0 0; }
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17,26,43,.96), rgba(11,17,31,.96));
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 22px 70px var(--shadow);
  margin-bottom: 16px;
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.hint { color: var(--muted2); font-size: 13px; }
.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(540px, 100%), 1fr));
  gap: 16px;
}
.private-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(680px, 100%), 1fr));
  gap: 16px;
}
.stage-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 27, .58);
  padding: 14px;
  min-width: 0;
}
.private-card { background: rgba(15, 24, 41, .8); }
.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stage-code {
  border: 1px solid #2a3b5d;
  background: #0d172b;
  color: #b8c9ea;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.kv { display: grid; gap: 8px; margin-bottom: 14px; }
.kv div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.kv span { color: var(--muted2); }
.kv a {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}
.form-stack, .mini-form { display: grid; gap: 12px; }
.form-stack.dense { gap: 10px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label span {
  display: block;
  color: #b9c9e7;
  font-size: 13px;
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #283650;
  background: #0b1222;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #3c78ff; box-shadow: 0 0 0 3px rgba(45,109,246,.14); }
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { color: white; filter: brightness(1.08); }
.btn-secondary { background: #1b263a; color: white; border-color: #34435f; }
.btn-secondary:hover { color: white; background: #23314a; }
.btn-full { width: 100%; }
.login-panel { max-width: 520px; }
.pill {
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.pill.good { background: rgba(22,163,74,.2); color: #62e28f; border: 1px solid rgba(98,226,143,.35); }
.pill.muted { background: rgba(255,255,255,.06); color: #a6b3c8; border: 1px solid #313c52; }
.flash {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid;
}
.flash-ok { background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.45); }
.flash-err { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.45); }
.service-panel { min-height: 260px; }
.soon-panel { opacity: .72; filter: grayscale(.25); }
.preline {
  white-space: pre-line;
  max-width: none;
  width: 100%;
}
.url-line { margin-top: 12px; color: var(--muted2); font-size: 13px; }
.screenshot-placeholder {
  margin-top: 18px;
  min-height: 180px;
  border: 1px dashed #384964;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #7888a3;
  background: rgba(255,255,255,.025);
}
.muted-text { color: var(--muted2); }
@media (max-width: 920px) {
  .sidebar { position: static; width: auto; }
  .main {
    margin-left: 0;
    padding: 18px;
    width: 100%;
  }
  .private-grid, .stage-grid, .cols-2 { grid-template-columns: 1fr; }
  .kv a {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.settings-active {
  border-color: rgba(45, 109, 246, .65);
  box-shadow: 0 0 0 3px rgba(45, 109, 246, .12);
}

.settings-panel {
  max-width: 860px;
}

.settings-form {
  display: grid;
  gap: 18px;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 27, .58);
  padding: 16px;
  cursor: pointer;
}

.toggle-row strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.toggle-row p {
  margin: 0;
  max-width: 680px;
}

.toggle-row input {
  display: none;
}

.toggle-ui {
  position: relative;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: #263247;
  border: 1px solid #3a4862;
  transition: .16s ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #9aa9c2;
  transition: .16s ease;
}

.toggle-row input:checked + .toggle-ui {
  background: var(--green);
  border-color: rgba(98, 226, 143, .45);
}

.toggle-row input:checked + .toggle-ui::after {
  left: 28px;
  background: white;
}

.audit-panel {
  max-width: none;
}

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

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

.audit-table th,
.audit-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(38, 52, 77, .75);
  text-align: left;
  font-size: 13px;
}

.audit-table th {
  color: #b9c9e7;
  background: rgba(8, 13, 27, .58);
  font-weight: 800;
}

.audit-table td {
  color: #d8e4fa;
}

.audit-table tr:last-child td {
  border-bottom: 0;
}

.agent-panel {
  max-width: none;
}

.agent-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.agent-table th,
.agent-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(38, 52, 77, .75);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

.agent-table th {
  color: #b9c9e7;
  background: rgba(8, 13, 27, .58);
  font-weight: 800;
}

.agent-table td {
  color: #d8e4fa;
}

.agent-table tr:last-child td {
  border-bottom: 0;
}

.ingest-help {
  margin-top: 14px;
}

code {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px 6px;
  background: #0b1222;
  color: #d7e5ff;
}

.subhead {
  margin-top: 18px;
  margin-bottom: 12px;
}

[data-tip] {
  position: relative;
}

[data-tip]:hover::after,
[data-tip]:focus-within::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 1000;
  left: 12px;
  top: calc(100% + 8px);
  max-width: min(520px, 82vw);
  width: max-content;
  padding: 9px 11px;
  border: 1px solid #3d4d6a;
  border-radius: 10px;
  background: #080d1b;
  color: #edf4ff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  pointer-events: none;
}

.sidebar [data-tip]:hover::after {
  left: 16px;
  top: auto;
  bottom: calc(100% + 8px);
}

.nav-item[data-tip]:hover::after,
.btn[data-tip]:hover::after {
  left: 0;
}

.toggle-row[data-tip]:hover::after {
  right: 14px;
  left: auto;
}

/* Tooltip v2: JS-controlled, delayed, single tooltip.
   Disable old CSS hover pseudo tooltips to avoid duplicated hints. */
[data-tip]:hover::after,
[data-tip]:focus-within::after,
.sidebar [data-tip]:hover::after,
.nav-item[data-tip]:hover::after,
.btn[data-tip]:hover::after,
.toggle-row[data-tip]:hover::after {
  content: none !important;
  display: none !important;
}

.app-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(560px, 82vw);
  padding: 10px 12px;
  border: 1px solid #3d4d6a;
  border-radius: 10px;
  background: #080d1b;
  color: #edf4ff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .48);
  font-size: 12px;
  line-height: 1.38;
  white-space: normal;
  pointer-events: none;
}

.app-tooltip[hidden] {
  display: none !important;
}

.screenshots-panel {
  max-width: none;
}

.screenshots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 16px;
}

.screenshot-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 27, .58);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.screenshot-card img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;
  background: #060915;
  border: 1px solid rgba(38, 52, 77, .75);
}

.screenshot-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.screenshot-meta strong {
  color: var(--text);
}

.screenshot-upload-form {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
