/* Field Budget — instructor app
   Pacific Discovery brand: Poppins and DM Serif Display, topaz #55bbd2 and
   green #81c243, pill buttons, body grey #4a4a4a.

   Fonts are self-hosted rather than pulled from a CDN: this app has to open in
   Cuyabeno with no signal, and a webfont that fails to load is a layout that
   shifts under an instructor mid-entry. */

@font-face {
  font-family: 'Poppins';
  src: url('/fonts/Poppins-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('/fonts/Poppins-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Poppins';
  src: url('/fonts/Poppins-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'DM Serif Display';
  src: url('/fonts/DMSerifDisplay-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --paper: #f7f7f7;
  --card: #ffffff;
  --ink: #4a4a4a;          /* brand body grey, 8.9:1 on white */
  --ink-strong: #2f3133;
  --muted: #797979;
  --rule: #dee2e6;
  --gauge: #e4e7ea;

  --topaz: #55bbd2;        /* brand primary — identity, fills, accents */
  --topaz-dark: #288195;   /* derived along the same hue to reach 4.5:1 with
                              white text; brand topaz itself is only 2.2:1 */
  --topaz-darker: #1e6a7a;
  --topaz-soft: #eaf7fa;
  --green: #81c243;        /* brand secondary */
  --over: #b02a37;
  --over-soft: #fbeaec;

  --pad: 16px;
  --radius: 10px;
  --pill: 70px;            /* brand button radius */
  font-size: 17px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Poppins', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 400;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

/* overflow-x on `html` makes it a scroll container and, on iOS Safari and
   Android WebView, breaks vertical scrolling outright. `clip` on body alone
   contains a stray wide child without creating a scroll container or forcing
   overflow-y to auto. */
body { overflow-x: clip; }
@supports not (overflow: clip) {
  body { overflow-x: hidden; }
}

h1, h2 {
  font-family: 'DM Serif Display', Times, serif;
  font-weight: 400;
  color: var(--ink);
}

/* Poppins has no tabular figures — its "1" is half the width of its "0" — so
   money is right-aligned to keep the decimal flush rather than relying on a
   font feature that isn't there. */
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---- top bar ---- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--pad) 10px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
.bar-logo { flex: none; height: 22px; width: auto; display: block; }
.bar-id {
  flex: 1; min-width: 0; text-align: left;
  border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer;
}
.bar-id:focus-visible { outline: 2px solid var(--topaz-dark); outline-offset: 2px; border-radius: 6px; }
.bar-name {
  display: block; font-family: 'DM Serif Display', Times, serif;
  font-size: 1.06rem; line-height: 1.25; color: var(--ink);
}
.bar-sub { display: block; font-size: 0.75rem; color: var(--muted); }

.chip {
  flex: none; border: 1px solid var(--rule); background: var(--card);
  color: var(--muted); border-radius: var(--pill);
  padding: 6px 14px; font: inherit; font-size: 0.75rem; font-weight: 500; cursor: pointer;
}
.chip[data-state="pending"] {
  border-color: var(--topaz-dark); color: var(--topaz-dark);
  background: var(--topaz-soft); font-weight: 600;
}
.chip[data-state="offline"] { border-color: var(--over); color: var(--over); background: var(--over-soft); }

/* ---- main ---- */
main { padding: var(--pad) var(--pad) 108px; max-width: 560px; margin: 0 auto; }
.dock, .sheet-body { max-width: 560px; margin-left: auto; margin-right: auto; }

.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 24px 2px 10px;
}
.section-head:first-child { margin-top: 4px; }
.section-head h2 {
  margin: 0; font-family: 'Poppins', sans-serif; font-size: 0.72rem;
  font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.section-head span { font-size: 0.78rem; color: var(--muted); }

/* ---- category gauges ----
   Each row is a fuel gauge; the bar is the row's own bottom edge, so the
   remaining balance reads without a legend. */
.gauge-list { display: flex; flex-direction: column; gap: 8px; }

.gauge {
  position: relative; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 13px 14px 16px;
  font: inherit; color: inherit; cursor: pointer;
  overflow: hidden;
}
.gauge:active { background: #fbfdfe; }
.gauge:focus-visible { outline: 2px solid var(--topaz-dark); outline-offset: 2px; }

.gauge-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.gauge-name { font-weight: 500; color: var(--ink-strong); }
.gauge-left { font-size: 1rem; font-weight: 600; text-align: right; }
.gauge-meta { margin-top: 2px; font-size: 0.74rem; color: var(--muted); }

.gauge-track {
  position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: var(--gauge);
}
.gauge-fill { height: 100%; background: var(--topaz); transition: width .3s ease; }
.gauge.over .gauge-left { color: var(--over); }
.gauge.over .gauge-fill { background: var(--over); }

/* Three levels: leg headings are section-heads, so gauges start at depth 2.
   Depth 3 sits inside its parent's group. */
.gauge.d3 {
  margin-left: 14px; border-left: 3px solid var(--topaz-soft);
  padding-top: 11px; padding-bottom: 14px;
}
.gauge.d3 .gauge-name { font-weight: 400; }
.gauge.d3 .gauge-left { font-size: 0.92rem; }
/* A roll-up row is not directly loggable; it reads as a heading with a total. */
.gauge[data-parent] { background: #fcfefe; }
.gauge[data-parent] .gauge-name { font-weight: 600; }

/* ---- cash float ---- */
.float-row {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px;
}
.float-cur { font-weight: 500; color: var(--ink-strong); }
.float-amt { font-weight: 600; text-align: right; }
.float-amt.negative { color: var(--over); }

.empty {
  background: var(--card); border: 1px dashed var(--rule);
  border-radius: var(--radius); padding: 22px 18px; color: var(--muted);
  font-size: 0.88rem;
}

/* ---- search and filters ----
   The search field sits directly under the sheet title with no label above it:
   at this size a placeholder is enough, and a uppercase label would push the
   first result below the fold on a small phone. */
.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;
}

input.search {
  margin-top: 4px;
  /* iOS renders type=search with its own rounded chrome and a clear button that
     ignores the border radius set here. */
  -webkit-appearance: none; appearance: none;
}
input.search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
input.search::placeholder { color: var(--muted); }

.filters { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
/* The select takes the slack so the two-button toggle keeps its natural width;
   min-width:0 stops a long category name forcing the row off screen. */
.filters select { flex: 1 1 150px; min-width: 0; min-height: 42px; padding: 8px 10px; font-size: 0.86rem; }
.filters .seg { flex: 0 0 auto; }

.seg.small button {
  min-height: 42px; padding: 0 14px; font-size: 0.84rem; border-width: 1px;
}
.seg.small button[aria-pressed="true"] { border-width: 1px; }

.result-count {
  margin: 12px 2px 2px; font-size: 0.76rem; color: var(--muted);
  min-height: 1.2em;
}
.result-count:empty { margin: 4px 0 0; min-height: 0; }

mark {
  background: #fdf3c7; color: inherit; border-radius: 2px; padding: 0 1px;
}

/* ---- category sheet ---- */
.cat-summary {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 12px 14px 16px; margin-bottom: 4px;
}
.cat-figs { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
/* The remaining figure is the headline; wrapping "left" onto its own line reads
   as a second number. The allocated pair on the right can wrap instead. */
.cat-left { font-size: 1.1rem; font-weight: 600; color: var(--ink-strong); white-space: nowrap; }
.cat-of { font-size: 0.78rem; color: var(--muted); text-align: right; }
.cat-summary.over .cat-left { color: var(--over); }
.cat-summary.over .gauge-fill { background: var(--over); }
/* The sheet's Log button is the primary action, so it does not need the 22px of
   air the form submit carries at the bottom of a long form. */
.cat-summary + .submit { margin-top: 12px; }

/* ---- history ---- */
.entry {
  display: flex; gap: 12px; padding: 12px 2px; width: 100%;
  border: 0; border-bottom: 1px solid var(--rule);
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.entry:active { background: #fbfdfe; }
.entry:focus-visible { outline: 2px solid var(--topaz-dark); outline-offset: 2px; }
/* A corrected entry stays visible — the record is the point — but reads as
   settled rather than as spend still counting. */
.entry.void { cursor: default; opacity: .55; }
.entry.void .entry-desc, .entry.void .entry-amt { text-decoration: line-through; }
.entry:last-child { border-bottom: 0; }
.entry-main { flex: 1; min-width: 0; }
/* Wraps to two lines rather than truncating on the first. Once descriptions are
   searchable, an ellipsis can hide the very word that produced the match. */
.entry-desc {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
/* Wraps rather than truncates: with the logger's name on the end, one line is
   no longer enough on a narrow phone, and the name is the part that would be
   cut. */
.entry-meta { font-size: 0.74rem; color: var(--muted); line-height: 1.4; }
.entry-amt { font-weight: 600; white-space: nowrap; text-align: right; }
/* Someone else's entry is the one worth noticing in a shared budget, so the
   marker goes on theirs rather than on your own. */
.entry:not(.mine):not(.void) .entry-desc { border-left: 2px solid var(--topaz-soft); padding-left: 7px; margin-left: -9px; }
.dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 5px; vertical-align: middle;
}
.dot.pending { background: var(--over); }

/* ---- dock ---- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; gap: 8px;
  padding: 10px var(--pad) calc(env(safe-area-inset-bottom) + 10px);
  background: var(--card); border-top: 1px solid var(--rule);
}
.dock-btn {
  flex: 1; min-height: 52px; border-radius: var(--pill);
  border: 2px solid var(--rule); background: var(--card);
  font: inherit; font-weight: 500; color: var(--ink); cursor: pointer;
}
.dock-btn.primary {
  flex: 2; background: var(--topaz-dark); border-color: var(--topaz-dark);
  color: #fff; font-weight: 600;
}
.dock-btn.primary:active { background: var(--topaz-darker); border-color: var(--topaz-darker); }
.dock-btn:active { transform: translateY(1px); }

/* ---- sheet ---- */
.scrim { position: fixed; inset: 0; background: rgba(74,74,74,.45); z-index: 30; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-height: 92vh; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--paper);
  border-radius: 18px 18px 0 0;
  padding: 8px var(--pad) calc(env(safe-area-inset-bottom) + 20px);
}
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(18px); opacity: .6; } }
}
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--rule); margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 1.32rem; }

/* ---- forms ---- */
label {
  display: block; margin: 14px 0 6px;
  font-size: 0.76rem; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
input, select, textarea {
  width: 100%; max-width: 100%; min-width: 0;
  font: inherit; color: var(--ink);
  background: var(--card); border: 1px solid var(--rule);
  border-radius: var(--radius); padding: 13px 12px; min-height: 50px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--topaz-dark); outline-offset: -1px; border-color: var(--topaz-dark);
}

/* Date inputs carry an intrinsic width from their shadow DOM that width:100%
   does not beat on mobile Safari. Without this the row overflows the viewport
   and the fixed dock and sheet detach from the visible area. */
input[type="date"] {
  -webkit-appearance: none; appearance: none;
  display: block; height: 50px; line-height: normal;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { margin-left: 4px; }

.amount-input {
  font-size: 1.7rem; font-weight: 600; text-align: right;
  padding: 14px 12px; min-height: 62px;
}

.field-row { display: flex; gap: 10px; }
/* min-width:0 is required — flex items default to min-width:auto and will not
   shrink below their content, which is what pushes the row off screen. */
.field-row > div { flex: 1; min-width: 0; }

.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; min-height: 50px; border-radius: var(--pill);
  border: 2px solid var(--rule); background: var(--card);
  font: inherit; color: var(--ink); cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--topaz-dark); border-color: var(--topaz-dark);
  color: #fff; font-weight: 600;
}

.receipt {
  display: flex; align-items: center; gap: 12px;
  border: 1px dashed var(--rule); background: var(--card);
  border-radius: var(--radius); padding: 12px; margin-top: 6px;
}
.receipt img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.receipt-actions { flex: 1; display: flex; flex-direction: column; align-items: flex-start; }
.receipt-btn {
  min-height: 40px; border: 0; background: none; font: inherit; padding: 0;
  text-align: left; color: var(--topaz-dark); font-weight: 500; cursor: pointer;
}
.receipt-btn.alt { font-weight: 400; color: var(--muted); }
.receipt-btn.alt:active { color: var(--topaz-dark); }

.hint { font-size: 0.76rem; color: var(--muted); margin-top: 6px; }
.hint strong { font-weight: 600; color: var(--ink-strong); }
.error { font-size: 0.8rem; color: var(--over); margin-top: 6px; }

.submit {
  width: 100%; min-height: 56px; margin-top: 22px;
  border: 2px solid var(--topaz-dark); border-radius: var(--pill);
  background: var(--topaz-dark); color: #fff;
  font: inherit; font-weight: 600; font-size: 1rem;
  cursor: pointer;
}
.submit:active { background: var(--topaz-darker); border-color: var(--topaz-darker); transform: translateY(1px); }
.ghost {
  width: 100%; min-height: 48px; margin-top: 8px;
  border: 2px solid var(--rule); border-radius: var(--pill);
  background: none; color: var(--muted); font: inherit; cursor: pointer;
}

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 50; max-width: 88vw;
  background: var(--ink); color: #fff;
  border-radius: var(--pill); padding: 11px 20px; font-size: 0.86rem;
}

/* ---- sign-in ---- */
.signin {
  max-width: 400px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 44px) var(--pad) 40px;
  text-align: center;
}
.signin-logo { width: 190px; height: auto; margin: 0 auto 26px; display: block; }
.signin h1 { margin: 0 0 6px; font-size: 1.7rem; }
.signin-lede { margin: 0 0 26px; color: var(--muted); font-size: 0.88rem; }
.signin label, .signin input { text-align: left; }
.gbtn { min-height: 44px; display: flex; justify-content: center; }
.gbtn[hidden], .signin-or[hidden] { display: none; }
.signin-or {
  display: flex; align-items: center; gap: 12px;
  margin: 24px 0 4px; color: var(--muted); font-size: 0.74rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.signin-or::before, .signin-or::after {
  content: ''; flex: 1; height: 1px; background: var(--rule);
}
body.signed-out .bar, body.signed-out .dock, body.signed-out main { display: none; }


/* ==== Unearthed Education brand layer ====================================
   Appended to app.css by scripts/apply-brand.mjs when BRAND=ue. Everything
   above this line is the shared app; this only re-points tokens and type.

   Taken from the Unearthed leader portal: Inter, deep teal #2d6b74 header and
   buttons, light teal #59a1aa accents, cream #f9f8f2 paper, sand #e2decf rules,
   near-black #231f20 text, square-cornered controls.

   Inter is self-hosted for the same reason Poppins is: the app has to open
   with no signal. */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  --paper: #f9f8f2;
  --card: #ffffff;
  --ink: #231f20;
  --ink-strong: #231f20;
  --muted: #6b6b6b;         /* 5.2:1 on white, 4.9:1 on the cream paper */
  --rule: #e2decf;
  --gauge: #ece6d6;

  /* The PD token names are kept so no rule above needs touching. */
  --topaz: #59a1aa;         /* light teal — gauge fills, accents */
  --topaz-dark: #2d6b74;    /* deep teal — buttons, focus; 6.1:1 with white */
  --topaz-darker: #22535a;
  --topaz-soft: #eaf3f4;
  --green: #5b8f6a;         /* synced dot */
  --over: #c0392b;
  --over-soft: #fdf0ef;

  --radius: 4px;
  --pill: 4px;              /* the portal's controls are square-cornered */
}

html, body,
.section-head h2 {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Inter has real tabular figures, so money columns can use them. */
.num { font-feature-settings: 'tnum' 1; letter-spacing: 0; }

h1, h2, .bar-name {
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Header as on the portal: deep teal with the cream logo. */
.bar {
  background: var(--topaz-dark);
  border-bottom-color: var(--topaz-darker);
}
.bar-logo { height: 20px; }
.bar-name { color: #ffffff; }
.bar-sub { color: rgba(255, 255, 255, 0.78); }
.bar-id:focus-visible { outline-color: #ffffff; }
.bar .chip { border-color: rgba(255, 255, 255, 0.35); }

