/* UI v2: consumer-friendly skeleton shell (Resend-style panel).
 *
 * This intentionally stays minimal and editable. Do not hardcode API keys here.
 */

:root {
  color-scheme: dark light;
  --bg: #0a0c10;
  --panel: rgba(15, 19, 26, 0.7);
  --panel-2: rgba(15, 19, 26, 0.9);
  --chrome: rgba(10, 12, 16, 0.75);
  --chrome-2: rgba(10, 12, 16, 0.6);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: rgba(244, 244, 245, 0.68);
  --accent: #7dd3fc;
  --danger: #ff6b6b;
  --ok: #4ade80;

  --topbar-h: 84px;
  --radius: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;

  --ui-bg-pattern:
    radial-gradient(1200px 800px at 20% 10%, rgba(125, 211, 252, 0.06), transparent 55%),
    radial-gradient(1000px 700px at 80% 0%, rgba(74, 222, 128, 0.04), transparent 55%),
    radial-gradient(1000px 900px at 50% 100%, rgba(251, 191, 36, 0.03), transparent 65%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 18px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-2: rgba(255, 255, 255, 0.96);
  --chrome: rgba(255, 255, 255, 0.72);
  --chrome-2: rgba(255, 255, 255, 0.66);
  --line: rgba(2, 6, 23, 0.12);
  --text: #0b1220;
  --muted: rgba(2, 6, 23, 0.68);
  --shadow: 0 10px 40px rgba(2, 6, 23, 0.12);
  --ui-bg-pattern:
    radial-gradient(1200px 800px at 20% 10%, rgba(125, 211, 252, 0.10), transparent 55%),
    radial-gradient(1000px 700px at 80% 0%, rgba(74, 222, 128, 0.07), transparent 55%),
    radial-gradient(1000px 900px at 50% 100%, rgba(251, 191, 36, 0.06), transparent 65%),
    repeating-linear-gradient(45deg, rgba(2, 6, 23, 0.06) 0 1px, transparent 1px 18px);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  background: var(--ui-bg-pattern), var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

.small {
  font-size: 12px;
}

.is-hidden {
  display: none !important;
}

/* ---------- Toasts (bottom-of-screen warnings/errors) ---------- */

.toast-stack {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(560px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-out {
  opacity: 0;
  transform: translateY(6px);
}

.toast .dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
  flex: 0 0 auto;
  margin-top: 4px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--muted) 14%, transparent);
}

.toast .msg {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.toast.err {
  border-color: rgba(255, 107, 107, 0.35);
}
.toast.err .dot {
  background: rgba(255, 107, 107, 0.95);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.16);
}

.toast.warn {
  border-color: rgba(251, 191, 36, 0.35);
}
.toast.warn .dot {
  background: rgba(251, 191, 36, 0.95);
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.16);
}

.toast.ok {
  border-color: rgba(74, 222, 128, 0.35);
}
.toast.ok .dot {
  background: rgba(74, 222, 128, 0.95);
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.16);
}

.app {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: var(--chrome);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.nav-backdrop {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: var(--topbar-h);
  margin: -16px -14px 12px -14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--chrome-2);
  backdrop-filter: blur(6px);
}

.brand-title {
  font-family: var(--mono);
  letter-spacing: 0.18em;
  font-size: 13px;
  text-transform: uppercase;
}

.brand-pill {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nav-item[data-alert="1"]::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 59, 48, 0.95);
  box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.16);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
  background: rgba(125, 211, 252, 0.08);
  border-color: rgba(125, 211, 252, 0.22);
}

.nav-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  width: 18px;
  opacity: 0.85;
  font-family: var(--mono);
  text-align: center;
}

.lock {
  font-size: 14px;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: 14px;
  padding: 12px 10px;
  border-top: 1px solid var(--line);
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--chrome-2);
  backdrop-filter: blur(6px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-mid {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.page-title {
  font-size: 14px;
  letter-spacing: 0.06em;
  font-family: var(--mono);
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44vw;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Keep the topbar visually even: same control height and alignment across pages/views. */
.topbar-left,
.topbar-mid,
.topbar-right {
  height: 100%;
}

.topbar .btn,
.topbar .brand-pill {
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  line-height: 1;
}

.topbar .brand-pill {
  padding: 0 10px;
  border-radius: 14px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

:root[data-theme="light"] .btn {
  background: rgba(2, 6, 23, 0.03);
}

.btn:hover {
  border-color: rgba(125, 211, 252, 0.25);
}

.btn.primary {
  background: rgba(125, 211, 252, 0.14);
  border-color: rgba(125, 211, 252, 0.28);
}

.btn.danger {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

.app .content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.panel {
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.banner {
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.1);
  color: rgba(251, 191, 36, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 0 0 12px 0;
  font-family: var(--mono);
  font-size: 12px;
}

.empty {
  height: calc(100vh - var(--topbar-h) - 36px);
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
}

.empty h1 {
  margin: 0;
  font-size: 22px;
}

.empty p {
  margin: 8px 0 0 0;
  color: var(--muted);
}

.avatar {
  position: relative;
}

.avatar-vbadge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  margin-left: 0;
  z-index: 60;
}

.avatar-btn {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  flex: 0 0 auto;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-fallback {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: rgba(125, 211, 252, 0.9);
  background: rgba(125, 211, 252, 0.08);
}

.dropdown {
  position: absolute;
  right: 0;
  top: 56px;
  min-width: 260px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 50;
}

.dropdown .head {
  padding: 10px 10px 12px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.dropdown .head .handle {
  font-family: var(--mono);
  letter-spacing: 0.08em;
}

.dropdown a,
.dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-align: left;
}

.dropdown a:hover,
.dropdown button:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.06);
}

.form {
  display: grid;
  gap: 10px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

input,
select,
textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 10px 12px;
  font-family: var(--sans);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(125, 211, 252, 0.35);
  box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.08);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.row > * {
  flex: 1 1 auto;
}

.hint {
  font-size: 12px;
  color: var(--muted);
}

.err {
  border: 1px solid rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.1);
  color: rgba(255, 107, 107, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
}

.ok {
  border: 1px solid rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.1);
  color: rgba(74, 222, 128, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
}

.spot-slot {
  width: min(700px, 100%);
  min-width: 0;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: rgba(125, 211, 252, 0.08);
  color: var(--text);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;
  transition:
    opacity 240ms ease,
    transform 240ms ease,
    filter 180ms ease;
}

.spot-slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(10, 12, 16, 0.82),
    rgba(10, 12, 16, 0.28),
    rgba(10, 12, 16, 0.82)
  );
  opacity: 0;
  transition: opacity 240ms ease;
}

.spot-slot[data-has-media="1"]::before {
  opacity: 0;
}

.spot-slot:hover {
  filter: brightness(1.06);
}

.spot-slot.is-fading {
  opacity: 0;
  transform: translateY(-2px);
}

.spot-badge {
  flex: 0 0 auto;
  height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(125, 211, 252, 0.32);
  background: rgba(125, 211, 252, 0.12);
  color: rgba(125, 211, 252, 0.98);
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  position: relative;
  z-index: 1;
}

.spot-media {
  flex: 0 0 auto;
  position: relative;
  width: 74px;
  height: 28px;
  border-radius: 14px;
  overflow: hidden;
  opacity: 1;
  pointer-events: none;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: rgba(0, 0, 0, 0.25);
  z-index: 1;
}

.spot-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: none;
}

.spot-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  z-index: 1;
}

.spot-title {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 680;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spot-body {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.vbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.45);
  background: rgba(125, 211, 252, 0.12);
  color: rgba(125, 211, 252, 0.98);
  margin-left: 6px;
  flex: 0 0 auto;
  cursor: help;
}

.vbadge svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tbadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 16px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.08);
  color: rgba(226, 232, 240, 0.92);
  margin-left: 6px;
  flex: 0 0 auto;
  cursor: help;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.tbadge.t2 {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
  color: rgba(187, 247, 208, 0.92);
}

.tbadge.t3 {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
  color: rgba(254, 243, 199, 0.95);
}

/* ---------- Page helpers (no inline styles; CSP blocks them) ---------- */

.kicker {
  font-family: var(--mono);
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
}

.auth-card {
  max-width: 560px;
  margin: 80px auto 0 auto;
}

.auth-card.narrow {
  max-width: 520px;
}

.auth-card h1 {
  margin: 10px 0 6px 0;
}

.auth-card .subtitle {
  margin: 0 0 14px 0;
}

.page-h1 {
  margin: 10px 0 4px 0;
}

.page-subtitle {
  margin: 0 0 10px 0;
}

.row.between {
  justify-content: space-between;
}

.tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

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

.card.flat {
  box-shadow: none;
}

/* Billing tier cards */
.tier-card .tier-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.tier-card .tier-name {
  font-weight: 820;
  letter-spacing: 0.02em;
}

.tier-card .tier-price {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.tier-card .tier-pill {
  margin-top: 2px;
}

.tier-card .tier-pill.t2 {
  border-color: rgba(34, 197, 94, 0.25);
  color: rgba(187, 247, 208, 0.92);
}

.tier-card .tier-pill.t3 {
  border-color: rgba(251, 191, 36, 0.3);
  color: rgba(254, 243, 199, 0.95);
}

/* Store stats chart */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.chart-tip {
  position: absolute;
  pointer-events: none;
  padding: 6px 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: var(--shadow);
  transform: translate(-50%, -120%);
}

.mt12 {
  margin-top: 12px;
}

progress.full {
  width: 100%;
}

.no-grow {
  flex: 0 0 auto !important;
}

.menu-btn {
  display: none;
}

/* Off-canvas nav for mobile: keeps the app usable on small screens. */
@media (max-width: 920px) {
  .menu-btn {
    display: inline-flex;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 180ms ease;
    pointer-events: none;
    z-index: 55;
  }

  .app.is-nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-110%);
    transition: transform 180ms ease;
    z-index: 60;
  }

  .app.is-nav-open .sidebar {
    transform: translateX(0);
  }
}

@media (max-width: 720px) {
  .content {
    padding: 14px;
  }

  .card {
    padding: 14px;
  }

  .topbar {
    padding: 0 12px;
  }

  .page-title {
    max-width: 34vw;
  }

  .row {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .row > * {
    flex: 1 1 220px;
  }

  .auth-card {
    margin: 28px auto 0 auto;
  }

  .chart-wrap {
    height: 140px;
  }

  .dropdown {
    max-width: min(320px, calc(100vw - 24px));
  }
}
