/* Workup Lead Engine — mobile-first.
   Palette, type and shapes taken directly from workupsolutions.com. */
:root {
  /* brand tokens, verbatim from the company site */
  --ink: #151515;
  --char: #202020;
  --lime: #EAFD04;
  --lime-2: #D6F03A;
  --lime-deep: #8AA000;
  --muted: #5F625A;
  --soft: #95988E;
  --line: #E4E6DC;
  --paper: #F4F4ED;
  --paper-2: #ECEDE2;
  --card: #FBFBF6;
  --dark-soft: #C9CCC2;
  --dark-line: #333331;
  --near-black: #131312;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Poppins', var(--sans);
  --mono: 'Space Mono', ui-monospace, Consolas, monospace;

  --bg: var(--paper);
  --panel: var(--card);
  --panel-2: var(--paper-2);
  --accent: var(--lime-deep);
  --accent-ink: var(--ink);
  --accent-soft: #F2F7CC;
  --ok: #3F7A2E;
  --ok-bg: #E8F1DA;
  --warn: #8A6410;
  --warn-bg: #F5EBD5;
  --bad: #A8362B;
  --bad-bg: #F6E2DE;
  --info: #3D5F86;
  --info-bg: #E6ECF3;
  --radius: 12px;
  --pill: 100px;
  --tap: 44px;                    /* minimum comfortable touch target */
  --tabbar-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--near-black); --panel: #1A1A18; --panel-2: #232321;
    --ink: #F1F1EA; --muted: #9DA096; --soft: #7E8177; --line: var(--dark-line);
    --accent: var(--lime); --accent-ink: #151515; --accent-soft: #2B3305;
    --ok: #96C97F; --ok-bg: #1E2A17; --warn: #D8B269; --warn-bg: #2E2612;
    --bad: #E39187; --bad-bg: #331C19; --info: #93B4D8; --info-bg: #17222E;
  }
}
:root[data-theme="dark"] {
  --bg: var(--near-black); --panel: #1A1A18; --panel-2: #232321;
  --ink: #F1F1EA; --muted: #9DA096; --soft: #7E8177; --line: var(--dark-line);
  --accent: var(--lime); --accent-ink: #151515; --accent-soft: #2B3305;
  --ok: #96C97F; --ok-bg: #1E2A17; --warn: #D8B269; --warn-bg: #2E2612;
  --bad: #E39187; --bad-bg: #331C19; --info: #93B4D8; --info-bg: #17222E;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(138,160,0,.15); }
html, body { margin: 0; padding: 0; overscroll-behavior-y: contain; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* ---------- wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 10px; line-height: 1; text-decoration: none; }
.wordmark:hover { text-decoration: none; }
.wm-glyph { width: auto; height: 28px; flex: none; display: block; }
.wm-txt { font-family: var(--display); line-height: .86; }
.wm-txt .mk { font-weight: 700; font-size: 20px; letter-spacing: -.02em; display: block; color: var(--ink); }
.wm-txt .mk .u { color: var(--lime-deep); }
.wm-txt .sub { font-weight: 500; font-size: 7.5px; letter-spacing: .4em; color: var(--soft);
               text-transform: uppercase; display: block; margin-top: 3px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wm-txt .mk .u { color: var(--lime); } }
:root[data-theme="dark"] .wm-txt .mk .u { color: var(--lime); }

/* ---------- top bar (mobile) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px calc(10px) 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.menu-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap); min-width: var(--tap); padding: 0 14px;
  font-family: var(--display); font-size: 13px; font-weight: 600;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--pill); cursor: pointer;
}
.menu-btn svg { width: 18px; height: 18px; }

/* ---------- shell ---------- */
.shell { display: block; }
.side {
  position: fixed; inset: 0 0 0 auto; width: min(84vw, 320px); z-index: 60;
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 14px 0 calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto; transform: translateX(100%);
  transition: transform .22s cubic-bezier(.22,.61,.36,1);
  box-shadow: -18px 0 40px rgba(0,0,0,.12);
}
.side.open { transform: translateX(0); }
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(19,19,18,.42);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.on { opacity: 1; pointer-events: auto; }
.side .brand { display: flex; align-items: center; justify-content: space-between;
               padding: 4px 16px 14px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.side .tool { display: none; }
.close-btn {
  min-height: 38px; min-width: 38px; border-radius: var(--pill); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 10px 16px; color: var(--ink); font-size: 15px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { border-left-color: var(--lime); background: var(--accent-soft); font-weight: 600; }
.nav .grp { padding: 14px 16px 4px; font-family: var(--display); font-size: 10px;
            text-transform: uppercase; letter-spacing: .18em; color: var(--soft); font-weight: 600; }
.nav .count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.main { padding: 16px 14px 26px; }

/* ---------- bottom tab bar (mobile) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tabbar-h); padding: 6px 2px; color: var(--muted);
  font-family: var(--display); font-size: 10px; font-weight: 600; letter-spacing: .02em;
  text-decoration: none; position: relative;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.on { color: var(--ink); }
.tabbar a.on::before {
  content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px;
  background: var(--lime); border-radius: 0 0 3px 3px;
}
.tabbar .badge {
  position: absolute; top: 7px; left: 54%; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--bad); color: #fff; border-radius: var(--pill);
  font-family: var(--mono); font-size: 9.5px; line-height: 17px; text-align: center;
}

/* ---------- headings ---------- */
.head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
        justify-content: space-between; margin-bottom: 16px; }
h1 { font-family: var(--display); font-size: 22px; font-weight: 600; margin: 0 0 3px; letter-spacing: -.02em; }
h2 { font-family: var(--display); font-size: 15.5px; font-weight: 600; margin: 0 0 11px; letter-spacing: -.01em; }
h3 { font-family: var(--display); font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 13.5px; margin: 0; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 15px 15px; margin-bottom: 14px; }
.card.tight { padding: 12px 13px; }
.card h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid.c2, .grid.c3 { grid-template-columns: 1fr; }
.grid.c4 { grid-template-columns: repeat(2, 1fr); }

/* ---------- stat tiles ---------- */
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.tile .k { font-family: var(--display); font-size: 9.5px; text-transform: uppercase;
           letter-spacing: .14em; color: var(--soft); font-weight: 600; }
.tile .v { font-family: var(--display); font-size: 25px; font-weight: 600;
           font-variant-numeric: tabular-nums; letter-spacing: -.03em; margin-top: 2px; }
.tile .d { font-size: 12px; color: var(--muted); }
.tile.accent { border-left: 3px solid var(--lime); }
.tile.good { border-left: 3px solid var(--ok); }
.tile.warn { border-left: 3px solid var(--warn); }
.tile.bad  { border-left: 3px solid var(--bad); }

/* ---------- tables: stacked cards on phones ---------- */
.tw { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
thead { display: none; }
tbody tr {
  display: block; padding: 12px 13px; border-bottom: 1px solid var(--line);
}
tbody tr:last-child { border-bottom: none; }
tbody td {
  display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
  padding: 3px 0; border: none; text-align: right;
}
tbody td::before {
  content: attr(data-label); flex: 0 0 auto; text-align: left;
  font-family: var(--display); font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--soft);
  padding-top: 3px;
}
tbody td:not([data-label]) { justify-content: flex-start; text-align: left; }
tbody td:not([data-label])::before { content: none; }
/* the first labelled cell reads as the row title */
tbody td[data-primary] { display: block; text-align: left; padding-bottom: 6px; }
tbody td[data-primary]::before { content: none; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.empty { padding: 26px 14px; text-align: center; color: var(--muted); }

/* ---------- chips ---------- */
.chip { display: inline-block; font-family: var(--display); font-size: 10px; font-weight: 600;
        letter-spacing: .1em; text-transform: uppercase; padding: 3px 9px; border-radius: var(--pill);
        white-space: nowrap; background: var(--panel-2); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }

.meter { display: inline-flex; align-items: center; gap: 7px; }
.meter .bar { width: 46px; height: 6px; border-radius: var(--pill); background: var(--panel-2); overflow: hidden; flex: none; }
.meter .bar i { display: block; height: 100%; background: var(--lime-deep); border-radius: var(--pill); }
.meter .n { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .meter .bar i { background: var(--lime); } }
:root[data-theme="dark"] .meter .bar i { background: var(--lime); }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=file], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; font: inherit;
  font-size: 16px;                       /* 16px stops iOS zooming on focus */
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; min-height: var(--tap);
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--lime-deep); }
textarea { min-height: 140px; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; }
.field { margin-bottom: 13px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); padding: 10px 18px;
  font-family: var(--display); font-size: 14px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: var(--pill); cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.pri { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.btn.pri:hover { background: var(--lime-2); border-color: var(--lime-2); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 38px; padding: 7px 14px; font-size: 13px; }
.btn.wide { width: 100%; }
.btns { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.btns form { display: contents; }

/* sticky action bar for bulk operations on phones */
.actionbar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 30; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 13px; margin-top: 14px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.07);
}
.selectall {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
  font-size: 14px; color: var(--ink); min-height: var(--tap); cursor: pointer;
}
.selectall input { flex: none; }

/* ---------- flash ---------- */
.flash { padding: 12px 15px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.flash.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.flash.err { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.flash.info { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.note { font-size: 13px; color: var(--muted); }
pre.log { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 11px;
          font-family: var(--mono); font-size: 11.5px; overflow-x: auto; max-height: 300px;
          white-space: pre-wrap; word-break: break-word; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2);
       padding: 1px 5px; border-radius: 4px; word-break: break-all; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 0; }
.filters .field.wide, .filters .btns { grid-column: 1 / -1; }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: block; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tl li:last-child { border-bottom: none; }
.tl .when { display: block; color: var(--soft); font-family: var(--mono); font-size: 11px; margin-bottom: 2px; }

.auth { max-width: 420px; margin: 6vh auto; padding: 0 16px; }
.auth .card { padding: 22px 18px; }
.auth .brand-lg { margin-bottom: 20px; }

.pagination { display: flex; gap: 9px; margin-top: 14px; align-items: center;
              flex-wrap: wrap; justify-content: center; }
.kv { display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 14px; margin: 0; }
.kv dt { color: var(--soft); font-family: var(--display); font-size: 10px;
         text-transform: uppercase; letter-spacing: .12em; font-weight: 600; margin-top: 9px; }
.kv dd { margin: 0; }
.trunc { display: inline-block; max-width: 100%; overflow: hidden;
         text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
details summary { cursor: pointer; min-height: 32px; }

/* =====================================================================
   Tablet and desktop
   ===================================================================== */
@media (min-width: 720px) {
  .grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
  .grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .grid.c4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .row { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .filters { display: flex; flex-wrap: wrap; }
  .filters .field { min-width: 150px; }
  .filters .field.wide { min-width: 220px; }
  .card { padding: 18px 20px; }
  .main { padding: 20px 22px 30px; }
}

@media (min-width: 900px) {
  body { font-size: 14.5px; padding-bottom: 0; }
  .topbar, .tabbar, .scrim { display: none; }
  .shell { display: flex; min-height: 100vh; }
  .side {
    position: sticky; inset: auto; top: 0; height: 100vh;
    width: 236px; flex: 0 0 236px; transform: none; box-shadow: none;
    border-left: none; border-right: 1px solid var(--line); padding: 20px 0;
  }
  .side .brand { display: block; padding: 0 18px 16px; }
  .side .tool { display: block; margin-top: 10px; font-family: var(--display); font-size: 10px;
                font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
  .close-btn { display: none; }
  .nav a { min-height: 0; padding: 8px 18px; font-size: 14px; }
  .main { flex: 1; min-width: 0; padding: 24px 28px 60px; }

  /* tables return to a real grid */
  .tw { overflow-x: auto; }
  table { font-size: 13.5px; }
  thead { display: table-header-group; }
  tbody tr { display: table-row; padding: 0; }
  tbody td { display: table-cell; padding: 10px 13px; border-bottom: 1px solid var(--line);
             text-align: left; vertical-align: top; }
  tbody tr:last-child td { border-bottom: none; }
  tbody td::before { content: none; }
  tbody td[data-primary] { display: table-cell; padding-bottom: 10px; }
  tbody tr:hover { background: var(--panel-2); }
  th { text-align: left; font-family: var(--display); font-size: 10px; text-transform: uppercase;
       letter-spacing: .14em; color: var(--soft); font-weight: 600; padding: 10px 13px;
       border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
  td.num, th.num { text-align: right; white-space: nowrap; }
  .btn { min-height: 0; padding: 8px 16px; font-size: 13px; }
  .btn.sm { min-height: 0; padding: 5px 12px; font-size: 12px; }
  .btns form { display: inline; }
  .actionbar { position: static; box-shadow: none; }
  input[type=text], input[type=email], input[type=password], input[type=number],
  input[type=date], input[type=file], input[type=search], select, textarea {
    font-size: 13.5px; padding: 8px 11px; min-height: 0;
  }
  select { padding-right: 28px; }
  textarea { min-height: 110px; font-size: 12.5px; }
  .kv { grid-template-columns: 145px 1fr; gap: 5px 12px; }
  .kv dt { font-family: var(--sans); font-size: 13.5px; text-transform: none;
           letter-spacing: normal; font-weight: 400; color: var(--muted); margin-top: 0; }
  .tl li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
  .tl .when { display: inline; margin-bottom: 0; font-size: 11.5px; }
  .trunc { max-width: 260px; }
  .pagination { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .side, .scrim { transition: none; }
}
