:root {
  --accent: #4f7cff;
  --accent-dark: #3a63e0;
  --text: #1b2330;
  --muted: #707b8c;
  --border: #e4e8ef;
  --field-bg: #f7f9fc;
  --ok: #138a52;
  --err: #d23b3b;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win, even over class rules that set
   `display` (e.g. .fixed-note { display: flex }), otherwise JS toggling
   `element.hidden` has no visible effect. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #5b6cf0 0%, #7d4fe0 50%, #9b3fd1 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 20px;
}
.page.wide {
  max-width: 1480px;
}

/* ---- Menu / hub page ---- */
.menu-page {
  max-width: 720px;
}
.menu {
  padding: 22px 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.menu-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
a.menu-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px -14px rgba(79, 90, 224, 0.55);
}
a.menu-card:active {
  transform: translateY(1px);
}
.menu-card.disabled {
  opacity: 0.6;
  background: var(--field-bg);
  cursor: not-allowed;
}
.menu-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  color: #fff;
}
.menu-icon-blue { background: linear-gradient(120deg, #4f7cff, #7d4fe0); }
.menu-icon-green { background: #29c285; }
.menu-icon-amber { background: #f5a623; }
.menu-icon-red { background: #ec5b5b; }
.menu-text {
  flex: 1;
  min-width: 0;
}
.menu-text h3 {
  margin: 0 0 3px;
  font-size: 15.5px;
  font-weight: 600;
}
.menu-text p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.menu-arrow {
  flex: none;
  color: var(--muted);
}
.menu-soon {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- Customer portal ---- */
.hero-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.hero-user {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.hero-right .logout-btn {
  margin-left: 0;
}
.card-meta {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}
.card-meta b {
  color: #36404f;
  font-weight: 600;
}
.cust-pad {
  padding: 16px 32px 32px;
}
.staff-search {
  margin-bottom: 16px;
}
.staff-search select {
  width: auto;
  flex: none;
}
.staff-search .row input {
  flex: 1;
}
.cust-pad .menu {
  padding: 6px 0 0;
}
#detail-map {
  height: 360px;
  width: 100%;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  z-index: 0;
}
.detail-media {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 12px;
}
.detail-image {
  width: auto;
  height: auto;
  max-width: 280px;
  max-height: 220px;
  display: block;
}
.detail-qr {
  text-align: center;
}
.detail-qr img {
  width: 150px;
  height: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: block;
}
.detail-qr-tag {
  margin-top: 6px;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 12.5px;
  font-weight: 600;
}
.info-table th {
  width: 200px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: #36404f;
  background: #f3f6fc;
  vertical-align: top;
}
.info-table td {
  vertical-align: top;
}

/* ---- Login page ---- */
.login-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 8vh 20px 48px;
}
.login-card form {
  padding: 8px 32px 28px;
}
.login-card #login-btn {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 15px;
  background: linear-gradient(120deg, #4f7cff, #7d4fe0);
}

/* Top-right logout button in the app hero. */
.logout-btn {
  margin-left: 10px;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 7px 12px;
  font-size: 12.5px;
}
.logout-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 60px -20px rgba(40, 30, 90, 0.45),
    0 8px 24px -12px rgba(40, 30, 90, 0.3);
  overflow: hidden;
}

/* ---- Hero ---- */
.hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px 32px;
  background: linear-gradient(120deg, #3a63e0, #6a3fd1);
  color: #fff;
}
.hero-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  flex: none;
}
.back-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  flex: none;
  text-decoration: none;
  margin-right: 2px;
}
.back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}
.hero h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.hero .sub {
  margin: 3px 0 0;
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.82);
}
.hero-badges {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-snipe {
  background: #ffd24a;
  color: #5a4500;
}
.badge-map {
  background: #8be29a;
  color: #0c3d18;
}

/* ---- Form ---- */
form {
  padding: 8px 32px 32px;
}
#lookup-form {
  padding-bottom: 0;
}

.section {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
form:last-of-type .section:last-of-type {
  border-bottom: none;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
}
.doc-btn {
  margin-left: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.dot-blue { background: #4f7cff; }
.dot-green { background: #29c285; }
.dot-amber { background: #f5a623; }
.dot-purple { background: #8b5cf6; }
.dot-teal { background: #2fd3c5; }
.dot-red { background: #ec5b5b; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.full {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  font-weight: 600;
  color: #36404f;
  gap: 6px;
}

input,
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-weight: 400;
  font-family: inherit;
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--field-bg);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder {
  color: #aab2c0;
}
input:focus,
select:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(79, 124, 255, 0.14);
}
input:disabled {
  color: var(--muted);
  background: #eef1f6;
  cursor: not-allowed;
}

.field-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
}

.fixed-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 10px;
  background: #fff6e8;
  border: 1px solid #ffe0b0;
  color: #8a5a00;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 14px;
}
.fixed-note svg {
  flex: none;
}
.fixed-note b {
  color: #6b4500;
}
.fixed-note.danger {
  background: #fdecec;
  border-color: #f6cccc;
  color: var(--err);
}
.fixed-note.danger b {
  color: #a01b1b;
}

.danger-btn {
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  font-size: 15px;
  background: var(--err);
}
.danger-btn:hover {
  background: #b62b2b;
}

.row {
  display: flex;
  gap: 10px;
}
.row input {
  flex: 1;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  background: var(--accent);
  padding: 11px 16px;
  transition: background 0.15s, transform 0.05s;
}
button:hover {
  background: var(--accent-dark);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.55;
  cursor: default;
}
button.secondary {
  background: #fff;
  color: #36404f;
  border: 1.5px solid var(--border);
}
button.secondary:hover {
  background: #f1f4f9;
}

#save-btn {
  width: 100%;
  margin-top: 26px;
  padding: 15px;
  font-size: 15px;
  background: linear-gradient(120deg, #4f7cff, #7d4fe0);
  box-shadow: 0 12px 24px -10px rgba(79, 90, 224, 0.7);
}
#save-btn:hover {
  filter: brightness(1.05);
  background: linear-gradient(120deg, #4f7cff, #7d4fe0);
}

/* ---- Status ---- */
.status {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.status.pending {
  background: #eef3ff;
  border-color: #d4e0ff;
  color: var(--accent-dark);
}
.status.ok {
  background: #e7f7ee;
  border-color: #c2ecd3;
  color: var(--ok);
}
.status.error {
  background: #fdecec;
  border-color: #f6cccc;
  color: var(--err);
}

.footer {
  text-align: center;
  margin: 22px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.75);
}
.footer-link {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.footer-link:hover {
  text-decoration: underline;
}

/* ---- Map ---- */
#map,
#cam-map {
  height: 340px;
  width: 100%;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  overflow: hidden;
  z-index: 0;
}
#cam-map {
  height: 460px;
}

/* Camera markers on the snapshot map: a red dot with a text label beside it. */
.cam-marker {
  position: relative;
}
.cam-dot {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e3242b;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.4);
  cursor: grab;
}
.cam-marker:active .cam-dot {
  cursor: grabbing;
}
/* A device with no saved position yet is faded + dashed until dragged (saved). */
.cam-dot-unsaved {
  opacity: 0.5;
  border-style: dashed;
}

.cam-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.cam-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cam-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.cam-label {
  position: absolute;
  left: 12px;
  top: -2px;
  white-space: nowrap;
  font: 600 9.5px/1.1 "Inter", sans-serif;
  color: #c81e1e;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 2px #fff;
  pointer-events: none;
}

/* The NVR location marker — a red dot drawn in CSS (no external image). */
.nvr-dot {
  background: #ec5b5b;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(236, 91, 91, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: grab;
}
.nvr-dot:active {
  cursor: grabbing;
}

.loc-actions {
  display: flex;
  gap: 10px;
}

.addr-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  font-weight: 400;
  max-height: 220px;
  overflow-y: auto;
}
.addr-results li {
  padding: 9px 13px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.addr-results li:last-child {
  border-bottom: none;
}
.addr-results li:hover {
  background: var(--field-bg);
}
.addr-results li.addr-empty {
  color: var(--muted);
  cursor: default;
}
.addr-results li.addr-empty:hover {
  background: #fff;
}

/* ---- Sub-assets ---- */
.children-wrap {
  overflow-x: auto;
}
.children-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.children-table th,
.children-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.children-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
}
.children-table td {
  font-weight: 500;
  color: #36404f;
}
.children-table tbody tr:hover {
  background: var(--field-bg);
}
.children-empty {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.children-table td.child-pw {
  white-space: normal;
}
.children-table td.vault-user {
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 12.5px;
}
.child-pw .pw-show,
.child-pw .bc-show {
  background: #fff;
  color: var(--muted);
  border: 1.5px solid var(--border);
  padding: 5px 8px;
}
.child-pw .pw-show:hover,
.child-pw .bc-show:hover {
  background: var(--field-bg);
  color: var(--text);
}
.child-pw .bc-show {
  margin-left: 5px;
}
.child-pw .pw-text {
  display: inline-block;
  margin-left: 6px;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}
.children-table td.child-action {
  text-align: right;
  padding: 4px 8px;
}
.child-action {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.child-edit {
  background: #fff;
  color: var(--accent-dark);
  border: 1.5px solid #cfe0ff;
  padding: 6px 9px;
}
.child-edit:hover {
  background: #eef3ff;
  color: var(--accent-dark);
}
.child-del {
  background: #fff;
  color: var(--err);
  border: 1.5px solid #f3d0d0;
  padding: 6px 9px;
}
.child-del:hover {
  background: #fdecec;
  color: var(--err);
}

input[readonly] {
  background: #eef1f6;
  color: var(--muted);
  cursor: not-allowed;
}

input[type="file"] {
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
}

/* Asset / sub-asset images. */
.asset-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--field-bg);
  vertical-align: middle;
  cursor: zoom-in;
}

/* Modal popup (sub-asset full info). */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 16, 40, 0.55);
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 30px 60px -20px rgba(40, 30, 90, 0.5);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  padding: 20px 24px 24px;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  word-break: break-all;
}
.modal-close {
  margin-left: auto;
  background: var(--field-bg);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 4px 11px;
  border-radius: 8px;
}
.modal-close:hover {
  background: #e7ebf2;
  color: var(--text);
}

/* Full-size image overlay. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
}
.lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.barcode-card {
  background: #fff;
  padding: 24px 28px;
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  max-width: 95vw;
  overflow: auto;
}
.barcode-card svg {
  max-width: 100%;
}
#f-image {
  width: 84px;
  height: 84px;
}
.image-row {
  align-items: center;
}
.image-row input[type="file"] {
  flex: 1;
}
.child-img {
  white-space: nowrap;
}
.child-img .no-img {
  display: inline-block;
  width: 44px;
  text-align: center;
  color: var(--muted);
}
.child-img-btn {
  padding: 5px 8px;
  margin-left: 6px;
  vertical-align: middle;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: #36404f;
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover {
  background: #232a35;
}

.subadd {
  margin-top: 18px;
  padding: 18px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  background: var(--field-bg);
}
.subadd-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: #36404f;
}

/* Radio custom fields (e.g. Bredband on a Router). */
.radio-group {
  font-weight: 600;
}
.radio-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 400;
}
.radio-row input {
  width: auto;
}
label.inline {
  font-weight: 400;
  flex-direction: row;
}
#sub-add-btn {
  margin-top: 14px;
}

@media (max-width: 560px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .hero {
    flex-wrap: wrap;
  }
  .hero-badges {
    flex-direction: row;
    margin-left: 0;
    width: 100%;
  }
}
