:root { --bg:#ffffff; --fg:#1b1d21; --muted:#6b7280; --line:#e5e7eb; --accent:#2563eb; --accent-soft:#eaf0fe; --ok:#15803d; --warn:#b45309; --bad:#b91c1c; --soft:#f5f6f8; --card:#ffffff; --shadow: 0 1px 2px rgba(0,0,0,.05); }
@media (prefers-color-scheme: dark) { :root { --bg:#121417; --fg:#e6e7ea; --muted:#9aa0aa; --line:#2a2e35; --accent:#7aa2ff; --accent-soft:#1b2440; --soft:#1a1d22; --card:#17191e; --shadow: 0 1px 2px rgba(0,0,0,.4); } }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); min-height: 100%; }
body { margin:0; min-height: 100vh; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
nav { position: sticky; top:0; z-index: 10; display:flex; gap:4px; align-items:center; padding:8px 20px; border-bottom:1px solid var(--line); background: var(--bg); flex-wrap:wrap; }
nav a { color: var(--fg); text-decoration:none; padding:6px 10px; border-radius:8px; transition: background .12s; }
nav a:hover { background: var(--soft); }
nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav .brand { font-weight:800; color: var(--accent); margin-right: 8px; letter-spacing: -.01em; }
nav #status { margin-left:auto; }
main { max-width: 1200px; margin: 0 auto; padding: 20px 20px 70px; }
h1 { font-size: 24px; margin: 4px 0 16px; letter-spacing: -.01em; } h2 { font-size: 16px; margin: 22px 0 8px; } h3 { font-size:15px; margin: 14px 0 6px; }
a { color: var(--accent); }
.toast { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 20; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 720px; font-size: 14px; animation: toastin .18s ease-out; }
.toast.hide { opacity: 0; transition: opacity .35s; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, -6px);} to { opacity: 1; transform: translate(-50%, 0);} }
.flash { background: var(--accent-soft); border:1px solid var(--line); padding:8px 12px; border-radius:8px; margin-bottom:14px; }
.pill { display:inline-block; padding:1px 9px; border-radius:999px; font-size:12px; border:1px solid var(--line); background: var(--soft); white-space:nowrap; line-height: 1.6; }
.pill.run { color: var(--warn); border-color: var(--warn); background: transparent; }
.pill.ok { color: var(--ok); border-color: var(--ok); background: transparent; } .pill.bad { color: var(--bad); border-color: var(--bad); background: transparent; } .pill.warn { color: var(--warn); border-color: var(--warn); background: transparent; }
.spin { display:inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.score { font-weight:700; font-variant-numeric: tabular-nums; }
.score.hi { color: var(--ok); } .score.mid { color: var(--warn); } .score.lo { color: var(--muted); }
table { width:100%; border-collapse: collapse; margin: 8px 0 18px; }
th, td { text-align:left; padding: 8px 8px; border-bottom:1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--soft); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.card { border:1px solid var(--line); border-radius:12px; padding: 14px 16px; background: var(--card); box-shadow: var(--shadow); }
.card h2 { margin-top: 0; }
button, .btn { font: inherit; padding: 7px 13px; border-radius: 8px; border:1px solid var(--line); background: var(--card); color: var(--fg); cursor:pointer; text-decoration:none; display:inline-block; transition: background .12s, transform .05s; box-shadow: var(--shadow); }
button:hover, .btn:hover { background: var(--soft); }
button:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--accent); color:#fff; border-color: var(--accent); }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); border-color: var(--bad); background: transparent; box-shadow: none; }
button.small, .btn.small { padding: 3px 9px; font-size: 12.5px; }
button:disabled { opacity: .6; cursor: progress; }
button.busy::after { content: ""; display:inline-block; width: 10px; height: 10px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
form.inline { display:inline; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local], input[type=date], input[type=url], select, textarea {
  font: inherit; padding: 7px 9px; border:1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); width:100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; }
textarea.letter { min-height: 440px; font-family: Georgia, "Times New Roman", serif; font-size: 15.5px; line-height: 1.6; }
label { display:block; font-size: 13px; color: var(--muted); margin: 10px 0 3px; }
.field { margin-bottom: 8px; }
.help { font-size: 12px; color: var(--muted); margin-top: 2px; }
pre { background: var(--soft); padding: 10px; border-radius: 8px; overflow:auto; font-size: 12.5px; max-height: 420px; white-space: pre-wrap; }
.desc { white-space: pre-wrap; max-height: 560px; overflow:auto; padding: 12px; border:1px solid var(--line); border-radius: 10px; font-size: 14px; background: var(--card); }
.two { display:grid; grid-template-columns: 1.1fr .9fr; gap: 18px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } nav #status { margin-left: 0; } }
td.chk, th.chk { width: 28px; padding-right: 0; } td.chk input, th.chk input { width: 18px; height: 18px; }
td.acts { white-space: nowrap; }
.paper { white-space: pre-wrap; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.65; padding: 18px 20px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
/* Desktop/laptop: letter shows like a printed page (US Letter width, 12pt, 1in margins). */
html[data-device=desktop] .paper { max-width: 8.5in; font-size: 12pt; line-height: 1.5; padding: 1in; background: #fff; color: #111; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
html[data-device=desktop] .letter-card { width: min(8.5in + 40px, 100%); }
html[data-device=desktop] textarea.letter { max-width: 8.5in; font-size: 12pt; }
@media (min-width: 901px) { html[data-device=desktop] .two { grid-template-columns: minmax(0, 8.5in) minmax(280px, 1fr); } }
.letter-card { width: min(680px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.letter-card .paper { overflow: auto; flex: 1; }
@media (max-width: 700px) {
  nav { padding: 6px 10px; } main { padding: 14px 12px 70px; }
  button, .btn { min-height: 40px; } button.small, .btn.small { padding: 8px 14px; font-size: 13.5px; }
  td.chk input, th.chk input { width: 22px; height: 22px; }
  /* table.stack: each row becomes a card */
  table.stack, table.stack tbody { display: block; }
  table.stack tr:first-child { display: flex; padding: 4px 0; }
  table.stack tr:first-child th { display: none; }
  table.stack tr:first-child th.chk { display: block; }
  table.stack tr:first-child th.chk::after { content: " Select all"; font-size: 12px; color: var(--muted); }
  table.stack tr { display: grid; grid-template-columns: 30px 1fr auto; gap: 2px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack td { display: block; border: 0; padding: 0; background: none !important; }
  table.stack td.chk { grid-row: 1 / span 4; padding-top: 2px; }
  table.stack td.job { grid-column: 2 / span 2; font-size: 16px; }
  table.stack td[data-label] { grid-column: 2 / span 2; font-size: 13px; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  table.stack td.acts { grid-column: 2 / span 2; display: flex; gap: 8px; margin-top: 6px; }
}
.stat { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.stat a { text-decoration: none; }
ul.clean { list-style:none; padding:0; margin:0; } ul.clean li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.tabs a { margin-right: 10px; text-decoration: none; padding: 4px 8px; border-radius: 6px; } .tabs a.on { font-weight: 700; background: var(--accent-soft); }
img.shot { max-width: 100%; border:1px solid var(--line); border-radius: 8px; }
.check { color: var(--ok); } .cross { color: var(--bad); }
details > summary { cursor: pointer; }

/* Corner run box: live progress of background tasks (top right, under the nav) */
.runbox { position: fixed; top: 54px; right: 16px; z-index: 15; width: min(380px, calc(100vw - 32px)); display:flex; flex-direction:column; gap:8px; }
.runbox .run { min-width: 0; max-width: 100%; overflow: hidden; background: var(--card); border: 1px solid var(--warn); border-radius: 10px; padding: 8px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); font-size: 13px; }
.runbox .run-head { display:flex; align-items:center; gap:6px; }
.runbox .run-line { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 3px; }
.runbox a { text-decoration: none; font-size: 12px; }

iframe.vnc { width: 100%; height: calc(100vh - 190px); min-height: 420px; border: 1px solid var(--line); border-radius: 10px; background: #000; }

/* Score badges: number + band word; click/tap opens the breakdown popover */
.badge { display:inline-flex; align-items:baseline; gap:5px; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; line-height: 1.5;
  border: 1px solid currentColor; background: transparent; box-shadow: none; cursor: pointer; white-space: nowrap; min-height: 0; }
.badge b { font-size: 14px; font-variant-numeric: tabular-nums; }
.badge span { opacity: .85; }
.badge:hover { background: var(--soft); }
.fit-strong, .legit-trusted { color: var(--ok); }
.fit-good { color: var(--ok); border-style: dashed; }
.fit-weak, .legit-ok { color: var(--warn); }
.fit-poor, .fit-title-filtered, .fit-unscored { color: var(--muted); }
.legit-doubtful { color: var(--bad); }
.legit-ok { color: var(--muted); }
[popover].pop { width: min(380px, calc(100vw - 32px)); max-height: 70vh; overflow: auto; margin: auto; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--fg); box-shadow: 0 16px 48px rgba(0,0,0,.35); }
[popover].pop::backdrop { background: rgba(0,0,0,.25); }
.pop-head { font-weight: 700; margin-bottom: 6px; }
.pop ul { padding-left: 18px; margin: 4px 0 8px; }
.legend { margin: 6px 0 12px; } .legend table { margin: 6px 0; } .legend td, .legend th { padding: 4px 8px; }

/* Needs you */
nav .count { display:inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: var(--bad);
  color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; line-height: 18px; }
.todo { display: grid; gap: 10px; }
.todo-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.todo-item.urgent { border-color: var(--warn); }
.todo-kind { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.todo-item.urgent .todo-kind { color: var(--warn); }
@media (max-width: 700px) { .todo-item { flex-direction: column; align-items: stretch; } }

/* Review-before-submit */
.card.review { border-color: var(--warn); margin: 12px 0 16px; }
.review-list { display: grid; gap: 10px; }
.review-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.review-item.src-ai { border-color: var(--warn); }
.review-item.src-missing { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 6%, var(--bg)); }
.review-label { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.review-label .pill { font-weight: 400; }
.src-ai .review-label .pill { color: var(--warn); border-color: var(--warn); }
.src-missing .review-label .pill { color: var(--bad); border-color: var(--bad); }

/* Login page */
main.login { max-width: 380px; padding-top: 12vh; }
main.login .brand { font-weight: 800; color: var(--accent); font-size: 22px; margin-bottom: 8px; }
main.login input { min-height: 44px; font-size: 16px; }   /* 16px stops iOS zooming into the field */
.error-text { color: var(--bad); margin: 10px 0 0; font-size: 14px; }

/* In-page confirm dialog */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; padding: 16px; }
.modal-card { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 14px; width: min(420px, 100%); box-shadow: 0 16px 48px rgba(0,0,0,.35); }
.modal-text { margin-bottom: 14px; font-size: 15px; }
.warn-text { color: var(--warn); }
