:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --panel: #ffffff;
  --ink: #17201b;
  --muted: #66716b;
  --line: #dbe3dd;
  --accent: #0e7c66;
  --accent-dark: #075f50;
  --warn: #b7791f;
  --bad: #b42318;
  --good-bg: #e5f5ee;
  --bad-bg: #fde8e7;
  --shadow: 0 12px 30px rgba(30, 44, 37, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #eef3ef;
  color: var(--ink);
}

button.secondary:hover {
  background: #dfe8e2;
}

button.small {
  min-height: 32px;
  padding: 0 10px;
}

button.danger {
  background: var(--bad-bg);
  color: var(--bad);
}

button.danger:hover {
  background: #f9cfcc;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

select[multiple] {
  min-height: 120px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel h1,
.topbar h2 {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.error-text {
  color: var(--bad);
  margin: 0;
}

.muted-text {
  color: var(--muted);
  margin: 8px 0 0;
}

.portal-access-link {
  color: var(--accent);
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.portal-access-link:hover {
  color: var(--accent-dark);
}

.portal-login-page {
  background:
    radial-gradient(circle at 50% 22%, rgba(13, 148, 238, 0.2), transparent 34rem),
    linear-gradient(140deg, #020611 0%, #061227 48%, #02050d 100%);
  color: #f6fbff;
}

.portal-login-page .login-shell {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 26%, rgba(19, 186, 255, 0.14), transparent 22rem),
    radial-gradient(circle at 82% 74%, rgba(14, 124, 102, 0.12), transparent 24rem);
}

.portal-network-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.92;
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(33, 202, 255, 0.16) 13%, transparent 16% 100%),
    linear-gradient(36deg, transparent 0 22%, rgba(33, 202, 255, 0.18) 23%, transparent 26% 100%),
    linear-gradient(144deg, transparent 0 28%, rgba(33, 202, 255, 0.14) 29%, transparent 32% 100%);
  background-size: 420px 220px, 520px 300px, 560px 320px;
  animation: portalNetworkDrift 18s linear infinite;
}

.portal-network-bg::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.18;
  background: url("/assets/stadik-systems-primary-logo-2000w.png") center 18% / min(760px, 88vw) auto no-repeat;
  filter: drop-shadow(0 0 46px rgba(13, 148, 238, 0.7));
}

.portal-network-bg::after {
  position: absolute;
  inset: -20%;
  content: "";
  background:
    radial-gradient(circle, rgba(99, 230, 255, 0.95) 0 2px, transparent 3px),
    linear-gradient(90deg, transparent 0 18%, rgba(99, 230, 255, 0.62) 19%, transparent 22% 100%),
    linear-gradient(28deg, transparent 0 44%, rgba(99, 230, 255, 0.42) 45%, transparent 48% 100%);
  background-size: 160px 120px, 640px 260px, 700px 300px;
  filter: blur(0.1px);
  animation: portalSignalSweep 7s linear infinite;
}

.portal-login-page .login-panel {
  position: relative;
  z-index: 1;
  max-width: 480px;
  border-color: rgba(99, 230, 255, 0.26);
  background: linear-gradient(180deg, rgba(7, 18, 38, 0.86), rgba(2, 7, 17, 0.92));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48), 0 0 52px rgba(13, 148, 238, 0.16);
}

.portal-brand-block {
  display: flex;
  justify-content: center;
}

.portal-brand-logo {
  display: block;
  width: min(240px, 72vw);
  height: auto;
  max-width: 100%;
  filter: drop-shadow(0 0 20px rgba(13, 148, 238, 0.45));
}

.billing-form-page .portal-login-shell {
  padding: 22px;
}

.billing-form-page .billing-form-panel {
  max-width: 760px;
  width: min(760px, 100%);
  gap: 14px;
}

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

.billing-form-grid .span {
  grid-column: 1 / -1;
}

.portal-login-page .login-panel h1 {
  color: #f6fbff;
}

.portal-login-page .eyebrow,
.portal-login-page .portal-access-link {
  color: #63e6ff;
}

.portal-login-page .muted-text,
.portal-login-page label {
  color: #a9bdd4;
}

.portal-login-page input {
  border-color: rgba(99, 230, 255, 0.24);
  background: rgba(2, 8, 18, 0.86);
  color: #f6fbff;
}

.portal-login-page button[type="submit"] {
  background: linear-gradient(135deg, #63e6ff, #19aaff 62%, #5ff0c8);
  color: #021020;
  box-shadow: 0 18px 46px rgba(13, 148, 238, 0.28);
}

.portal-login-logo {
  display: block;
  width: min(340px, 86vw);
  height: auto;
  justify-self: center;
  margin: 0 0 2px;
  filter: drop-shadow(0 0 28px rgba(13, 148, 238, 0.52));
}

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

.sidebar {
  background: #17201b;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
}

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

.portal-sidebar-logo {
  display: block;
  width: 112px;
  height: auto;
  filter: drop-shadow(0 0 16px rgba(13, 148, 238, 0.35));
}

.brand small {
  color: #b8c8bf;
  display: block;
  margin-top: 4px;
  word-break: break-word;
}

.mark {
  background: #9bd8ca;
  border-radius: 6px;
  display: inline-block;
  height: 34px;
  width: 34px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: #dbe8df;
  justify-content: flex-start;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar .secondary {
  margin-top: auto;
}

.content {
  min-width: 0;
  padding: 26px;
}

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

.notice {
  background: #fff7dd;
  border: 1px solid #f3d98e;
  border-radius: 6px;
  color: #68480a;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

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

.grid.two {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stat,
.panel,
.row-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.row-card.created-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.14), var(--shadow);
}

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  font-size: 28px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 16px;
}

.panel-header h3 {
  margin: 0;
}

.panel-body {
  padding: 16px;
}

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

.form-grid .span {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  margin-bottom: 14px;
}

.storage-status {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.upload-guidance {
  background: #f8fbf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px;
}

.upload-guidance span {
  color: var(--muted);
  font-size: 13px;
}

.signage-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 12px;
}

.signage-editor-stage {
  align-items: center;
  aspect-ratio: 16 / 9;
  background: #050706;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  width: 100%;
}

.signage-editor-stage canvas,
.signage-editor-stage video {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.editor-empty {
  color: #cbd5ce;
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

.signage-editor-tools {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signage-editor-tools .span {
  grid-column: 1 / -1;
}

.signage-preview {
  background: #050706;
  border-radius: 6px;
  display: block;
  height: 92px;
  object-fit: contain;
  width: 140px;
}

.audience-chart {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-auto-flow: column;
  min-height: 260px;
  overflow-x: auto;
  padding: 12px 4px 4px;
}

.audience-bar-cell {
  align-items: center;
  display: grid;
  gap: 7px;
  grid-template-rows: 1fr auto auto;
  min-width: 58px;
  text-align: center;
}

.audience-bar-track {
  align-items: end;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: flex;
  height: 180px;
  justify-content: center;
  overflow: hidden;
  width: 22px;
  justify-self: center;
}

.audience-bar-track span {
  background: linear-gradient(180deg, #42bdf2, var(--accent));
  border-radius: 999px 999px 0 0;
  box-shadow: 0 0 18px rgba(66, 189, 242, 0.34);
  display: block;
  width: 100%;
}

.audience-bar-cell strong {
  font-size: 12px;
}

.audience-bar-cell small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  min-height: 28px;
}

.audience-peak-grid {
  display: grid;
  gap: 16px;
}

.audience-hour-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.intelligence-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.intelligence-card {
  align-content: start;
}

.intelligence-value {
  color: var(--ink) !important;
  display: block;
  font-size: 26px !important;
  font-weight: 800;
}

.intelligence-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.report-export-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.report-export-grid .upload-guidance {
  align-content: start;
}

.report-export-grid button {
  justify-self: start;
  margin-top: 4px;
}

.code-block {
  background: #101713;
  border-radius: 8px;
  color: #d7f6e8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-x: auto;
  padding: 14px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  text-transform: uppercase;
}

.badge.online {
  background: var(--good-bg);
  color: var(--accent-dark);
}

.badge.offline {
  background: var(--bad-bg);
  color: var(--bad);
}

.badge.neutral {
  background: #eef3ef;
  color: var(--muted);
}

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

.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

.track-builder {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.track-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 180px;
  overflow: hidden;
}

.track-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.track-row:last-child {
  border-bottom: 0;
}

.track-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.device-config {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-top: 8px;
  padding: 10px;
}

.map-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
}

.map-search-panel {
  overflow: visible;
}

.map-panel {
  min-height: 560px;
}

.google-map-canvas {
  height: min(66vh, 620px);
  min-height: 500px;
  width: 100%;
}

.map-canvas {
  background: #e8f0ed;
  min-height: 500px;
  padding: 14px;
}

.map-canvas svg {
  display: block;
  height: min(66vh, 620px);
  min-height: 460px;
  width: 100%;
}

.map-water {
  fill: #dbece8;
}

.map-land {
  fill: #f7fbf7;
  stroke: #8fb3aa;
  stroke-linejoin: round;
  stroke-width: 7;
}

.map-line {
  fill: none;
  opacity: 0.28;
  stroke: #9ab7af;
  stroke-width: 3;
}

.map-marker circle:nth-child(2) {
  stroke: #fff;
  stroke-width: 4;
}

.map-marker text {
  fill: #fff;
  font-size: 18px;
  font-weight: 900;
  pointer-events: none;
}

.map-marker-label,
.map-empty {
  fill: #34413b;
  font-size: 18px;
  font-weight: 800;
}

.building-card,
.unmapped-row {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding: 12px 0;
}

.building-card:first-child,
.unmapped-row:first-child {
  padding-top: 0;
}

.building-card:last-child,
.unmapped-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.building-card strong,
.unmapped-row strong {
  display: block;
}

.building-card .muted,
.unmapped-row .muted {
  display: block;
  margin-top: 3px;
}

.building-devices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.group-device-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
}

.check-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 8px 0;
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row input {
  min-height: 0;
  width: auto;
}

.check-row strong,
.check-row small {
  display: block;
}

.check-row small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.selected-place {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  min-height: 40px;
  padding: 10px;
}

.settings-grid {
  display: grid;
  gap: 18px;
}

.user-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.user-search-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  padding-bottom: 10px;
}

.user-edit {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  padding: 10px;
}

.user-edit .span {
  grid-column: 1 / -1;
}

.user-edit.main-admin-user {
  border-color: rgba(14, 124, 102, 0.42);
  box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.08);
}

.user-edit input,
.user-edit select {
  min-height: 34px;
}

.user-meta {
  display: grid;
  gap: 5px;
}

.billing-request-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 2px;
  padding-top: 12px;
}

.billing-request-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.billing-request-item > summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.billing-request-item > summary::-webkit-details-marker {
  display: none;
}

.billing-request-grid {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  padding-top: 10px;
}

.billing-request-grid .span {
  grid-column: 1 / -1;
}

.button-link {
  align-items: center;
  background: #eef3ef;
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  min-height: 32px;
  padding: 0 10px;
  text-decoration: none;
}

.button-link:hover {
  background: #dfe8e2;
}

audio {
  width: 220px;
}

.live-audio-page {
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 230, 255, 0.18), transparent 28rem),
    radial-gradient(circle at 82% 72%, rgba(95, 240, 200, 0.14), transparent 30rem),
    #020711;
  color: #f6fbff;
  min-height: 100vh;
}

.live-audio-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 28px;
}

.live-audio-panel {
  background: linear-gradient(180deg, rgba(7, 18, 38, 0.88), rgba(2, 7, 17, 0.94));
  border: 1px solid rgba(99, 230, 255, 0.24);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.46), 0 0 52px rgba(13, 148, 238, 0.14);
  display: grid;
  gap: 16px;
  margin: auto;
  max-width: 520px;
  padding: 28px;
  width: min(100%, 520px);
}

.live-audio-panel h1 {
  color: #f6fbff;
  margin: 0;
}

.live-audio-panel .muted-text {
  color: #a9bdd4;
}

.live-meter {
  align-items: end;
  display: flex;
  gap: 7px;
  height: 70px;
  justify-content: center;
}

.live-meter span {
  animation: liveMeter 1.15s ease-in-out infinite;
  background: linear-gradient(180deg, #63e6ff, #19aaff);
  border-radius: 999px;
  box-shadow: 0 0 18px rgba(99, 230, 255, 0.36);
  display: block;
  height: 32px;
  width: 8px;
}

.live-meter span:nth-child(2) { animation-delay: 0.12s; height: 48px; }
.live-meter span:nth-child(3) { animation-delay: 0.24s; height: 64px; }
.live-meter span:nth-child(4) { animation-delay: 0.36s; height: 48px; }
.live-meter span:nth-child(5) { animation-delay: 0.48s; height: 32px; }

@keyframes liveMeter {
  0%, 100% { transform: scaleY(0.62); opacity: 0.72; }
  50% { transform: scaleY(1); opacity: 1; }
}

@keyframes portalNetworkDrift {
  0% {
    background-position: 0 0, 0 0, 0 0;
  }
  100% {
    background-position: 420px 0, -520px 300px, 560px -320px;
  }
}

@keyframes portalSignalSweep {
  0% {
    transform: translateX(-8%) translateY(-3%);
    opacity: 0.46;
  }
  50% {
    opacity: 0.86;
  }
  100% {
    transform: translateX(8%) translateY(3%);
    opacity: 0.46;
  }
}

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

  .sidebar {
    position: static;
  }

  .stats,
  .grid.two,
  .map-layout,
  .track-builder,
  .signage-editor-tools,
  .form-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

  .user-edit {
    grid-template-columns: 1fr;
  }

  .billing-request-grid {
    grid-template-columns: 1fr;
  }

  .billing-form-grid {
    grid-template-columns: 1fr;
  }
}
