:root {
  color-scheme: dark;
  --bg: #101018;
  --panel: rgba(28, 27, 40, 0.86);
  --panel-soft: rgba(22, 27, 36, 0.88);
  --ink: #f4f7fb;
  --muted: #9ba6b6;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #0fb7b4;
  --accent-strong: #74f5dd;
  --accent-soft: rgba(15, 183, 180, 0.15);
  --warning: #f2d659;
  --danger: #ff6b7a;
  --ok: #2ee884;
  --lime: #c6ff00;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(145deg, #151622 0%, #0f1018 44%, #0c1116 100%);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  border: 1px solid rgba(116, 245, 221, 0.22);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 183, 180, 0.96), rgba(198, 255, 0, 0.74));
  color: #061110;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 650;
  box-shadow: 0 10px 26px rgba(15, 183, 180, 0.18);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar {
  background: linear-gradient(180deg, rgba(31, 30, 45, 0.96), rgba(18, 18, 28, 0.96));
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 16px 12px;
  position: sticky;
  top: 18px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 20px;
}

.brand-mark {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(116, 245, 221, 0.35);
  border-radius: 10px;
  display: inline-flex;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.brand-copy {
  display: grid;
  gap: 1px;
}

.brand-copy strong {
  font-size: 14px;
  line-height: 1;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.workspace-chip {
  background: rgba(15, 183, 180, 0.07);
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  gap: 2px;
  margin: 0 4px 16px;
  padding: 10px 11px;
}

.workspace-chip span {
  font-weight: 700;
}

.workspace-chip small {
  color: var(--muted);
  font-weight: 650;
  text-transform: capitalize;
}

.nav-link {
  border: 1px solid transparent;
  border-radius: 12px;
  color: #aab3c2;
  display: block;
  font-size: 13px;
  font-weight: 650;
  padding: 9px 11px;
  margin: 3px 0;
}

.nav-link.active,
.nav-link:hover {
  background: linear-gradient(90deg, rgba(15, 183, 180, 0.2), rgba(198, 255, 0, 0.06));
  border-color: rgba(116, 245, 221, 0.16);
  color: var(--accent-strong);
  box-shadow: inset 0 0 18px rgba(15, 183, 180, 0.08);
}

.nav-heading {
  color: var(--muted);
  cursor: default;
  font-size: 11px;
  margin-top: 12px;
  text-transform: uppercase;
}

.nav-heading:hover {
  background: transparent;
  color: var(--muted);
}

.nav-sub {
  padding-left: 22px;
}

dialog {
  background: #171722;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
  max-width: 560px;
  width: calc(100% - 32px);
}

dialog::backdrop {
  background: rgba(3, 5, 10, 0.72);
}

.main {
  min-width: 0;
  padding: 10px 0 40px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  padding: 12px 0 22px;
}

.topbar h1 {
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}

.topbar-meta {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.search-box {
  display: block;
}

.search-box input {
  background: rgba(255, 255, 255, 0.04);
  min-height: 36px;
  width: 240px;
}

.user-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #d6dde8;
  display: inline-flex;
  font-size: 12px;
  font-weight: 650;
  min-height: 32px;
  align-items: center;
  padding: 0 10px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.card {
  background: linear-gradient(145deg, rgba(31, 30, 45, 0.9), rgba(21, 21, 32, 0.9));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  padding: 20px;
  position: relative;
}

.card::before {
  background: linear-gradient(110deg, rgba(116, 245, 221, 0.12), transparent 38%, rgba(198, 255, 0, 0.06));
  content: "";
  height: 1px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.card h2,
.card h3 {
  font-size: 15px;
  letter-spacing: 0;
  line-height: 1.3;
  margin: 0 0 12px;
}

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

.card-header h2,
.card-header h3 {
  margin: 0;
}

.card-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.metric {
  color: #f7fbff;
  font-size: 31px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.15;
}

.metric-card {
  min-height: 134px;
}

.metric-card:nth-child(2),
.metric-card:nth-child(3),
.metric-card:nth-child(5) {
  background:
    linear-gradient(145deg, rgba(31, 30, 45, 0.9), rgba(20, 26, 32, 0.92)),
    linear-gradient(90deg, rgba(15, 183, 180, 0.08), rgba(198, 255, 0, 0.05));
}

.metric-card .muted {
  font-size: 12px;
  margin: 10px 0 0;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.bar-row span {
  color: #d8deea;
  font-size: 13px;
  font-weight: 650;
  min-width: 0;
}

.bar-row strong {
  color: var(--ink);
  font-size: 13px;
}

.bar-row i {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 999px;
  display: block;
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  position: relative;
}

.bar-row i::before {
  background: linear-gradient(90deg, var(--accent), var(--lime));
  border-radius: inherit;
  content: "";
  display: block;
  height: 100%;
  width: calc(var(--value, 0) * 1%);
}

.dashboard-charts {
  align-items: stretch;
}

.chart-card {
  min-height: 336px;
  overflow: hidden;
}

.chart-card .card-header {
  margin-bottom: 16px;
}

.chart-kpi {
  align-items: center;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #dffcf7;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.chart-shell {
  height: 238px;
  position: relative;
}

.chart-shell-sm {
  height: 220px;
}

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

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

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

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.table td {
  color: #d6dde8;
  font-size: 13px;
}

.table tr:last-child td {
  border-bottom: 0;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
}

.status.good {
  background: rgba(46, 232, 132, 0.13);
  color: var(--ok);
}

.status.warn {
  background: rgba(242, 214, 89, 0.13);
  color: var(--warning);
}

.status.bad {
  background: rgba(255, 107, 122, 0.13);
  color: var(--danger);
}

form {
  display: grid;
  gap: 11px;
}

label {
  color: #cbd4e2;
  display: grid;
  font-size: 12px;
  font-weight: 650;
  gap: 6px;
}

label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
  align-items: center;
  display: flex;
  gap: 8px;
}

.inline-check {
  align-items: center;
  display: flex;
  gap: 8px;
}

.mapping-preview,
.custom-field-picker {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.preview-row,
.custom-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preview-row span {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #d6dde8;
  font-size: 12px;
  padding: 4px 8px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

select option {
  background: #171722;
  color: var(--ink);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  box-shadow: none;
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  min-height: 0;
  padding: 0;
  width: 16px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 183, 180, 0.18);
  outline: 0;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: 0 0 0 3px rgba(15, 183, 180, 0.18);
}

textarea {
  min-height: 130px;
  resize: vertical;
}

.public-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.public-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  max-width: 440px;
  padding: 24px;
  width: 100%;
}

.public-panel h1 {
  margin-top: 0;
}

.notice {
  border-radius: 6px;
  padding: 10px 12px;
}

.notice.error {
  background: rgba(255, 107, 122, 0.13);
  color: var(--danger);
}

.notice.success {
  background: rgba(46, 232, 132, 0.13);
  color: var(--ok);
}

pre,
code {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #d9fff5;
}

code {
  padding: 1px 4px;
}

pre {
  overflow-x: auto;
  padding: 12px;
}

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

  .sidebar {
    height: auto;
    position: static;
  }

  .grid.cols-2,
  .grid.cols-3 {
    grid-template-columns: 1fr;
  }

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