:root {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f7fb;
  --bg-tint: #f0edff;
  --panel: #ffffff;
  --panel-soft: #f8f7ff;
  --ink: #15122f;
  --ink-strong: #090721;
  --muted: #6f7183;
  --line: #e2e6ef;
  --line-strong: #cad0df;
  --violet: #5538d8;
  --violet-deep: #2f197e;
  --blue: #2363d8;
  --green: #22a95a;
  --green-soft: #eaf8ef;
  --danger: #c83d4c;
  --danger-soft: #fff0f2;
  --shadow: 0 18px 48px rgba(39, 44, 74, .10);
  --shadow-soft: 0 10px 26px rgba(39, 44, 74, .08);
  --radius: 8px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0;
  overflow-x: hidden;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    linear-gradient(135deg, rgba(85, 56, 216, .08), transparent 34rem),
    linear-gradient(180deg, #fff 0, var(--bg) 340px);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button { border: 0; }
img { max-width: 100%; }
svg { width: 18px; height: 18px; fill: currentColor; flex: 0 0 auto; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid rgba(202, 208, 223, .72);
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(246,246,255,.92));
}

.logo {
  display: inline-flex;
  align-items: center;
  width: fit-content;
}

.logo img {
  display: block;
  width: 166px;
  max-width: 100%;
  height: auto;
}

.sidebar .logo {
  width: 100%;
  padding: 0 10px 26px;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: #33286f;
  font-weight: 800;
  transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.nav-link:hover {
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  box-shadow: 0 14px 28px rgba(85, 56, 216, .22);
}

.main { min-width: 0; }

.topbar {
  min-height: 76px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 32px;
  border-bottom: 1px solid rgba(202, 208, 223, .78);
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(18px);
}

.topbar strong {
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 850;
}

.topbar > div:last-child {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
}

.mobile-brand { display: none; }
.content { padding: 34px 32px 60px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1, h2, h3 { margin: 0; color: var(--ink-strong); letter-spacing: 0; }
h1 { font-size: clamp(34px, 4vw, 52px); line-height: 1.02; }
h2 { font-size: 22px; line-height: 1.18; }
h3 { font-size: 15px; line-height: 1.2; }
p { margin: 10px 0 0; color: var(--muted); line-height: 1.62; }
.muted { color: var(--muted); }

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: middle;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  box-shadow: 0 15px 30px rgba(55, 62, 180, .24);
}
.btn.secondary { color: var(--violet); background: #f0edff; }
.btn.danger, .danger-link { color: var(--danger); background: var(--danger-soft); }
.btn.small { min-height: 32px; padding: 7px 10px; font-size: 13px; line-height: 1.15; }
.btn.full { width: 100%; }
.button-row, .row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions form,
.button-row form,
.file-row form,
.map-list-item form,
.hotspot-row form,
.recipient-actions form,
.recipient-panel-head form {
  display: inline-flex;
  margin: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.metric, .panel {
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(202, 208, 223, .78);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.metric {
  min-height: 116px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--violet), var(--green));
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 12px;
  color: var(--ink-strong);
  font-size: 36px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.panel { padding: 22px; }
.panel,
.metric,
.viewer-video-card,
.public-resources,
.public-map-section {
  min-width: 0;
}
.panel-head, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head a {
  color: var(--violet);
  font-weight: 850;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .65fr);
  gap: 18px;
}

.accent-panel {
  color: #fff;
  background:
    linear-gradient(135deg, rgba(31, 23, 93, .96), rgba(42, 91, 198, .92));
  border-color: rgba(255,255,255,.16);
}
.accent-panel h2 { color: #fff; }
.accent-panel p { color: rgba(255,255,255,.76); }
.mini-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 22px;
}
.mini-flow span {
  padding: 10px 8px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-sm);
  text-align: center;
  color: rgba(255,255,255,.86);
  font-size: 12px;
  font-weight: 850;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(290px, .58fr) minmax(0, 1.42fr);
  gap: 18px;
  align-items: start;
}
.two-column.wide-left { grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); }
.two-column.wide-right { grid-template-columns: minmax(360px, .75fr) minmax(0, 1.25fr); }
.form-panel { position: sticky; top: 96px; }

.form-row {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid .form-row {
  margin-bottom: 0;
}

label {
  color: #293154;
  font-weight: 820;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid #cfd6e5;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(85, 56, 216, .12);
}
input:disabled {
  color: var(--muted);
  background: #f1f4f9;
  cursor: not-allowed;
}

.helper-text {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.file-picker {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 8px;
  border: 1px solid #cfd6e5;
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
}
.file-picker:focus-within {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(85, 56, 216, .12);
}
.file-picker input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 100%;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}
.file-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--violet);
  background: #f0edff;
  font-weight: 850;
  line-height: 1.15;
}
.file-picker-name {
  min-width: 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-row, .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 48px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  line-height: 1.25;
}

.toggle-row input, .check-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--violet);
}
.toggle-row span,
.check-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.check-row {
  align-items: flex-start;
  cursor: pointer;
}
.check-row span { display: grid; gap: 3px; }
.check-row small {
  color: var(--muted);
  font-size: 12px;
}
.check-stack {
  max-height: 520px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}
.check-group-title {
  margin: 12px 0 3px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.access-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
  gap: 16px;
  margin: 14px 0 18px;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
#links-table {
  min-width: 0;
}
#links-table tr:first-child {
  display: none;
}
#links-table tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 14px 6px;
  border-bottom: 1px solid var(--line);
}
#links-table tr:last-child {
  border-bottom: 0;
}
#links-table td {
  border-bottom: 0;
  padding: 0;
}
#links-table td:nth-child(2),
#links-table td:nth-child(3) {
  align-self: center;
}
#links-table td:nth-child(4) {
  display: none;
}
#links-table td:nth-child(5) {
  grid-column: 1 / -1;
}
#links-table .row-actions {
  justify-content: flex-start;
}
th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--violet);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
}
td strong { display: block; color: var(--ink-strong); }
td small {
  display: block;
  max-width: 52ch;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}
tr:last-child td { border-bottom: 0; }
tr[hidden] { display: none; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}
.status.success { color: #14753d; background: var(--green-soft); }
.status.muted { color: #6d7280; background: #eef1f6; }
.status.error { color: var(--danger); background: var(--danger-soft); }

.notice {
  margin-bottom: 18px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}
.notice.success { color: #116935; background: var(--green-soft); border-color: #c3ecd0; }
.notice.error { color: var(--danger); background: var(--danger-soft); border-color: #ffd1d8; }

.attachment-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.file-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.file-row > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-row strong {
  display: block;
  overflow-wrap: anywhere;
}
.file-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.copy-box {
  margin: 14px 0 18px;
  padding: 14px;
  border: 1px solid rgba(85, 56, 216, .20);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.copy-box label {
  display: block;
  margin-bottom: 8px;
}
.copy-box > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}
.copy-box input {
  min-width: 0;
}

.editor-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7f8fc;
}
.editor-tab {
  min-height: 36px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: #373660;
  background: transparent;
  cursor: pointer;
  font-weight: 850;
  line-height: 1.15;
}
.editor-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  box-shadow: 0 10px 20px rgba(55, 62, 180, .18);
}
.editor-tab-panel {
  margin-top: 4px;
}
.editor-save-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.preset-tools {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.access-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}
.email-template-textarea {
  min-height: 180px;
}
.compact-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.compact-metrics > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.compact-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.compact-metrics strong {
  display: block;
  margin-top: 6px;
  color: var(--ink-strong);
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.stat-list {
  display: grid;
  gap: 8px;
}
.stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.stat-row strong,
.stat-row small {
  min-width: 0;
  overflow-wrap: anywhere;
}
.stat-row span {
  color: var(--violet);
  font-weight: 850;
}
.stat-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.expiry-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.recipient-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.recipient-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}
.recipient-add-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.recipient-add-form .btn {
  justify-self: start;
}
.recipient-add-form .form-row {
  margin-bottom: 0;
}
.recipient-add-form textarea {
  min-height: 78px;
}
.recipient-list {
  display: grid;
  gap: 8px;
}
.recipient-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.recipient-row strong,
.recipient-row small {
  display: block;
  overflow-wrap: anywhere;
}
.recipient-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.recipient-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  min-width: max-content;
}
.recipient-empty-action {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  max-width: 290px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: #eef1f6;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.maps-grid {
  display: grid;
  grid-template-columns: 320px 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.map-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}
.map-list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.map-list-item.active {
  border-color: rgba(85, 56, 216, .44);
  background: var(--panel-soft);
}
.map-list-item strong,
.map-list-item small {
  display: block;
}
.map-list-item small { color: var(--muted); margin-top: 2px; }

.hotspot-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.map-canvas {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #0d1328;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.map-canvas img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  border: 2px solid #25d366;
  border-radius: 5px;
  background: rgba(34, 169, 90, .18);
  box-shadow: 0 0 0 2px rgba(255,255,255,.88), 0 10px 26px rgba(4, 20, 40, .24);
}
.hotspot-draft {
  z-index: 8;
  border-color: #48ff92;
  background: rgba(34, 169, 90, .24);
  cursor: move;
  touch-action: none;
}
.is-hotspot-editing,
.is-hotspot-editing * {
  cursor: grabbing;
}
.hotspot-draft::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 5px 8px;
  border-radius: 5px;
  color: #071022;
  background: rgba(255,255,255,.88);
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
  white-space: nowrap;
}
.resize-handle {
  position: absolute;
  z-index: 9;
  display: block;
  background: #fff;
  border: 2px solid #22a95a;
  box-shadow: 0 4px 12px rgba(4, 20, 40, .22);
}
.handle-n,
.handle-s {
  left: 50%;
  width: 38px;
  height: 10px;
  margin-left: -19px;
  cursor: ns-resize;
}
.handle-n { top: -7px; }
.handle-s { bottom: -7px; }
.handle-e,
.handle-w {
  top: 50%;
  width: 10px;
  height: 38px;
  margin-top: -19px;
  cursor: ew-resize;
}
.handle-e { right: -7px; }
.handle-w { left: -7px; }
.public-hotspot {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: 38px;
  min-height: 32px;
  border-color: rgba(85, 56, 216, .58);
  background: rgba(255,255,255,.018);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.72),
    0 0 0 1px rgba(85, 56, 216, .18),
    0 10px 28px rgba(8, 20, 50, .10);
  outline: 1px solid rgba(12, 22, 48, .12);
  outline-offset: 2px;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.public-hotspot:hover {
  transform: scale(1.02);
  border-color: rgba(85, 56, 216, .96);
  background: rgba(255,255,255,.10);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.92),
    0 14px 34px rgba(8, 20, 50, .18),
    0 0 0 4px rgba(85, 56, 216, .14);
}
.public-hotspot span {
  position: relative;
  transform: translateY(calc(-100% - 6px));
  display: grid;
  gap: 2px;
  max-width: 230px;
  padding: 7px 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  color: #fff;
  background: rgba(7, 11, 30, .90);
  box-shadow: 0 10px 24px rgba(7, 11, 30, .18);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.public-hotspot span strong,
.public-hotspot span small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.public-hotspot span small {
  color: rgba(255,255,255,.72);
  font-size: 11px;
  font-weight: 700;
}
.public-hotspot span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(7, 11, 30, .90);
}
.hotspot-form {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.coordinate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.hotspot-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}
.hotspot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.hotspot-row strong,
.hotspot-row small {
  display: block;
}
.hotspot-row small { color: var(--muted); margin-top: 2px; }
.existing-hotspot {
  cursor: pointer;
}
.existing-hotspot.is-selected {
  border-color: #fff;
  background: rgba(85, 56, 216, .20);
  box-shadow: 0 0 0 3px rgba(85, 56, 216, .86), 0 12px 30px rgba(4, 20, 40, .26);
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(14, 22, 68, .94), rgba(50, 86, 189, .88)),
    #101a44;
}
.auth-card, .start-panel {
  width: min(480px, 100%);
  padding: 34px;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: var(--radius);
  background: rgba(255,255,255,.96);
  box-shadow: 0 28px 80px rgba(9, 16, 48, .30);
}
.auth-card h1, .start-panel h1 {
  margin-top: 28px;
}
.auth-card .logo img, .start-panel .logo img { width: 180px; }

.public-start {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.start-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.viewer-page {
  background: #f5f7fb;
}
.viewer-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.viewer-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(18px);
}
.viewer-header div {
  display: grid;
  justify-items: end;
  gap: 3px;
}
.viewer-header strong {
  color: var(--ink-strong);
  font-weight: 900;
}
.viewer-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.viewer-main {
  width: min(1460px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
  padding: 26px;
}
.viewer-sidebar,
.viewer-content {
  min-width: 0;
}
.viewer-sidebar {
  align-self: start;
  position: sticky;
  top: 96px;
  display: grid;
  gap: 14px;
}
.public-topic {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.public-topic h3 {
  margin-bottom: 11px;
}
.public-video-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.public-video-link + .public-video-link { margin-top: 6px; }
.public-video-link svg {
  margin-top: 2px;
  color: var(--violet);
}
.public-video-link strong,
.public-video-link small {
  display: block;
}
.public-video-link small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}
.public-video-link.active {
  border-color: rgba(85, 56, 216, .28);
  background: var(--panel-soft);
}
.viewer-content {
  display: grid;
  gap: 20px;
}
.viewer-video-card, .public-resources, .public-map-section {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}
.video-frame {
  overflow: hidden;
  border-radius: var(--radius);
  background: #071022;
  aspect-ratio: 16 / 9;
}
.video-frame iframe,
.video-frame video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.video-empty {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  text-align: center;
}
.video-meta {
  margin-top: 18px;
}
.video-meta span {
  color: var(--violet);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.video-meta h1 {
  margin-top: 6px;
  font-size: clamp(28px, 4vw, 44px);
}
.public-resources {
  display: grid;
  gap: 10px;
}
.resource-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}
.resource-link strong,
.resource-link small {
  display: block;
}
.resource-link small {
  margin-top: 3px;
  color: var(--muted);
}
.map-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.map-tab {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--violet);
  background: #fff;
  font-weight: 850;
}
.map-tab.active {
  color: #fff;
  background: var(--violet);
  border-color: var(--violet);
}
.public-map {
  margin-top: 16px;
}

@media (max-width: 1220px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .two-column, .two-column.wide-left, .two-column.wide-right, .maps-grid {
    grid-template-columns: 1fr;
  }
  .form-panel { position: static; }
  .maps-grid .map-editor-panel { order: 3; }
}

@media (max-width: 1080px) {
  .two-column.wide-right,
  .two-column.wide-left,
  .dashboard-grid,
  .maps-grid {
    gap: 14px;
  }
  .access-toolbar,
  .preset-tools {
    grid-template-columns: 1fr;
  }
  .inline-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .logo { display: none; }
  .sidebar nav {
    display: flex;
    gap: 8px;
  }
  .nav-link {
    white-space: nowrap;
    min-height: 38px;
    padding: 9px 11px;
  }
  .topbar {
    position: relative;
    padding: 14px 18px;
    flex-wrap: wrap;
  }
  .topbar > div:last-child {
    justify-content: flex-start;
  }
  .mobile-brand { display: inline-flex; }
  .mobile-brand img { width: 134px; }
  .content { padding: 24px 16px 44px; }
  .page-head, .panel-head, .section-head { flex-direction: column; align-items: flex-start; }
  .recipient-panel-head {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }
  .form-grid, .access-grid, .hotspot-layout, .viewer-main {
    grid-template-columns: 1fr;
  }
  .recipient-add-form,
  .recipient-row {
    grid-template-columns: 1fr;
  }
  .recipient-actions {
    justify-content: flex-start;
  }
  .viewer-sidebar { position: static; }
  .viewer-header {
    padding: 16px;
    flex-direction: column;
    align-items: flex-start;
  }
  .viewer-header div { justify-items: start; }
  .viewer-main { padding: 16px; }
}

@media (max-width: 720px) {
  .table-wrap {
    overflow: visible;
  }
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .table-wrap tr:first-child {
    display: none !important;
  }
  .table-wrap tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
  }
  .table-wrap td {
    padding: 0;
    border-bottom: 0;
  }
  .table-wrap td + td {
    margin-top: 8px;
  }
  .table-wrap td:empty {
    display: none;
  }
  #links-table tr {
    grid-template-columns: 1fr;
  }
  #links-table td:nth-child(2),
  #links-table td:nth-child(3),
  #links-table td:nth-child(5) {
    display: block;
  }
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .content { padding: 20px 12px 38px; }
  h1 { font-size: clamp(30px, 10vw, 40px); }
  .panel, .viewer-video-card, .public-resources, .public-map-section { padding: 16px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .btn { width: 100%; }
  .row-actions .btn,
  .button-row .btn,
  .copy-box .btn,
  .recipient-actions .btn,
  .recipient-panel-head .btn,
  .start-actions .btn { width: auto; }
  .copy-box > div { grid-template-columns: 1fr; }
  .editor-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .editor-tab {
    width: 100%;
  }
  .access-toolbar .button-row,
  .editor-save-row {
    align-items: stretch;
  }
  .access-toolbar .button-row .btn,
  .editor-save-row .btn {
    width: 100%;
  }
  .file-picker { grid-template-columns: 1fr; }
  .file-picker-button { justify-self: start; }
  .metric { min-height: 98px; }
  .metric strong { font-size: 32px; }
  table { min-width: 0; }
  input, select, textarea { font-size: 16px; }
  .hotspot-row, .file-row, .map-list-item {
    align-items: flex-start;
    flex-direction: column;
    display: flex;
  }
  .map-tabs {
    justify-content: flex-start;
  }
  .public-hotspot span {
    max-width: min(220px, 76vw);
  }
  .compact-metrics {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .content,
  .viewer-main {
    padding-left: 10px;
    padding-right: 10px;
  }
  .panel,
  .viewer-video-card,
  .public-resources,
  .public-map-section,
  .auth-card,
  .start-panel {
    padding: 14px;
  }
  .editor-tabs {
    grid-template-columns: 1fr;
  }
  .coordinate-grid {
    grid-template-columns: 1fr;
  }
  .mini-flow {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
