/* Admin portal (cameras.2kpawresort.com). Builds on cameras.css tokens and fonts.
   Phone-first: staff often work from phones at the front desk. */

.admin .admin-bar { padding-bottom: 0; }

.admin .admin-bar > .wrap {
  justify-content: space-between;
  padding-bottom: 9px;
}

.link-button {
  border: 0;
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 10px 0;
}

.admin-nav {
  background: var(--deep-pine);
}

.admin-nav .wrap {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-nav a {
  flex: none;
  padding: 12px 12px;
  color: rgba(249, 241, 230, 0.78);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}

.admin-nav a[aria-current="page"] {
  color: var(--cream);
  border-bottom-color: var(--gold);
}

.admin-nav a:focus-visible,
.link-button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

.admin-main { padding-top: 16px; padding-bottom: 24px; }

.admin-footer {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 13px;
}

/* ---- cards and type ------------------------------------------------------- */

.card {
  margin-bottom: 16px;
  padding: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.card h1,
.card h2 {
  margin: 4px 0 14px;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  line-height: 1.15;
}

.card h1 { font-size: 1.7rem; }
.card h2 { font-size: 1.3rem; }

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

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(49, 83, 66, 0.08);
  font-size: 0.9em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
}

.flash.ok { background: rgba(49, 83, 66, 0.12); color: var(--heading); }
.flash.error { background: #f6e1dc; color: #7a2716; }

@media (prefers-color-scheme: dark) {
  .flash.error { background: #4a2a22; color: #f6d8cf; }
  code { background: rgba(249, 241, 230, 0.1); }
}

/* ---- forms -------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .wide { grid-column: 1 / -1; }
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--heading);
  font-size: 14px;
  font-weight: 700;
}

.field input,
.field select,
.move-form select,
.link-field {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid rgba(49, 83, 66, 0.35);
  border-radius: 10px;
  background: var(--white);
  color: var(--cocoa);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming into fields */
}

@media (prefers-color-scheme: dark) {
  .field input,
  .field select,
  .move-form select,
  .link-field {
    background: var(--deep-pine);
    color: var(--cream);
    border-color: rgba(249, 241, 230, 0.35);
  }
}

.field input:focus,
.field select:focus,
.move-form select:focus {
  outline: 2px solid var(--heading);
  outline-offset: 1px;
}

.field.check label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 600;
}

.field.check input { width: 22px; min-height: 22px; margin-top: 2px; }

/* ---- sign-in page: brand panel + form; split screen on desktop ---------------- */

.signin-page { min-height: 100vh; min-height: 100dvh; }

.signin-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.signin-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(28px, env(safe-area-inset-top)) 24px 24px;
  background: var(--pine);
  color: var(--cream);
  text-align: center;
}

.signin-brand-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signin-brand .emblem { width: 72px; }

.signin-product {
  margin: 10px 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.1;
}

/* Tagline and place line are for the roomy desktop panel only. */
.signin-tagline,
.signin-place { display: none; }

.signin-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px max(32px, env(safe-area-inset-bottom));
}

.signin-form {
  width: 100%;
  max-width: 400px;
}

.signin-form h1 {
  margin: 6px 0 0;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 2.25rem;
  line-height: 1.1;
}

.signin-lead {
  margin: 8px 0 24px;
  color: var(--text);
}

.signin-form .flash { margin-bottom: 16px; }

/* Google's sign-in button (branding guidelines): white fill, #747775 outline, #1F1F1F text,
   standard multi-colour "G". Same look on light and dark pages. */
.google-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid #747775;
  border-radius: 999px;
  background: #ffffff;
  color: #1f1f1f;
  font-family: Roboto, "Google Sans", Arial, sans-serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: 0.25px;
  text-decoration: none;
  transition: background-color 0.15s, box-shadow 0.15s;
}

.google-button:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
}

.google-button:focus-visible {
  outline: 2px solid var(--heading);
  outline-offset: 3px;
}

.google-g { width: 20px; height: 20px; flex: none; }

.signin-help {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.dev-signin { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--rule); }
.dev-signin .button { margin-top: 12px; }

/* Desktop: Pine brand half on the left, form centred on the right. */
@media (min-width: 900px) {
  .signin-layout { flex-direction: row; }

  .signin-brand {
    flex: 0 0 46%;
    justify-content: space-between;
    padding: 48px;
  }

  .signin-brand-inner { margin: auto 0; }
  .signin-brand .emblem { width: 160px; }
  .signin-product { margin-top: 20px; font-size: 2.6rem; }

  .signin-tagline {
    display: block;
    margin: 14px 0 0;
    font-family: var(--display);
    font-style: italic;
    font-weight: 400;
    font-size: 36px; /* Brand Book: tagline at least 24 px cap height */
    line-height: 1.05;
    opacity: 0.92;
  }

  .signin-place {
    display: block;
    margin: 0;
    font-size: 13px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.7;
  }

  .signin-main { align-items: center; padding: 48px; }
}

/* ---- small buttons ------------------------------------------------------- */

.button.small-secondary,
.button.small-danger {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 14px;
}

.button.small-secondary {
  background: transparent;
  color: var(--heading);
  box-shadow: inset 0 0 0 1.5px var(--heading);
}

.button.small-danger {
  background: transparent;
  color: #9a2f19;
  box-shadow: inset 0 0 0 1.5px #9a2f19;
}

@media (prefers-color-scheme: dark) {
  .button.small-danger { color: #f0a08c; box-shadow: inset 0 0 0 1.5px #f0a08c; }
}

.button.whatsapp { background: #1f6f4a; color: var(--white); }

.button .icon { width: 18px; height: 18px; }

/* ---- links list -------------------------------------------------------- */

.link-list,
.staff-list,
.history,
.status-grid {
  margin: 0;
  padding: 0;
  list-style: none;
}

.link-item,
.staff-list li {
  padding: 14px 0;
  border-top: 1px solid var(--rule);
}

.link-item:first-child,
.staff-list li:first-child { border-top: 0; }

.link-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.link-pet {
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.2rem;
  text-decoration: none;
}

.link-meta {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.link-actions form { margin: 0; }

.move-form { display: flex; gap: 8px; }
.move-form select { width: auto; min-height: 44px; font-size: 15px; }

.status-expired .link-pet,
.status-revoked .link-pet { color: var(--muted); }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.chip-active { background: rgba(49, 83, 66, 0.14); color: var(--heading); }
.chip-expired { background: rgba(77, 60, 46, 0.12); color: var(--muted); }
.chip-revoked { background: #f1ddd6; color: #8a2c17; }

@media (prefers-color-scheme: dark) {
  .chip-active { background: rgba(249, 241, 230, 0.16); }
  .chip-revoked { background: #4a2a22; color: #f6d8cf; }
}

.link-box { margin: 16px 0 4px; }
.link-field { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }

/* ---- tables ------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th {
  padding: 8px 10px 8px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table td {
  padding: 10px 10px 10px 0;
  border-top: 1px solid var(--rule);
  vertical-align: middle;
}

.table .actions { white-space: nowrap; text-align: right; }
.table .actions .button { margin-left: 4px; }
.table.compact td { padding: 6px 10px 6px 0; font-size: 14px; white-space: nowrap; }
.is-disabled td { color: var(--muted); }

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
}

.dot-on { background: #2f8a55; }
.dot-idle { background: var(--gold); }
.dot-off { background: rgba(77, 60, 46, 0.3); }

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.status-tile {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.status-tile .dot { margin-top: 6px; flex: none; }

.history li {
  padding: 8px 0;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}

.history .when { color: var(--muted); }
.history pre { white-space: pre-wrap; word-break: break-all; font-size: 12px; }

.nvr {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.nvr summary { cursor: pointer; padding: 4px 0; }
.nvr form { margin-top: 12px; }

/* Narrow screens: table rows become stacked cards (villas list). */
@media (max-width: 639px) {
  .table.cards thead { display: none; }
  .table.cards,
  .table.cards tbody,
  .table.cards tr { display: block; width: 100%; }
  .table.cards tr { padding: 12px 0; border-top: 1px solid var(--rule); }
  .table.cards tr:first-child { border-top: 0; }
  .table.cards td { display: block; padding: 2px 0; border: 0; }
  .table.cards td.num,
  .table.cards td.name { display: inline; font-size: 1.05rem; }
  .table.cards td.num::after { content: " ·"; }
  .table.cards td[data-label]::before {
    content: attr(data-label) "  ";
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
  .table.cards .actions { padding-top: 8px; text-align: left; }
  .table.cards .actions .button { margin: 0 6px 0 0; }
  .table-wrap:has(.cards) { overflow-x: visible; margin: 0; padding: 0; }
}

/* ---- NVR list: usage and delete ---------------------------------------- */

.nvr-usage {
  margin-left: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.nvr-villas { margin-top: 10px; }

.nvr-delete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.nvr-delete .hint { margin: 0; }

.button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- Links page: heading, tabs, search, empty state --------------------- */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.page-head h1 { margin: 0; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 -4px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--rule);
}

.tabs a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.tabs a[aria-current="page"] {
  color: var(--heading);
  border-bottom-color: var(--heading);
}

.tabs .count {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(49, 83, 66, 0.1);
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

.tabs a:focus-visible { outline: 2px solid var(--heading); outline-offset: -2px; }

.search {
  position: relative;
  margin-bottom: 8px;
}

.search input {
  width: 100%;
  min-height: 46px;
  padding: 10px 70px 10px 14px;
  border: 1.5px solid rgba(49, 83, 66, 0.3);
  border-radius: 999px;
  background: var(--white);
  color: var(--cocoa);
  font: inherit;
  font-size: 16px;
}

.search input:focus { outline: 2px solid var(--heading); outline-offset: 1px; }

.search .clear {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: var(--heading);
  font-size: 14px;
  font-weight: 700;
}

.empty {
  padding: 28px 8px;
  color: var(--muted);
  text-align: center;
}

.empty p { margin: 0 0 12px; }

.chip-soon {
  margin-left: 6px;
  background: rgba(203, 152, 79, 0.18);
  color: #6b4a1c;
  letter-spacing: 0.02em;
  text-transform: none;
}

@media (prefers-color-scheme: dark) {
  .tabs .count { background: rgba(249, 241, 230, 0.14); }
  .search input { background: var(--deep-pine); color: var(--cream); border-color: rgba(249, 241, 230, 0.35); }
  .chip-soon { color: #f1d4a6; }
}

/* ---- Dialog: centred card on desktop, bottom sheet on phones ------------- */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(16, 27, 22, 0.35);
  overflow-y: auto;
}

.dialog::backdrop { background: rgba(16, 27, 22, 0.55); }

/* Padding lives on the form, so a click on the dialog element itself is always the backdrop. */
.dialog > form { padding: 20px; }

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-head h2 {
  margin: 0;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.4rem;
}

.icon-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--heading);
  cursor: pointer;
}

.icon-close:focus-visible { outline: 2px solid var(--heading); }

.dialog .flash { margin: 0; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

@media (max-width: 639px) {
  .dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }
  .dialog > form { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .dialog-actions .button { flex: 1; }
}

/* ===========================================================================
   Portal design v2 (2026-11-07): filled primary buttons, colour-coded actions,
   segmented filter, aligned link table. Scoped to .admin; parent pages unchanged.
   =========================================================================== */

.admin {
  --pine-08: rgba(49, 83, 66, 0.08);
  --pine-14: rgba(49, 83, 66, 0.14);
  --gold-18: rgba(203, 152, 79, 0.2);
  --gold-30: rgba(203, 152, 79, 0.32);
  --gold-ink: #5b3f17;
  --red: #9a2f19;
  --red-10: rgba(154, 47, 25, 0.1);
  --wa: #1f8f55;
  --wa-dark: #176b40;
  --shadow-card: 0 1px 2px rgba(36, 59, 48, 0.06), 0 6px 20px rgba(36, 59, 48, 0.06);
}

@media (prefers-color-scheme: dark) {
  .admin {
    --pine-08: rgba(249, 241, 230, 0.1);
    --pine-14: rgba(249, 241, 230, 0.16);
    --gold-18: rgba(203, 152, 79, 0.24);
    --gold-30: rgba(203, 152, 79, 0.36);
    --gold-ink: #f1d4a6;
    --red: #f0a08c;
    --red-10: rgba(240, 160, 140, 0.14);
  }
}

/* ---- buttons ------------------------------------------------------------- */

.admin .button {
  white-space: nowrap;
  transition: background-color 0.15s, box-shadow 0.15s, transform 0.08s;
}

.admin .button:active { transform: translateY(1px); }

/* Primary (a plain .button): filled Pine, raised, gold icon. */
.admin .button.primary {
  background: var(--pine);
  color: var(--cream);
  box-shadow: 0 2px 0 var(--deep-pine), 0 6px 16px rgba(36, 59, 48, 0.22);
}

.admin .button.primary:hover { background: var(--deep-pine); }
.admin .button.primary .icon { color: var(--gold); }

@media (prefers-color-scheme: dark) {
  .admin .button.primary {
    background: var(--cream);
    color: var(--pine);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35), 0 6px 16px rgba(0, 0, 0, 0.3);
  }
  .admin .button.primary:hover { background: #fffaf3; }
  .admin .button.primary .icon { color: var(--pine); }
}

/* Secondary / tonal: soft Pine fill, no outline. */
.admin .button.secondary,
.admin .button.small-secondary {
  background: var(--pine-08);
  color: var(--heading);
  box-shadow: none;
}

.admin .button.secondary:hover,
.admin .button.small-secondary:hover { background: var(--pine-14); }

.admin .button.small-danger {
  background: var(--red-10);
  color: var(--red);
  box-shadow: none;
}

/* Share on WhatsApp: the familiar green. */
.admin .button.share,
.admin .button.whatsapp {
  background: var(--wa);
  color: var(--white);
  box-shadow: 0 2px 0 var(--wa-dark), 0 4px 12px rgba(23, 107, 64, 0.22);
}

.admin .button.share:hover,
.admin .button.whatsapp:hover { background: var(--wa-dark); }

/* Gold tonal: time actions (+1 day). */
.admin .button.gold {
  background: var(--gold-18);
  color: var(--gold-ink);
  box-shadow: none;
}

.admin .button.gold:hover { background: var(--gold-30); }

.admin .button.sm {
  min-height: 38px;
  padding: 6px 13px;
  font-size: 14px;
  gap: 6px;
}

.admin .button.sm .icon { width: 16px; height: 16px; }

.icon-button.plain {
  width: 38px;
  height: 38px;
  background: transparent;
  color: var(--heading);
}

.icon-button.plain:hover { background: var(--pine-08); }

/* ---- status chips ---------------------------------------------------------- */

.admin .chip { white-space: nowrap; }
.admin .chip-active { background: var(--pine); color: var(--cream); }
.admin .chip-soon { margin: 0; background: var(--gold); color: var(--deep-pine); text-transform: none; letter-spacing: 0; }
.admin .chip-expired { background: var(--pine-08); color: var(--muted); }
.admin .chip-revoked { background: var(--red-10); color: var(--red); }

@media (prefers-color-scheme: dark) {
  .admin .chip-active { background: var(--cream); color: var(--pine); }
}

/* ---- page head, segmented filter, search --------------------------------- */

.page-head { align-items: flex-end; }
.page-head h1 { font-size: 2rem; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 15px; }

.seg {
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  margin: 0 0 12px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--rule);
}

.seg a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.seg a[aria-current="page"] { background: var(--pine); color: var(--cream); }
.seg .count { padding: 0 7px; border-radius: 999px; background: var(--pine-08); font-size: 12px; line-height: 20px; }
.seg a[aria-current="page"] .count { background: rgba(249, 241, 230, 0.22); }
.seg a:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }

@media (prefers-color-scheme: dark) {
  .seg a[aria-current="page"] { background: var(--cream); color: var(--pine); }
  .seg a[aria-current="page"] .count { background: var(--pine-08); }
}

.search { display: flex; align-items: center; margin-bottom: 16px; }
.search .search-icon { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; box-shadow: var(--shadow-card); border-color: transparent; }

/* ---- links table: one panel, every row on the same column grid ------------ */
/* All rows (heading, active, ended) share one grid-template-columns, so columns line up. */

.links-panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.links-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.9fr) minmax(180px, 1.2fr) 120px 316px;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--pine-14);
}

.links-row:first-child { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
.links-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.links-row:not(.links-head):hover { background: rgba(203, 152, 79, 0.06); }

.links-head {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--pine-08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.links-row .who { display: flex; align-items: center; gap: 8px; min-width: 0; }

.links-row .pet {
  overflow: hidden;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.1rem;
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.links-row .pet:hover { text-decoration: underline; }

.villa-badge {
  flex: none;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--pine-08);
  color: var(--heading);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.links-row .cell {
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.links-row .acts { display: flex; align-items: center; gap: 6px; }
.links-row .acts form { margin: 0; }
.links-row.ended .pet { color: var(--muted); }

/* More menu (details/summary, so it works without JavaScript). */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }

.menu-pop {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 20;
  width: 260px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(16, 27, 22, 0.25);
}

.menu-pop .move-form { display: flex; flex-wrap: wrap; gap: 6px; }
.menu-pop .move-form .menu-label { flex: 0 0 100%; }
.menu-pop .move-form select { flex: 1; min-width: 0; }

.menu-pop .menu-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-pop hr { margin: 12px 0; border: 0; border-top: 1px solid var(--rule); }
.menu-pop .revoke { width: 100%; justify-content: center; }

/* Narrower screens: each row stacks (name + status, date, buttons). */
@media (max-width: 860px) {
  .links-head { display: none; }

  .links-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 10px;
    padding: 14px 16px;
  }

  .links-row:nth-child(2) { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .links-row .who { grid-column: 1; grid-row: 1; }
  .links-row .status { grid-column: 2; grid-row: 1; justify-self: end; }
  .links-row .cell.parent { display: none; }
  .links-row .cell.until { grid-column: 1 / -1; }
  .links-row .acts { grid-column: 1 / -1; margin-top: 8px; gap: 4px; flex-wrap: nowrap; }
  /* Share, Copy, +1 day and the menu fit one line on a 320-375 px phone. */
  .admin .links-row .button.sm { padding: 6px 10px; }
  .links-row .acts .menu { margin-left: auto; }
}

/* ---- floating New link on phones ------------------------------------------ */

.fab { display: none !important; }

@media (max-width: 640px) {
  .page-head .button.new-link { display: none; }

  .admin .fab {
    position: fixed;
    right: 18px;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 30;
    display: inline-flex !important;
    min-height: 56px;
    padding: 0 22px;
    font-size: 16px;
  }

  .admin-main { padding-bottom: 96px; }
}

/* Very narrow phones (under 360 px): Copy shows its icon only, so the row stays inside the panel. */
@media (max-width: 359px) {
  .links-row .acts .copy .lbl { display: none; }
}

.admin .button.is-copied { background: var(--pine); color: var(--cream); }

/* ===========================================================================
   Portal design v3 (2026-11-07): the Links patterns for every page.
   .panel = white card; .lrow = list row on a shared per-list grid (.cols-*), so
   columns line up; on narrow screens rows stack (.c-main + .c-tag on top).
   =========================================================================== */

.admin .panel {
  margin-bottom: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.admin .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
}

.admin .panel-head h2 {
  margin: 0;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.25rem;
}

.admin .panel-head .hint { margin: 2px 0 0; }
.admin .panel-body { padding: 4px 18px 18px; }

.lrow {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--pine-14);
}

.panel > .lrow:first-child { border-top: 0; }
.lrow:not(.lhead):hover { background: rgba(203, 152, 79, 0.06); }

.lhead {
  padding-top: 10px;
  padding-bottom: 10px;
  background: var(--pine-08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-head + .lhead { border-top: 0; }

.lrow .title {
  overflow: hidden;
  color: var(--heading);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.05rem;
  text-decoration: none;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lrow .sub { color: var(--muted); font-size: 13px; }
.lrow .c-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.lrow .cell { overflow: hidden; color: var(--muted); font-size: 14px; white-space: nowrap; text-overflow: ellipsis; }
.lrow .c-acts { display: flex; align-items: center; gap: 6px; }
.lrow .c-acts form { margin: 0; }
.lrow.is-off .title { color: var(--muted); }

.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }

/* Per-list column grids. */
.cols-villas { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, 1fr) 210px; }
.cols-cams   { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) 110px; }
.cols-checks { grid-template-columns: 150px 80px minmax(0, 0.9fr) 90px minmax(0, 1fr) 130px; }
.cols-staff  { grid-template-columns: minmax(0, 1.6fr) 90px minmax(0, 1fr) 190px; }
.cols-nvrs   { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr) 150px; }
.cols-history { grid-template-columns: 150px minmax(0, 1fr) minmax(0, 1.4fr); }

/* Live dot with label. */
.live { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.admin .dot { width: 10px; height: 10px; border-radius: 50%; }
.admin .dot-on { background: #2f8a55; box-shadow: 0 0 0 3px rgba(47, 138, 85, 0.18); }
.admin .dot-idle { background: var(--gold); }
.admin .dot-off { background: rgba(77, 60, 46, 0.3); }

.admin .chip-owner { background: var(--gold-18); color: var(--gold-ink); }
.admin .chip-staff { background: var(--pine-08); color: var(--heading); }

/* Banner for whole-page problems (camera server unreachable). */
.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--red-10);
  color: var(--red);
  font-weight: 700;
}

.banner.ok { background: rgba(47, 138, 85, 0.1); color: #22663f; }

@media (prefers-color-scheme: dark) {
  .banner.ok { color: #9be0b4; }
}

/* Back link above a page title. */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--heading);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back:hover { text-decoration: underline; }

/* Danger zone at the bottom of an edit page. */
.danger-zone { border: 1px solid var(--red-10); }
.danger-zone .panel-head h2 { color: var(--red); }

/* History rows open to show before/after. */
.lrow details summary { cursor: pointer; color: var(--heading); font-weight: 700; font-size: 13px; }
.lrow details pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; color: var(--muted); }

/* Narrow screens: rows stack. Title + tag on top, everything else full width. */
@media (max-width: 860px) {
  .lhead { display: none; }
  .panel-head + .lhead + .lrow { border-top: 0; }

  .lrow { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 14px 16px; }
  .lrow > * { grid-column: 1 / -1; }
  .lrow > .c-main { grid-column: 1; grid-row: 1; }
  .lrow > .c-tag { grid-column: 2; grid-row: 1; justify-self: end; }
  .lrow > .c-hide-sm { display: none; }
  .lrow > .c-acts { margin-top: 8px; flex-wrap: wrap; }
}

.preview-panel { overflow: hidden; }
.preview-panel .player { border-radius: var(--radius); }

/* Single link page. */
.page-head .chip { align-self: center; }
.page-sub .villa-badge { vertical-align: 1px; }
.link-detail .until-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; color: var(--heading); font-size: 17px; }
.link-detail .link-field { margin-top: 14px; }
.link-detail .buttons form { margin: 0; }
.move-inline .inline { display: flex; gap: 8px; }
.move-inline .inline select { flex: 1; min-width: 0; }

/* ---- Camera wall (Owners) ---------------------------------------------------------------- */
.admin.is-wall .wrap { max-width: 1480px; }

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin: 0 0 12px;
}

.tile {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--player-bg);
  box-shadow: var(--shadow-card);
}

.tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--player-bg);
}

.tile:fullscreen, .tile:-webkit-full-screen { aspect-ratio: auto; border-radius: 0; }

.tile-msg {
  position: absolute;
  inset: 0 0 44px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 12px;
  color: rgba(249, 241, 230, 0.78);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.tile-msg > span { display: none; }
.tile[data-state="connecting"] .when-connecting,
.tile[data-state="offline"] .when-offline,
.tile[data-state="paused"] .when-paused,
.tile[data-state="off"] .when-off { display: inline; }
.tile[data-state="playing"] .tile-msg { display: none; }
.tile[data-state="off"] { background: rgba(36, 59, 48, 0.82); }

.tile figcaption {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 6px 6px 10px;
  background: linear-gradient(to top, rgba(16, 27, 22, 0.86), rgba(16, 27, 22, 0));
  color: var(--cream);
}

.tile .villa-badge { background: rgba(249, 241, 230, 0.16); color: var(--cream); }

.tile-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-live {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tile-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5484d;
}

.tile[data-state="playing"] .tile-live { display: inline-flex; }

.tile-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(249, 241, 230, 0.12);
  color: var(--cream);
  cursor: pointer;
}

.tile-btn:hover { background: rgba(249, 241, 230, 0.24); }
.tile-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.tile-btn .icon { width: 18px; height: 18px; }

.dialog-actions .spacer { flex: 1; }

@media (max-width: 860px) {
  .wall { grid-template-columns: 1fr; }
}

@media (min-width: 861px) and (max-width: 1100px) {
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Villa recordings: seekbar over the last 12 hours under the player. */
.timeline { padding: 14px 16px 16px; display: grid; gap: 10px; }
.timeline-now { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.timeline-now strong { font-size: 20px; color: var(--heading); font-variant-numeric: tabular-nums; }
.timeline-now .hint { margin: 0; }
.seek { position: relative; }
.seek input[type="range"] { width: 100%; margin: 0; accent-color: var(--pine); height: 28px; cursor: pointer; }
.seek-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.seek-ticks span { flex: 0 0 auto; }
.timeline-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.player .rec-badge {
  position: absolute; top: 12px; left: 12px; padding: 4px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums; pointer-events: none;
}
.player .rec-badge[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  .seek input[type="range"] { accent-color: var(--gold); }
}
