* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-0: #030712;
  --bg-1: #0a1020;
  --bg-2: #111827;
  --surface: rgba(9, 15, 28, 0.84);
  --surface-strong: rgba(12, 18, 34, 0.94);
  --surface-soft: rgba(255, 255, 255, 0.04);
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #f8fafc;
  --muted: #a8b4c7;
  --muted-strong: #e2e8f0;
  --accent: #38bdf8;
  --accent-2: #14b8a6;
  --accent-3: #f59e0b;
  --danger: #fb7185;
  --success: #34d399;
  --shadow: 0 24px 80px rgba(2, 6, 23, 0.52);
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  --spiral-bg: url("ttten.svg");
  --spiral-opacity: 0.5;
  background:
    radial-gradient(circle at 12% 18%, rgba(56, 189, 248, 0.16), transparent 24%),
    radial-gradient(circle at 88% 12%, rgba(20, 184, 166, 0.12), transparent 22%),
    radial-gradient(circle at 78% 84%, rgba(245, 158, 11, 0.10), transparent 28%),
    linear-gradient(145deg, var(--bg-0) 0%, var(--bg-1) 45%, #070b14 100%);
  background-attachment: fixed;
}

body.admin-page {
  --spiral-bg: url("admin-ttten.svg");
  --spiral-opacity: 1;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at center, black 45%, transparent 88%);
  opacity: 0.45;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: var(--spiral-bg);
  background-repeat: no-repeat;
  background-position: center top;
  background-size: max(1422px, 100vw) auto;
  opacity: var(--spiral-opacity);
}

.page-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(18px);
  pointer-events: none;
  opacity: 0.35;
}

.glow-a {
  width: 360px;
  height: 360px;
  top: -40px;
  left: -40px;
  background: rgba(56, 189, 248, 0.36);
}

.glow-b {
  width: 420px;
  height: 420px;
  right: -60px;
  bottom: -80px;
  background: rgba(20, 184, 166, 0.28);
}

.page-grid-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(15, 23, 42, 0.18));
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: 24px;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  padding: 24px;
  overflow-x: clip;
}

.glass-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  border-radius: 28px;
  min-height: calc(100vh - 48px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.95), rgba(20, 184, 166, 0.8));
  box-shadow: 0 16px 36px rgba(20, 184, 166, 0.24);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted-strong);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  font-weight: 800;
}

.sidebar h1,
.topbar h2,
.section-head h2 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  line-height: 1.1;
}

.sidebar h1 {
  font-size: 1.55rem;
}

.sidebar-copy,
.subtext,
.helper-text,
.status-text,
.sidebar-footnote,
.legend-empty,
.empty-cell {
  color: var(--muted);
}

.sidebar-copy,
.sidebar-footnote,
.helper-text,
.status-text,
.subtext {
  line-height: 1.6;
}

.info-card,
.settings-card,
.auth-card,
.sidebar-nav-card {
  border-radius: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  padding: 18px;
}

.info-card-label,
.kpi-label {
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 800;
}

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

.info-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-nav-card {
  display: grid;
  gap: 14px;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.workspace-nav-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.workspace-nav-button::after {
  content: "Jump";
  font-size: 0.74rem;
  color: var(--muted);
}

.workspace-nav-button:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

.workspace-nav-button.locked {
  opacity: 0.62;
  border-style: dashed;
}

.workspace-nav-button.locked::after {
  content: "Premium";
  color: #f8fafc;
}

.workspace-nav-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head.small h2 {
  font-size: 1rem;
}

.field-label {
  display: inline-block;
  margin: 16px 0 8px;
  font-size: 0.84rem;
  color: var(--muted-strong);
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.72);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

input::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

textarea {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(2, 6, 23, 0.72);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  min-height: 92px;
}

textarea::placeholder {
  color: rgba(148, 163, 184, 0.6);
}

textarea:focus {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(15, 23, 42, 0.88);
}

input:focus,
select:focus {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(15, 23, 42, 0.88);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.tab-button,
.ghost-button,
.primary-button,
.danger-button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.tab-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.04);
}

.tab-button.active,
.primary-button {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(20, 184, 166, 0.22));
  border-color: rgba(56, 189, 248, 0.38);
  box-shadow: 0 12px 28px rgba(20, 184, 166, 0.16);
}

.danger-button {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.26);
}

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

.auth-form,
.mini-form {
  display: grid;
  gap: 14px;
}

.auth-form label,
.mini-form label {
  display: grid;
  gap: 8px;
  color: #e2e8f0;
  font-size: 0.92rem;
}

.status-text {
  margin: 14px 0 0;
}

.logout-button {
  width: 100%;
  margin-top: 14px;
}

.sidebar-footnote {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.main-content {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.workspace-section {
  border-radius: 28px;
  padding: 22px;
  scroll-margin-top: 24px;
  min-width: 0;
}

.workspace-head {
  margin-bottom: 18px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.resource-card {
  padding: 20px;
  scroll-margin-top: 24px;
}

.resource-form {
  margin-top: 8px;
}

.resource-form textarea {
  min-height: 94px;
}

.resource-table-wrap {
  margin-top: 12px;
}

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

.checkbox-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}

.premium-only {
  border-color: rgba(56, 189, 248, 0.28);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 28px;
}

.topbar h2 {
  font-size: clamp(1.4rem, 2vw, 2.1rem);
}

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

.badge,
.metric-pill,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 700;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

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

.kpi-grid > *,
.content-grid > *,
.workspace-grid > * {
  min-width: 0;
}

.kpi-card,
.panel-card {
  border-radius: 28px;
  padding: 22px;
  min-width: 0;
}

.kpi-card h3 {
  margin: 10px 0 6px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(1.55rem, 3vw, 2.7rem);
}

.content-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 18px;
  min-width: 0;
}

.lower-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.section-head {
  margin-bottom: 16px;
}

.chart-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.pie-chart {
  width: min(300px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  position: relative;
  border: 14px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 24px 50px rgba(2, 6, 23, 0.38);
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(248, 250, 252, 0.92) 0 34%, rgba(255, 255, 255, 0.08) 35% 100%);
  background-clip: padding-box;
}

.pie-center {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 44%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(2, 6, 23, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.pie-center span {
  color: var(--muted);
  font-size: 0.8rem;
}

.pie-center strong {
  display: block;
  margin-top: 3px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 1.15rem;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.legend li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.03);
}

.legend-empty {
  padding: 18px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  min-width: 0;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted-strong);
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.empty-cell {
  text-align: center;
  padding: 18px 10px;
}

.pill.success {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.22);
  color: #d1fae5;
}

.pill.danger {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.22);
  color: #ffe4ea;
}

.row-warning td {
  background: rgba(251, 113, 133, 0.05);
}

.report-meta,
.muted-cell {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 8px;
  min-width: 230px;
}

.report-summary-grid span {
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.report-summary-grid strong,
.report-summary-grid small {
  display: block;
}

.report-summary-grid small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.report-mini-list {
  list-style: none;
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  min-width: 220px;
}

.report-mini-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.report-mini-list span {
  color: var(--muted-strong);
  line-height: 1.35;
}

.report-highlight {
  display: grid;
  gap: 4px;
  min-width: 190px;
}

.report-highlight small {
  color: var(--muted);
}

.report-highlight strong {
  font-size: 0.98rem;
}

.report-highlight span {
  color: var(--muted-strong);
}

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

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

.admin-kpi-grid .kpi-card h3 {
  font-size: clamp(1.7rem, 3vw, 2.45rem);
}

.admin-kpi-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.admin-inline-form {
  margin: -4px 0 16px;
}

.compact-label {
  margin-top: 0;
}

.admin-table-wrap {
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(255, 255, 255, 0.025);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.admin-table-wrap table {
  width: max-content;
  min-width: 100%;
}

.tall-table {
  max-height: 420px;
  overflow-y: auto;
}

.admin-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-btn {
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.admin-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.08);
}

.admin-btn-danger {
  border-color: rgba(251, 113, 133, 0.26);
  background: rgba(251, 113, 133, 0.14);
}

.admin-btn-danger:hover {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(251, 113, 133, 0.2);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 148px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-panel {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 24px;
  padding: 22px;
}

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

.modal-head h2 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
}

.modal-close-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-form {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.status-admin {
  color: #e0f2fe;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.14);
}

.status-premium {
  color: #ccfbf1;
  border-color: rgba(20, 184, 166, 0.28);
  background: rgba(20, 184, 166, 0.14);
}

.status-basic {
  color: #fef3c7;
  border-color: rgba(245, 158, 11, 0.26);
  background: rgba(245, 158, 11, 0.12);
}

.audit-table strong {
  display: block;
  margin-bottom: 4px;
}

.audit-muted {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.audit-state {
  margin-top: 8px;
  width: fit-content;
  padding: 5px 9px;
  font-size: 0.74rem;
}

.audit-action-insert {
  color: #d1fae5;
  border-color: rgba(52, 211, 153, 0.28);
  background: rgba(52, 211, 153, 0.14);
}

.audit-action-update {
  color: #e0f2fe;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.14);
}

.audit-action-delete {
  color: #ffe4ea;
  border-color: rgba(251, 113, 133, 0.3);
  background: rgba(251, 113, 133, 0.15);
}

.users-table-wrap {
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

.error {
  color: #fecdd3;
}

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

  .sidebar {
    position: relative;
    top: 0;
    min-height: auto;
  }

  .kpi-grid,
  .content-grid,
  .lower-grid,
  .chart-layout,
  .admin-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
  }

  .sidebar,
  .topbar,
  .kpi-card,
  .panel-card {
    padding: 18px;
    border-radius: 22px;
  }

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

  .inline-field {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}
