/* Hari Villa design shell — locked system:
   navy #0F2440 · content #FAFBFC · gold #C9A227 · chips #1E8E5A/#B7791F/#C0392B
   Playfair Display for the masthead, Manrope for everything else.
   Mobile-first: the phone is the primary device. */

:root {
  --navy: #0F2440;
  --paper: #FAFBFC;
  --gold: #C9A227;
  --ink: #1C2733;
  --muted: #5B6B7B;
  --line: #E3E8EE;
  --green: #1E8E5A;
  --amber: #B7791F;
  --red: #C0392B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Manrope", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

.masthead-name {
  font-family: "Playfair Display", Georgia, serif;
  letter-spacing: 0.02em;
  color: var(--gold);
}

/* ---------- auth card (login / invite) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  padding: 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  background: var(--paper);
  border-radius: 14px;
  padding: 2rem 1.5rem;
  box-shadow: 0 18px 50px rgba(4, 12, 24, 0.45);
}

.auth-card .masthead-name { font-size: 2rem; text-align: center; display: block; }

.auth-card .welcome {
  text-align: center;
  color: var(--muted);
  margin: 0.4rem 0 1.6rem;
  font-size: 0.95rem;
}

label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin: 0.9rem 0 0.3rem; }

input {
  width: 100%;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

input:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

button.primary {
  width: 100%;
  margin-top: 1.3rem;
  padding: 0.95rem;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button.primary:active { background: #0a1a30; }

.form-error { color: var(--red); font-size: 0.86rem; margin-top: 0.8rem; min-height: 1.2em; }

.qr-box { display: flex; justify-content: center; margin: 1rem 0; }
.qr-box svg { width: 200px; height: 200px; }

.hint { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

.hidden { display: none; }

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh; flex-direction: column; }

.mobile-bar {
  display: flex; align-items: center; gap: 0.7rem;
  background: var(--navy); padding: 0.6rem 1rem; position: sticky; top: 0; z-index: 20;
}
.mobile-bar .masthead-name { font-size: 1.25rem; }
#nav-toggle {
  background: none; border: 1px solid rgba(255,255,255,0.25); color: #dfe6ee;
  border-radius: 8px; font-size: 1.1rem; min-width: 44px; min-height: 44px; cursor: pointer;
}

.sidebar {
  background: var(--navy);
  color: #cfd8e3;
  padding: 1rem;
  display: none;
}
.sidebar.open { display: block; }
.side-masthead { display: none; }

.sidebar .masthead-name { font-size: 1.5rem; }

.sidebar nav { margin-top: 1rem; }

.nav-group { margin-bottom: 1rem; }

.nav-group h3 {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7d8ea3;
  margin-bottom: 0.35rem;
}

.nav-group a, .nav-group span.soon {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  font-size: 0.92rem;
  color: #dfe6ee;
  text-decoration: none;
}

.nav-group a.active { background: rgba(201, 162, 39, 0.16); color: var(--gold); font-weight: 700; }

.nav-group span.soon { color: #6d7f95; }
.nav-group span.soon em { font-style: normal; font-size: 0.7rem; color: #55677e; }

.content { flex: 1; padding: 1.25rem; }

.topline { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.topline h1 { font-size: 1.35rem; }
.topline form button {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 0.4rem 0.8rem; font: inherit; font-size: 0.85rem; color: var(--muted); cursor: pointer;
  min-height: 44px;
}

.cards { display: grid; gap: 0.9rem; grid-template-columns: 1fr; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.card .stat { font-size: 1.9rem; font-weight: 800; }
.card .stat-label { color: var(--muted); font-size: 0.88rem; }

.chip { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; color: #fff; }
.chip.ok { background: var(--green); }
.chip.expiring { background: var(--amber); }
.chip.expired { background: var(--red); }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .mobile-bar { display: none; }
  .sidebar { display: block; width: 240px; flex-shrink: 0; min-height: 100vh; }
  .side-masthead { display: inline; }
  .content { padding: 2rem 2.5rem; }
  .cards { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- renewals (card rows, one glance on the phone) ---------- */
.renewal-list { display: flex; flex-direction: column; gap: 0.6rem; }
.renewal-row {
  display: flex; justify-content: space-between; gap: 0.8rem;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1rem;
}
.renewal-main { flex: 1; text-decoration: none; color: inherit; min-width: 0; }
.renewal-title { font-weight: 800; font-size: 0.98rem; }
.renewal-sub { color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }
.renewal-side { text-align: right; flex-shrink: 0; }
.renewal-date { color: var(--muted); font-size: 0.78rem; margin-top: 0.25rem; }
.renew-link {
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 0.35rem; font-size: 0.82rem; font-weight: 700;
  color: var(--navy); border: 1px solid var(--gold); border-radius: 999px;
  padding: 0.25rem 0.8rem; text-decoration: none; min-height: 44px;
}

/* ---------- module screens ---------- */
.card-title { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.7rem; }
.stat-link { text-decoration: none; color: inherit; display: block; }
.stat-link:active { background: #f2f5f8; }
.person-card { text-decoration: none; color: inherit; }
.person-name { font-weight: 800; font-size: 1.05rem; }
.person-meta { color: var(--muted); font-size: 0.88rem; margin-top: 0.25rem; }
.actor-badge {
  font-size: 0.68rem; font-weight: 700; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 999px; padding: 0.05rem 0.5rem;
  vertical-align: middle; margin-left: 0.3rem;
}
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; }
dl.kv dt { color: var(--muted); font-size: 0.88rem; }
dl.kv dd { font-weight: 600; }
.contact-row { padding: 0.45rem 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.contact-row:last-child { border-bottom: 0; }

/* CEO polish: generous touch targets in the nav */
.nav-group a, .nav-group span.soon { padding: 0.72rem 0.6rem; min-height: 44px; display: flex; align-items: center; }

.reveal-btn {
  margin-left: 0.5rem; font: inherit; font-size: 0.75rem; font-weight: 700;
  color: var(--navy); background: none; border: 1px solid var(--gold);
  border-radius: 999px; padding: 0.2rem 0.7rem; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.masked-value { font-variant-numeric: tabular-nums; }

.page-actions { margin-bottom: 0.9rem; }
.btn-add {
  display: inline-flex; align-items: center; min-height: 44px;
  background: var(--navy); color: #fff; text-decoration: none; font-weight: 700;
  font-size: 0.9rem; padding: 0 1.1rem; border-radius: 10px;
}
.table-card { padding: 0.4rem 0; overflow-x: auto; }
table.dense { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.dense th {
  text-align: left; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--line);
}
table.dense td { padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); }
table.dense tr:last-child td { border-bottom: 0; }
select {
  width: 100%; padding: 0.85rem 0.9rem; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff;
}
select:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.check-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; margin-top: 0.9rem; }
.check-row input { width: auto; min-height: 20px; }

.contact-edit-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.4rem; margin-top: 0.5rem; }
.page-actions .btn-add { margin-right: 0.5rem; }

.filter-on { background: var(--gold); color: var(--navy); }

.gap-card { border-left: 4px solid var(--amber); }

.modal {
  position: fixed; inset: 0; background: rgba(8, 18, 34, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--paper); border-radius: 14px; padding: 1.4rem;
  width: 100%; max-width: 22rem; box-shadow: 0 18px 50px rgba(4, 12, 24, 0.45);
}
.modal-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.4rem; }
.modal-actions .primary { margin-top: 0.9rem; }
#revealed-box { word-break: break-all; font-family: ui-monospace, monospace; margin-top: 0.7rem; }

.duty-list { margin-top: 0.7rem; }
.duty-title { font-size: 0.85rem; font-weight: 700; margin-bottom: 0.4rem; }
.duty-item {
  display: flex; align-items: center; width: 100%; text-align: left;
  font: inherit; font-size: 0.92rem; background: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px; padding: 0.65rem 0.8rem;
  margin-bottom: 0.4rem; min-height: 44px; color: var(--ink);
}
.duty-item.done { color: var(--green); border-color: var(--green); background: #f0faf5; cursor: default; }

/* credentials: title first, actions wrap below — nothing collapses at 390px */
.cred-row {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1rem;
}
.cred-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; align-items: center; }

/* bills: same law as credentials — the title owns the card, the pills queue
   beneath it (phase-5 CEO F7) */
.bill-row {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 0.85rem 1rem;
}
.bill-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; align-items: center;
}
.bill-actions .reveal-btn { margin-left: 0; }
.bill-actions .renewal-date { margin-top: 0; }
.cred-btn {
  font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--navy);
  background: none; border: 1px solid var(--gold); border-radius: 999px;
  padding: 0.5rem 1rem; cursor: pointer; min-height: 44px;
}
.cred-edit {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--navy); font-size: 0.85rem; font-weight: 700; margin-left: 0.3rem;
  text-decoration: underline; text-decoration-color: var(--gold);
}

/* family life */
textarea {
  width: 100%; padding: 0.85rem 0.9rem; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; background: #fff; resize: vertical;
}
textarea:focus { outline: 2px solid var(--gold); border-color: var(--gold); }
.post-card { margin-bottom: 0; }
.post-head { display: flex; align-items: baseline; gap: 0.5rem; }
.post-archive {
  margin-left: auto; background: none; border: 0; color: var(--muted);
  font-size: 1.1rem; cursor: pointer; min-width: 44px; min-height: 32px;
}
.post-body { margin: 0.5rem 0; white-space: pre-wrap; }
.post-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin: 0.5rem 0; }
.post-photos img, .thumb-grid img, .album-cover {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block;
}
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
@media (min-width: 900px) { .thumb-grid { grid-template-columns: repeat(6, 1fr); } }
.post-comment { padding: 0.35rem 0 0.35rem 0.8rem; border-left: 2px solid var(--line); font-size: 0.9rem; margin-top: 0.4rem; }
.comment-form { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.comment-form input { flex: 1; }
.album-cover { margin-bottom: 0.6rem; }
/* saffron: reserved for celebration (festivals, birthdays) */
.chip.saffron { background: #E8862D; }

.allergy-strip {
  background: #FDF3E7; border: 1px solid var(--amber); border-radius: 10px;
  padding: 0.55rem 0.8rem; font-size: 0.9rem; margin-bottom: 0.6rem;
}

.month-head { font-size: 0.85rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0.9rem 0 0.5rem; }
/* remembrance: quiet slate for shraadh — saffron stays with joy */
.chip.remembrance { background: #5B6B7B; }

/* control panel: the grants matrix stays readable on the phone */
.grants-table { border-collapse: collapse; font-size: 0.82rem; margin: 0.6rem 0; }
.grants-table th, .grants-table td { padding: 0.3rem 0.55rem; text-align: center; }
.grants-table td:first-child { text-align: left; color: var(--muted); text-transform: capitalize; }
.grants-table input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }

/* ---------- v2: density, nav icons, text-size control ----------
   Base is 13px = 80% of the browser's 16px default, so more of the
   page is visible at once. The A-/A/A+ control overrides this at
   runtime in 3px steps and remembers the choice per browser.
   Phone keeps 44px touch targets (Ch.9 law); only desktop tightens. */
html { font-size: 13px; }

.sprite { display: none; }

.nav-ico {
  width: 1.2rem; height: 1.2rem; flex: 0 0 auto; margin-right: 0.55rem;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.85;
}
.nav-group a.active .nav-ico { opacity: 1; }

/* main groups read as blocks, each divided from the next */
.nav-group { margin-bottom: 0.5rem; padding-bottom: 0.1rem; }
.nav-group + .nav-group {
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  padding-top: 0.6rem;
}
.nav-group h3 { margin-bottom: 0.2rem; }

.topline-tools { display: flex; align-items: center; gap: 0.5rem; }
.fontsize {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: #fff;
}
.fontsize button {
  background: none; border: 0; border-left: 1px solid var(--line);
  font: inherit; font-weight: 700; color: var(--muted);
  padding: 0 0.7rem; min-height: 44px; cursor: pointer;
}
.fontsize button:first-child { border-left: 0; }
.fontsize button:hover { background: #eef2f6; color: var(--navy); }
.fontsize button:active { background: var(--gold); color: var(--navy); }

@media (min-width: 900px) {
  .sidebar { width: 232px; padding: 0.9rem 0.7rem; }
  .nav-group a, .nav-group span.soon {
    min-height: 0; padding: 0.33rem 0.5rem; font-size: 0.92rem;
  }
  .nav-group { margin-bottom: 0.4rem; }
  .nav-group + .nav-group { padding-top: 0.45rem; }
  .fontsize button { min-height: 30px; padding: 0 0.6rem; }
  .topline form button { min-height: 30px; }
}

/* ---------- v2.1: sticky nav + footer ----------
   The nav outgrew the fold once it got dense, so on desktop it holds
   its own column and scrolls independently of the page. */
@media (min-width: 900px) {
  .sidebar {
    position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: #33455e var(--navy);
  }
  .sidebar::-webkit-scrollbar { width: 8px; }
  .sidebar::-webkit-scrollbar-track { background: var(--navy); }
  .sidebar::-webkit-scrollbar-thumb { background: #33455e; border-radius: 4px; }
  .content { min-width: 0; }
}

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 2.2rem; padding-top: 0.9rem;
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 0.5rem 1.2rem;
  font-size: 0.78rem; color: var(--muted);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0.9rem; margin: 0; }
.site-footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line); }
.site-footer a:hover { color: var(--navy); border-bottom-color: var(--gold); }
.site-footer .build { font-variant-numeric: tabular-nums; letter-spacing: 0.01em; }
.site-footer .build b { color: var(--ink); font-weight: 700; }

/* ---------- v2.2: footer holds the floor ----------
   Short page: footer sits at the bottom of the viewport.
   Long page: it flows naturally after the content.
   .shell already carries min-height:100vh and .content already has
   flex:1, so margin-top:auto is all that is needed — no 100vh maths,
   works the same in the mobile column and the desktop row. */
.content { display: flex; flex-direction: column; }
.site-footer { margin-top: auto; }

/* ---------- v2.3: the size control must not move ----------
   Found by accident: enlarging text reflowed the topline and slid
   "Sign out" under the pointer, so pressing A+ twice could sign you
   out. The controls are chrome, not content — pin them to fixed px so
   they hold position at every text size, and keep a hard gap between
   the size buttons and the destructive one. */
.topline-tools { font-size: 13px; gap: 1.4rem; flex-shrink: 0; }
.fontsize button { font-size: 13px; min-width: 34px; justify-content: center; }
.topline form button { font-size: 13px; white-space: nowrap; }
.topline { gap: 1rem; align-items: flex-start; }

   The existing `.post-photos img, .thumb-grid img, .album-cover` rule still
   applies to the <img> inside .thumb — this only adds the frame around it. */

/* ---------- v0.4.0: gallery dates ---------- */
.album-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin: -0.3rem 0 0.9rem;
}
.album-date {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 700;
}

/* ---------- v0.4.0: gallery tiles ----------
   A tile is now a figure: the photo, and a download control under it.
   The control is always visible on phone — a hover-only affordance on a
   touch screen is a control that does not exist. */
.thumb { position: relative; margin: 0; }
.thumb-open { display: block; }
.thumb-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background: var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 3px;
}
.thumb-dl {
  display: block;
  min-height: 44px;
  line-height: 44px;
  text-align: center;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
}
.thumb-dl:hover { color: var(--navy); }

/* ---------- v0.4.0: lightbox ----------
   Fixed overlay, navy at near-full opacity so the photograph is the only
   lit thing on the screen. Controls are 44px targets on phone. */
body.lb-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 36, 64, 0.96);
  padding: 3.5rem 0.5rem 4rem;
}
.lightbox[hidden] { display: none; }

.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.lb-btn {
  position: absolute;
  background: transparent;
  border: 0;
  color: var(--paper);
  font-size: 2rem;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  opacity: 0.75;
}
.lb-btn:hover, .lb-btn:focus { opacity: 1; color: var(--gold); outline: none; }
.lb-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.lb-close { top: 0.5rem; right: 0.6rem; font-size: 1.9rem; }
.lb-prev { left: 0.2rem; top: 50%; transform: translateY(-50%); font-size: 2.6rem; }
.lb-next { right: 0.2rem; top: 50%; transform: translateY(-50%); font-size: 2.6rem; }

.lb-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  color: var(--paper);
  font-size: 0.84rem;
}
.lb-count { font-variant-numeric: tabular-nums; opacity: 0.8; }
.lb-dl {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  min-height: 44px;
  line-height: 44px;
}
.lb-dl:hover { border-bottom-color: var(--gold); }

@media (min-width: 900px) {
  .lightbox { padding: 4rem 4.5rem; }
  .lb-prev { left: 1rem; }
  .lb-next { right: 1rem; }
  .thumb-dl { min-height: 26px; line-height: 26px; }
}
