/* Shark Industrial Supplies — Expo Leads. Light, clean, tablet-first.
   Brand: shark blue accent, cream background, near-black text. */
:root {
  --bg: #fbf5ea;           /* brand cream */
  --surface: #ffffff;
  --surface-2: #f1ece1;
  --line: #e7dfce;
  --text: #1a1a1a;
  --muted: #6e6a62;
  --accent: #1f86c9;       /* shark blue */
  --accent-ink: #ffffff;
  --navy: #15355a;         /* deep shark navy */
  --ok: #15a36b;
  --warn: #b7791f;
  --err: #d64545;
  --radius: 14px;
  --tap: 56px;             /* minimum touch target */
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: calc(12px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; flex: none; }
.brand-name { display: flex; flex-direction: column; line-height: 1.12; font-weight: 800; font-size: 14px; color: var(--text); }
.brand-name em { font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Chips / small buttons */
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.chip:active { transform: scale(.97); }
.chip.net { font-size: 12px; padding: 6px 10px; }
.chip.net.online { color: var(--ok); }
.chip.net.offline { color: var(--err); }
.chip.warn { background: #fdf3d8; color: #97701a; border-color: #f0e0b0; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

/* Form */
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .row { grid-template-columns: 1fr; } }

label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 17px; outline: none; box-shadow: var(--shadow);
}
input::placeholder, textarea::placeholder { color: #9aa6b4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,134,201,.18); }
textarea { min-height: 64px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) center, calc(100% - 14px) center; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }

/* Brand toggles */
.brands { border: none; padding: 0; margin: 6px 0 16px; }
.brands legend { font-size: 14px; color: var(--muted); font-weight: 600; padding: 0; margin-bottom: 8px; }
.brand-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.brand-toggle { position: relative; }
.brand-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.brand-toggle .brand-tile {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 86px; padding: 14px; border-radius: var(--radius);
  background: var(--navy); border: 2px solid var(--navy); box-shadow: var(--shadow);
  cursor: pointer; transition: border-color .12s, transform .08s, box-shadow .12s;
}
.brand-tile .brand-img { max-width: 82%; max-height: 46px; object-fit: contain; pointer-events: none; }
.brand-tile .brand-txt { color: #fff; font-weight: 800; font-size: 18px; }
.brand-toggle input:checked + .brand-tile {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,134,201,.4);
}
.brand-toggle .brand-check {
  position: absolute; top: 7px; right: 8px; width: 22px; height: 22px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 13px; line-height: 22px; text-align: center;
  opacity: 0; transform: scale(.5); transition: opacity .12s, transform .12s;
}
.brand-toggle input:checked + .brand-tile .brand-check { opacity: 1; transform: scale(1); }
.brand-toggle .brand-tile:active { transform: scale(.98); }
.brand-toggle input:focus-visible + .brand-tile { box-shadow: 0 0 0 3px rgba(31,134,201,.5); }

/* Consent */
.consent {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
  font-size: 15px; color: var(--text); line-height: 1.45;
}
.consent input { width: 26px; height: 26px; min-height: 0; flex: none; margin-top: 1px; accent-color: var(--accent); }
.consent a { color: #166aa6; }

/* Submit */
.submit {
  width: 100%; min-height: 60px; border: none; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-size: 19px; font-weight: 800; letter-spacing: .3px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(31,134,201,.35);
}
.submit:active { transform: scale(.99); }
.submit:disabled { opacity: .5; box-shadow: none; }

/* Ledger */
.ledger { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; }
.ledger-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ledger-head h2 { font-size: 16px; margin: 0; color: var(--muted); font-weight: 700; }
.ledger-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ledger-list { list-style: none; margin: 14px 0 40px; padding: 0; }
.ledger-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  border-radius: 12px; margin-bottom: 8px;
}
.ledger-item .who { font-weight: 600; }
.ledger-item .meta { font-size: 13px; color: var(--muted); }
.status { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.synced { background: #e3f6ec; color: #0f7a4f; }
.status.pending { background: #fdf3d8; color: #97701a; }
.status.error { background: #fbe3e3; color: var(--err); }

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ok); color: #ffffff; font-weight: 700;
  padding: 12px 20px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 6px 20px rgba(16,24,40,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--err); color: #ffffff; }

/* Status banner (offline / not-syncing) */
.banner { padding: 9px 16px; font-size: 14px; font-weight: 600; text-align: center; }
.banner.info { background: #eaf1fb; color: #1c4e8a; border-bottom: 1px solid #cdddf2; }
.banner.warn { background: #fdf3d8; color: #8a6d1f; border-bottom: 1px solid #f0e0b0; }

/* Required-field markers */
.req { color: var(--err); font-weight: 700; }
.req-legend { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

/* Net status text */
.chip.net { display: inline-flex; align-items: center; gap: 6px; }
.chip.net .dot { font-size: 10px; line-height: 1; }

/* Rejected status badge */
.status.rejected { background: #fbe3e3; color: var(--err); }

/* (brand-tile press feedback is on .brand-tile:active, above) */

/* Consent flash when submitted without ticking it */
.consent.flash { border-color: var(--err); box-shadow: 0 0 0 3px rgba(214,69,69,.25); }

/* Ledger row layout + delete (GDPR erasure / fix a bad capture) */
.ledger-item .who-wrap { flex: 1; min-width: 0; }
.ledger-item .del {
  flex: none; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.ledger-item .del:active { transform: scale(.95); }

/* Keyboard focus visibility (incl. Windows High Contrast) */
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,134,201,.25); }
@media (forced-colors: active) {
  input:focus-visible, select:focus-visible, textarea:focus-visible,
  .brand-toggle input:focus-visible + .brand-tile, .chip:focus-visible, .submit:focus-visible {
    outline: 2px solid Highlight; outline-offset: 2px;
  }
}

/* ⚙ icon button */
.chip.icon { padding: 6px 12px; font-size: 18px; line-height: 1; }

/* Manage panel (captured leads / export / clear) — opened from ⚙, hidden otherwise */
.manage {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(16,24,40,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 16px; overflow-y: auto;
}
.manage-card {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 640px;
  padding: 18px; box-shadow: 0 14px 44px rgba(16,24,40,.32);
}
.manage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.manage-head h2 { font-size: 17px; margin: 0; color: var(--text); font-weight: 800; }
.manage-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.manage .ledger-list { margin: 0; max-height: 60vh; overflow-y: auto; }

/* Tablet optimisation — wider card, 4-across brand tiles, bigger targets */
@media (min-width: 680px) {
  body { font-size: 18px; }
  .wrap { max-width: 780px; padding: 28px 24px 40px; }
  #leadForm {
    background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: 20px; padding: 26px;
  }
  input, select, textarea { font-size: 18px; min-height: 60px; }
  .brand-grid { grid-template-columns: repeat(4, 1fr); }
  .brand-toggle .brand-tile { min-height: 96px; }
  .brand-tile .brand-img { max-height: 52px; }
  .submit { font-size: 21px; min-height: 66px; }
  .consent { font-size: 16px; }
}
