/* Master Portal styles. Palette and reasons: docs/DESIGN.md. Ported from docs/mockups/portal_v1.html. */
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/newsreader-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/newsreader-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/newsreader-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }

:root {
  /* Palette and reasons: docs/DESIGN.md */
  --paper: #F5F1E8;
  --sheet: #FCFAF5;
  --ink: #1C201E;
  --ink-2: #585D56;
  --ink-3: #6B6F68;
  --rule: #D9D1BF;
  --hover: #ECE6D8;
  --accent: #25386A;
  --accent-hover: #1B2A52;
  --red: #9A2A20;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 4px;
  --r-md: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--sheet); padding: 10px 14px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { top: 12px; }

/* Shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; padding: 32px 20px 24px; border-right: 1px solid var(--rule);
}
.brand { font: 600 25px/1.1 var(--serif); margin: 0; letter-spacing: -0.01em; }
.brand-sub { margin: 6px 0 28px; font-size: 14px; color: var(--ink-2); }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px; min-height: 44px; border-radius: var(--r-sm);
  text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--hover); }
.nav a[aria-current="page"] { background: var(--sheet); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px var(--rule); }
.nav .count { font-size: 14px; color: var(--ink-3); font-weight: 400; }
.rail-foot { margin-top: auto; font-size: 13px; color: var(--ink-2); display: grid; gap: 8px; }
.rail-foot .who { overflow-wrap: anywhere; }
.topbar, .tabs { display: none; }

main { padding: 44px 56px 72px; max-width: 980px; width: 100%; }
h1 { font: 500 42px/1.1 var(--serif); margin: 0; letter-spacing: -0.015em; }
h1:focus { outline: none; }
.lede { margin: 10px 0 0; color: var(--ink-2); max-width: 60ch; }
.h3 { font: 600 15px/1.3 var(--sans); margin: 0 0 12px; }
.label { margin: 0; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.meta { margin: 0; font-size: 14px; color: var(--ink-2); }
.small { font-size: 13px; color: var(--ink-3); }
.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Identity motif: the accounting double rule under totals */
.total {
  display: inline-block; margin: 6px 0 10px; padding-bottom: 6px;
  font: 500 56px/1 var(--serif); letter-spacing: -0.02em; border-bottom: 4px double var(--ink);
}
.total.sm { font-size: 24px; margin: 0; padding-bottom: 3px; border-bottom-width: 3px; }
.total.zero { color: var(--ink-2); border-bottom-color: var(--ink-3); }

.leaf { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 24px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--sheet); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary[disabled] { background: var(--ink-3); cursor: progress; }
.btn-quiet { background: transparent; border-color: var(--ink-3); color: var(--ink); }
.btn-quiet:hover { background: var(--hover); }
.text-link { font-weight: 500; text-underline-offset: 3px; }
.text-link:hover { color: var(--accent); }

/* State blocks (empty / loading / error) */
.state { margin-top: 32px; padding: 28px 0; border-top: 1px solid var(--rule); max-width: 56ch; }
.state .t { font: 500 24px/1.25 var(--serif); margin: 0 0 8px; }
.state p { margin: 0 0 16px; color: var(--ink-2); }
.state.err { border-top: 2px solid var(--red); }
.state.err .t { color: var(--red); }

/* Overview */
.ov-head { display: flex; align-items: center; gap: 12px; }
.step {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid var(--rule); background: transparent; cursor: pointer; font: 400 22px/1 var(--serif); text-decoration: none;
}
.step:hover:not([disabled]) { background: var(--hover); }
.step[disabled] { color: var(--rule); cursor: not-allowed; }
.ov-spend { margin-top: 36px; }
.cats { list-style: none; margin: 28px 0 0; padding: 0; max-width: 640px; }
.cats a {
  display: grid; grid-template-columns: minmax(120px, 180px) 1fr auto; align-items: center; gap: 16px;
  min-height: 44px; padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: none;
}
.cats a:hover .cat-name { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cats .bar { height: 6px; background: var(--ink-2); border-radius: 1px; width: var(--w); }
.ov-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 40px; margin-top: 56px; align-items: start; }
.figure { font: 500 44px/1 var(--serif); margin: 4px 0 8px; letter-spacing: -0.015em; }
.figure .u { font-size: 22px; color: var(--ink-2); margin-left: 4px; }
.ov-water p.body { margin: 14px 0 20px; color: var(--ink-2); }
.mini { list-style: none; margin: 0 0 16px; padding: 0; }
.mini li { padding: 10px 0; border-bottom: 1px solid var(--rule); }
.mini li:first-child { padding-top: 0; }
.mini a { font-weight: 500; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini a:hover { color: var(--accent); text-decoration: underline; }

/* Invoices */
.filters { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 28px; }
.filters label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
select, input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[inputmode] {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--ink-3); border-radius: var(--r-sm);
  background: var(--sheet); font-size: 16px; color: var(--ink); width: 100%;
}
select { min-width: 200px; }
.inv-sum { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 32px 0 8px; }
.month-h {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  margin: 28px 0 0; padding-bottom: 8px; border-bottom: 1px solid var(--ink);
  font: 500 21px/1.2 var(--serif);
}
.month-h .amt { font: 500 16px var(--sans); color: var(--ink-2); }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 14px 4px; border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left; cursor: pointer;
}
.row:hover { background: var(--hover); }
.day { display: grid; justify-items: center; line-height: 1; }
.day b { font: 500 28px/1 var(--serif); }
.day small { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.who { min-width: 0; }
.who b { display: block; font-weight: 600; }
.who span { display: block; font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 600; }

/* Invoice detail sheet: the one raised surface, so it carries the only shadow */
.backdrop { position: fixed; inset: 0; background: rgba(28, 32, 30, 0.28); z-index: 40; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(540px, 100%); z-index: 41;
  background: var(--sheet); border-left: 1px solid var(--rule); box-shadow: -14px 0 36px rgba(28, 32, 30, 0.14);
  overflow-y: auto; padding: 24px 28px 40px;
  animation: sheet-in 160ms ease-out;
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-top { display: flex; justify-content: flex-end; }
.sheet h2 { font: 500 30px/1.15 var(--serif); margin: 8px 0 6px; }
table.ledger { width: 100%; border-collapse: collapse; margin-top: 24px; font-size: 15px; }
.ledger th { text-align: left; font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0 8px 8px 0; border-bottom: 1px solid var(--ink); }
.ledger td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger .num { text-align: right; white-space: nowrap; }
.ledger tfoot td { border-bottom: 0; padding-top: 14px; font-weight: 600; }
.ledger tfoot .total { margin: 0; }
.facts { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; margin: 28px 0 0; font-size: 15px; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Water */
.w-focal { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 8px 40px; align-items: end; }
.w-focal .figure { font-size: 64px; }
.w-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 28px 0 0; max-width: 640px; }
.w-stats dt { font-size: 14px; color: var(--ink-2); }
.w-stats dd { margin: 4px 0 0; font: 500 24px/1.2 var(--serif); }
.w-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 40px; margin-top: 44px; align-items: start; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 500; }
.field .opt { color: var(--ink-3); font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-msg { margin: 0; font-size: 14px; color: var(--red); min-height: 0; }
input[aria-invalid="true"] { border-color: var(--red); border-width: 2px; }
.form-status { margin: 14px 0 0; font-size: 15px; }
.saved { margin: 0 0 16px; padding: 14px 16px; background: var(--sheet); border: 1px solid var(--ink-3); border-radius: var(--r-md); }
.table-wrap { overflow-x: auto; }
.bills { list-style: none; margin: 0; padding: 0; }
.bills a { display: flex; justify-content: space-between; gap: 12px; min-height: 44px; align-items: center; border-bottom: 1px solid var(--rule); text-decoration: none; }
.bills a:hover span:first-child { color: var(--accent); text-decoration: underline; }

/* Bookmarks */
.bm-tools { margin-top: 28px; display: grid; gap: 14px; max-width: 720px; }
.bm-tools label { font-size: 14px; font-weight: 500; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  min-height: 44px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--ink-3);
  background: transparent; cursor: pointer; font-size: 15px;
}
.seg button:hover { background: var(--hover); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.seg .c { color: inherit; opacity: 0.75; margin-left: 4px; }
.bm-list { list-style: none; margin: 8px 0 0; padding: 0; max-width: 760px; }
.bm-list li { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.bm-list a.t { font-size: 17px; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.bm-list a.t:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.bm-list .d { margin: 6px 0 0; color: var(--ink-2); font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bm-list .tg { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }

/* Paging + sorting (Hendra's standard: 50/100/200, pager top and bottom, Sort dropdown) */
.listbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px 20px; margin-top: 22px; }
.listbar label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.listbar select { min-width: 200px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 14px 0; font-size: 14px; }
.pager-count, .pager-all { margin: 0; font-size: 14px; color: var(--ink-2); }
.pager-count b, .pager-all b { color: var(--ink); font-weight: 600; }
.pager-nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager-btn {
  min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--rule); background: transparent;
  border-radius: var(--r-sm); cursor: pointer; font-size: 14px;
}
.pager-btn:hover:not([disabled]):not([aria-disabled]) { background: var(--hover); }
.pager-btn[aria-current="page"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); font-weight: 600; }
.pager-btn[disabled], .pager-btn[aria-disabled="true"] { color: var(--ink-3); cursor: not-allowed; }
a.pager-btn, span.pager-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.pager-btn:hover { background: var(--hover); }
.pager form { display: contents; }
.pager-gap { padding: 0 4px; color: var(--ink-3); }
.pager-phone { display: none; padding: 0 8px; color: var(--ink-2); }
.pager label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.pager select { min-width: 0; width: auto; }
.pager input { width: 76px; }
.th-sort { background: none; border: 0; padding: 10px 0; margin: -10px 0; font: inherit; color: inherit; cursor: pointer; }
.th-sort:hover { color: var(--accent); }

/* Login */
main.login { max-width: none; padding: 32px 16px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.login-col { width: 100%; max-width: 400px; }
.login .brand { font-size: 44px; display: inline-block; padding-bottom: 8px; border-bottom: 4px double var(--ink); }
.login .intro { margin: 20px 0 28px; color: var(--ink-2); font-size: 17px; }
.gbtn {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 12px;
  background: #FFFFFF; border: 1px solid #747775; border-radius: var(--r-sm); cursor: pointer; font-size: 16px; font-weight: 500; color: #1F1F1F;
}
.gbtn:hover { background: #F7F7F7; }
.gbtn[disabled] { cursor: progress; color: var(--ink-2); }
.login .fine { margin: 16px 0 0; font-size: 14px; color: var(--ink-2); }
.notice { margin: 0 0 20px; padding: 14px 16px; border-radius: var(--r-md); background: var(--sheet); border: 1px solid var(--ink-3); }
.notice.err { border: 2px solid var(--red); }
.notice b { display: block; margin-bottom: 4px; }
.notice.err b { color: var(--red); }

@media (max-width: 899px) {
  .shell { display: block; }
  .rail { display: none; }
  .topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--rule);
  }
  .topbar .brand { font-size: 21px; }
  .tabs {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--paper); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs a {
    min-height: 56px; display: grid; place-items: center; text-decoration: none; font-size: 14px; font-weight: 500;
    color: var(--ink-2); border-top: 3px solid transparent;
  }
  .tabs a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); font-weight: 600; }
  main { padding: 24px 16px 104px; }
  h1 { font-size: 32px; }
  .total { font-size: 42px; }
  .ov-pair, .w-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; margin-top: 40px; }
  .cats a { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .cats .bar { grid-column: 1 / -1; grid-row: 2; }
  .w-focal .figure { font-size: 52px; }
  .w-stats { grid-template-columns: 1fr; gap: 14px; }
  .filters label { flex: 1 1 140px; }
  select { min-width: 0; }
  a.pager-num, .pager-gap { display: none; }
  .pager-phone { display: inline; }
  .listbar label, .listbar select { width: 100%; }
  .sheet { padding: 16px 16px 40px; border-left: 0; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 10px; }
  .col-price { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
}

/* Real-app additions */
.list-anchor { scroll-margin-top: 16px; }
.error-page { margin: 0; }
.login .gbtn { text-decoration: none; }
.signout { margin: 0; }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: inherit; text-align: left; }
.link-btn:hover { color: var(--accent); }

/* Screens: server-rendered links where the mockup used buttons */
a.row { text-decoration: none; color: inherit; }
.seg a {
  min-height: 44px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--ink-3);
  display: inline-flex; align-items: center; text-decoration: none; font-size: 15px;
}
.seg a:hover { background: var(--hover); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.mini .t { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-list span.t { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
a.th-sort { display: inline-flex; align-items: center; min-height: 44px; margin: -10px 0; text-decoration: none; }
a.backdrop { display: block; }
