/* lead-agent — mobile first.
   The review queue is worked from a phone, so the base styles assume a narrow
   screen and the only media query widens things for a desktop browser. Tap
   targets are 44px minimum; the three review actions are the largest things on
   the page because they are the ones pressed hundreds of times. */

:root {
  --accent: #1f6f6b;
  --accent-dark: #17544f;
  --danger: #a3352b;
  --bg: #f7f6f3;
  --border: #ddd8d0;
  --ink: #2b2a28;
  --muted: #77706a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0; padding: 0 14px env(safe-area-inset-bottom) 14px;
  background: var(--bg); color: var(--ink); line-height: 1.45;
}

h1 { font-size: 1.3rem; }
h2 { font-size: 1.1rem; margin: 0 0 4px; }
h3 { font-size: 0.98rem; margin: 20px 0 4px; }
code { background: #ece8e2; padding: 0.08em 0.32em; border-radius: 3px; font-size: 0.86em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.err { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }
.msg { font-size: 0.88rem; min-height: 1.2em; }
.msg.ok { color: var(--accent-dark); }
.msg.bad { color: var(--danger); }

/* --- controls ------------------------------------------------------------ */

input[type=text], input[type=password], input[type=number], input[type=file],
textarea, select {
  width: 100%; padding: 11px; border: 1px solid var(--border); border-radius: 8px;
  background: white; color: var(--ink); font: inherit; font-size: 16px;  /* 16px stops iOS zooming on focus */
  margin-bottom: 10px;
}
textarea { line-height: 1.45; resize: vertical; }

button, .button {
  min-height: 44px; padding: 11px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: white; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
button.primary, .button { background: var(--accent); border-color: var(--accent); color: white; }
button.danger { color: var(--danger); border-color: #e0bdb8; }
button.link { background: none; border: none; color: var(--accent); font-weight: 600;
              padding: 8px 4px; min-height: 36px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.field { display: block; margin-bottom: 4px; }
.field > span { display: block; font-size: 0.84rem; font-weight: 600; color: var(--muted);
                margin-bottom: 4px; }
.field > span em { font-weight: 400; font-style: normal; }
.row { display: flex; gap: 10px; }
.row > .field { flex: 1; }
.check { display: block; margin: 4px 0 12px; font-size: 0.92rem; }
.check input { margin-right: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.actions > button, .actions > .button { flex: 1; min-width: 120px; }

/* --- shell --------------------------------------------------------------- */

#login-section { max-width: 380px; margin: 60px auto; }
#app { display: none; max-width: 720px; margin: 0 auto; }

#userbar { display: flex; align-items: center; justify-content: space-between;
           padding: 10px 0 6px; font-size: 0.85rem; color: var(--muted); }

#tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 8px;
        border-bottom: 1px solid var(--border); margin-bottom: 14px;
        scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
.tab { min-height: 38px; padding: 8px 12px; border: none; background: none;
       color: var(--muted); font-size: 0.9rem; white-space: nowrap; border-radius: 8px; }
.tab.is-active { background: white; color: var(--ink); border: 1px solid var(--border); }
.badge { display: none; background: var(--accent); color: white; border-radius: 10px;
         padding: 1px 7px; font-size: 0.74rem; margin-left: 4px; }
.badge.on { display: inline-block; }

.panel { display: none; padding-bottom: 40px; }
.panel.is-active { display: block; }

details { background: white; border: 1px solid var(--border); border-radius: 10px;
          padding: 12px 14px; margin-bottom: 12px; }
details > summary { cursor: pointer; font-weight: 600; color: var(--accent-dark);
                    min-height: 28px; }
details[open] > summary { margin-bottom: 10px; }

.callout { background: #eef4f3; border-left: 3px solid var(--accent);
           border-radius: 6px; padding: 10px 14px; margin: 12px 0; font-size: 0.9rem; }
.callout.warn { background: #fdf6ec; border-left-color: #b5651d; }
.callout ul { margin: 6px 0 0; padding-left: 1.2em; }
.callout li { margin: 4px 0; }
.callout:empty { display: none; }

/* --- the lead card ------------------------------------------------------- */

#lead-card { display: none; background: white; border: 1px solid var(--border);
             border-radius: 12px; padding: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
#lead-company { font-size: 1.25rem; line-height: 1.25; }
#lead-contact { margin: 2px 0 0; font-size: 0.9rem; }
.score { flex: none; min-width: 52px; height: 52px; border-radius: 50%;
         background: var(--accent); color: white; display: none;
         align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }
.score.on { display: flex; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 12px 0 0; }
.chips li, .chips button { background: #f0ede8; border: 1px solid var(--border);
       border-radius: 20px; padding: 5px 11px; font-size: 0.82rem; color: var(--muted);
       min-height: 32px; font-weight: 500; }
.chips.choice button { cursor: pointer; color: var(--ink); background: white; }
.chips.choice button.on { background: var(--accent); border-color: var(--accent); color: white; }

.brief { font-size: 0.94rem; margin: 12px 0; }
.brief:empty { display: none; }
.notes { font-size: 0.88rem; color: var(--muted); white-space: pre-wrap; margin: 10px 0 0; }
.notes:empty { display: none; }

#draft-box { margin-top: 14px; border-radius: 8px; }

/* The three decisions. Send-ready is visually dominant because it is the
   outcome the whole pipeline exists to produce. */
#lead-card > .actions { margin-top: 16px; }
#btnSendReady { flex: 2; }

.subpanel { display: none; border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.subpanel.on { display: block; }
.subpanel-title { font-size: 0.84rem; font-weight: 700; text-transform: uppercase;
                  letter-spacing: 0.05em; color: var(--muted); margin: 0 0 8px; }

.empty { display: none; background: white; border: 1px dashed var(--border);
         border-radius: 12px; padding: 32px 20px; text-align: center; }
.empty.on { display: block; }

/* --- lists --------------------------------------------------------------- */

.item { background: white; border: 1px solid var(--border); border-radius: 10px;
        padding: 12px 14px; margin-bottom: 10px; font-size: 0.9rem; }
.item h4 { margin: 0 0 2px; font-size: 1rem; }
.item .sub { color: var(--muted); font-size: 0.85rem; }
.item .actions { margin: 10px 0 0; }
.item .actions button { flex: none; min-width: 0; padding: 8px 12px; min-height: 38px;
                        font-size: 0.85rem; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border);
         vertical-align: top; word-break: break-word; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.rubric-row { background: #fbfaf8; border: 1px solid var(--border); border-radius: 8px;
              padding: 10px 12px; margin-bottom: 8px; }
.rubric-row .row { align-items: flex-end; }
.rubric-row .weight { max-width: 90px; }

.stat { display: inline-block; margin-right: 14px; font-size: 0.85rem; color: var(--muted); }
.stat b { color: var(--ink); font-size: 1.05rem; }

.link-block { display: block; text-align: center; text-decoration: none; margin: 4px 0 14px; }

/* scam-risk badge, used inline in chips */
.chips li.risk-high { background: #f6d9d5; border-color: #e0bdb8; color: var(--danger); font-weight: 700; }
.chips li.risk-medium { background: #fdf0d9; border-color: #e6c88a; color: #8a5a1f; font-weight: 600; }

@media (min-width: 700px) {
  body { padding: 0 24px 40px; }
  #app { padding-top: 8px; }
  .actions > button, .actions > .button { flex: none; }
  #btnSendReady { flex: none; min-width: 170px; }
}
