/* Mobile-first, system fonts (nothing to download), kept small for budget phones. */
:root {
  --navy: #1d4f91; --navy-dark: #163d71; --blue: #3fa9dd; --green: #3cb54a;
  --ink: #1f2933; --muted: #5f6b78; --line: #d9e1ea; --bg: #f3f6f9; --card: #fff;
  --danger: #b42318; --danger-bg: #fdecea;
  --radius: 10px;
}
* { box-sizing: border-box; }
/* Elements with the hidden attribute stay hidden even if a class gives them display: flex */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--navy); }

.stripe { display: flex; height: 4px; }
.stripe span { flex: 1; background: var(--blue); }
.stripe span + span { background: var(--green); }

/* ---------- Login ---------- */
.auth { max-width: 400px; margin: 0 auto; padding: 32px 16px 48px; }
.auth .logo { display: block; width: 200px; height: auto; margin: 8px auto 24px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 18px;
}
.card h1 { margin: 0 0 18px; font-size: 1.3rem; color: var(--navy); }

label { display: block; font-weight: 600; font-size: 0.92rem; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
input[type=email], input[type=password], input[type=text] {
  width: 100%; height: 48px; padding: 0 12px; font: inherit; color: inherit;
  border: 1px solid #b9c4d0; border-radius: 8px; background: #fff;
}
input:focus { outline: 3px solid rgba(63, 169, 221, 0.35); border-color: var(--blue); }

.pw { position: relative; }
.pw input { padding-right: 68px; }
.pw button {
  position: absolute; right: 4px; top: 4px; height: 40px; padding: 0 12px;
  border: 0; background: none; color: var(--navy); font: inherit; font-size: 0.9rem; font-weight: 600;
}

.btn {
  display: block; width: 100%; height: 50px; border: 0; border-radius: 8px;
  background: var(--navy); color: #fff; font: inherit; font-weight: 700; font-size: 1.05rem;
}
.btn:active { background: var(--navy-dark); }
.btn-plain {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px;
  height: 40px; padding: 0 14px; font: inherit; font-size: 0.92rem;
}

.alert {
  background: var(--danger-bg); color: var(--danger); border: 1px solid #f5c2bc;
  border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; font-size: 0.95rem;
}
.hint { color: var(--muted); font-size: 0.85rem; text-align: center; margin-top: 18px; }

/* ---------- App shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar img { height: 34px; width: auto; display: block; }
.topbar form { margin: 0; }
.main { max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; }
.who { color: var(--muted); font-size: 0.92rem; margin: 0 0 4px; }
.main h1 { margin: 0 0 18px; font-size: 1.4rem; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.75rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: #e6f0fb; color: var(--navy);
}

/* ---------- Shared ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.pre { white-space: pre-line; margin-bottom: 12px; }
.help { margin: 6px 0 0; color: var(--muted); font-size: 0.85rem; }
.back { text-decoration: none; font-weight: 600; font-size: 1.05rem; padding: 8px 4px; }
a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-big { margin: 4px 0 18px; height: 54px; font-size: 1.1rem; }
.btn:disabled { opacity: 0.6; }
.btn-plain.wide { flex: 1; display: flex; align-items: center; justify-content: center; text-decoration: none; height: 46px; }
.btn-plain.small { height: 34px; padding: 0 12px; }
.btn-row { display: flex; gap: 10px; margin: -6px 0 18px; }
.btn-danger-link { display: block; margin: 24px auto 0; background: none; border: 0; color: var(--danger); font: inherit; text-decoration: underline; padding: 10px; }
.card + .card, .card + section, section + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; color: var(--navy); }
textarea { width: 100%; padding: 10px 12px; font: inherit; color: inherit; border: 1px solid #b9c4d0; border-radius: 8px; resize: vertical; }
input[type=date], input[type=tel], input[type=search] {
  width: 100%; height: 48px; padding: 0 12px; font: inherit; color: inherit;
  border: 1px solid #b9c4d0; border-radius: 8px; background: #fff;
}
.success { background: #e6f4ea; color: #1e6b34; border: 1px solid #b7dfc3; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.notice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  background: #fff6e0; border: 1px solid #f2d48a; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 0.95rem; }
.notice-actions { display: flex; gap: 8px; }
.alert ul { margin: 0; padding-left: 18px; }

.status { display: inline-block; vertical-align: middle; padding: 1px 8px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.status.draft { background: #fff2d6; color: #8a5a00; }
.status.signed { background: #e3f4e5; color: #1f7a2b; }
.status.void { background: #fbe3e3; color: #9b1c1c; }

/* ---------- Invoice list ---------- */
.section { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 22px 0 8px; }
.count { background: var(--navy); color: #fff; border-radius: 99px; padding: 0 7px; font-size: 0.75rem; }
.empty { color: var(--muted); margin: 0; }
.list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; color: inherit; text-decoration: none; min-height: 64px; }
.row:active { background: #f0f5fa; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 0.88rem; }
.row-sub.addr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.row-total { font-weight: 700; }

/* ---------- Invoice form ---------- */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fbfcfe; }
.line-name { width: 100%; height: 42px; margin-bottom: 8px; }
.line-name.static { height: auto; font-weight: 600; }
.line-nums { display: flex; align-items: flex-end; gap: 6px; }
.mini { display: flex; flex-direction: column; margin: 0; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.mini input { height: 42px; margin-top: 2px; font-size: 1rem; font-weight: 400; color: var(--ink); }
.in-qty { width: 4.2em !important; text-align: center; padding: 0 4px !important; }
.in-money { width: 5.6em !important; text-align: right; padding: 0 8px !important; }
.times { color: var(--muted); padding-bottom: 10px; }
.rate { padding-bottom: 10px; font-size: 0.92rem; white-space: nowrap; }
.line-amount { margin-left: auto; padding-bottom: 10px; font-weight: 700; white-space: nowrap; }
.remove { width: 40px; height: 42px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: 1.3rem; line-height: 1; }
.btn-add { margin-top: 10px; width: 100%; height: 46px; border: 1px dashed #9fb3c8; border-radius: 8px; background: #fff; color: var(--navy); font: inherit; font-weight: 600; }
.search { position: relative; margin-bottom: 10px; }
.results { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results button { display: flex; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; border: 0; background: none; font: inherit; text-align: left; color: inherit; }
.results button:active { background: #eef4fa; }
.results .price { color: var(--muted); white-space: nowrap; }
.results .no-match { padding: 10px 12px; color: var(--muted); font-size: 0.92rem; }
.bottombar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px; margin: 16px -16px -40px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.bottom-total { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.bottom-total span { color: var(--muted); font-size: 0.8rem; }
.bottom-total strong { font-size: 1.3rem; color: var(--navy); }
.bottombar .btn { width: 46%; }

/* ---------- Summary / signing ---------- */
.summary { font-size: 0.95rem; }
.sum-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sum-right { text-align: right; }
.sum-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--navy); margin-bottom: 2px; }
.sum-strong { font-weight: 700; font-size: 1.05rem; }
.sum-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sum-table td, .sum-table th { padding: 8px 0; border-top: 1px solid var(--line); vertical-align: top; text-align: left; }
.sum-table .sub th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--navy); padding-top: 14px; }
.sum-table .muted { font-size: 0.85rem; }
.sum-table .num { text-align: right; white-space: nowrap; padding-left: 10px; }
.sum-table .grand td { border-top: 2px solid var(--navy); font-weight: 800; font-size: 1.2rem; color: var(--navy); padding-top: 10px; }
.signed-line { margin: -8px 0 16px; text-align: center; font-size: 0.9rem; }
.pad-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.pad-head label { margin: 0; }
.pad-wrap { position: relative; }
#pad { display: block; width: 100%; height: 190px; border: 1.5px solid #9fb3c8; border-radius: 8px; background: #fff; touch-action: none; }
.pad-x { position: absolute; left: 14px; bottom: 36px; color: #b9c4d0; font-size: 1.1rem; pointer-events: none; }
.pad-line { position: absolute; left: 36px; right: 16px; bottom: 40px; border-bottom: 1px solid #c9d3de; pointer-events: none; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 6px 0 18px; font-size: 0.95rem; }
.check input { width: 26px; height: 26px; flex-shrink: 0; margin: 0; }

/* ---------- Account & admin ---------- */
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.toplink { font-weight: 600; text-decoration: none; padding: 8px 2px; }
.lead { color: var(--muted); margin: -10px 0 16px; }
.center { text-align: center; }
.admin-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -4px 0 8px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); min-height: 70px; }
.tile b { color: var(--navy); }
.tile span { color: var(--muted); font-size: 0.85rem; line-height: 1.3; }
.tile:active { background: #f0f5fa; }
.money-input { display: flex; align-items: center; gap: 6px; }
.money-input span { font-weight: 700; color: var(--muted); }
fieldset.choice { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.choice legend { font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; padding: 0; }
.radio { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 8px; background: #fff; }
.radio input { width: 22px; height: 22px; margin: 2px 0 0; flex-shrink: 0; }
.radio .muted { font-size: 0.88rem; }
.btn-plain.danger { color: var(--danger); border-color: #f0c4bf; }
details.removed { margin-top: 22px; }
details.removed summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
li.row { align-items: center; }
.big-text { font-size: 1.15rem; font-weight: 600; margin: 0 0 12px; word-break: break-all; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.25rem; letter-spacing: 0.02em;
  background: #f3f6f9; border: 1px dashed #b9c4d0; border-radius: 6px; padding: 8px 10px; }

/* ---------- Customers ---------- */
.tile.wide { grid-column: span 2; }
.linked { border: 1px solid #b7d3ee; background: #f2f8fd; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; }
.linked-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.linked .help { margin-top: 6px; }
.cust-notes { margin-top: 8px; padding: 8px 10px; background: #fff8e1; border: 1px solid #f2d48a; border-radius: 6px;
  white-space: pre-line; font-size: 0.93rem; }
#cust-find { margin-bottom: 16px; }
.cust-option { flex-direction: column; align-items: flex-start !important; gap: 0 !important; }
.cust-option .row-sub { font-size: 0.85rem; }
.search-form { display: flex; gap: 8px; margin: 0 0 12px; }
.search-form input { flex: 1; }
.search-form .btn-plain { height: 48px; }

/* ---------- Email ---------- */
.email-log { list-style: none; margin: 0 0 12px; padding: 0; font-size: 0.93rem; }
.email-log li { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.email-log li:first-child { border-top: 0; }
.email-icon { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-size: 0.75rem; font-weight: 800; margin-top: 2px; }
.email-log .sent .email-icon { background: #e3f4e5; color: #1f7a2b; }
.email-log .failed .email-icon { background: #fbe3e3; color: #9b1c1c; }
.email-log .skipped .email-icon { background: #eef1f4; color: var(--muted); }
.email-form { display: flex; gap: 8px; }
.email-form input { flex: 1; min-width: 0; }
.email-form .btn-plain { height: 48px; white-space: nowrap; }
