:root {
  --ground: #F6F6F3; --card: #FFFFFF; --line: #E2E2DC; --line-2: #D8D8D1; --soft: #EDEDE8;
  --ink: #1B1B19; --ink-2: #2E2E2A; --muted: #5C5C56;
  --teal: #0F766E; --teal-ink: #0F5F58; --teal-bg: #E6F2F0;
  --amber-ink: #7C2D12; --amber-bg: #FEF3C7;
  --blue-ink: #1E3A8A; --blue-bg: #DBEAFE;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--teal); }
a:hover { color: #115E59; }
button { font-family: inherit; }
[hidden] { display: none !important; }
.error { color: #9A3412; min-height: 1.2em; font-size: 14px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login-box h1 { margin: 0 0 12px; font-size: 26px; }
.login-box label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { min-height: 180px; resize: vertical; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 24px 14px; width: 220px; flex-shrink: 0; }
.nav .brand { font-weight: 600; font-size: 17px; padding: 0 12px 18px; }
.nav a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 15px; }
.nav a.active { background: var(--teal-bg); color: var(--teal-ink); font-weight: 600; }
.count { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.view { flex: 1; min-width: 0; padding: 24px 28px 40px; outline: none; }
.view h1 { margin: 0 0 4px; font-size: 24px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

@media (max-width: 760px) {
  .actions { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4; padding: 10px 0 4px;
    background: linear-gradient(to bottom, rgba(246,246,243,0), var(--ground) 30%); }
  .shell { flex-direction: column-reverse; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; width: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); z-index: 5; }
  .nav .brand { display: none; }
  .nav a { flex: 1; justify-content: center; gap: 4px; font-size: 13.5px; padding: 0 6px; }
  .view { padding: 18px 14px 96px; }
}

/* buttons */
.btn { min-height: 48px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font-size: 15px; font-weight: 600; padding: 0 18px; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.small { min-height: 36px; font-size: 13.5px; border-radius: 10px; padding: 0 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* triage */
.triage { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.stack { position: relative; }
.ghost { position: absolute; inset: 0; background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.ghost.g1 { transform: translateY(14px) scale(.94); opacity: .55; }
.ghost.g2 { transform: translateY(7px) scale(.97); opacity: .8; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px; touch-action: pan-y; user-select: none; will-change: transform;
  transition: transform .25s ease, opacity .25s ease; }
.card.dragging { transition: none; }
.card .head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card .company { font-size: 13px; color: var(--muted); }
.card h2 { margin: 4px 0 0; font-size: 19px; line-height: 1.3; }
.score { flex-shrink: 0; width: 58px; height: 58px; border-radius: 14px; background: var(--teal-bg); display: flex;
  flex-direction: column; align-items: center; justify-content: center; }
.score b { font-family: var(--mono); font-size: 21px; font-weight: 500; color: var(--teal); }
.score span { font-size: 10.5px; color: var(--teal-ink); }
.why { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); background: var(--ground); border-radius: 10px; padding: 10px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 12.5px; font-weight: 500; padding: 5px 10px; border-radius: 999px; background: var(--soft); color: #3F3F3A; }
.chip.tier { background: var(--teal-bg); color: var(--teal-ink); }
.chip.warn { background: var(--amber-bg); color: var(--amber-ink); }
.chip.info { background: var(--blue-bg); color: var(--blue-ink); }
.label { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.summary { margin: 4px 0 0; font-size: 14.5px; line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }
.meta { border-top: 1px solid var(--soft); padding-top: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
details summary { cursor: pointer; font-size: 13.5px; color: var(--teal); }
details pre { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; line-height: 1.5; color: var(--ink-2);
  max-height: 320px; overflow: auto; background: var(--ground); padding: 10px 12px; border-radius: 10px; }
.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; min-height: 56px; font-size: 16px; }
.hint { text-align: center; font-size: 12px; color: var(--muted); margin: 0; }
.stamp { position: absolute; top: 22px; padding: 4px 10px; border: 3px solid; border-radius: 8px; font-weight: 600;
  font-size: 18px; opacity: 0; pointer-events: none; }
.stamp.yes { left: 18px; color: var(--teal); transform: rotate(-12deg); }
.stamp.no { right: 18px; color: #9A3412; transform: rotate(12deg); }

/* reasons sheet */
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex;
  flex-direction: column; gap: 10px; }
.sheet .row { display: flex; flex-wrap: wrap; gap: 8px; }

/* lists */
.list { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex;
  flex-direction: column; gap: 8px; }
.item .top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.item h3 { margin: 0; font-size: 15.5px; }
.item .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; background: var(--card); border: 1px dashed var(--line-2); border-radius: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; max-width: 760px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat b { font-family: var(--mono); font-size: 24px; font-weight: 500; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
.tablebox { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; max-width: 760px; margin-bottom: 20px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--soft); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
form.add { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
form.add label { font-size: 13px; font-weight: 600; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 12px; display: flex; gap: 14px; align-items: center; font-size: 14px; z-index: 10;
  max-width: calc(100% - 24px); }
.toast button { background: none; border: none; color: #8EE0D6; font-weight: 600; font-size: 14px; cursor: pointer; min-height: 32px; }
