/* Turnkey365 Control Room. Light and calm: white surfaces on a soft grey
   page, soft charcoal text, hairline borders, the logo's teal as the one
   accent, gently rounded corners. Every colour and size lives here as a
   variable, and the other Turnkey365 apps use the same values. */
:root {
  --black: #243035;          /* soft charcoal, used where black was */
  --ink: #243035;            /* body text: 13:1 on white */
  --ink-2: #48555b;
  --muted: #5f6c72;          /* 5.5:1 on white */
  --page: #f6f7f7;
  --surface: #ffffff;
  --line: #e5e9ea;
  --line-input: #8c979b;     /* input edges: 3:1 on white */
  --teal: #189890;           /* logo teal, for lines and highlights */
  --teal-ink: #127a73;       /* teal for text and buttons on white (5.2:1) */
  --teal-hover: #0e655f;
  --teal-soft: #e8f4f3;
  --focus: #127a73;
  --ok-ink: #0f5f59; --ok-bg: #e8f4f3;
  --bad-ink: #8a1c12; --bad-bg: #fbe9e6;
  --warn-ink: #6b450b; --warn-bg: #fbf2df;
  --font: 'Montserrat', Arial, Helvetica, sans-serif;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(36, 48, 53, .05), 0 4px 14px rgba(36, 48, 53, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; }
a { color: var(--teal-ink); }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus-visible { outline: none; }
[hidden] { display: none !important; }

h1 { font-size: 26px; line-height: 1.25; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 17px; line-height: 1.3; margin: 0; font-weight: 600; }
p { margin: 0; }
.sub { font-size: 16px; color: var(--muted); }
.note { font-size: 14px; color: var(--muted); }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; background: var(--page); padding: 2px 6px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }

.wrap { max-width: 1360px; margin: 0 auto; padding: 28px 24px; }
.entry { max-width: 460px; margin: 64px auto; padding: 0 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.cards .card { gap: 12px; }
.cards .card h2 { font-size: 16px; }

.btn, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 46px; padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid var(--line-input);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.btn { background: var(--surface); color: var(--ink); }
.btn-primary { background: var(--teal-ink); border-color: var(--teal-ink); color: #ffffff; }
.btn:hover { border-color: var(--teal-ink); color: var(--teal-ink); }
.btn-primary:hover { background: var(--teal-hover); border-color: var(--teal-hover); }
.btn[disabled], .btn-primary[disabled] { opacity: .55; cursor: not-allowed; }

.logo-mark { width: 44px; height: 44px; background: var(--teal-ink); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.logo-mark.bad { background: var(--bad-ink); }

/* ---------- top bar and tabs: white, with the dark logo ---------- */
.topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1360px; margin: 0 auto; padding: 14px 24px 4px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand img { height: 24px; width: auto; display: block; }
.brand-title { font-size: 13px; font-weight: 500; color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px; }
.who { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.who .btn { width: auto; min-height: 38px; padding: 0 14px; font-size: 13px; }
.tabs { max-width: 1360px; margin: 0 auto; padding: 0 16px; display: flex; gap: 2px; overflow-x: auto; }
.tab {
  display: inline-flex; align-items: center; min-height: 46px; padding: 0 12px;
  border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted);
  font: 500 14px var(--font); text-decoration: none; white-space: nowrap; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--teal-ink); font-weight: 600; border-bottom-color: var(--teal); }

/* ---------- pages inside a tab ---------- */
/* One slim bar above a system: back link or page switch, and front-end pages. */
.framebar { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 6px 24px; background: var(--page); border-bottom: 1px solid var(--line); font-size: 14px; }
.backlink { color: var(--teal-ink); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 34px; }
.backlink:hover { text-decoration: underline; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; color: var(--ink-2); text-decoration: none; font-weight: 500; border-radius: 999px; }
.page-link[aria-current="page"] { color: var(--teal-ink); background: var(--teal-soft); font-weight: 600; }
.newtab { color: var(--teal-ink); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; }
#frames { --top: 120px; }
#frames > section { display: flex; flex-direction: column; height: calc(100vh - var(--top)); height: calc(100dvh - var(--top)); min-height: 520px; }
.sysframe { display: block; width: 100%; flex: 1 1 auto; min-height: 380px; border: 0; background: var(--surface); }

/* ---------- front-end pages: one small chip each, with Copy link and Open ---------- */
.frontlinks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.frontlinks:not(.compact) { margin-left: 0; border-top: 1px solid var(--line); padding-top: 12px; }
.frontlinks-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 12px; }
.chip-label { font-size: 13px; font-weight: 600; color: var(--ink); margin-right: 4px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 10px; border: 0; border-radius: 999px;
  background: none; color: var(--teal-ink); font: 600 12px var(--font); text-decoration: none; cursor: pointer;
}
.chip-btn:hover { background: var(--teal-soft); }
.chip-btn { white-space: nowrap; }
/* In a card (Home, Villa Audit's list): one chip per line, name left, buttons right. */
.frontlinks:not(.compact) { flex-direction: column; align-items: stretch; gap: 6px; }
.frontlinks:not(.compact) .chip { display: flex; flex-wrap: wrap; width: 100%; border-radius: var(--radius-sm); padding: 4px 4px 4px 12px; row-gap: 0; }
.frontlinks:not(.compact) .chip-label { flex: 1 1 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 30px; display: inline-flex; align-items: center; }
.mini {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px;
  border: 1px solid var(--line-input); background: var(--surface); color: var(--ink);
  font: 600 13px var(--font); text-decoration: none; cursor: pointer; border-radius: var(--radius-sm);
}
.mini:hover { border-color: var(--teal-ink); color: var(--teal-ink); }
.toast { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--black); color: #ffffff; padding: 12px 18px; font-size: 14px; line-height: 1.4; z-index: 1000; width: max-content; max-width: min(480px, calc(100vw - 32px)); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, .22); display: flex; align-items: center; gap: 10px; cursor: pointer; animation: toast-in .18s ease-out; }
.toast[hidden] { display: none; }
/* Success: Turnkey365's green pop-up (white on #1F7A4D, contrast about 5.6:1). */
.toast.ok { background: #1F7A4D; }
.toast svg { flex: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Settings ---------- */
table.people { width: 100%; border-collapse: collapse; font-size: 14px; }
table.people th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 8px; vertical-align: bottom; }
table.people th .tabname { display: block; color: var(--ink); }
table.people td { border-top: 1px solid var(--line); padding: 10px 8px; vertical-align: middle; }
table.people td.c, table.people th.c { text-align: center; }
.scroll { overflow-x: auto; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal-ink); cursor: pointer; }
input[type="text"], input[type="email"] {
  min-height: 46px; border-radius: var(--radius-sm); border: 1px solid var(--line-input);
  background: var(--surface); color: var(--ink); font: 16px var(--font); padding: 0 14px; width: 100%;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.ticks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.ticks label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.msg { padding: 10px 14px; font-size: 14px; border-radius: var(--radius-sm); }
.msg.ok { background: var(--ok-bg); color: var(--ok-ink); }
.msg.bad { background: var(--bad-bg); color: var(--bad-ink); }

/* ---------- Home: "Your properties" ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.figs-wrap { margin: 0 0 32px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head .note { margin-top: 4px; }
.section-title { margin: 0 0 14px; }
.figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; align-items: start; }
.figs:empty { display: none; }
.figcard { gap: 14px; min-width: 0; }
.figtitle { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.figopen { color: var(--teal-ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.figopen:hover { text-decoration: underline; }
/* Headline figures for the whole system: small tiles. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.tile { background: var(--page); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-value { font-size: 22px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-label { font-size: 12px; color: var(--muted); }
.tile.tone-bad .tile-value { color: var(--bad-ink); }
.tile.tone-warn .tile-value { color: var(--warn-ink); }
.tile.tone-ok .tile-value { color: var(--ok-ink); }
.fighead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.fighead h3 { margin: 0; font-size: 16px; font-weight: 600; }
.fighead .label { color: var(--teal-ink); }
table.figtable { width: 100%; border-collapse: collapse; font-size: 14px; }
table.figtable thead th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 8px; vertical-align: bottom; }
table.figtable tbody th { text-align: left; font-weight: 500; padding: 9px 8px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
table.figtable td { padding: 9px 8px; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
table.figtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- A tab that lists entries (Villa Audit) ---------- */
#panel-entries .section-head { align-items: flex-start; }
#panel-entries .section-head h1 { margin-top: 2px; }
.entries-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.entries-actions .btn-primary { width: auto; }
.entries-links { margin: 0 0 16px; }
.entries-links .frontlinks { margin-left: 0; border-top: 0; padding-top: 0; }
#entries-table { margin-top: 4px; }
.tag { display: inline-block; padding: 2px 10px; font-size: 12px; font-weight: 600; border-radius: 999px; }
.tag-ok { background: var(--ok-bg); color: var(--ok-ink); }
.tag-draft { background: var(--warn-bg); color: var(--warn-ink); }

/* ---------- Settings: properties per person, and who looks after each ---------- */
.pm-tools { display: flex; align-items: flex-end; gap: 12px 20px; flex-wrap: wrap; }
.pm-tools .field { flex: 1 1 260px; }
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; min-height: 48px; }
td.mono-cell { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: nowrap; }
select {
  min-height: 40px; max-width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--line-input);
  background: var(--surface); color: var(--ink); font: 14px var(--font); padding: 0 10px;
}
.props-list label .label { margin-left: auto; color: var(--teal-ink); font-size: 11px; }
#pm-table { table-layout: fixed; }
#pm-table th:nth-child(2), #pm-table td:nth-child(2) { width: 84px; }
#pm-table th:nth-child(3), #pm-table td:nth-child(3) { width: 46%; }
#pm-table select { width: 100%; }
table.people select.levelpick { width: auto; min-width: 118px; min-height: 36px; padding: 4px 8px; font-size: 13px; }
#pm-table td { overflow-wrap: anywhere; }
td.propcell { white-space: nowrap; }
td.propcell span { margin-right: 10px; }
input[type="radio"] { width: 20px; height: 20px; accent-color: var(--teal-ink); cursor: pointer; }
dialog.sheet { border: 0; padding: 0; width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); background: var(--surface); color: var(--ink); border-radius: var(--radius); }
dialog.sheet::backdrop { background: rgba(36, 48, 53, .35); }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 24px; max-height: calc(100dvh - 32px); }
.sheet-body .ticks { flex-direction: column; gap: 8px; }
.props-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.props-tools .note { flex: 1 1 100%; }
.props-list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 120px; max-height: 42vh; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 10px; }
.props-list label { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 14px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.sheet-actions .btn, .sheet-actions .btn-primary { width: auto; }

@media (max-width: 600px) {
  .wrap { padding: 20px 16px; }
  /* Figures: each property becomes a small block, each figure its own line. */
  table.figtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.figtable, table.figtable tbody, table.figtable tr, table.figtable th, table.figtable td { display: block; width: 100%; }
  table.figtable tbody tr { border-top: 1px solid var(--line); padding: 8px 0; }
  table.figtable tbody th { border: 0; padding: 0 0 4px; }
  table.figtable td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; }
  table.figtable td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  table.figtable td.num { text-align: right; }
  .sheet-body { padding: 18px; }
  .sheet-actions .btn, .sheet-actions .btn-primary { flex: 1 1 auto; }
  .topbar-inner, .tabs, .framebar { padding-left: 16px; padding-right: 16px; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .brand img { height: 20px; }
  .frontlinks { margin-left: 0; }
  .brand-title { display: none; }
  h1 { font-size: 24px; }
  .card { padding: 18px; }
}
