:root {
  color-scheme: dark;
  --bg: #0c1014;
  --panel: rgba(22, 28, 35, 0.78);
  --panel-strong: #151c24;
  --line: rgba(255, 255, 255, 0.1);
  --text: #edf4f7;
  --muted: #98a6af;
  --cyan: #3dd9c4;
  --green: #70e079;
  --amber: #f2bd57;
  --rose: #ef7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(145deg, rgba(61, 217, 196, 0.08), transparent 35%),
    linear-gradient(315deg, rgba(242, 189, 87, 0.08), transparent 42%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.hidden {
  display: none !important;
}

.portal {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 22px;
  padding: 30px;
  background: rgba(20, 26, 34, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(61, 217, 196, 0.34);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(61, 217, 196, 0.18), rgba(242, 189, 87, 0.12));
  color: var(--cyan);
  font-weight: 800;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 0.85rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 3rem;
  line-height: 1;
}

h2 {
  font-size: 2.4rem;
}

h3 {
  font-size: 1.02rem;
}

.status-line,
.login-panel p:not(.eyebrow) {
  color: var(--muted);
}

.google-button-slot {
  min-height: 44px;
}

.login-divider {
  height: 1px;
  background: var(--line);
}

.admin-login-form {
  display: grid;
  gap: 10px;
}

.primary-button.full {
  width: 100%;
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 18, 0.76);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-row span {
  display: block;
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button,
.primary-button,
.icon-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  padding: 0 13px;
}

.nav-item.active,
.nav-item:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: rgba(61, 217, 196, 0.4);
  background: rgba(61, 217, 196, 0.1);
}

.ghost-button {
  margin-top: auto;
  padding: 0 14px;
}

.ghost-button.compact {
  margin-top: 0;
  min-height: 36px;
}

.primary-button {
  flex: 0 0 auto;
  padding: 0 16px;
  border-color: rgba(61, 217, 196, 0.48);
  background: #2fb9a9;
  color: #06100f;
  font-weight: 800;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #3dd9c4;
}

.icon-button {
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
}

[data-lucide] {
  width: 18px;
  height: 18px;
}

.content {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.link-panel,
.panel,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.link-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  padding: 18px;
}

.admin-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(242, 189, 87, 0.28);
  border-radius: 8px;
  background: rgba(242, 189, 87, 0.08);
}

.admin-tools span {
  display: block;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-tools strong {
  overflow-wrap: anywhere;
}

.admin-search-form {
  display: flex;
  gap: 8px;
  min-width: min(420px, 100%);
}

label,
.panel-header span,
.metric-card span,
.code-panel span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.link-copy,
.code-form {
  display: grid;
  gap: 9px;
}

.copy-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text);
}

input:focus {
  border-color: rgba(61, 217, 196, 0.58);
  box-shadow: 0 0 0 3px rgba(61, 217, 196, 0.12);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  min-height: 130px;
  overflow: hidden;
}

.metric-card strong {
  font-size: 2.2rem;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
}

.accent-cyan {
  border-top: 3px solid var(--cyan);
}

.accent-green {
  border-top: 3px solid var(--green);
}

.accent-amber {
  border-top: 3px solid var(--amber);
}

.accent-rose {
  border-top: 3px solid var(--rose);
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.7fr);
  gap: 14px;
}

.panel {
  padding: 18px;
}

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

.legend {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
}

.dot.cyan {
  background: var(--cyan);
}

.dot.amber {
  background: var(--amber);
}

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

.code-panel {
  display: grid;
  align-content: center;
  gap: 12px;
  min-height: 220px;
}

.code-panel strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--cyan);
  font-size: 2.5rem;
}

.code-panel p {
  color: var(--muted);
}

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

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  color: #dce6ea;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(61, 217, 196, 0.36);
  border-radius: 8px;
  background: rgba(15, 22, 28, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 1020px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
  }

  .ghost-button {
    margin-left: auto;
    margin-top: 0;
    white-space: nowrap;
  }

  .link-panel,
  .analytics-grid,
  .admin-tools {
    grid-template-columns: 1fr;
  }

  .admin-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 16px;
  }

  h1 {
    font-size: 2.2rem;
  }

  h2 {
    font-size: 1.9rem;
  }

  .metric-card strong,
  .code-panel strong {
    font-size: 1.9rem;
  }

  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-row span {
    max-width: calc(100vw - 120px);
  }

  .nav-list {
    display: grid;
  }

  .ghost-button {
    margin-left: 0;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .copy-row {
    flex-wrap: wrap;
  }

  .copy-row input {
    flex-basis: 100%;
  }

  .admin-search-form {
    flex-direction: column;
    min-width: 0;
  }
}
