:root {
  --bg: #f3f8fb;
  --bg-dark: #071722;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --surface-muted: #eef5f8;
  --sidebar: #0d1d2d;
  --sidebar-soft: #15283b;
  --text: #10283b;
  --text-soft: #667b8c;
  --text-faint: #8ea0ae;
  --line: #e2ebf0;
  --line-strong: #d4e1e8;
  --blue: #1671a5;
  --cyan: #35b8c2;
  --green: #78cf4f;
  --green-soft: #e8f8dc;
  --danger: #b42318;
  --danger-soft: #fff0ec;
  --danger-border: #fecaca;
  --shadow: 0 20px 45px rgba(17, 40, 59, 0.08);
  --shadow-soft: 0 10px 24px rgba(17, 40, 59, 0.05);
  --shadow-strong: 0 30px 70px rgba(0, 0, 0, 0.34);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  color: var(--text);
}

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

/* Login */
body:has(.scene) {
  background:
    radial-gradient(circle at 18% 18%, rgba(53, 184, 194, 0.12), transparent 24%),
    radial-gradient(circle at 82% 16%, rgba(120, 207, 79, 0.12), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(22, 113, 165, 0.18), transparent 28%),
    linear-gradient(145deg, #020d15 0%, #061827 35%, #04111c 100%);
  color: #eff8fb;
  overflow: hidden;
}

.scene {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
}

.scene-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(111, 212, 84, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(111, 212, 84, 0.1) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at center, black 28%, transparent 80%);
  opacity: 0.42;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(50px);
  opacity: 0.55;
}

.ambient-a {
  width: 320px;
  height: 320px;
  left: 18%;
  top: 18%;
  background: rgba(53, 184, 194, 0.16);
}

.ambient-b {
  width: 320px;
  height: 320px;
  right: 18%;
  bottom: 12%;
  background: rgba(120, 207, 79, 0.16);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(100%, 560px);
  padding: 30px 30px 22px;
  border-radius: 30px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(5, 18, 29, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(22px);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 30px;
  background:
    linear-gradient(135deg, rgba(53, 184, 194, 0.06), transparent 32%),
    linear-gradient(315deg, rgba(120, 207, 79, 0.05), transparent 36%);
  pointer-events: none;
}

.brand-lockup {
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}

.brand-logo {
  width: min(100%, 300px);
  height: auto;
  display: block;
}

.auth-copy {
  text-align: center;
  margin-bottom: 14px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(120, 207, 79, 0.24);
  background: rgba(120, 207, 79, 0.08);
  color: #d7f8c7;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-copy h1 {
  margin: 16px 0 10px;
  font-size: clamp(2.1rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.05em;
  color: #eff8fb;
}

.auth-copy p {
  margin: 0 auto;
  max-width: 430px;
  color: rgba(222, 238, 243, 0.78);
  line-height: 1.65;
  font-size: 0.98rem;
}

.login-form {
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(249, 252, 253, 0.96), rgba(243, 249, 251, 0.93));
  box-shadow: 0 24px 60px rgba(0, 12, 20, 0.25);
}

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.alert-error {
  color: #7f1d1d;
  background: #fee2e2;
  border: 1px solid var(--danger-border);
}

.alert-success {
  color: #146c43;
  background: #eaf8ec;
  border: 1px solid #b7e4c3;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  color: var(--text);
  font-size: 0.93rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  border: 1px solid rgba(16, 40, 59, 0.12);
  border-radius: 14px;
  padding: 14px 15px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  border-color: rgba(22, 113, 165, 0.44);
  box-shadow: 0 0 0 4px rgba(53, 184, 194, 0.12);
}

.field-error {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 700;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.ghost-button,
.primary-button {
  border: 0;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.ghost-button {
  padding: 0 15px;
  color: var(--blue);
  background: rgba(22, 113, 165, 0.08);
  font-weight: 700;
}

.form-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 16px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.text-link {
  color: var(--blue);
  font-weight: 700;
}

.text-link:hover {
  text-decoration: underline;
}

.auth-links {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.primary-button {
  width: 100%;
  padding: 15px 18px;
  color: white;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue), var(--cyan) 54%, var(--green));
  box-shadow: var(--shadow-soft);
}

.ghost-button:hover,
.primary-button:hover,
.logout-link:hover,
.side-link:hover {
  transform: translateY(-1px);
}

/* Dashboard */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background:
    radial-gradient(circle at top right, rgba(53, 184, 194, 0.08), transparent 24%),
    linear-gradient(180deg, #f7fbfd 0%, #eef4f8 100%);
}

.app-sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #112538 100%);
  color: #edf7fb;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mini-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.brand-mini strong,
.brand-mini span {
  display: block;
}

.brand-mini strong {
  font-size: 1.1rem;
}

.brand-mini span {
  color: rgba(237, 247, 251, 0.68);
  font-size: 0.82rem;
}

.side-group {
  display: grid;
  gap: 8px;
}

.side-heading {
  color: rgba(237, 247, 251, 0.52);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0 10px 6px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  color: rgba(237, 247, 251, 0.86);
}

.side-link.active,
.side-link:hover {
  background: linear-gradient(135deg, rgba(22, 113, 165, 0.28), rgba(53, 184, 194, 0.18), rgba(120, 207, 79, 0.16));
}

.side-icon {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}

.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.user-pill {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--cyan), var(--green));
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
}

.sidebar-user span {
  color: rgba(237, 247, 251, 0.66);
  font-size: 0.82rem;
  margin-top: 4px;
}

.workspace {
  padding: 26px;
  overflow: auto;
}

.workspace-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar-label,
.panel-overline {
  display: inline-flex;
  align-items: center;
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.workspace-topbar h1 {
  margin: 10px 0;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}

.workspace-topbar p {
  margin: 0;
  max-width: 760px;
  color: var(--text-soft);
  line-height: 1.7;
}

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

.topbar-chip,
.panel-badge,
.trend-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.logout-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue), var(--cyan) 58%, var(--green));
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card,
.saas-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 18px 18px 16px;
  border-radius: var(--radius-lg);
}

.kpi-label,
.kpi-value,
.kpi-delta {
  display: block;
}

.kpi-label {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.kpi-delta {
  font-size: 0.86rem;
  font-weight: 700;
}

.kpi-delta.up {
  color: #1f8f53;
}

.kpi-delta.down {
  color: #c4562a;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 340px;
  gap: 18px;
}

.main-stack,
.right-rail {
  display: grid;
  gap: 18px;
}

.saas-panel {
  border-radius: var(--radius-xl);
  padding: 22px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-title-row h2 {
  margin: 10px 0 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.hero-analytics {
  background:
    radial-gradient(circle at top right, rgba(53, 184, 194, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.chart-card {
  padding: 18px;
  border-radius: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.chart-head strong {
  font-size: 1rem;
}

.chart-head span {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.spark-area {
  height: 220px;
  padding: 18px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(22, 113, 165, 0.02), rgba(53, 184, 194, 0.04)),
    repeating-linear-gradient(to top, transparent 0, transparent 37px, rgba(16, 40, 59, 0.05) 38px);
  display: flex;
  align-items: flex-end;
}

.spark-bars {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.spark-bars span {
  display: block;
  border-radius: 14px 14px 4px 4px;
  background: linear-gradient(180deg, var(--cyan), var(--blue) 52%, var(--green));
}

.bullet-metrics {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 12px;
}

.bullet-metrics li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.bullet-metrics span {
  color: var(--text-soft);
}

.bullet-metrics strong {
  color: var(--text);
  font-size: 0.9rem;
}

.table-shell {
  overflow: auto;
}

.market-table {
  width: 100%;
  border-collapse: collapse;
}

.market-table th,
.market-table td {
  padding: 14px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
}

.market-table thead th {
  border-top: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.market-table tbody td {
  color: var(--text);
}

.trend-pill {
  background: var(--green-soft);
  border-color: rgba(120, 207, 79, 0.18);
  color: #2e7b26;
}

.table-meta {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.alert-list,
.timeline-list {
  display: grid;
  gap: 12px;
}

.alert-item,
.timeline-item {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.alert-item strong,
.timeline-time {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.alert-item p,
.timeline-item p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.timeline-time {
  color: var(--blue);
}

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.select-input {
  width: 100%;
  border: 1px solid rgba(16, 40, 59, 0.12);
  border-radius: 14px;
  padding: 14px 15px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  outline: none;
}

.compact-select {
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 12px;
}

.inline-admin-form {
  margin: 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.mini-button.secondary {
  color: var(--blue);
}

.mini-button:hover {
  background: var(--surface-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill.ok {
  background: var(--green-soft);
  color: #2e7b26;
}

.status-pill.muted {
  background: #eef2f5;
  color: #6c7f8f;
}

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

.settings-submit {
  margin-top: 8px;
}

.status-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.status-card.success {
  background: #edf9ee;
  border-color: #bfe6c3;
}

.status-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.status-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.code-box,
.uri-box {
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px dashed var(--line-strong);
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 12px;
  word-break: break-all;
}

.ghost-wide-button {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ghost-wide-button:hover {
  background: var(--surface-muted);
}

@media (max-width: 1200px) {
  .dashboard-layout,
  .analytics-grid,
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .right-rail {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  body:has(.scene) {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace-topbar {
    flex-direction: column;
  }

  .dashboard-layout,
  .analytics-grid,
  .kpi-grid,
  .right-rail,
  .admin-create-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body:has(.scene) {
    overflow: auto;
  }

  .scene {
    min-height: auto;
    padding: 14px;
  }

  .auth-card {
    padding: 20px 16px 16px;
  }

  .login-form {
    padding: 18px;
  }

  .password-row {
    grid-template-columns: 1fr;
  }

  .form-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}
