/* BossDocs — navy + white, phone-first, big tap targets. Nothing fancy. */
:root {
  --navy: #12262e;
  --navy-2: #1b3644;
  --navy-3: #2a4a5a;
  --ink: #16232a;
  --muted: #6b7d86;
  --line: #dde5e9;
  --bg: #f4f7f8;
  --card: #ffffff;
  --accent: #2f80c1;
  --red: #c22f2f;
  --green: #1e8e4f;
  --amber: #b97d10;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.4;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--navy); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
}
#topbar .brand { font-size: 22px; font-weight: 700; letter-spacing: .2px; }
.icon-btn {
  background: transparent; border: 0; color: #fff;
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px;
}
.icon-btn:active { background: var(--navy-3); }

/* ---------- layout ---------- */
#view { padding: 14px 14px 110px; max-width: 640px; margin: 0 auto; }
h1.screen-title { font-size: 24px; margin: 6px 2px 12px; }

/* ---------- bottom tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: stretch; justify-content: space-around;
  background: var(--navy);
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 14px rgba(18, 38, 46, .25);
}
#tabbar .tab {
  flex: 1; background: transparent; border: 0; color: #b9ccd4;
  font-size: 17px; font-weight: 600; min-height: 56px; border-radius: 12px;
}
#tabbar .tab.active { color: #fff; background: var(--navy-3); }
#tabbar .tab-new {
  flex: 0 0 76px; margin: -22px 8px 0;
  background: var(--accent); color: #fff; border: 3px solid var(--bg);
  border-radius: 50%; width: 76px; height: 76px;
  font-size: 34px; font-weight: 700; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(18, 38, 46, .35);
}
#tabbar .tab-new span { font-size: 12px; font-weight: 600; margin-top: 1px; }
#tabbar .tab-new:active { background: #256ea7; }

/* ---------- cards & lists ---------- */
.search {
  width: 100%; padding: 14px 16px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card); margin-bottom: 12px; outline: none;
}
.search:focus { border-color: var(--accent); }
.doc-card {
  display: block; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; min-height: 76px;
}
.doc-card:active { background: #eef3f5; }
.doc-card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc-card .num { font-weight: 700; color: var(--navy); font-size: 16px; }
.doc-card .client { display: block; font-size: 20px; font-weight: 600; margin: 4px 0 2px; }
.doc-card .row3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 15px; }
.doc-card .total { font-size: 18px; font-weight: 700; color: var(--ink); }
.doc-card .balance { font-size: 16px; font-weight: 700; }
.balance.due { color: var(--red); }
.balance.paid { color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 42px 16px; font-size: 17px; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
  background: #e3eaed; color: var(--navy-2);
}
.pill.draft { background: #e3eaed; color: #54666f; }
.pill.sent { background: #fdf0d3; color: var(--amber); }
.pill.accepted, .pill.paid { background: #d9f2e2; color: var(--green); }
.pill.declined, .pill.overdue { background: #fadede; color: var(--red); }
.pill.partial { background: #fdf0d3; color: var(--amber); }

/* ---------- document view ---------- */
.back-btn {
  background: transparent; border: 0; color: var(--accent);
  font-size: 17px; font-weight: 600; padding: 10px 4px; min-height: 48px;
}
.head-card, .block {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.head-card .num { font-size: 15px; font-weight: 700; color: var(--muted); }
.head-card .client { font-size: 24px; font-weight: 700; margin: 2px 0 6px; }
.head-card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 15px; }
.block h2 { font-size: 16px; margin: 0 0 10px; color: var(--navy); text-transform: uppercase; letter-spacing: .4px; }
table.items { width: 100%; border-collapse: collapse; }
table.items td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.items tr:last-child td { border-bottom: 0; }
table.items .desc { font-weight: 600; }
table.items .det { color: var(--muted); font-size: 14px; font-weight: 400; white-space: pre-wrap; }
table.items .qty { color: var(--muted); font-size: 14px; }
table.items .amt { text-align: right; font-weight: 600; white-space: nowrap; padding-left: 10px; }
.totals { width: 100%; border-collapse: collapse; }
.totals td { padding: 6px 0; }
.totals td:last-child { text-align: right; font-weight: 600; white-space: nowrap; }
.totals .grand td { font-size: 20px; font-weight: 800; border-top: 2px solid var(--navy); padding-top: 10px; }
.totals .bal td { font-size: 18px; font-weight: 800; }
.totals .bal.due td { color: var(--red); }
.totals .bal.paid td { color: var(--green); }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-row .p-main { flex: 1; }
.pay-row .p-amt { font-weight: 700; }
.pay-row .p-sub { color: var(--muted); font-size: 14px; }
.pay-del {
  background: #fbeaea; color: var(--red); border: 0; border-radius: 10px;
  width: 44px; height: 44px; font-size: 20px; font-weight: 700; flex: 0 0 44px;
}
.notes-text { white-space: pre-wrap; color: var(--ink); }

/* ---------- action buttons ---------- */
.actions { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.btn {
  display: block; width: 100%; min-height: 56px; padding: 14px 16px;
  border-radius: var(--radius); border: 1.5px solid var(--navy);
  background: var(--card); color: var(--navy); font-size: 18px; font-weight: 700;
  text-align: center; text-decoration: none;
}
.btn.primary { background: var(--navy); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .5; }
.link-box {
  display: flex; gap: 8px; align-items: stretch; margin-top: 10px;
}
.link-box input {
  flex: 1; min-width: 0; padding: 12px; font-size: 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg);
}
.link-box button {
  flex: 0 0 auto; padding: 0 18px; min-height: 48px;
  background: var(--navy); color: #fff; border: 0; border-radius: 10px; font-weight: 700;
}

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 700; color: var(--navy); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field textarea {
  width: 100%; padding: 14px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 76px; resize: vertical; }
.form-error { color: var(--red); font-weight: 600; margin: 10px 0; min-height: 1.2em; }
.two-col { display: flex; gap: 10px; }
.two-col .field { flex: 1; }

/* items editor */
.item-edit {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.item-edit .ie-desc { width: 100%; padding: 12px; font-size: 17px; border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 8px; outline: none; }
.item-edit .ie-row { display: flex; gap: 8px; align-items: center; }
.item-edit .ie-row input {
  padding: 12px; font-size: 17px; border: 1.5px solid var(--line); border-radius: 10px; outline: none; min-width: 0;
}
.item-edit .ie-qty { flex: 0 0 76px; }
.item-edit .ie-price { flex: 1; }
.item-edit .ie-total { flex: 0 0 auto; font-weight: 700; white-space: nowrap; }
.item-edit .ie-del {
  flex: 0 0 48px; width: 48px; height: 48px; border: 0; border-radius: 10px;
  background: #fbeaea; color: var(--red); font-size: 20px; font-weight: 700;
}
.item-edit input:focus { border-color: var(--accent); }

/* type chooser + lead picker */
.type-row { display: flex; gap: 10px; margin-bottom: 16px; }
.type-btn {
  flex: 1; min-height: 84px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--card);
  font-size: 20px; font-weight: 800; color: var(--navy);
}
.type-btn.sel { border-color: var(--navy); background: var(--navy); color: #fff; }
.lead-hit {
  display: block; width: 100%; text-align: left; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; margin-bottom: 8px; min-height: 56px;
}
.lead-hit .ln { font-weight: 700; font-size: 17px; }
.lead-hit .lc { color: var(--muted); font-size: 14px; }
.selected-client {
  background: #e7f0f6; border: 1.5px solid var(--accent); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.selected-client button { background: transparent; border: 0; color: var(--red); font-weight: 700; font-size: 16px; min-height: 44px; padding: 0 6px; }

/* ---------- login ---------- */
.login-wrap { max-width: 420px; margin: 8vh auto 0; padding: 0 6px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 30px; color: var(--navy); }
.login-card p { margin: 0 0 20px; color: var(--muted); }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 22, 28, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 16px; font-size: 22px; color: var(--navy); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 70px; min-height: 52px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 16px; color: var(--navy);
}
.seg button.sel { background: var(--navy); color: #fff; border-color: var(--navy); }
.amount-big { font-size: 26px !important; font-weight: 700; text-align: center; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 108px; transform: translateX(-50%); z-index: 60;
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 88vw; text-align: center;
}
