/* Mastro UI — mobile-first, warm paper + deep navy + amber. */
:root {
  --navy: #12294b;
  --amber: #e8a13c;
  --paper: #f7f5f0;
  --ink: #1a2233;
  --line: #e2ddd2;
  --muted: #6b7280;
  --green: #2e7d4f;
  --red: #b3372f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--paper); color: var(--ink); font-size: 16px; line-height: 1.5;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--navy); }

/* Sticky top nav */
nav {
  position: sticky; top: 0; z-index: 10; background: var(--navy);
  display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
nav a {
  color: #cdd6e4; text-decoration: none; padding: 14px 14px; font-size: 14px;
  white-space: nowrap; border-bottom: 3px solid transparent;
}
nav a.active { color: #fff; border-bottom-color: var(--amber); }
nav a.brand { font-family: Georgia, serif; font-weight: bold; color: var(--amber); font-size: 17px; }
/* Phones: tighter tabs, no brand — 7 tabs + toggles don't fit otherwise
   and the cut-off row read as broken. The row still scrolls sideways. */
@media (max-width: 600px) {
  nav a { padding: 12px 10px; font-size: 13px; }
  nav a.brand { display: none; }
}

main { max-width: 640px; margin: 0 auto; padding: 20px 16px 80px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

/* Cards & lists */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; margin-bottom: 12px;
}
.card.tappable { cursor: pointer; }
.card.tappable:active { background: #faf8f4; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub { color: var(--muted); font-size: 13px; }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Stat tiles (dashboard). minmax(0,1fr) lets a tile shrink below its
   content width — without it a long amount forces the grid past the
   screen edge on phones. */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
@media (min-width: 480px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0; }
.stat .v { font-family: Georgia, serif; font-size: 19px; color: var(--navy); font-weight: bold; overflow-wrap: break-word; }
.stat .l { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stat.warn .v { color: var(--red); }

/* Status pills */
.pill {
  display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; padding: 2px 9px; border-radius: 999px; background: #e5e7eb; color: #4b5563;
}
.pill.sent { background: #fdf0dc; color: #9a6516; }
.pill.accepted, .pill.paid { background: #ddf0e4; color: var(--green); }
.pill.rejected, .pill.overdue { background: #f7dedc; color: var(--red); }
.pill.partial { background: #fdf0dc; color: #9a6516; }
.pill.void { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 4px; color: var(--navy); }
input, select, textarea {
  width: 100%; padding: 10px 12px; font-size: 16px; /* 16px stops iOS zoom */
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); border-color: var(--amber); }

button, .btn {
  display: inline-block; border: none; border-radius: 8px; padding: 11px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--navy); color: #fff; font-family: inherit;
}
button.secondary, .btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
button.amber, .btn.amber { background: var(--amber); color: var(--navy); }
button.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
button.small { padding: 7px 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Quote builder line items */
.item-row {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  margin-bottom: 10px; background: #fff;
}
.item-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.item-grid > div { min-width: 0; }
.item-grid label { margin-top: 0; font-size: 11px; }
/* Column variants. minmax(0,1fr) everywhere: iOS date/select widgets have a
   large intrinsic width and overflow a plain 1fr track (fields overlapped
   on iPhone without it). */
.item-grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.item-grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 430px) { .item-grid.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
input[type="date"], input[type="month"] { min-width: 0; }
.builder-total {
  position: sticky; bottom: 0; background: var(--navy); color: #fff; border-radius: 10px;
  padding: 12px 16px; margin-top: 14px; font-variant-numeric: tabular-nums;
}
.builder-total .grand { font-size: 20px; font-family: Georgia, serif; color: var(--amber); }
.builder-total .band { font-size: 13px; color: #cdd6e4; }

.error-msg { background: #f7dedc; color: var(--red); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.ok-msg { background: #ddf0e4; color: var(--green); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* Auth screen */
.auth-wrap { max-width: 380px; margin: 8vh auto 0; padding: 0 16px; }
.auth-wrap .auth-icon { display: block; width: 64px; margin: 4vh auto 12px; }
.auth-wrap .logo-word { font-family: Georgia, serif; font-size: 42px; color: var(--navy); text-align: center; }
.auth-wrap .logo-word span { color: var(--amber); }
.auth-wrap .tag { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.home-link { display: block; text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
table.mini td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.mini tr.total td { border-bottom: none; font-weight: 700; color: var(--navy); }

.receipt-thumb { max-height: 60px; border-radius: 6px; display: block; }

/* VAT4 form box numbers */
.box-num {
  display: inline-block; min-width: 30px; text-align: center; font-weight: 700;
  font-size: 12px; color: var(--navy); background: #fdf0dc; border: 1px solid var(--amber);
  border-radius: 6px; padding: 1px 4px; margin-right: 6px; font-variant-numeric: tabular-nums;
}
