/* ============================================================
   Holiday portal

   One accent, a lot of white space, and type that gets out of the way.
   Everything is a token so light and dark are the same stylesheet twice, and
   nothing anywhere carries a shadow bright enough to notice.
   ============================================================ */

@font-face {
  font-family: 'Figtree';
  src: url('/fonts/figtree.woff2') format('woff2');
  font-weight: 300 800;
  font-display: swap;
}

:root {
  --bg: #F6F7F6;
  --surface: #FFFFFF;
  --surface-2: #F1F3F1;
  --surface-3: #E9ECEA;
  --text: #161A18;
  --muted: #6B736D;
  --faint: #98A099;
  --line: #E2E6E3;
  --line-strong: #CFD5D1;

  --accent: #1B6B4F;
  --accent-hover: #175B43;
  --accent-soft: #E9F1ED;
  --accent-text: #FFFFFF;

  --danger: #A93227;
  --danger-soft: #FBECEA;
  --warn: #8A6410;
  --warn-soft: #FBF3E2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 14px rgba(20, 30, 25, .04);

  --font: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0F1211;
    --surface: #171A18;
    --surface-2: #1D211F;
    --surface-3: #252A27;
    --text: #E7ECE9;
    --muted: #969E98;
    --faint: #6F776F;
    --line: #262B28;
    --line-strong: #333A36;

    --accent: #45A57E;
    --accent-hover: #55B58D;
    --accent-soft: #16241E;
    --accent-text: #0B0F0D;

    --danger: #E07C70;
    --danger-soft: #2A1917;
    --warn: #D2A24C;
    --warn-soft: #2A2418;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .2);
  }
}

:root[data-theme='dark'] {
  --bg: #0F1211;
  --surface: #171A18;
  --surface-2: #1D211F;
  --surface-3: #252A27;
  --text: #E7ECE9;
  --muted: #969E98;
  --faint: #6F776F;
  --line: #262B28;
  --line-strong: #333A36;

  --accent: #45A57E;
  --accent-hover: #55B58D;
  --accent-soft: #16241E;
  --accent-text: #0B0F0D;

  --danger: #E07C70;
  --danger-soft: #2A1917;
  --warn: #D2A24C;
  --warn-soft: #2A2418;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .6em; }
a { color: var(--accent); }

/* ---------- Boot ---------- */
.boot { display: grid; place-items: center; min-height: 100dvh; }
.boot-mark {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-brand strong { font-size: .98rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); flex: none; }
.topbar-spacer { flex: 1; }
.topbar-season {
  font-size: .82rem; color: var(--muted);
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 100px;
  background: var(--surface-2); cursor: pointer; white-space: nowrap;
}
.topbar-season:hover { border-color: var(--line-strong); color: var(--text); }

.tabs {
  display: flex; gap: 2px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  padding: 12px 14px 11px; font: inherit; font-size: .88rem; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current='true'] { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- Page heading ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head-text { flex: 1; min-width: 200px; }
.page-head .sub { color: var(--muted); font-size: .88rem; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2 { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); font-weight: 600; }
.stat .value { font-size: 1.4rem; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.owing { color: var(--accent); }
.stat .hint { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; cursor: pointer; font: inherit; font-size: .88rem; font-weight: 550;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: .8rem; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field .help { font-size: .77rem; color: var(--faint); margin-top: 4px; }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=tel], select, textarea {
  width: 100%; font: inherit; font-size: .92rem;
  padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }
.row.tight { gap: 8px; }
.row .shrink { flex: 0 0 auto; min-width: 0; }

.money-input { font-variant-numeric: tabular-nums; }

/* Repeatable rows: contacts, apartments, services */
.repeat { display: flex; flex-direction: column; gap: 8px; }
.repeat-row {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.repeat-row > .grow { flex: 1; min-width: 0; }
.repeat-row .repeat-fields { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.repeat-row .repeat-fields > * { flex: 1 1 130px; min-width: 0; }
.repeat-remove {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--faint); font-size: 1.1rem; line-height: 1; padding: 8px 4px; flex: none;
}
.repeat-remove:hover { color: var(--danger); }

/* ---------- Date field ---------- */
.datefield { position: relative; display: flex; align-items: stretch; }
.datefield-input { padding-right: 38px !important; }
.datefield-btn {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 34px;
  appearance: none; border: 0; background: none; cursor: pointer;
  font-size: .95rem; line-height: 1; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--muted);
}
.datefield-btn:hover { background: var(--surface-2); }

.datefield-pop {
  position: absolute; z-index: 70; top: calc(100% + 6px); left: 0;
  width: 268px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: 0 8px 28px rgba(15, 25, 20, .16);
}
.datefield-pop.above { top: auto; bottom: calc(100% + 6px); }
.datefield-pop[hidden] { display: none; }

.datefield-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.datefield-month { flex: 1; text-align: center; font-weight: 650; font-size: .92rem; }
.datefield-nav {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); cursor: pointer; width: 28px; height: 28px;
  border-radius: var(--radius-sm); font-size: 1rem; line-height: 1;
}
.datefield-nav:hover { border-color: var(--faint); }

.datefield-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.datefield-dow {
  text-align: center; font-size: .68rem; font-weight: 650; color: var(--faint);
  text-transform: uppercase; letter-spacing: .04em; padding-bottom: 4px;
}
.datefield-day {
  appearance: none; border: 1px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: .84rem; color: var(--text);
  height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.datefield-day:hover:not(:disabled) { background: var(--surface-2); }
.datefield-day.empty { cursor: default; }
.datefield-day.today { border-color: var(--line-strong); font-weight: 650; }
.datefield-day.chosen { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 650; }
.datefield-day.blocked, .datefield-day:disabled { color: var(--faint); cursor: not-allowed; opacity: .45; }

.datefield-foot {
  display: flex; gap: 6px; justify-content: space-between;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 650; padding: 11px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.name { font-weight: 550; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); }

.sub-line { font-size: .78rem; color: var(--muted); margin-top: 2px; font-weight: 400; }

/* ---------- Pills ---------- */
.pill {
  display: inline-block; font-size: .74rem; font-weight: 600;
  padding: 2px 9px; border-radius: 100px; white-space: nowrap;
}
.pill.owing { background: var(--accent-soft); color: var(--accent); }
.pill.settled { background: var(--surface-3); color: var(--muted); }
.pill.credit { background: var(--warn-soft); color: var(--warn); }
.pill.muted { background: var(--surface-3); color: var(--muted); }
.pill.edited { background: var(--warn-soft); color: var(--warn); }

/* ---------- Empty / notices ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { font-size: .9rem; max-width: 380px; margin: 0 auto .9rem; }

.notice {
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: .86rem;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.notice + .notice, .notice + .card, .card + .notice { margin-top: 14px; }

/* ---------- Season cards ---------- */
.season-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.season-card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .12s, transform .12s;
}
.season-card:hover { border-color: var(--accent); }
.season-card .name { font-size: 1.08rem; font-weight: 650; letter-spacing: -.015em; }
.season-card .dates { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.season-card .foot { display: flex; align-items: baseline; gap: 8px; margin-top: 16px; }
.season-card .amount { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.season-card .amount.zero { color: var(--muted); }
.season-card.archived { opacity: .6; }

/* ---------- Login ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100dvh; padding: 20px; }
.login {
  width: 100%; max-width: 350px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px;
  box-shadow: var(--shadow);
}
.login .mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); margin-bottom: 18px; }
.login h1 { font-size: 1.25rem; margin-bottom: 4px; }
.login .sub { color: var(--muted); font-size: .87rem; margin-bottom: 22px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 18, 15, .45); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 18px;
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  max-height: calc(100dvh - 36px); display: flex; flex-direction: column;
}
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: calc(100% - 36px); max-width: 420px;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 100px; font-size: .87rem; font-weight: 500;
  animation: rise .2s ease-out;
}
.toast.bad { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Copy box ---------- */
.copybox {
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px; max-height: 320px; overflow-y: auto;
  color: var(--text);
}

/* ---------- Food grid ---------- */
.food-grid { overflow-x: auto; }
.food-grid table { min-width: 520px; }
.food-grid input[type=number] { width: 68px; padding: 6px 8px; text-align: center; }
.food-grid td.qty { padding: 6px 8px; }

.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.daynav input[type=date] { width: auto; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 100px; padding: 3px; }
.seg button {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  font-size: .83rem; color: var(--muted); padding: 5px 14px; border-radius: 100px;
}
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.checkline { display: flex; align-items: center; gap: 9px; padding: 7px 0; font-size: .9rem; }
.checkline input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.section-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 650; margin: 22px 0 9px;
}
.section-label:first-child { margin-top: 0; }

@media (max-width: 600px) {
  .main { padding: 18px 14px 70px; }
  .topbar { padding: 10px 14px; }
  .card-body { padding: 15px; }
  h1 { font-size: 1.3rem; }
}

@media print {
  .topbar, .tabs, .page-actions, .toasts { display: none; }
  .card { box-shadow: none; border-color: #ccc; }
}
