:root {
  --page-bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-muted: #f6f8fc;
  --surface-dark: #121a2b;
  --text-main: #0f172a;
  --text-soft: #5f6f87;
  --border-soft: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.32);
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.07);
  --shadow-float: 0 28px 60px rgba(15, 23, 42, 0.12);
  --brand-ink: #0f1b34;
  --brand-blue: #3157d5;
  --brand-blue-soft: #dbe6ff;
  --brand-aqua: #7dd3fc;
  --teal: #2aa7a1;
  --teal-deep: #1f7a79;
  --blue: #3157d5;
  --amber: #d97706;
  --rose: #e11d48;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Manrope", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.22), transparent 24rem),
    radial-gradient(circle at top right, rgba(129, 140, 248, 0.14), transparent 26rem),
    radial-gradient(circle at bottom center, rgba(191, 219, 254, 0.22), transparent 22rem),
    linear-gradient(180deg, #f8fbff 0%, #f3f7fc 46%, #eef4fb 100%);
  color: var(--text-main);
}

.dashboard-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.26), transparent 70%);
  opacity: 0.45;
}

.auth-stage,
.dashboard-shell {
  position: relative;
}

.auth-shell {
  position: relative;
}

.auth-card,
.dashboard-header,
#app-shell main section.rounded-3xl,
#app-shell main article.rounded-3xl,
#app-shell main .rounded-3xl.border,
#app-shell main .rounded-2xl.border,
#app-shell main .rounded-2xl.bg-white,
#app-shell main .rounded-2xl.bg-slate-50,
#app-shell main .rounded-2xl.bg-white\/95,
#app-shell main .rounded-2xl.bg-teal-50,
#app-shell main .rounded-2xl.bg-sky-50,
#app-shell main .rounded-2xl.bg-amber-50 {
  border-color: var(--border-soft) !important;
  box-shadow: var(--shadow-soft);
}

.auth-card,
#app-shell main section.rounded-3xl,
#app-shell main article.rounded-3xl {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.88)) !important;
  backdrop-filter: blur(18px);
}

.auth-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(191, 219, 254, 0.55) !important;
  box-shadow:
    0 36px 80px rgba(15, 23, 42, 0.1),
    0 12px 24px rgba(49, 87, 213, 0.08);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(125, 211, 252, 0.22), transparent 22rem),
    radial-gradient(circle at top right, rgba(129, 140, 248, 0.14), transparent 22rem),
    linear-gradient(180deg, rgba(235, 242, 255, 0.65), rgba(255, 255, 255, 0) 42%);
  pointer-events: none;
}

.auth-form-panel {
  position: relative;
  z-index: 1;
  padding: 2.6rem 2.6rem 2.35rem;
}

.auth-form-header {
  margin-bottom: 1.9rem;
}

.auth-tab-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 0.45rem;
  border-radius: 1.65rem;
  background: linear-gradient(180deg, rgba(236, 242, 251, 0.98), rgba(244, 247, 252, 0.92));
  border: 1px solid rgba(206, 221, 247, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.auth-panel {
  position: relative;
}

.auth-panel form {
  max-width: 100%;
}

.auth-submit {
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
}

.auth-submit-dark {
  background: linear-gradient(135deg, var(--brand-ink), #16284d 44%, var(--brand-blue));
}

.auth-submit-dark:hover {
  background: linear-gradient(135deg, #132141, #1a315f 44%, #3d63df);
}

.auth-submit-mint {
  background: linear-gradient(135deg, #d9e7ff, #cfe2ff 52%, #bdd7ff);
  color: var(--brand-ink) !important;
}

.auth-submit-mint:hover {
  background: linear-gradient(135deg, #e4eeff, #d6e7ff 52%, #c5ddff);
}

.dashboard-header {
  background: rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(22px);
  border-bottom-color: rgba(148, 163, 184, 0.18) !important;
}

.dashboard-main {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.auth-tab-button,
.view-tab,
#dashboard-filters-toggle,
#table-filters-toggle,
#logout-button,
#schema-refresh-button,
#dataset-form-reset,
#export-xlsx-button,
#admin-settings-submit,
#dataset-submit-button,
#reset-filters,
#table-reset-filters,
#app-shell button[type="submit"],
#app-shell button[type="button"] {
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.auth-tab-button:hover,
.view-tab:hover,
#dashboard-filters-toggle:hover,
#table-filters-toggle:hover,
#logout-button:hover,
#schema-refresh-button:hover,
#dataset-form-reset:hover,
#export-xlsx-button:hover,
#admin-settings-submit:hover,
#dataset-submit-button:hover,
#reset-filters:hover,
#table-reset-filters:hover,
#app-shell button[type="submit"]:hover,
#app-shell button[type="button"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.08);
}

.auth-tab-button.is-active {
  background: linear-gradient(135deg, var(--brand-ink), #1b2f59 42%, var(--brand-blue));
  color: white;
  box-shadow: 0 16px 35px rgba(49, 87, 213, 0.2);
}

.view-tab {
  position: relative;
  overflow: hidden;
  border-color: rgba(191, 219, 254, 0.7) !important;
}

.view-tab.bg-slate-900 {
  background: linear-gradient(135deg, #111827, #0f766e) !important;
  border-color: rgba(15, 118, 110, 0.45) !important;
  box-shadow: 0 18px 35px rgba(15, 118, 110, 0.16);
}

.view-tab.bg-white {
  background: rgba(255, 255, 255, 0.8) !important;
  color: #334155 !important;
}

#app-shell header .rounded-full,
#dataset-badge {
  border-color: rgba(191, 219, 254, 0.72) !important;
  background: rgba(255, 255, 255, 0.7) !important;
}

#app-shell header .rounded-2xl {
  background: rgba(255, 255, 255, 0.74) !important;
}

#dashboard-status-title,
#contexts-title,
#client-table-title,
#hero-title,
.font-display {
  font-family: "Rubik", sans-serif !important;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.04;
}

#metrics-grid .font-display,
#findings-grid .font-display,
#admin-summary-grid .font-display,
#client-table-body td,
#insights-grid,
#dashboard-status-text,
#client-table-text,
#contexts-text {
  font-variant-numeric: tabular-nums;
}

input,
select,
textarea,
button {
  font-family: "Manrope", sans-serif;
}

#dashboard-status-text,
#hero-subtitle,
#contexts-text,
#client-table-text,
#dashboard-filters-summary,
#table-filters-summary {
  color: var(--text-soft) !important;
}

#metrics-grid > article,
#findings-grid > article,
#insights-grid > article,
#admin-summary-grid > article,
#dataset-list > article,
#user-list > article,
#context-list > article {
  position: relative;
  overflow: hidden;
}

#metrics-grid > article::before,
#findings-grid > article::before,
#insights-grid > article::before,
#admin-summary-grid > article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.95), rgba(20, 184, 166, 0.8));
}

#metrics-grid > article {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 255, 0.92)) !important;
  min-height: 196px;
}

#findings-grid > article,
#insights-grid > article {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 250, 255, 0.88)) !important;
}

.dashboard-summary-card {
  background:
    linear-gradient(135deg, rgba(16, 24, 40, 0.96), rgba(20, 78, 108, 0.9)) !important;
  border-color: rgba(45, 212, 191, 0.18) !important;
  box-shadow: var(--shadow-float);
  min-height: 0;
  padding-bottom: 2rem !important;
}

.dashboard-summary-card p,
.dashboard-summary-card h3,
.dashboard-summary-card #dashboard-status-text {
  color: #f8fbff !important;
}

.dashboard-summary-card p:first-child {
  color: rgba(153, 246, 228, 0.86) !important;
}

.dashboard-summary-card #dashboard-status-title {
  max-width: 16ch;
  text-wrap: balance;
}

.dashboard-summary-card #dashboard-status-text {
  max-width: 72ch;
}

.dashboard-filter-card,
.table-filter-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(244, 249, 255, 0.9)) !important;
}

#dashboard-view > .space-y-4 > div,
#table-view > section > div:first-child,
#contexts-view > div:first-child,
#admin-view > section > div:first-child {
  position: relative;
}

#dashboard-view > .space-y-4 > div::after,
#table-view > section > div:first-child::after,
#contexts-view > div:first-child::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.65rem;
  width: 72px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), rgba(37, 99, 235, 0.55));
}

input,
select,
textarea {
  border-color: rgba(201, 216, 243, 0.95) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(49, 87, 213, 0.8) !important;
  box-shadow:
    0 0 0 4px rgba(49, 87, 213, 0.1),
    0 14px 24px rgba(49, 87, 213, 0.08) !important;
}

label > span {
  color: #334155 !important;
}

#client-table-head {
  background: linear-gradient(135deg, #111827, #1e293b) !important;
}

#client-table-body tr {
  transition: background-color 140ms ease, transform 140ms ease;
}

#client-table-body tr:hover {
  background: #eef6ff !important;
}

#client-table-body td,
#client-table-head th {
  border-color: rgba(191, 219, 254, 0.55) !important;
}

#context-list > article,
#dataset-list > article,
#user-list > article {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 250, 255, 0.92)) !important;
}

.admin-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.admin-inline-actions {
  flex-wrap: wrap;
}

.admin-card-top {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.admin-kv-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-kv-grid-compact {
  width: 100%;
}

.admin-kv-item {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  padding: 0.95rem 1rem;
  border-radius: 1.1rem;
  border: 1px solid rgba(201, 216, 243, 0.82);
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.96), rgba(241, 245, 251, 0.88));
}

.admin-kv-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #64748b;
}

.admin-kv-value {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
}

.admin-card-panels {
  display: grid;
  gap: 1rem;
}

.admin-soft-panel {
  padding: 1rem 1.05rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(201, 216, 243, 0.9);
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.96), rgba(243, 247, 252, 0.92));
}

.admin-soft-panel-teal {
  border-color: rgba(153, 246, 228, 0.9);
  background: linear-gradient(180deg, rgba(240, 253, 250, 0.98), rgba(236, 253, 248, 0.9));
}

.admin-cache-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.admin-user-form {
  display: grid;
  gap: 1rem;
}

.admin-user-controls {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.filter-card-header {
  align-items: flex-start;
}

.quick-date-panel {
  border-color: rgba(201, 216, 243, 0.92) !important;
  background: linear-gradient(180deg, rgba(247, 250, 255, 0.96), rgba(241, 245, 251, 0.9)) !important;
}

.quick-range-group {
  align-items: center;
}

.filter-form-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.filter-field-grid {
  align-items: end;
}

.filter-actions {
  justify-content: flex-start;
}

.quick-range-button {
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease;
}

.quick-range-button.is-active {
  border-color: rgba(49, 87, 213, 0.55) !important;
  background: linear-gradient(135deg, var(--brand-ink), #1b2f59 42%, var(--brand-blue)) !important;
  color: white !important;
  box-shadow: 0 14px 28px rgba(49, 87, 213, 0.18);
}

.chart-shell {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.72));
  border: 1px solid rgba(191, 219, 254, 0.65);
  padding: 0.9rem;
}

.chart-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.55;
}

.chart-shell canvas {
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
}

.context-pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: linear-gradient(180deg, #f8fbff, #f4f8fc) !important;
}

.thin-scrollbar::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.thin-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}

#toast-root > div {
  backdrop-filter: blur(16px);
  border-width: 1px;
  box-shadow: var(--shadow-float);
}

@media (max-width: 1024px) {
  .dashboard-main {
    padding-top: 1.4rem;
  }

  .dashboard-summary-card #dashboard-status-title {
    max-width: none;
  }

  .admin-section-header {
    flex-direction: column;
  }

  #metrics-grid > article {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .auth-card,
  #app-shell main section.rounded-3xl,
  #app-shell main article.rounded-3xl {
    border-radius: 1.5rem !important;
  }

  .auth-form-panel {
    padding: 1.4rem;
  }

  .auth-tab-bar {
    padding: 0.35rem;
    border-radius: 1.35rem;
  }

  .filter-actions > button {
    width: 100%;
  }

  .view-tab,
  #dashboard-filters-toggle,
  #table-filters-toggle {
    width: 100%;
  }
}
