:root {
  color-scheme: dark;
  --bg: #05070d;
  --panel: #0b1019;
  --panel-2: #111827;
  --text: #f7f9ff;
  --muted: #9aa4b2;
  --line: rgba(255, 255, 255, 0.1);
  --cyan: #39dff4;
  --mint: #62f2bb;
  --danger: #ff5b6c;
  --warning: #f5b84b;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(57, 223, 244, 0.14), transparent 34rem),
    radial-gradient(circle at 90% 0%, rgba(98, 242, 187, 0.09), transparent 28rem),
    var(--bg);
  color: var(--text);
}

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

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

button,
a,
input,
select,
textarea {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(57, 223, 244, 0.28);
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  transform: translateY(-150%);
  border-radius: 999px;
  background: var(--cyan);
  color: #001018;
  padding: 0.7rem 1rem;
  font-weight: 800;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(5, 7, 13, 0.82);
  padding: 1.25rem;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.brand-mark {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(57, 223, 244, 0.18), rgba(98, 242, 187, 0.08));
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand small,
.muted {
  color: var(--muted);
}

.sidebar nav {
  display: grid;
  gap: 0.35rem;
}

.sidebar nav a {
  border-radius: 14px;
  color: var(--muted);
  font-weight: 750;
  padding: 0.82rem 0.95rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 1.4rem 1.6rem;
}

.topbar h1 {
  margin: 0.2rem 0;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-chip,
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
}

.panel {
  padding: 1.6rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.metrics {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.card,
.table-wrap,
.form-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(11, 16, 25, 0.82);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

.card {
  padding: 1rem;
}

.metric-value {
  margin-top: 0.5rem;
  font-size: 2rem;
  font-weight: 950;
}

.platform-card {
  overflow-x: auto;
}

.platform-grid {
  display: grid;
  gap: 0.7rem;
}

.platform-row {
  display: grid;
  grid-template-columns: minmax(90px, 1.1fr) repeat(6, minmax(94px, 1fr));
  gap: 0.7rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  min-width: 760px;
}

.platform-row:first-child {
  border-top: 0;
}

.chart-card {
  overflow-x: auto;
}

.chart-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.chart-header h2 {
  margin: 0 0 0.25rem;
}

.chart-svg {
  display: block;
  min-width: 680px;
  width: 100%;
  height: auto;
}

.chart-svg rect {
  fill: var(--cyan);
  opacity: 0.82;
}

.chart-svg .chart-ios,
.chart-key.chart-ios {
  fill: #30d5ff;
  background: #30d5ff;
}

.chart-svg .chart-android,
.chart-key.chart-android {
  fill: #73f2b6;
  background: #73f2b6;
}

.chart-svg .chart-other,
.chart-key.chart-other {
  fill: #a78bfa;
  background: #a78bfa;
}

.chart-svg .chart-empty {
  fill: rgba(148, 163, 184, 0.35);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.chart-key {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  margin-right: 0.35rem;
}

.chart-count {
  fill: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-button {
  min-height: 30px;
  margin-top: 0.45rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.flag-badge {
  margin: 0 0.25rem 0.25rem 0;
  color: var(--cyan);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.settings-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.settings-control h2 {
  margin: 0 0 0.35rem;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  grid-template-columns: none;
  gap: 0.7rem;
  min-width: 126px;
  color: var(--text);
  font-size: 0.9rem;
}

.switch-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  display: inline-flex;
  width: 54px;
  height: 30px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  padding: 3px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.switch-thumb {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 0.18s ease, background 0.18s ease;
}

.switch-label input:checked + .switch-track {
  border-color: rgba(98, 242, 187, 0.5);
  background: rgba(98, 242, 187, 0.22);
}

.switch-label input:checked + .switch-track .switch-thumb {
  transform: translateX(24px);
  background: var(--mint);
}

.switch-label input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(57, 223, 244, 0.28);
}

.danger-text {
  color: var(--danger);
}

.warning-text {
  color: var(--warning);
}

.toolbar,
.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.content-maker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1rem;
  align-items: start;
}

.panel-heading {
  margin-bottom: 1rem;
}

.panel-heading h2 {
  margin: 0 0 0.35rem;
}

.panel-heading p {
  margin: 0;
}

.full-span {
  flex-basis: 100%;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select,
textarea {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  padding: 0.68rem 0.75rem;
}

textarea {
  min-width: min(560px, 100%);
  min-height: 110px;
  resize: vertical;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  min-height: 42px;
  padding: 0.7rem 1rem;
}

.primary {
  background: linear-gradient(135deg, var(--cyan), var(--mint));
  color: #031015;
}

.secondary {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.danger {
  background: rgba(255, 91, 108, 0.16);
  color: #ff9ca7;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem;
  text-align: left;
  vertical-align: top;
}

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

td {
  color: rgba(247, 249, 255, 0.86);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.actions button {
  min-height: 34px;
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
}

.form-card {
  padding: 1rem;
}

.toast,
.form-message {
  border-radius: 12px;
  color: var(--text);
}

.toast {
  position: fixed;
  right: 1rem;
  top: 1rem;
  z-index: 30;
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0.9rem 1rem;
}

.loading,
.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 2rem;
  text-align: center;
}

.admin-login {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(11, 16, 25, 0.9);
  padding: 2rem;
}

.login-card h1 {
  margin: 0.4rem 0;
  font-size: 2.4rem;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

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

@media (max-width: 640px) {
  .panel,
  .topbar,
  .sidebar {
    padding: 1rem;
  }

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

  .sidebar nav {
    grid-template-columns: 1fr;
  }

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