:root {
  --bg: #0b1017;
  --surface: #111824;
  --surface-alt: #162030;
  --border: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #6ee7b7;
  --accent-strong: #10b981;
  --warn-bg: #2b1d0e;
  --warn-border: #f59e0b;
  --warn-ink: #fde68a;
  --link: #7dd3fc;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--link);
}

.hidden {
  display: none !important;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 40px;
  background: #0d1420;
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tb-left,
.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  margin-right: 6px;
}

.tb-brand img {
  width: 22px;
  height: 22px;
  border-radius: 4px;
}

.next-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: var(--warn-ink);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.top-tab {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.top-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.top-tab.active {
  color: var(--accent);
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(110, 231, 183, 0.32);
}

.role-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(110, 231, 183, 0.14);
  border: 1px solid rgba(110, 231, 183, 0.35);
  color: var(--accent);
}

.role-pill-public {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--muted);
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.ui-btn:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: #1d293d;
}

.ui-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ui-btn-primary {
  background: var(--accent-strong);
  border-color: rgba(110, 231, 183, 0.55);
  color: #041b12;
  font-weight: 700;
}

.ui-btn-primary:hover {
  background: #0ea572;
}

.ui-btn-danger {
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.ui-btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.ui-btn-full {
  width: 100%;
  padding: 11px 16px;
  font-size: 0.92rem;
  border-radius: 10px;
}

/* Gate Screen & Auth Modal */
#gate-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 40px);
  padding: 24px 16px;
}

#auth-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 8, 13, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gate-card {
  width: 100%;
  max-width: 500px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  position: relative;
}

.gate-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accent);
  border: 1px solid rgba(110, 231, 183, 0.4);
  background: rgba(16, 185, 129, 0.12);
  margin-bottom: 10px;
}

.gate-eyebrow-warn {
  color: var(--warn-ink);
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.gate-eyebrow-danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
  background: var(--danger-bg);
}

.gate-card h1 {
  margin: 0 0 10px;
  font-size: 1.35rem;
}

.gate-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.93rem;
}

.gate-list {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.gate-list li {
  margin-bottom: 7px;
}

.gate-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0;
}

.gate-qr-frame {
  background: #ffffff;
  padding: 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gate-status {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}

.gate-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
}

.sim-exit-note {
  margin-top: 12px;
  text-align: center;
  font-size: 0.8rem;
}

/* Issues Portal Layout */
.issues-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 20px 18px 40px;
}

.issues-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.issues-header h1 {
  margin: 0;
  font-size: 1.45rem;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.08rem;
}

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

.ui-input,
.ui-select,
.ui-textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.86rem;
  font-family: inherit;
}

.ui-textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
}

.ui-input-full {
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.badge-open {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.14);
}

.badge-ok {
  color: var(--accent);
  border-color: rgba(110, 231, 183, 0.45);
  background: rgba(16, 185, 129, 0.14);
}

.badge-crit {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.55);
  background: var(--danger-bg);
}

.token-secret-banner {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(110, 231, 183, 0.5);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.token-secret-code {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.84rem;
  word-break: break-all;
}

.vcs-details {
  margin-top: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.vcs-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.diag-pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-msg {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--accent);
}

.status-msg-err {
  color: #fca5a5;
}

.scope-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.scope-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.84rem;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.issues-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(5, 8, 14, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: auto;
  padding: 20px;
}

.issues-lightbox-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1200px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: rgba(15, 22, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.issues-lightbox-caption {
  font-size: 13px;
  color: #cbd5e1;
}

.issues-lightbox-actions {
  display: flex;
  gap: 8px;
}

.issues-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  width: 100%;
  overflow: auto;
}

.issues-lightbox-img {
  max-width: 94vw;
  max-height: 84vh;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 6px;
}

.issues-lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.bug-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 4px;
}

.bug-meta-ver {
  opacity: 0.75;
  font-size: 12px;
}

.bug-meta-coords {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.bug-meta-loc {
  opacity: 0.85;
  font-size: 12px;
}

.bug-meta-target {
  font-size: 11px;
}

.bug-body-text {
  white-space: pre-wrap;
}

.bug-shot-wrap {
  margin-top: 6px;
}
