:root {
  --accent: #2f6feb;
  --accent-dark: #1e50b5;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2333;
  --muted: #67748c;
  --line: #e3e8f0;
  --green: #1d8a4e;
  --red: #c43d3d;
  --amber: #b07d18;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; margin-bottom: .6rem; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { background: var(--card); border-radius: 14px; padding: 1.6rem; width: 100%; max-width: 380px; box-shadow: 0 8px 30px rgba(20,40,80,.12); }
.auth-card h1 { text-align: center; margin-bottom: .3rem; }
.auth-card .muted { text-align: center; margin-bottom: 1.2rem; }
.auth-card label { display: block; margin-bottom: .9rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
.auth-card input { width: 100%; margin-top: .3rem; }
.auth-links { margin-top: 1rem; display: flex; flex-direction: column; gap: .45rem; text-align: center; font-size: .9rem; }
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-msg { margin-top: 1rem; padding: .6rem .8rem; border-radius: 8px; font-size: .9rem; background: #eef2fb; }
.auth-msg.error { background: #fbeeee; color: var(--red); }
.auth-msg.ok { background: #ecf7f0; color: var(--green); }

/* ---------- inputs & buttons ---------- */
input, select, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 9px; padding: .55rem 1rem; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.danger { color: var(--red); border-color: #eecccc; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- app chrome ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
header {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; margin-right: auto; }
.timer-badge { background: var(--accent); color: #fff; font-weight: 700; border-radius: 999px; padding: .15rem .7rem; font-variant-numeric: tabular-nums; }
main { flex: 1; padding: 1rem; padding-bottom: 5.2rem; max-width: 760px; width: 100%; margin: 0 auto; }
nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav a { flex: 1; text-align: center; padding: .5rem 0 .4rem; text-decoration: none; color: var(--muted); font-size: 1.15rem; }
nav a span { display: block; font-size: .62rem; font-weight: 600; }
nav a.active { color: var(--accent); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; text-align: center; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.list-item { display: flex; gap: .7rem; align-items: baseline; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.badge { font-size: .72rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge.sent { background: #fdf3dd; color: var(--amber); }
.badge.paid { background: #ecf7f0; color: var(--green); }
.badge.void, .badge.draft { background: #eef0f4; color: var(--muted); }
.badge.overdue { background: #fbeeee; color: var(--red); }
.form-grid { display: grid; gap: .8rem; }
.form-grid label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.form-grid label > * { margin-top: .3rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.actions { display: flex; gap: .6rem; margin-top: .9rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 1.1rem 0 .5rem; }

/* ---------- timer ---------- */
.timer-card { text-align: center; }
.timer-time { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .4rem 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: .6rem 1.1rem; border-radius: 999px;
  font-size: .9rem; z-index: 20; max-width: 90vw; text-align: center;
}

/* invoice detail table */
table.lines { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.lines td { padding: .45rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.lines td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* invoice detail (old-app layout) */
table.lines th { text-align: left; padding: .35rem .3rem; border-bottom: 2px solid var(--line); font-size: .75rem; color: var(--muted); }
table.lines th.num, table.lines td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.totals-block div { padding: .15rem 0; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; }

/* invoice UI sizing (Steve 2026-08-14: table was squished, wizard rows oversized) */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table.lines { min-width: 460px; }
table.lines td { font-size: .82rem; }
table.lines td .sub { font-size: .75rem; }
#form-wizard .list-item { padding: .4rem 0; gap: .55rem; align-items: center; }
#form-wizard .list-item .title { font-weight: 400; font-size: .85rem; line-height: 1.3; }
#form-wizard .list-item .amount { font-weight: 400; font-size: .78rem; color: var(--muted); }
#form-wizard input[type="checkbox"] { width: 1.05rem; height: 1.05rem; flex: none; }
#form-wizard .card h2 { font-size: .95rem; }

/* phone-first line items: stack each line as a card row, no horizontal scroll */
@media (max-width: 640px) {
  .table-scroll { overflow-x: visible; }
  .table-scroll table.lines { min-width: 0; }
  table.lines thead { display: none; }
  table.lines, table.lines tbody, table.lines tr, table.lines td { display: block; width: 100%; }
  table.lines tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.lines tr:last-child { border-bottom: 0; }
  table.lines td { border: 0; padding: 0; font-size: .88rem; }
  table.lines td.num { display: inline-block; width: auto; margin: .15rem .7rem 0 0; color: var(--muted); font-size: .8rem; }
  table.lines td.num:last-child { float: right; margin-right: 0; color: inherit; font-weight: 700; font-size: .88rem; }
}

/* brand: Track & Bill — a tuning labs company */
.brand-tagline { font-size: .72rem; letter-spacing: .04em; color: var(--muted); text-transform: lowercase; margin: 0 0 .8rem; }
.brand-tagline-inline { font-size: .6rem; font-weight: 400; letter-spacing: .03em; color: var(--muted); text-transform: lowercase; margin-left: .35rem; opacity: .8; }
