/* K&N Equipment CRM */
:root {
  --bg: #101410; --panel: #1a211a; --panel2: #222b22; --line: #2e3a2e;
  --text: #eef2ea; --muted: #93a08f; --accent: #a3e635; --accent-dark: #3f6212;
  --danger: #f87171; --blue: #60a5fa; --amber: #fbbf24;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.pos { color: var(--accent); } .neg { color: var(--danger); }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

/* header */
.page-head {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 10px;
  position: sticky; top: 0; background: linear-gradient(var(--bg) 80%, transparent); z-index: 5;
}
.page-head h1 { font-size: 1.35rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-head h1 { color: var(--accent); }
.back { font-size: 1.4rem; padding: 2px 8px; background: var(--panel); border-radius: 10px; }

section { margin: 18px 0 0; }
section h2 { font-size: .95rem; padding: 0 16px 8px; color: var(--muted); font-weight: 600; }
.count { background: var(--panel2); border-radius: 10px; padding: 1px 8px; font-size: .8rem; margin-left: 4px; }
.pad-h { margin-left: 16px; margin-right: 16px; }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat b { font-size: 1.25rem; display: block; }
.stat span { color: var(--muted); font-size: .78rem; }

/* cards */
.card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; margin: 0 16px 10px; padding: 12px 14px;
}
.card.pad { padding: 14px; }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-name { font-weight: 650; font-size: 1.02rem; }
.card-sub { font-size: .85rem; margin-top: 3px; }
.due { color: var(--amber); font-weight: 600; }
.empty { color: var(--muted); padding: 8px 20px 4px; font-size: .9rem; }
.row-line { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.row-line:last-of-type { border-bottom: 0; }
.card > .row-line, section .row-line { margin: 0 16px; }
.card .row-line { margin: 0; }
section > .row-line { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin: 0 16px 8px; padding: 10px 14px; }

/* badges */
.badge { font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.badge.serious { background: var(--accent-dark); color: var(--accent); }
.badge.notserious { background: #3f1d1d; color: var(--danger); }
.badge.st-new { background: #1e3a5f; color: var(--blue); }
.badge.st-talking { background: #333; color: #ddd; }
.badge.st-deposit { background: #4a3a10; color: var(--amber); }
.badge.st-bought { background: var(--accent-dark); color: var(--accent); }
.badge.st-dead { background: #2a2a2a; color: #777; }
.badge.it-available { background: var(--accent-dark); color: var(--accent); }
.badge.it-deposit { background: #4a3a10; color: var(--amber); }
.badge.it-sold { background: #3f1d1d; color: var(--danger); }
.badge.overdue { background: #3f1d1d; color: var(--danger); }
.badge.today { background: #4a3a10; color: var(--amber); }

/* contact buttons */
.cbtns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cbtn {
  flex: 1; min-width: 84px; text-align: center; padding: 10px 8px; border-radius: 12px;
  font-weight: 700; font-size: .92rem; border: 1px solid var(--line);
}
.cbtn.call { background: var(--accent-dark); color: var(--accent); }
.cbtn.text { background: #1e3a5f; color: var(--blue); }
.cbtn.fb { background: #1e2a4a; color: #8ab4f8; }
.cbtns.big .cbtn { padding: 13px 8px; font-size: 1rem; }

/* follow-up cards */
.fu-card .fu-main { display: block; }
.fu-actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.mini {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; font-size: .85rem; font-weight: 600;
}
.mini.done { background: var(--accent-dark); color: var(--accent); }
.mini.on-serious { background: var(--accent-dark); color: var(--accent); border-color: var(--accent); }
.mini.on-notserious { background: #3f1d1d; color: var(--danger); border-color: var(--danger); }
.serious-row { display: flex; gap: 8px; margin-top: 12px; }
.serious-row .mini { flex: 1; padding: 11px; }

/* chips + search */
.chips { display: flex; gap: 8px; padding: 6px 16px 12px; overflow-x: auto; }
.chip {
  background: var(--panel); color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--accent); color: #14210a; border-color: var(--accent); }
.search {
  display: block; width: calc(100% - 32px); margin: 0 16px 4px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 11px 14px; font-size: 1rem;
}

/* item cards */
.item-card { display: flex; gap: 12px; align-items: center; }
.item-card.sold-card { opacity: .6; }
.item-ph { width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--panel2); flex-shrink: 0; }
.item-ph img { width: 100%; height: 100%; object-fit: cover; }
.ph-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.6rem; }
.item-info { flex: 1; min-width: 0; }
.item-line { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.price { color: var(--accent); font-weight: 750; }
.price.big { font-size: 1.4rem; }

/* photo strip */
.photo-strip { display: flex; gap: 10px; padding: 4px 16px 12px; overflow-x: auto; }
.ph { position: relative; width: 110px; height: 110px; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--panel2); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph.add { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line); color: var(--muted); font-weight: 600; }
.ph-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); color: #fff; border: 0; border-radius: 8px; width: 24px; height: 24px; font-size: 1rem; }

/* forms */
.form label { display: block; font-size: .8rem; color: var(--muted); margin: 10px 0 4px; }
.form label:first-child { margin-top: 0; }
.form input, .form select, .form textarea, #modal input, #modal select, #modal textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 1rem; font-family: inherit;
}
.card select, .card input[type=date] { margin-top: 8px; width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: .95rem; }
.fu-actions input[type=date] { width: auto; flex: 1; margin-top: 0; }
#fu-note { margin-top: 10px; width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: .95rem; }
.addnote { display: flex; gap: 8px; margin-bottom: 10px; }
.addnote input { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; }
.log-line { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.log-line:last-child { border-bottom: 0; }
.log-line .small { display: inline-block; min-width: 96px; }

/* templates */
.tpl {
  display: inline-block; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 10px 14px; margin: 0 8px 8px 0; font-size: .9rem; font-weight: 600;
}

/* buttons */
button { font-family: inherit; cursor: pointer; border: 0; }
.primary, .btn-link {
  display: block; width: 100%; background: var(--accent); color: #14210a; font-weight: 750;
  border-radius: 12px; padding: 14px; font-size: 1rem; margin-top: 14px; text-align: center;
}
.btn-link { margin-top: 10px; }
.pill-btn { background: var(--accent); color: #14210a; font-weight: 700; border-radius: 999px; padding: 8px 16px; font-size: .9rem; }
.danger-link { display: block; background: none; color: var(--danger); margin: 22px auto 8px; font-size: .9rem; text-align: center; }
.fab-row, .sell-row { display: flex; gap: 10px; padding: 18px 16px; }
.fab {
  flex: 1; background: var(--accent); color: #14210a; font-weight: 750; font-size: 1.02rem;
  border-radius: 14px; padding: 15px; box-shadow: 0 4px 18px rgba(163,230,53,.25);
}
.fab.alt { background: var(--panel2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }

/* tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; z-index: 20;
  background: rgba(16,20,16,.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a { flex: 1; text-align: center; padding: 9px 0 7px; color: var(--muted); font-size: .68rem; font-weight: 600; }
#tabbar a.active { color: var(--accent); }
.tab-ic { display: block; font-size: 1.25rem; margin-bottom: 1px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #000; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal */
#modal { position: fixed; inset: 0; z-index: 40; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-card {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.modal-card h2 { font-size: 1.1rem; margin-bottom: 6px; padding-right: 30px; }
.modal-x { position: absolute; top: 12px; right: 14px; background: var(--panel2); color: var(--text); border-radius: 10px; width: 32px; height: 32px; font-size: 1.1rem; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px 24px; width: 100%; max-width: 340px; text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--accent); color: #14210a; font-weight: 800; font-size: 1.3rem; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-card h1 { font-size: 1.3rem; }
.login-card input { width: 100%; margin: 18px 0 12px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 13px; font-size: 1rem; text-align: center; }
.login-card button { width: 100%; background: var(--accent); color: #14210a; font-weight: 750; border-radius: 12px; padding: 13px; font-size: 1rem; }
.login-err { color: var(--danger); font-size: .85rem; margin-top: 10px; min-height: 1em; }

/* ---------- bill of sale ---------- */
.bos-body { background: #e8e8e4; color: #111; padding: 0 0 40px; }
.bos-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; }
.bos-toolbar a { color: #333; font-weight: 600; }
.bos-toolbar button { background: #16a34a; color: #fff; font-weight: 700; border-radius: 10px; padding: 10px 18px; font-size: .95rem; }
.bos-sheet {
  background: #fff; max-width: 720px; margin: 0 auto; padding: 48px 44px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12); font-family: Georgia, 'Times New Roman', serif; line-height: 1.5;
}
.bos-sheet h1 { text-align: center; letter-spacing: .18em; font-size: 1.5rem; margin-bottom: 4px; }
.bos-date { text-align: center; color: #444; margin-bottom: 26px; }
.bos-sheet h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: #666; border-bottom: 1px solid #ccc; padding-bottom: 4px; margin: 22px 0 10px; }
.bos-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.bos-parties p { margin: 1px 0; }
.bos-table { width: 100%; border-collapse: collapse; }
.bos-table td { padding: 6px 8px; border: 1px solid #ddd; font-size: .95rem; }
.bos-table td:first-child { width: 38%; color: #555; }
.bos-legal { font-size: .88rem; color: #333; margin-top: 22px; text-align: justify; }
.bos-sigs { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; }
.sigline { border-bottom: 1px solid #111; height: 40px; }
.sigline.short { margin-top: 22px; height: 30px; }
.bos-sigs p { font-size: .85rem; margin-top: 5px; }
.bos-sigs .muted { color: #777; margin-top: 0; }
@media print {
  .noprint { display: none !important; }
  .bos-body { background: #fff; padding: 0; }
  .bos-sheet { box-shadow: none; max-width: none; padding: 20px 10px; }
}
@media (max-width: 560px) {
  .bos-sheet { padding: 30px 20px; margin: 0 10px; }
  .bos-parties, .bos-sigs { gap: 18px; }
}
