/* Theme: Titip Counter Blue (titip-counter-blue), pulled with the theme library.
   The page uses the tokens only. No web fonts are loaded: the stacks fall back to the phone's own. */
:root {
  color-scheme: light dark;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1b1a17;
  --muted: #6c665d;
  --line: #e1dbcf;
  --accent: #2f5b8c;
  --accent-ink: #ffffff;
  --ok: #2e7566;
  --x-signal: #d9481f;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-body: "Geist", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b18;
    --surface: #201f1c;
    --ink: #efebe3;
    --muted: #968f83;
    --line: #2e2c28;
    --accent: #86aee0;
    --accent-ink: #1c1b18;
    --ok: #6fc2ad;
    --x-signal: #f0764f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font-body);
}
main {
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 1.1rem) 1rem calc(env(safe-area-inset-bottom) + 2rem);
}
[hidden] { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; }
h1 { font-size: 2.3rem; line-height: 1.05; }
h2 { font-size: 1.45rem; margin: 1.6rem 0 0.5rem; }
h3 { font-size: 1.2rem; margin: 1.4rem 0 0.4rem; }
p { margin: 0; }

.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.week { color: var(--muted); margin-top: 0.15rem; }
.link { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 0.6rem; font-size: 0.92rem; color: var(--muted); }
.dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--line); transform: translateY(-0.05rem); }
.link.fine .dot { background: var(--ok); }
.link.trouble { color: var(--ink); }
.link.trouble .dot { background: var(--x-signal); }

.banner {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.95rem;
}

button { font: inherit; color: inherit; }
.quiet {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius);
  padding: 0.45rem 0.8rem;
  min-height: 2.75rem;
  color: var(--muted);
}
.quiet:active { background: var(--surface); }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 0.9rem;
  width: 100%;
  min-height: 3.4rem;
  padding: 0.6rem 0.85rem;
  border: 0;
  background: transparent;
  text-align: left;
}
.row:active { background: var(--bg); }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .rate { font-family: var(--font-mono); font-weight: 500; text-align: right; white-space: nowrap; }
.row .sub { grid-column: 1; color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.row .qty { grid-column: 2; color: var(--muted); font-size: 0.86rem; text-align: right; white-space: nowrap; }

details.group > summary {
  font-family: var(--font-display);
  font-size: 1.45rem;
  margin: 1.6rem 0 0.5rem;
  cursor: pointer;
  list-style-position: outside;
  margin-left: 1.1rem;
}
.count { font-family: var(--font-body); font-size: 0.9rem; color: var(--muted); margin-left: 0.4rem; }

.back { border: 0; background: transparent; color: var(--accent); padding: 0.6rem 0.6rem 0.6rem 0; min-height: 2.75rem; margin-top: 0.6rem; }
.project-name { font-size: 2rem; line-height: 1.1; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 0.92rem; margin-top: 0.2rem; }
.figure { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-top: 0.9rem; }
.figure .big { font-family: var(--font-mono); font-size: 2.1rem; font-weight: 500; line-height: 1; }
.figure .beside { color: var(--muted); }

table { width: 100%; border-collapse: collapse; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 0.95rem; }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-top: 1px solid var(--line); }
thead th { border-top: 0; font-weight: 500; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
thead th.num { font-family: var(--font-body); }
.tag { display: inline-block; margin-left: 0.4rem; padding: 0 0.35rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.72rem; color: var(--muted); vertical-align: 0.08em; }
.empty { color: var(--muted); padding: 0.75rem 0; }

.periods { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.period {
  min-height: 3rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.period:active { opacity: 0.85; }
.period[disabled] { background: transparent; color: var(--muted); border-color: var(--line); }
.hint { color: var(--muted); font-size: 0.88rem; margin-top: 0.5rem; }
.reading table + table { margin-top: 0.6rem; }

.reading { margin-top: 0.75rem; padding: 0.8rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.reading .head { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; }
.reading .when { color: var(--muted); font-weight: 400; font-size: 0.88rem; white-space: nowrap; }
.reading .state { color: var(--muted); margin-top: 0.2rem; }
.reading.failed .state { color: var(--x-signal); }
.reading table { margin-top: 0.7rem; }
.reading .figure { margin-top: 0.5rem; }
.reading .figure .big { font-size: 1.7rem; }

footer { margin-top: 2.2rem; color: var(--muted); font-size: 0.85rem; }
footer .quiet { margin-top: 0.8rem; }

@media (prefers-reduced-motion: no-preference) {
  .reading.busy .state::after { content: ""; display: inline-block; width: 0.45rem; height: 0.45rem; margin-left: 0.45rem; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.2; } }
}
