: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-logo.svg") 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-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(6, minmax(120px, 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;
}

.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;
}

.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;
}

.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-edit {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(130px, 1fr) minmax(160px, 1.2fr) minmax(120px, 0.8fr) minmax(110px, 0.7fr) minmax(130px, 0.9fr) minmax(130px, 1fr) auto;
  padding: 10px;
}

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

audio {
  width: 220px;
}

@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 {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 18px;
  }

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