:root {
  color-scheme: dark light;
  --bg: #101114;
  --surface: #191b20;
  --surface-strong: #20242b;
  --line: #303742;
  --text: #f5f7fb;
  --muted: #a9b0bd;
  --soft: #737d8c;
  --mint: #65f3b6;
  --cyan: #77d4ff;
  --amber: #ffd166;
  --coral: #f78c6b;
  --rose: #ff5c8a;
  --violet: #c7a6ff;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

html[data-theme="light"] {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-strong: #f7f9fc;
  --line: #d8dee8;
  --text: #141820;
  --muted: #526071;
  --soft: #7c8795;
  --mint: #0f9f72;
  --cyan: #1a78c2;
  --amber: #c27a04;
  --coral: #c7512e;
  --rose: #c23b62;
  --violet: #745cc6;
  --shadow: 0 18px 50px rgba(32, 41, 56, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(120, 135, 155, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 135, 155, 0.09) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

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

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

.icon-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
}

.icon-button span,
.icon-button span::before,
.icon-button span::after {
  display: block;
  border-radius: 999px;
}

.icon-button span {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
}

html[data-theme="dark"] .icon-button span {
  border-color: transparent;
  box-shadow: inset -6px -2px 0 currentColor;
}

html[data-theme="light"] .icon-button span::before,
html[data-theme="light"] .icon-button span::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

html[data-theme="light"] .icon-button span::after {
  transform: rotate(90deg);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--mint);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2.35rem);
}

h2 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 6vw, 5.2rem);
  line-height: 0.96;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.officer-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.officer-chip > span {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: #101114;
  font-weight: 900;
}

.officer-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.auth-dock {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(280px, 1.2fr) minmax(280px, 1fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.auth-copy {
  display: grid;
  gap: 2px;
}

.auth-copy strong {
  font-size: 1.05rem;
}

.auth-copy small,
.auth-form span,
.create-team-form span,
.join-team-form span,
.session-panel span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.auth-form,
.create-team-form,
.join-team-form,
.session-panel {
  display: flex;
  align-items: end;
  gap: 8px;
  min-width: 0;
}

.auth-form label,
.create-team-form label,
.join-team-form label {
  display: grid;
  flex: 1 1 150px;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.auth-form input,
.create-team-form input,
.join-team-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 8px 10px;
}

.auth-form button,
.create-team-form button,
.join-team-form button,
.session-panel button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 900;
  white-space: nowrap;
}

.team-forms {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.55fr);
  gap: 10px;
}

.create-team-form,
.join-team-form {
  min-height: 56px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

.create-team-form button {
  background: var(--mint);
  color: #0f1115;
}

.session-panel {
  grid-column: span 2;
  justify-content: end;
  flex-wrap: wrap;
}

.session-panel strong {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--mint);
  font-size: 0.82rem;
  white-space: nowrap;
}

.session-panel button:first-of-type {
  background: var(--mint);
  color: #0f1115;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: center;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--mint) 16%, transparent), transparent 34%),
    radial-gradient(circle at 74% 18%, color-mix(in srgb, var(--cyan) 12%, transparent), transparent 32%),
    color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
}

.period-control {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  margin-bottom: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-strong) 84%, #000 16%);
  overflow-x: auto;
}

.period-control button {
  min-width: 74px;
  min-height: 36px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.period-control button.active {
  background: var(--text);
  color: var(--bg);
}

.custom-range {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(128px, 1fr)) auto;
  align-items: end;
  gap: 8px;
  max-width: min(560px, 100%);
  margin: -12px 0 22px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-strong) 76%, transparent);
}

.custom-range label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.custom-range input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.custom-range button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 12px;
  background: var(--mint);
  color: #0f1115;
  font-weight: 900;
  white-space: nowrap;
}

#heroNarrative {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.hero-gauge {
  position: relative;
  width: 220px;
  height: 220px;
  justify-self: end;
}

.hero-gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track,
.gauge-fill {
  fill: none;
  stroke-width: 18;
}

.gauge-track {
  stroke: #2a3038;
}

.gauge-fill {
  stroke: var(--mint);
  stroke-linecap: round;
  stroke-dasharray: 552.92;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 220ms ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.gauge-center strong {
  display: block;
  font-size: 2.8rem;
  line-height: 1;
}

.gauge-center span {
  color: var(--muted);
  font-weight: 700;
}

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

.kpi-strip article,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}

.kpi-strip article {
  min-height: 112px;
  padding: 18px;
}

.kpi-strip span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.kpi-strip strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.wide {
  grid-column: span 1;
}

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

.panel-header > span,
.save-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.day-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(54px, 1fr));
  align-items: end;
  min-height: 270px;
  gap: 10px;
}

.day-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 10px;
  min-width: 0;
  height: 100%;
}

.bar-track {
  display: flex;
  align-items: end;
  height: 210px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-strong) 84%, #000 16%);
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: var(--cyan);
  transition: height 180ms ease;
}

.day-bar strong,
.day-bar span {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-bar strong {
  font-size: 1.15rem;
}

.day-bar span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(7, minmax(34px, 1fr));
  gap: 8px;
}

.heat-cell {
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--surface-strong) 84%, #000 16%);
  color: var(--muted);
  font-weight: 900;
}

.heat-cell.active {
  background: color-mix(in srgb, var(--mint) var(--heat), var(--surface-strong));
  color: var(--text);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

.metric-card strong {
  display: block;
  margin-bottom: 12px;
  color: var(--metric-color);
  font-size: 2rem;
  line-height: 1;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric-meter {
  height: 5px;
  margin-top: 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 68%, transparent);
  overflow: hidden;
}

.metric-meter > i {
  display: block;
  width: var(--meter-width);
  height: 100%;
  border-radius: inherit;
  background: var(--metric-color);
}

.narcotics-list {
  display: grid;
  gap: 9px;
}

.narcotics-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--muted);
  font-size: 0.9rem;
}

.narcotics-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--category-color);
}

.narcotics-row strong {
  color: var(--text);
}

.squad-pulse {
  display: grid;
  gap: 14px;
}

.pulse-copy,
.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.pulse-row {
  display: grid;
  gap: 7px;
}

.pulse-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.pulse-row strong {
  color: var(--text);
}

.pulse-meter {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 68%, transparent);
  overflow: hidden;
}

.pulse-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--mint));
}

.log-panel {
  grid-column: 1 / -1;
}

.log-panel .panel-header button {
  min-width: 84px;
  min-height: 38px;
  border-radius: 7px;
  background: var(--mint);
  color: #0f1115;
  font-weight: 900;
}

.log-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

.log-panel input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 8px 10px;
}

.entry-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.save-status {
  min-height: 18px;
  margin: 14px 0 0;
}

@media (max-width: 900px) {
  .topbar,
  .hero {
    grid-template-columns: 1fr;
  }

  .auth-dock {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .session-panel {
    grid-column: auto;
    justify-content: start;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
  }

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

  .hero-gauge {
    justify-self: start;
  }

  .kpi-strip,
  .dashboard-grid,
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.wide,
  .log-panel {
    grid-column: 1 / -1;
  }

  .day-bars {
    grid-template-columns: repeat(7, minmax(38px, 1fr));
    gap: 6px;
  }

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 12px;
  }

  .hero {
    padding: 20px;
  }

  .kpi-strip,
  .dashboard-grid,
  .metric-grid,
  .entry-inputs {
    grid-template-columns: 1fr;
  }

  .auth-form,
  .create-team-form,
  .join-team-form,
  .session-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .team-forms {
    grid-template-columns: 1fr;
  }

  .day-bars {
    min-height: 220px;
    overflow-x: auto;
  }

  .custom-range {
    grid-template-columns: 1fr;
  }

  .day-bar {
    min-width: 48px;
  }
}
