/* The static wallet. Self-contained for the same reason the capture page is:
 * it is a file on GitHub Pages with no Flask behind it, so the tokens are
 * declared here rather than fetched from the app's stylesheet. Same scale and
 * palette as the app and the capture page, kept in step by eye -- there is no
 * build step to share them, and inventing one for three pages would cost more
 * than it saves.
 *
 * Sized for a thumb. This is opened on a phone, standing in a shop, and is
 * judged on the seconds between opening it and having recorded something --
 * so every control that gets tapped is at least 44px. */

:root {
  --bg: #12141a;
  --panel: #1a1d26;
  --panel-2: #21252f;
  --line: #2c313d;
  --ink: #e8eaf0;
  --ink-dim: #9aa2b4;
  --ink-faint: #6b7387;

  --accent: #6ea8fe;
  --good: #4bbd8a;
  --warn: #e8b04b;
  --bad: #e8695d;

  --text: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --t-small: 11.5px;
  --t-body: 13px;
  --t-mid: 15px;
  --t-big: 26px;
  --t-h1: 20px;
  --t-icon: 17px;

  --tap: 44px;
  --radius: 10px;
  --gap: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }

/* Any rule in this file that sets `display` beats the browser's own
   `[hidden] { display: none }`, because an author rule always beats a user
   agent one. `.progress` did exactly that: the empty progress track was
   drawn under the drop zone before any image was chosen, and setting
   `progress.hidden = true` after a read did nothing at all. This makes the
   attribute mean what it says whatever is declared below. */
[hidden] { display: none !important; }

body {
  background: var(--bg); color: var(--ink);
  font: 400 var(--t-body)/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--gap); padding: 18px 16px 12px;
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: var(--t-h1); font-weight: 600; letter-spacing: -0.2px; }
.sub { margin: 2px 0 0; color: var(--ink-dim); font-size: var(--t-small); font-family: var(--mono); }
.acts { display: flex; gap: 8px; }

.totals {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--line); border-bottom: 1px solid var(--line);
}
.total { background: var(--panel); padding: 11px 16px; }
.total .label {
  display: block; color: var(--ink-dim); font-size: var(--t-small);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.figure {
  display: block; margin-top: 2px;
  font: 500 var(--t-big)/1.2 var(--mono); font-variant-numeric: tabular-nums;
}
.figure.small { font-size: var(--t-mid); color: var(--ink-dim); }

main { padding: var(--gap) 16px 28px; display: grid; gap: var(--gap); }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;

  /* A grid item's min-width is `auto` -- "at least as wide as my content
     refuses to shrink below" -- and a seven-column table refuses a long
     way. That made .tableWrap's overflow-x: auto do nothing at all: rather
     than the table scrolling inside the card, the card grew, main grew, and
     the whole page ran off the right of a phone screen with every paragraph
     clipped mid-sentence. It only appeared once the table had rows in it,
     which is why it went unnoticed.

     min-width: 0 lets the card shrink to its column, so the overflow lands
     where it was meant to: on the table, which scrolls. */
  min-width: 0;
}
.card h2 { margin: 0 0 8px; font-size: var(--t-mid); font-weight: 600; }
.cardHead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.cardHead h2 { margin: 0; }
.hint { margin: 8px 0 0; color: var(--ink-faint); font-size: var(--t-small); }

/* ------------------------------------------------------------ the target */
/* Large on purpose: it is the one action on the page, so it should not look
 * like a form field. */
.drop {
  display: grid; place-items: center; gap: 4px;
  margin-top: 12px; padding: 34px 20px; cursor: pointer; text-align: center;
  background: var(--panel-2); border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop input[type="file"] {
  /* Hidden but reachable: the label wraps it, so a tap or a keyboard
   * activation still opens the picker and it stays in the tab order. */
  position: absolute; width: 1px; height: 1px; opacity: 0;
}
.dropBig { font-size: var(--t-mid); color: var(--ink); }
.dropSmall { color: var(--ink-faint); font-size: var(--t-small); }

.progress { display: grid; gap: 5px; margin-top: 12px; }
.progress .bar { display: block; height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.progress .bar > span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ----------------------------------------------------------- the reading */
.readingTop { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; margin-top: 14px; }
.fields { min-width: 0; }
@media (max-width: 700px) { .readingTop { grid-template-columns: 1fr; } }

.shot { display: block; max-width: 190px; max-height: 260px; border: 1px solid var(--line); border-radius: 8px; }

.needs {
  margin: 0 0 12px; padding: 9px 12px;
  background: #2a2118; border: 1px solid var(--line); border-radius: 7px;
  color: var(--warn); font-size: var(--t-small);
}
.needs p { margin: 0 0 4px; }
.needs p:last-child { margin-bottom: 0; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.row.actions { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.field.grow { flex: 1 1 200px; }
.field > span {
  color: var(--ink-dim); font-size: var(--t-small);
  text-transform: uppercase; letter-spacing: 0.05em;
}
input {
  min-height: var(--tap); font: 400 var(--t-body) var(--text);
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input[type="date"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  min-height: var(--tap); padding: 10px 16px; cursor: pointer;
  background: var(--accent); border: 1px solid var(--accent); color: #0d1017;
  border-radius: 8px; font: 600 var(--t-body) var(--text);
}
button.ghost { background: var(--panel-2); border-color: var(--line); color: var(--ink); font-weight: 400; }
button:hover { filter: brightness(1.08); }

.linky {
  min-height: 0; padding: 0; background: none; border: none;
  color: var(--accent); font: inherit; font-weight: 400;
  text-decoration: underline; cursor: pointer;
}

/* ----------------------------------------------------------- the entries */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.entries li {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  align-items: center; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
}
.what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.when { color: var(--ink-faint); font-size: 10.5px; font-family: var(--mono); }
.much { font: 500 var(--t-body) var(--mono); font-variant-numeric: tabular-nums; }
.iconButton {
  min-height: 34px; min-width: 34px; padding: 0;
  background: none; border: none; color: var(--ink-faint); font-size: var(--t-icon);
}
.iconButton:hover { color: var(--bad); filter: none; }
.empty { color: var(--ink-faint); font-size: var(--t-small); }

/* ----------------------------------------------------------- the notice */
.notice {
  margin: 0; padding: 9px 16px; font-size: var(--t-small);
  background: #2a2118; color: var(--warn); border-bottom: 1px solid var(--line);
}
.notice.good { background: #16281f; color: var(--good); }
.notice.bad { background: #2b1a18; color: var(--bad); }
.notice.warn { background: #2a2118; color: var(--warn); }

.foot {
  display: flex; justify-content: space-between; gap: var(--gap);
  flex-wrap: wrap; padding: 12px 16px 22px; border-top: 1px solid var(--line);
  color: var(--ink-faint); font: 400 var(--t-small) var(--mono);
}
.foot a { color: var(--ink-dim); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }

/* ---------------------------------------------------------- the table */
/* A column of money has one job, which is to line up, so every figure is
   monospaced with tabular figures and right-aligned. */
.tableWrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
th, td {
  text-align: left; padding: 7px 9px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
th {
  color: var(--ink-dim); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.06em; white-space: nowrap;
}
td.num, th.num {
  text-align: right; font-family: var(--mono);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
td.mono { font-family: var(--mono); }
.lag { color: var(--ink-faint); }
.warn { color: var(--warn); }
.tag {
  font: 10px var(--mono); color: var(--ink-dim);
  border: 1px solid var(--line); padding: 1px 5px; white-space: nowrap;
}

/* ----------------------------------------------------------- the bars */
/* Thin marks on a recessive track, rounded on the data end only so the mark
   stays anchored flat to the baseline it grows from. One measure, so one
   colour and no legend. */
.bars { display: grid; gap: 7px; margin-top: 12px; }
.bar {
  display: grid; grid-template-columns: 116px 1fr 84px;
  gap: 10px; align-items: center;
}
.bar .lab {
  font: 400 var(--t-small) var(--mono); color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar .rail {
  position: relative; height: 10px; background: var(--panel-2);
  border-radius: 3px;
}
.bar .fill {
  position: absolute; inset: 0 auto 0 0; background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.bar .val {
  text-align: right; font: 500 var(--t-small) var(--mono);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------- the totals */
/* Three figures across, so they wrap to one column on a phone rather than
   shrinking to something unreadable. */
.totals { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }

pre {
  margin: 12px 0 0; padding: 11px 13px; overflow-x: auto;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; font: var(--t-small)/1.7 var(--mono);
  color: var(--ink); white-space: pre-wrap;
}

select {
  min-height: var(--tap); font: 400 var(--t-body) var(--text);
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}

.limits { margin: 10px 0 0; padding-left: 18px; }
.limits li {
  color: var(--ink-dim); font-size: var(--t-small);
  margin-bottom: 5px; line-height: 1.5;
}
.limits a { color: var(--accent); }
.foot a { color: var(--accent); }
