/* ── Variables ── */
:root {
  --paper: #F7F5EF;
  --ink: #15191E;
  --blue: #1E4D8C;
  --graph: #5B6470;
  --line: #E3E3DD;
  --ok: #2E7D4F;
  --warn: #B4541A;
  --surface: #fff;
  --radius: 10px;
  --navbar-h: 44px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ── */
.jsp-top {
  display: flex;
  align-items: center;
  height: var(--navbar-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 30;
}
.jsp-brand {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
}
.jsp-brand:hover { opacity: 0.65; }
.jsp-brand:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 2px; }

/* ── Main ── */
.jsp-main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 36px 24px 72px;
}

/* ── Headings ── */
h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.jsp-sub {
  color: var(--graph);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── Status / loading view ── */
.jsp-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  gap: 14px;
}
.jsp-status h1 {
  font-size: 22px;
  font-weight: 600;
}
.jsp-status p {
  color: var(--graph);
  font-size: 14px;
  max-width: 380px;
}
/* subtle pulse on the loading title */
#view-status:not([hidden]) #status-title {
  animation: jsp-pulse 2.4s ease-in-out infinite;
}
@keyframes jsp-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

/* ── Buttons ── */
.jsp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: 8px;
  font: 600 14px/1 var(--font);
  cursor: pointer;
  border: none;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  transition: opacity 0.14s;
  white-space: nowrap;
  -webkit-appearance: none;
}
.jsp-btn:hover:not(:disabled) { opacity: 0.84; }
.jsp-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.jsp-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.jsp-btn-secondary {
  background: var(--surface);
  color: var(--blue);
  border: 1.5px solid var(--blue);
}

.jsp-link {
  background: none;
  border: none;
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--blue) 50%, transparent);
}
.jsp-link:hover { text-decoration-color: var(--blue); }
.jsp-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }

/* ── Paste panel ── */
.jsp-paste {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.jsp-paste summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 16px;
  cursor: pointer;
  list-style: none;
  color: var(--blue);
  font-weight: 600;
  font-size: 13px;
  user-select: none;
  transition: background 0.1s;
}
.jsp-paste summary::-webkit-details-marker { display: none; }
/* chevron icon */
.jsp-paste summary::before {
  content: "";
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%231E4D8C' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition: transform 0.18s;
}
details[open].jsp-paste summary::before { transform: rotate(180deg); }
.jsp-paste summary:hover { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.jsp-paste summary:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

.jsp-paste-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
}
.jsp-paste-hint {
  font-size: 13px;
  color: var(--graph);
  margin-bottom: 14px;
  line-height: 1.5;
}
.jsp-paste-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.jsp-paste-cols label,
.jsp-paste-common label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--graph);
}
.jsp-paste textarea {
  font: 13px/1.55 ui-monospace, Menlo, "Cascadia Code", monospace;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  resize: vertical;
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  transition: border-color 0.1s, box-shadow 0.1s;
}
.jsp-paste textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}
.jsp-paste textarea::placeholder { color: var(--graph); opacity: 0.55; }

.jsp-paste-common {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.jsp-paste-common label { flex: 1 1 120px; }
.jsp-paste-common input,
.jsp-paste-common select {
  font: 14px/1 var(--font);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.1s, box-shadow 0.1s;
  -webkit-appearance: none;
  appearance: none;
  /* custom select arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%235B6470' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  padding-right: 28px;
}
.jsp-paste-common input {
  background-image: none;
  padding-right: 10px;
}
.jsp-paste-common input:focus,
.jsp-paste-common select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}

/* ── Table wrapper ── */
.jsp-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
}

/* ── Table ── */
.jsp-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
  table-layout: fixed;
}

/* Column widths (desktop) */
.jsp-table th:nth-child(1), .jsp-table td:nth-child(1) { width: 42px; }
.jsp-table th:nth-child(2), .jsp-table td:nth-child(2) { width: 17%; }   /* APN */
.jsp-table th:nth-child(3), .jsp-table td:nth-child(3) { width: 25%; }   /* Address */
.jsp-table th:nth-child(4), .jsp-table td:nth-child(4) { width: 11%; }   /* City */
.jsp-table th:nth-child(5), .jsp-table td:nth-child(5) { width: 12%; }   /* County */
.jsp-table th:nth-child(6), .jsp-table td:nth-child(6) { width: 70px; }  /* State */
/* Note: takes remaining width */

/* Sticky header */
.jsp-table thead {
  position: sticky;
  top: var(--navbar-h);
  z-index: 10;
  background: var(--surface);
}
.jsp-table thead::after {
  content: "";
  display: block;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--line);
}
.jsp-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graph);
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}
.jsp-table th:first-child {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
}
/* Note column header: quieter */
.jsp-table th:last-child { color: color-mix(in srgb, var(--graph) 60%, transparent); }
.jsp-table th small { font-size: 10px; font-weight: 500; letter-spacing: 0; text-transform: none; }

/* APN + Address headers: slightly heavier to signal importance */
.jsp-table th:nth-child(2),
.jsp-table th:nth-child(3) { color: var(--ink); }

/* ── Rows ── */
.jsp-table td {
  padding: 2px 4px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.jsp-row:last-child td { border-bottom: none; }
.jsp-row:hover { background: color-mix(in srgb, var(--blue) 3%, transparent); }

/* Row status: left border stripe (non-color signal) + num color */
.jsp-row td:first-child { border-left: 3px solid transparent; }
.jsp-row.is-complete td:first-child { border-left-color: var(--ok); }
.jsp-row.is-incomplete td:first-child { border-left-color: var(--warn); }

/* Number cell */
.jsp-num {
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--graph);
  padding: 0 2px;
  user-select: none;
}
.jsp-row.is-complete .jsp-num { color: var(--ok); font-weight: 700; }
.jsp-row.is-incomplete .jsp-num { color: var(--warn); font-weight: 700; }

/* Table inputs — borderless by default, border on hover/focus */
.jsp-table input,
.jsp-table select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 7px 8px;
  font: 14px/1 var(--font);
  background: transparent;
  color: var(--ink);
  min-height: 36px;
  transition: border-color 0.1s, background 0.1s, box-shadow 0.1s;
  -webkit-appearance: none;
  appearance: none;
}
.jsp-table input::placeholder { color: var(--graph); opacity: 0.45; }
.jsp-table input:hover,
.jsp-table select:hover {
  border-color: var(--line);
  background: var(--surface);
}
.jsp-table input:focus,
.jsp-table select:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 14%, transparent);
}

/* State select: custom arrow */
.jsp-table select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%235B6470' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 13px;
  padding-right: 20px;
}

/* APN column: monospace, slightly larger visual weight */
.jsp-table td:nth-child(2) input {
  font-family: ui-monospace, Menlo, "Cascadia Code", monospace;
  font-size: 13px;
  letter-spacing: 0.03em;
}

/* Note column: visually quieter */
.jsp-table td:last-child input {
  font-size: 13px;
  color: var(--graph);
}
.jsp-table td:last-child input::placeholder { opacity: 0.4; }

/* ── Tools row ── */
.jsp-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 6px;
}
.jsp-progress {
  font-size: 13px;
  color: var(--graph);
  font-variant-numeric: tabular-nums;
}

/* ── Submit area ── */
.jsp-hint {
  font-size: 13px;
  color: var(--graph);
  line-height: 1.5;
  margin-bottom: 14px;
}
.jsp-error {
  font-size: 14px;
  color: var(--warn);
  font-weight: 600;
  line-height: 1.4;
}
.jsp-submit-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  padding-top: 4px;
}

/* ── Done view ── */
.jsp-done-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 20px 4px 48px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
}
.jsp-done-list li {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.jsp-done-list li:last-child { border-bottom: none; }

.jsp-done-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Footer ── */
.jsp-foot {
  text-align: center;
  padding: 20px 24px;
  color: var(--graph);
  font-size: 13px;
  border-top: 1px solid var(--line);
  margin-top: 56px;
}
.jsp-foot a { color: var(--blue); text-decoration: none; }
.jsp-foot a:hover { text-decoration: underline; }

/* ════════════════════════════════════════
   Mobile — card layout
   ════════════════════════════════════════ */
@media (max-width: 700px) {

  .jsp-main { padding: 20px 16px 110px; }
  h1 { font-size: 21px; }
  .jsp-sub { font-size: 13px; }

  /* Paste panel: stack columns */
  .jsp-paste-cols { grid-template-columns: 1fr; }
  .jsp-paste-common { gap: 10px; }

  /* Table wrapper: edge-to-edge card strip */
  .jsp-table-wrap {
    border-left: none;
    border-right: none;
    border-radius: 0;
    overflow-x: visible;
    margin-left: -16px;
    margin-right: -16px;
  }

  /* Flatten table into block layout */
  .jsp-table            { display: block; min-width: 0; table-layout: auto; }
  .jsp-table thead      { display: none; }
  .jsp-table tbody      { display: block; }

  /* Each row → compact card via CSS grid */
  .jsp-row {
    display: grid;
    grid-template-columns: 32px 1fr 1fr 60px;
    grid-template-rows: auto auto auto auto;
    column-gap: 6px;
    row-gap: 5px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    border-left: 3px solid transparent;
  }
  .jsp-row:last-child { border-bottom: none; }

  /* Status stripe on the row itself (not individual td) */
  .jsp-row.is-complete   { border-left-color: var(--ok); }
  .jsp-row.is-incomplete { border-left-color: var(--warn); }
  .jsp-row td:first-child { border-left: none; }

  /* Reset td borders for card mode */
  .jsp-row td { border-bottom: none; padding: 0; }

  /* num: col 1, rows 1–3 */
  .jsp-row td:nth-child(1) {
    grid-column: 1;
    grid-row: 1 / 4;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
  }

  /* APN: col 2–4, row 1 */
  .jsp-row td:nth-child(2) { grid-column: 2 / 5; grid-row: 1; }

  /* Address: col 2–4, row 2 */
  .jsp-row td:nth-child(3) { grid-column: 2 / 5; grid-row: 2; }

  /* City: col 2, row 3 */
  .jsp-row td:nth-child(4) { grid-column: 2; grid-row: 3; }

  /* County: col 3, row 3 */
  .jsp-row td:nth-child(5) { grid-column: 3; grid-row: 3; }

  /* State: col 4, row 3 */
  .jsp-row td:nth-child(6) { grid-column: 4; grid-row: 3; }

  /* Note: full width, row 4 */
  .jsp-row td:nth-child(7) { grid-column: 1 / 5; grid-row: 4; padding-left: 38px; }

  /* Mobile inputs: always show border, 16px font (prevents iOS zoom) */
  .jsp-table input,
  .jsp-table select {
    font-size: 16px;
    border-color: var(--line);
    background: var(--surface);
    border-radius: 6px;
    min-height: 40px;
    padding: 8px 10px;
  }
  .jsp-table select {
    background-color: var(--surface);
    background-position: right 6px center;
  }
  .jsp-table input:focus,
  .jsp-table select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 14%, transparent);
  }

  /* Note input slightly smaller on mobile too */
  .jsp-table td:last-child input { font-size: 15px; }

  /* Num cell: smaller */
  .jsp-num { font-size: 11px; }

  /* Hint text: hide below table on mobile (redundant with placeholders) */
  form > .jsp-hint { display: none; }

  /* Sticky bottom submit bar */
  .jsp-submit-bar {
    position: sticky;
    bottom: 0;
    background: var(--paper);
    padding: 10px 16px 14px;
    border-top: 1px solid var(--line);
    margin-left: -16px;
    margin-right: -16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 20;
    /* safe area on iPhone */
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  .jsp-submit-bar .jsp-btn { flex: 1; text-align: center; justify-content: center; }

  .jsp-tools { padding: 6px 0; }

  .jsp-done-list { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: none; border-right: none; }
  .jsp-done-actions { flex-direction: column; align-items: flex-start; }
}

/* ── Fixes applied by the JSP bot after Claude's pass (2026-11-27) ── */
/* Views toggled with the hidden attribute must disappear even when a rule sets display. */
[hidden] { display: none !important; }
/* Sticky header: the scroll wrapper made it overlap row 1. Wide screens: let the page scroll and stick under the top bar. */
@media (min-width: 900px) {
  .jsp-table-wrap { overflow: visible; }
  .jsp-table { min-width: 0; }
}
@media (min-width: 701px) and (max-width: 899px) {
  .jsp-table thead { position: static; }
}
/* Mobile cards: desktop column widths must not shrink the grid cells. */
@media (max-width: 700px) {
  .jsp-table th, .jsp-table td,
  .jsp-row td:nth-child(n) { width: auto !important; min-width: 0; }
  .jsp-row td input, .jsp-row td select { width: 100%; min-width: 0; }
}
