/* LTWC Events — a ledger, not a dashboard.
   Numbers are set in a mono face and right-aligned so columns of money read
   the way a bank statement does. Everything else stays quiet. */

.sm-only { display: none; }

:root {
  --ink:        #16202e;
  --ink-soft:   #4a5666;
  --ink-faint:  #8a94a3;
  --paper:      #f4f6f9;
  --surface:    #ffffff;
  --rule:       #dfe4ec;
  --rule-soft:  #edf0f5;
  --cedar:      #0e7c66;
  --cedar-soft: #e4f2ee;
  --amber:      #9a6a09;
  --amber-soft: #fbf1dc;
  --rust:       #a63930;
  --rust-soft:  #fbeae8;
  --focus:      #2f6fd0;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:  system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:  ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .06), 0 8px 24px -16px rgba(22, 32, 46, .25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-family: var(--sans); font-weight: 600; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* --- chrome --------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px; height: 54px;
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.brand {
  font-family: var(--serif); font-size: 18px; color: #fff; letter-spacing: .01em;
  display: flex; align-items: center; gap: 8px; max-width: 320px;
}
.brand-logo { height: 26px; width: auto; max-width: 120px; object-fit: contain; display: block; }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--cedar); }
.topbar nav { display: flex; gap: 22px; flex: 1; }
.topbar nav a { color: #b8c2d1; font-size: 14px; padding: 4px 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.on { color: #fff; border-bottom-color: var(--cedar); }
.who { display: flex; gap: 14px; align-items: center; font-size: 13px; color: #b8c2d1; }
.who a { color: #b8c2d1; }

.account-menu { position: relative; }
.account-menu summary {
  list-style: none; cursor: pointer; color: #b8c2d1; padding: 6px 0;
  display: flex; align-items: center; gap: 6px;
}
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary::after {
  content: "▾"; font-size: 10px; opacity: .7;
}
.account-menu summary:hover { color: #fff; }
.account-menu[open] summary { color: #fff; }
.account-drop {
  position: absolute; right: 0; top: 100%; z-index: 40; min-width: 218px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 10px 34px -12px rgba(22,32,46,.45); padding: 6px;
}
.account-head {
  padding: 10px 12px 12px; border-bottom: 1px solid var(--rule-soft); margin-bottom: 6px;
  display: grid; gap: 3px;
}
.account-head strong { color: var(--ink); font-size: 14px; }
.account-head span { color: var(--ink-faint); font-size: 12.5px; }
.account-head .tag { justify-self: start; margin-top: 4px; }
.account-drop a {
  display: block; padding: 9px 12px; color: var(--ink); font-size: 14px;
  border-radius: var(--radius);
}
.account-drop a:hover { background: var(--paper); text-decoration: none; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 24px 80px; }
.narrow { max-width: 720px; margin: 0 auto; padding: 40px 24px 80px; }

.flashes { margin-bottom: 18px; display: grid; gap: 8px; }
.flash {
  padding: 10px 14px; border-radius: var(--radius); font-size: 14px;
  background: var(--cedar-soft); color: #0a5a4a; border-left: 3px solid var(--cedar);
}
.flash.error { background: var(--rust-soft); color: #8a2b23; border-left-color: var(--rust); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- controls ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-faint); text-decoration: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #24344a; }
.btn.go { background: var(--cedar); border-color: var(--cedar); color: #fff; }
.btn.go:hover { background: #0b6b58; }
.btn.danger { color: var(--rust); border-color: #eccfcc; }
.btn.small { padding: 4px 9px; font-size: 13px; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=time], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); width: 100%;
}
textarea { line-height: 1.55; resize: vertical; }
label { font-size: 13px; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.checkline input { width: auto; }

.card {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card h2, .card h3 { margin-bottom: 14px; }
.hint { font-size: 13px; color: var(--ink-faint); }

/* --- the ledger strip: the one loud element ------------------------------- */

.ledger {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow);
}
.ledger div { padding: 14px 16px; border-right: 1px solid var(--rule-soft); }
.ledger div:last-child { border-right: 0; }
.ledger dt { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin: 0 0 6px; }
.ledger dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 21px; }
.ledger .settle { background: var(--ink); color: #fff; }
.ledger .settle dt { color: #98a4b5; }
.ledger .pos dd { color: #7ee0b8; }
.ledger .neg dd { color: #ffb0a6; }
.ledger small { display: block; font-family: var(--sans); font-size: 11px; color: var(--ink-faint); margin-top: 3px; }
.ledger .settle small { color: #98a4b5; }

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

.table-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
/* Not sticky: .table-wrap needs overflow-x for wide tables, which makes it a
   scroll container, and a sticky th then anchors to the wrapper rather than the
   viewport — leaving a gap and letting row 1 render behind the header. */
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600; padding: 11px 10px;
  border-bottom: 1px solid var(--rule); background: #f7f9fc;
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
td { padding: 9px 10px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
td .btn.small + .btn.small, td form { margin-left: 4px; }
tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }
.name { font-weight: 500; }
.name + .meta { margin-left: 6px; }
.meta { color: var(--ink-faint); font-size: 12.5px; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-faint); }
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; font-family: var(--serif); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  background: var(--rule-soft); color: var(--ink-soft);
}
.tag.yes { background: var(--cedar-soft); color: #0a5a4a; }
.tag.no { background: var(--rust-soft); color: #8a2b23; }
.tag.pending { background: var(--amber-soft); color: var(--amber); }
.tag.owed { background: var(--rust-soft); color: #8a2b23; }

/* Missing details. Red when the person cannot be reached at all, amber when it
   is recoverable — a page of uniform red would tell you nothing. */
.gap { color: var(--amber); font-style: italic; }
.gap.blocking { color: var(--rust); font-weight: 600; font-style: normal; }
tbody tr.row-blocking { background: #fffafa; }
tbody tr.row-blocking:hover { background: #fff5f4; }
tbody tr.row-blocking td:first-child { box-shadow: inset 3px 0 0 var(--rust); }
.tag.paid { background: var(--cedar-soft); color: #0a5a4a; }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg button {
  border: 0; background: var(--surface); font: inherit; font-size: 12.5px;
  padding: 4px 10px; cursor: pointer; color: var(--ink-soft);
  border-right: 1px solid var(--rule);
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on[data-value=yes] { background: var(--cedar); }
.seg button.on[data-value=no] { background: var(--rust); }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters select, .filters input[type=text] { width: auto; min-width: 130px; }

.qty { width: 54px; text-align: center; padding: 4px; }

/* --- check-in ------------------------------------------------------------- */

.checkin-list { display: grid; gap: 8px; }
.checkin-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
}
.checkin-row.done { background: var(--cedar-soft); border-color: #bfe0d6; }
.checkin-row .who-name { flex: 1; font-size: 16px; }
.checkin-row .who-name small { display: block; color: var(--ink-faint); font-size: 12.5px; }
.checkin-row button { min-width: 104px; justify-content: center; }

/* --- public RSVP ---------------------------------------------------------- */

.rsvp-page { background: var(--ink); min-height: 100vh; padding: 40px 20px; }
.rsvp-card { max-width: 520px; margin: 0 auto; background: var(--surface); border-radius: 4px; padding: 34px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
.rsvp-card h1 { font-size: 28px; margin-bottom: 6px; }
.rsvp-logo { max-height: 46px; max-width: 190px; width: auto; margin-bottom: 20px; display: block; }
.rsvp-when { font-family: var(--mono); font-size: 14px; color: var(--ink-soft); margin-bottom: 22px; }
.rsvp-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.rsvp-choice label {
  display: block; text-align: center; padding: 16px; border: 1px solid var(--rule);
  border-radius: var(--radius); cursor: pointer; font-size: 16px; color: var(--ink); margin: 0;
}
.rsvp-choice input { position: absolute; opacity: 0; }
.rsvp-choice input:checked + span { font-weight: 600; }
.rsvp-choice label:has(input:checked) { border-color: var(--ink); background: #f7f9fc; box-shadow: inset 0 0 0 1px var(--ink); }
.rsvp-extras { border-top: 1px solid var(--rule-soft); padding-top: 16px; margin-top: 4px; }

/* Confirmation state: the reply is done, so the page should look finished
   rather than showing a live form the guest can submit again. */
.rsvp-done { text-align: center; padding: 6px 0 2px; }
.rsvp-tick {
  width: 62px; height: 62px; margin: 6px auto 16px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 30px; line-height: 1;
}
.rsvp-tick.yes { background: var(--cedar-soft); color: var(--cedar); }
.rsvp-tick.no { background: var(--rule-soft); color: var(--ink-soft); }
.rsvp-done h2 { font-size: 22px; margin-bottom: 8px; }
.rsvp-summary { color: var(--ink-soft); font-size: 15px; margin: 0 0 18px; }
.rsvp-detail { width: 100%; text-align: left; border-collapse: collapse; margin-bottom: 18px; }
.rsvp-detail th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600; text-align: left;
  padding: 9px 12px 9px 0; vertical-align: top; white-space: nowrap; width: 84px;
}
.rsvp-detail td { padding: 9px 0; font-size: 15px; border-bottom: 1px solid var(--rule-soft); }
.rsvp-detail tr:last-child td { border-bottom: 0; }
.rsvp-detail .meta { display: block; font-size: 13px; margin-top: 2px; }

/* ---------------------------------------------------------------------------
   Mobile. Below 720px a table with nine columns is unreadable, so rows become
   cards: each cell shows its own label, and the columns that only make sense
   in a wide layout are hidden rather than squeezed.
   Opt in per table with class="stack" so dense reference tables keep scrolling.
--------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar {
    gap: 0; padding: 0 10px; height: auto; min-height: 52px;
    flex-wrap: wrap; align-items: center;
  }
  .brand { font-size: 17px; padding: 10px 0; flex: 1; max-width: none; }
  .brand-logo { height: 22px; }
  .who { padding: 10px 0; gap: 12px; }
  .account-drop { right: -4px; min-width: 210px; }
  /* The desktop rule sets flex:1, which lets the links wrap up beside the user
     name. Force a full-width basis so they always drop to their own row. */
  .topbar nav {
    order: 3; flex: 0 0 100%; width: 100%; gap: 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-top: 1px solid rgba(255,255,255,.12);
    scrollbar-width: none;
  }
  .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { padding: 11px 12px; white-space: nowrap; font-size: 13.5px; }

  .wrap { padding: 16px 12px 60px; }
  .narrow { padding: 20px 12px 60px; }
  h1 { font-size: 24px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }

  .page-head { gap: 12px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; justify-content: center; }

  /* Filters stack and fill the width instead of wrapping awkwardly */
  .filters { gap: 8px; }
  .filters input[type=text], .filters select { width: 100%; min-width: 0; }
  .filters .btn { flex: 1; justify-content: center; }

  /* Summary strip: two columns rather than seven cramped ones */
  .ledger { grid-template-columns: 1fr 1fr; }
  .ledger div { padding: 11px 12px; border-bottom: 1px solid var(--rule-soft); }
  .ledger dd { font-size: 18px; }
  .ledger .settle { grid-column: 1 / -1; }

  /* Rows become cards */
  .table-wrap.stack { border: 0; background: none; box-shadow: none; overflow: visible; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; width: 100%; }
  .stack thead { display: none; }
  .stack tr {
    background: var(--surface); border: 1px solid var(--rule);
    border-radius: var(--radius); margin-bottom: 10px; padding: 12px 14px;
    box-shadow: var(--shadow);
  }
  .stack tbody tr:hover { background: var(--surface); }
  .stack td { border: 0; padding: 3px 0; text-align: left; }
  .stack td.num { text-align: left; }

  /* Each cell announces itself */
  .stack td[data-label]::before {
    content: attr(data-label);
    display: inline-block; min-width: 96px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--ink-faint); font-weight: 600;
  }
  /* The first cell is the card heading, so no label and more room */
  .stack td.lead { padding: 0 0 8px; margin-bottom: 6px; border-bottom: 1px solid var(--rule-soft); }
  .stack td.lead::before { content: none; }
  .stack td.lead .name { font-size: 16px; font-weight: 600; }
  .stack td.lead .meta { display: block; margin: 2px 0 0; }
  .stack td.hide-sm { display: none; }
  /* A card of empty dashes helps nobody — hide stats the person has none of */
  .stack td.nil { display: none; }
  .sm-only { display: block; }
  .stack td.actions-cell { padding-top: 10px; margin-top: 6px;
    border-top: 1px solid var(--rule-soft); display: flex; gap: 8px; }
  .stack td.actions-cell::before { content: none; }
  .stack td.actions-cell .btn { flex: 1; justify-content: center; }
  .stack td.actions-cell form { flex: 1; display: flex; }
  .stack td.actions-cell form .btn { width: 100%; }
  .stack .empty { display: block; background: var(--surface);
    border: 1px solid var(--rule); border-radius: var(--radius); }

  /* Touch targets */
  .btn { padding: 9px 14px; }
  .btn.small { padding: 7px 11px; }
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=number], input[type=time], select, textarea { font-size: 16px; }
  /* 16px stops iOS zooming the page when a field is focused */

  /* Roster cards: the yes/no control and the tick boxes must be tappable */
  .roster .seg { width: 100%; }
  .roster .seg button { flex: 1; padding: 9px 0; font-size: 14px; }
  .roster td[data-label] input[type=checkbox] { width: 22px; height: 22px; vertical-align: middle; }
  .roster td[data-label="Self"], .roster td[data-label="Spouse"],
  .roster td[data-label="Came"], .roster td[data-label="Guests"] { text-align: left !important; }
  .roster .qty { width: 68px; padding: 7px; }
  /* Self / Spouse / Guests / Came sit inline rather than four stacked rows */
  .roster tr { display: flex; flex-wrap: wrap; }
  .roster td { flex: 1 1 100%; }
  .roster td[data-label="Self"], .roster td[data-label="Spouse"],
  .roster td[data-label="Came"] { flex: 0 0 auto; margin-right: 16px; }
  .roster td[data-label="Guests"] { flex: 0 0 auto; }
  .roster td[data-label="Self"]::before, .roster td[data-label="Spouse"]::before,
  .roster td[data-label="Came"]::before, .roster td[data-label="Guests"]::before {
    min-width: 0; margin-right: 5px;
  }
  .roster td[data-label="Due"], .roster td[data-label="Outstanding"] { flex: 0 0 48%; }

  dialog { max-width: 96vw !important; width: 96vw !important; padding: 18px; }
  .checkin-row { flex-wrap: wrap; gap: 10px; }
  .checkin-row .who-name { flex: 1 1 100%; }
  .checkin-row button { width: 100%; }
}

@media (max-width: 400px) {
  .ledger { grid-template-columns: 1fr; }
  .stack td[data-label]::before { min-width: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
