/* Components shared by every ODS app. 17px base, 48px tap targets, plain CSS. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font: 17px/1.5 var(--font-sans); }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top)); background: var(--brand); color: var(--brand-ink); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.brand img { border-radius: 6px; background: #fff; }
.brand img.wordmark { border-radius: 0; background: none; height: 28px; width: auto; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: inherit; text-decoration: none; padding: 8px 12px; border-radius: 6px; min-height: 40px; display: inline-flex; align-items: center; opacity: .85; white-space: nowrap; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.bell { position: relative; background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 6px; cursor: pointer; }
.badge { position: absolute; top: 2px; right: 2px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 6px; }
.main { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { max-width: 960px; margin: 0 auto; padding: 16px; display: flex; justify-content: space-between; gap: 12px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); }
.banner { padding: 10px 16px; text-align: center; font-weight: 600; background: var(--warn-wash); color: var(--warn); }
.banner.bad { background: var(--bad-wash); color: var(--bad); }

/* Cards, tables, forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stat { display: inline-block; min-width: 120px; padding: 10px 14px; background: var(--surface-2); border-radius: var(--radius); }
.stat b { display: block; font-size: 1.4rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
label { display: block; font-weight: 600; margin: 8px 0 4px; font-size: .9rem; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 1px; }
.field { margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* Buttons and chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.chip.good { background: var(--good-wash); color: var(--good); }
.chip.warn { background: var(--warn-wash); color: var(--warn); }
.chip.bad { background: var(--bad-wash); color: var(--bad); }

/* Tabs (Setup) and small form helpers */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 6px 0; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Setup editors: the list comes first; Add / Edit open one panel in place */
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.editor { scroll-margin-top: 72px; background: var(--surface-2); border: 1px solid var(--accent); border-left-width: 4px; border-radius: var(--radius); padding: 12px 16px 16px; margin: 10px 0; }
.editor h3 { margin-bottom: 8px; }
.editor input, .editor select, .editor textarea { background: var(--surface); }
tr.editor-row td { padding: 0 0 8px; border-bottom: 1px solid var(--line); }
.list li .editor { margin-top: 10px; }
.choice-row { margin-bottom: 6px; flex-wrap: nowrap; }
.choice-row input[name=opt_label] { flex: 1; min-width: 0; }
.sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.sentence select { width: auto; max-width: 100%; }
.checks { display: flex; flex-wrap: wrap; gap: 0 18px; }
.checks .check { margin: 4px 0; }
.cond { display: grid; grid-template-columns: 34px 2fr 1.2fr 2fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.cond .cond-and { align-self: center; font-style: italic; }
.cond .cond-value .checks { padding-top: 4px; }
.cond .cond-none { display: inline-block; padding-top: 12px; }
.rule { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule p { margin: 4px 0 0; }
.card.draft { border: 2px solid var(--accent); }
details.panel summary { cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; line-height: 1.2; list-style-position: inside; }
details.panel[open] summary { margin-bottom: 10px; }
.preview { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; }
.preview-body { white-space: pre-wrap; margin-top: 6px; }
.preview mark { background: var(--brand-soft); color: inherit; border-radius: 3px; padding: 0 3px; }
@media (max-width: 640px) { .cond { grid-template-columns: 1fr; } .cond .cond-and:empty { display: none; } }

/* Reports */
.num { text-align: right; white-space: nowrap; }
table.bars td { border-bottom: 0; padding: 6px 8px; }
table.bars td.bar { width: 40%; }
table.bars td.bar span { display: block; height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }

/* Lead detail */
.notice { background: var(--warn-wash); color: var(--warn); padding: 8px 12px; border-radius: var(--radius); }
.answers { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px; }
.answers dt { font-weight: 600; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.answers dd { margin: 0; }
.bad { color: var(--bad); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 30; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .footer { flex-direction: column; }
}
