@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* MeowGo radar blip: rgb(1, 0.35, 0.45) — LUNAR accent */
  --accent: #ff5973;
  --accent-hover: #ff7a8e;
  --accent-fg: #fff5f7;
  --accent-soft: rgba(255, 89, 115, 0.16);
  --accent-ring: rgba(255, 89, 115, 0.32);
  --blue: var(--accent); /* kill legacy blue refs */
  --blue-soft: var(--accent-hover);

  --bg: #09090b;
  --bg-elevated: #0f0f12;
  --fg: #fafafa;
  --muted: #a1a1aa;
  --muted-fg: #71717a;
  --border: #27272a;
  --input: #18181b;
  --card: #0c0c0e;
  --success: #22c55e;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);

  --radius: 0.625rem;
  --radius-lg: 0.875rem;
  --shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 40px rgba(0,0,0,0.45);
  --font: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --control-h: 2.5rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
  accent-color: var(--accent);
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, .mono { font-family: var(--mono); font-size: 0.84em; }
.break { word-break: break-all; }

.grid-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(700px 380px at 12% 0%, rgba(255, 89, 115, 0.12), transparent 55%),
    radial-gradient(600px 360px at 90% 10%, rgba(255, 89, 115, 0.05), transparent 50%),
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
  mask-image: radial-gradient(ellipse at top, #000 20%, transparent 75%);
}

.glass, .card {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
}

.muted { color: var(--muted); }
.tiny { font-size: 0.8rem; }
.center { text-align: center; display: block; }
.hint { color: var(--muted-fg); font-size: 0.85rem; margin-top: 1rem; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ——— Buttons (shadcn-like) ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  height: var(--control-h);
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #1f1f23; border-color: #3f3f46; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring); }
.btn.primary {
  background: #ff5973 !important;
  border-color: transparent !important;
  color: #1a060a !important;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(255, 89, 115, 0.35);
}
.btn.primary:hover { background: #ff7a8e !important; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255,255,255,0.04); }
.btn.danger {
  background: var(--danger-soft);
  border-color: rgba(239,68,68,0.35);
  color: #fecaca;
}
.btn.danger:hover { background: rgba(239,68,68,0.2); }
.btn.small { height: 2rem; padding: 0 .7rem; font-size: 0.8rem; }
.btn.block, .block { width: 100%; }
.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  border-radius: 999px;
  padding: .2rem .65rem;
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
}
.pill.live { color: #bbf7d0; border-color: rgba(34,197,94,.3); background: rgba(34,197,94,.08); }
.pill.live i, .pill i {
  width: .4rem; height: .4rem; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(34,197,94,.15);
  display: inline-block;
}
.pill.danger { color: #fecaca; border-color: rgba(239,68,68,.35); background: var(--danger-soft); }
.pill-row { display: flex; gap: .5rem; flex-wrap: wrap; }

.alert {
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin: .85rem 0;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  font-size: 0.875rem;
}
.alert.success { border-color: rgba(34,197,94,.3); color: #bbf7d0; background: rgba(34,197,94,.08); }
.alert.danger { border-color: rgba(239,68,68,.35); color: #fecaca; background: var(--danger-soft); }

/* ——— Form controls ——— */
label {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: .9rem;
}
label.check {
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  height: var(--control-h);
  margin-bottom: 0;
  color: var(--fg);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  height: var(--control-h);
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  padding: 0 .75rem;
  font: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  box-shadow: none;
}

textarea {
  height: auto;
  min-height: 5.5rem;
  padding: .7rem .75rem;
  resize: vertical;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder { color: var(--muted-fg); }

input:hover,
select:hover,
textarea:hover { border-color: #3f3f46; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: #121214;
}

/* Native select baseline */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 2.4rem;
  cursor: pointer;
  background-color: var(--input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  background-size: 14px;
  line-height: 1.25;
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23ff5973' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select option {
  background: #18181b;
  color: var(--fg);
}

/* Custom dropdown (replaces native on enhance) */
.lu-select {
  position: relative;
  width: 100%;
}
.lu-select.is-open { z-index: 40; }
.lu-select__btn {
  width: 100%;
  height: var(--control-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: 0 .75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
}
.lu-select__btn:hover { border-color: #3f3f46; }
.lu-select.is-open .lu-select__btn,
.lu-select__btn:focus {
  outline: none;
  border-color: #ff5973;
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.lu-select__value {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lu-select__chev {
  width: 14px; height: 14px; flex-shrink: 0; opacity: .7;
  transition: transform .15s;
}
.lu-select.is-open .lu-select__chev { transform: rotate(180deg); color: #ff5973; }
.lu-select__menu {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: .35rem;
  list-style: none;
  max-height: 220px;
  overflow: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #121214;
  box-shadow: 0 16px 40px rgba(0,0,0,.55);
  display: none;
}
.lu-select.is-open .lu-select__menu { display: block; }
.lu-select__opt {
  padding: .55rem .65rem;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
}
.lu-select__opt:hover { background: rgba(255,89,115,.1); color: var(--fg); }
.lu-select__opt.is-active {
  background: rgba(255,89,115,.16);
  color: #ff5973;
  font-weight: 600;
}
.lu-select select.lu-select__native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

.field-hint {
  display: block;
  margin-top: .35rem;
  font-size: .75rem;
  font-weight: 400;
  color: var(--muted-fg);
  line-height: 1.35;
}
.help-list {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.875rem;
  display: grid;
  gap: .45rem;
}
.help-list strong { color: var(--fg); }

input[type="file"] {
  height: auto;
  padding: .55rem .7rem;
  cursor: pointer;
  color: var(--muted);
}
input[type="file"]::file-selector-button {
  height: 1.75rem;
  margin-right: .75rem;
  padding: 0 .75rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  background: #222226;
  color: var(--fg);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

input[type="checkbox"] {
  appearance: none;
  width: 1rem;
  height: 1rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: .3rem;
  background: var(--input);
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-content: center;
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::after {
  content: "";
  width: .35rem;
  height: .55rem;
  border: solid #1a060a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.form-stack, .form-grid { display: grid; gap: .1rem 1rem; }
.form-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.inline-form { display: flex; gap: .4rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }
.inline-form input {
  height: 2rem;
  padding: 0 .55rem;
  width: auto;
  min-width: 8rem;
  flex: 1;
}

/* ——— Auth shell ——— */
.page-auth .auth-shell {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.panel { width: min(420px, 100%); padding: 1.5rem; }
.install-panel { width: min(560px, 100%); }
.brand-row { display: flex; gap: .85rem; align-items: center; margin-bottom: 1.25rem; }
.brand-row h1 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.brand-row.compact strong { font-size: 0.95rem; }
.logo-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
  background: #ff5973 !important;
  color: #1a060a !important;
  box-shadow: 0 8px 24px rgba(255, 89, 115, 0.45);
}
.kv { display: grid; gap: .5rem; margin: 1rem 0; }
.kv > div {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .65rem .8rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--input);
}
.kv span { color: var(--muted); font-size: 0.8rem; }

/* ——— Admin ——— */
.page-admin .admin-shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1rem;
  width: min(1400px, calc(100% - 1.5rem));
  margin: 1rem auto 2rem;
  min-height: calc(100vh - 2rem);
}
.sidebar { padding: 1rem; display: flex; flex-direction: column; gap: .85rem; }
.side-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-group-label {
  margin: .85rem 0 .25rem;
  padding: 0 .7rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-fg);
  opacity: .75;
}
.nav-group-label:first-child { margin-top: .15rem; }
.side-nav a {
  color: var(--muted);
  padding: .5rem .7rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.side-nav a:hover { background: rgba(255,255,255,0.04); color: var(--fg); }
.side-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.topbar-actions { align-items: center; }
.notify { position: relative; }
.notify__btn {
  position: relative;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.notify__btn:hover { color: var(--fg); border-color: var(--accent); }
.notify__btn.has-alerts {
  color: #ff5973;
  border-color: rgba(255, 89, 115, 0.45);
  animation: bell-pulse 1.6s ease-in-out infinite;
}
.notify__count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 .28rem;
  border-radius: 999px;
  background: #ff5973;
  color: #1a060a;
  font-size: .62rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.notify__panel {
  position: absolute;
  right: 0;
  top: calc(100% + .45rem);
  width: min(340px, 86vw);
  padding: .75rem;
  z-index: 50;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.notify__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin-bottom: .55rem;
}
.notify__head a { color: #ffb3c0; font-size: .75rem; }
.notify__empty { margin: .4rem 0; }
.notify__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .35rem;
  max-height: 320px;
  overflow: auto;
}
.notify__list a {
  display: grid;
  gap: .15rem;
  padding: .55rem .6rem;
  border-radius: calc(var(--radius) - 2px);
  background: rgba(255,255,255,.03);
  color: var(--fg);
}
.notify__list a:hover { background: rgba(255, 89, 115, 0.1); }
.notify__foot {
  display: block;
  margin-top: .65rem;
  text-align: center;
  font-size: .8rem;
  color: #ffb3c0;
}
@keyframes bell-pulse {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(12deg); }
  30% { transform: rotate(-10deg); }
  45% { transform: rotate(0); }
}
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem .85rem;
  margin: .35rem 0 .15rem;
}
.app-card .app-creds { margin: .85rem 0 1rem; }
.app-sec {
  margin: .85rem 0;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,.02);
}
.app-create summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: .65rem;
}
.app-create summary::-webkit-details-marker { display: none; }
.secret-mask + .secret-toggle { margin-left: .4rem; }
.log-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .85rem 0 .65rem;
}
.log-tab {
  padding: .4rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
}
.log-tab:hover { color: var(--fg); border-color: var(--accent); }
.log-tab.active {
  background: rgba(255, 89, 115, 0.16);
  border-color: #ff5973;
  color: #ffb3c0;
}
.log-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.log-chip {
  padding: .28rem .55rem;
  border-radius: 999px;
  background: rgba(255,255,255,.03);
  border: 1px solid transparent;
  color: var(--muted);
  font-size: .72rem;
}
.log-chip.active {
  border-color: var(--border);
  color: var(--fg);
}
.alert-dot {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: #ff5973;
  box-shadow: 0 0 0 3px rgba(255, 89, 115, 0.2);
}
.row-warn td { background: rgba(255, 89, 115, 0.06); }
.pill.danger {
  background: rgba(255, 89, 115, 0.18);
  color: #ffb3c0;
  border-color: rgba(255, 89, 115, 0.35);
}
.side-foot { margin-top: auto; display: grid; gap: .5rem; }
.admin-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.topbar {
  padding: 1rem 1.15rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.admin-main .panel {
  padding: 1.15rem;
  width: auto;
  overflow: visible;
  position: relative;
}
/* Open native selects / focused panels paint above the next card (backdrop-filter stacking) */
.admin-main .panel:focus-within,
.admin-main .stack-panel:focus-within {
  z-index: 20;
}
.admin-main h2 { margin: 0 0 .9rem; font-size: 1rem; letter-spacing: -0.01em; }

.user-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.user-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
}
.user-card__actions form { display: flex; flex-wrap: wrap; gap: .4rem; }

.file-list {
  margin: .5rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: .875rem;
  display: grid;
  gap: .35rem;
}
.file-list strong { color: var(--fg); }

.stack-panel { margin-bottom: .25rem; }
.stack-block {
  margin: .85rem 0;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  position: relative;
  z-index: 1;
}
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: .45rem;
  position: relative;
  z-index: 2;
}
.choice {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: .45rem;
  margin: 0 !important;
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--input);
  color: var(--fg);
  cursor: pointer;
  font-size: .8rem;
}
.choice:has(input:checked) {
  border-color: #ff5973;
  background: rgba(255, 89, 115, 0.14);
  color: #ffb3c0;
}
.choice input { width: auto; height: auto; accent-color: #ff5973; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat { padding: 1rem 1.1rem; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat strong { display: block; font-size: 1.65rem; margin-top: .15rem; letter-spacing: -0.03em; }
.live-strip { padding: 1rem 1.15rem; }
.strip-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.strip-head h2 { margin: 0; font-size: 1rem; }
.session-strip { display: flex; gap: .55rem; overflow-x: auto; padding-bottom: .15rem; }
.session-chip {
  min-width: 140px; padding: .65rem .75rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--input); display: grid;
}
.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td {
  text-align: left;
  padding: .7rem .5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: var(--muted-fg);
  font-weight: 500;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.row-warn { background: rgba(239,68,68,.05); }
.actions form { margin-bottom: .25rem; }

@media (max-width: 960px) {
  .stat-grid, .page-admin .admin-shell { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
