/* Permit list, selection, sidebar, footer */

/* Selection bar above feed */
.selbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.selbar.has-selection { background: var(--primary-soft); }
.selbar-check { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.selbar-text strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.selbar-spacer { flex: 1; }
.selbar-actions { display: flex; gap: 4px; }
.link-btn {
  background: transparent; border: 0;
  color: var(--ink-2); font-size: 12.5px; font-weight: 500;
  padding: 5px 9px; border-radius: var(--r-sm);
}
.link-btn:hover { background: var(--surface-3); color: var(--ink); }
.link-btn:disabled { color: var(--muted-2); cursor: not-allowed; }
.link-btn:disabled:hover { background: transparent; }

/* Custom checkbox */
.cb {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--line-2);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: background .12s, border-color .12s;
  flex-shrink: 0;
}
.cb:hover { border-color: var(--ink-2); }
.cb:checked { background: var(--primary); border-color: var(--primary); }
.cb:checked::after {
  content: ""; position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg);
}
.cb:indeterminate { background: var(--primary); border-color: var(--primary); }
.cb:indeterminate::after {
  content: ""; position: absolute;
  left: 3px; top: 6.5px;
  width: 8px; height: 2px;
  background: white; border-radius: 1px;
}
.cb:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

/* Permit list */
.feed-scroll {
  max-height: calc(100vh - 360px);
  min-height: 360px;
  overflow-y: auto;
}
@media (max-width: 1080px) { .feed-scroll { max-height: none; } }

.row {
  display: grid;
  grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1.4fr) 110px 90px;
  gap: 14px; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .1s;
  position: relative;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.is-selected { background: var(--primary-soft); }
.row.is-selected:hover { background: #e3e9f4; }
.row.is-active { box-shadow: inset 3px 0 0 var(--primary); }

.row-main { min-width: 0; }
.row-name {
  font-weight: 600; font-size: 14px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -0.005em;
}
.row-name.is-missing {
  color: var(--muted); font-style: italic; font-weight: 500;
}
.row-id {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--muted); margin-top: 3px;
}

.row-addr {
  font-size: 13px; color: var(--ink-2); min-width: 0;
}
.row-addr-line {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-addr-com {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.row-cost {
  font-family: var(--font-mono); font-size: 13.5px;
  font-weight: 500; color: var(--ink);
  text-align: right; font-variant-numeric: tabular-nums;
}
.row-cost.is-zero { color: var(--muted-2); font-weight: 400; }
.row-date {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  text-align: right; font-variant-numeric: tabular-nums;
}

/* Work-class badge */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-3); color: var(--muted);
}
.badge.b-new { background: var(--good-soft); color: var(--good); }
.badge.b-improvement { background: var(--info-soft); color: var(--info); }
.badge.b-addition { background: var(--warn-soft); color: var(--warn); }
.badge.b-demolition { background: var(--danger-soft); color: var(--danger); }

/* Empty / loading / error */
.feed-empty, .feed-error {
  padding: 56px 24px; text-align: center;
}
.feed-empty h3, .feed-error h3 {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 600;
  color: var(--ink);
}
.feed-empty p, .feed-error p {
  margin: 0 auto; max-width: 42ch;
  font-size: 13px; color: var(--muted);
}
.feed-error { color: var(--danger); }
.feed-error h3 { color: var(--danger); }

.skel-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1.4fr) 110px 90px;
  gap: 14px; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.skel {
  background: linear-gradient(90deg, var(--surface-3) 0%, #f4f1eb 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px; height: 12px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============ Right column ============ */
.side { display: flex; flex-direction: column; gap: 20px; }
.side-card { padding: 20px; }
.side-card h2 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 17px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.01em;
}
.side-card .lede {
  margin: 0 0 16px;
  font-size: 13px; color: var(--muted); line-height: 1.5;
}

/* Send card */
.summary-block {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 5px 0; font-size: 13px;
}
.summary-row + .summary-row { border-top: 1px dashed var(--line); }
.summary-row .label { color: var(--muted); }
.summary-row .value {
  font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.summary-row.total { padding-top: 9px; margin-top: 5px; border-top: 1px solid var(--line-2); }
.summary-row.total .value { font-size: 17px; font-weight: 600; font-family: var(--font-mono); }

.send-toggle {
  display: flex; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 14px;
  cursor: pointer; user-select: none;
}
.send-toggle:hover { background: var(--surface-3); }
.send-toggle input {
  margin: 2px 0 0;
  accent-color: var(--primary);
}
.send-toggle .copy strong {
  display: block; font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 3px;
}
.send-toggle .copy span {
  font-size: 12px; color: var(--muted); line-height: 1.45;
}
.send-toggle.is-on {
  background: var(--danger-soft);
  border-color: #e0c4bc;
}

.btn-block {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; width: 100%;
  height: 42px; padding: 0 16px;
  font-size: 14px;
}

.help-text {
  margin: 12px 0 0;
  font-size: 12px; color: var(--muted);
  line-height: 1.5;
}

/* Detail card */
.detail-empty {
  padding: 32px 20px;
  text-align: center;
  font-size: 13px; color: var(--muted);
}
.detail-empty h3 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 15px; font-weight: 600; color: var(--ink-2);
}
.detail {
  display: flex; flex-direction: column; gap: 16px;
}
.detail-name {
  font-family: var(--font-serif);
  font-size: 19px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink); margin: 0;
}
.detail-name.is-missing { color: var(--muted); font-style: italic; }
.detail-id {
  font-family: var(--font-mono);
  font-size: 12px; color: var(--muted); margin-top: 4px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 14px;
  font-size: 13px;
}
.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  align-self: center;
}
.detail-grid dd {
  margin: 0; color: var(--ink);
}
.detail-grid dd.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.disclosure {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.disclosure summary {
  cursor: pointer;
  font-size: 12px; color: var(--muted); font-weight: 500;
  list-style: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary::before {
  content: "▸"; font-size: 10px; transition: transform .15s;
}
.disclosure[open] summary::before { transform: rotate(90deg); }
.disclosure pre {
  margin: 10px 0 0;
  padding: 12px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11.5px; line-height: 1.5;
  color: var(--ink-2);
  overflow-x: auto;
  max-height: 280px;
}

/* Run modal */
.modal-veil {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(24,24,27,0.32);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px;
  max-height: 86vh;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-head .close {
  border: 0; background: transparent;
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  color: var(--muted); font-size: 18px; line-height: 1;
}
.modal-head .close:hover { background: var(--surface-3); color: var(--ink); }
.modal-progress {
  padding: 18px 22px;
  font-size: 13px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.progress-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width .25s ease;
}
.modal-list {
  flex: 1; overflow-y: auto;
  padding: 6px 0;
}
.modal-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px; align-items: flex-start;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.modal-row:last-child { border-bottom: 0; }
.modal-row .check {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.modal-row .check.pending { color: var(--muted-2); }
.modal-row .check.pending::before {
  content: ""; width: 12px; height: 12px;
  border: 2px solid var(--line-2);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.modal-row .check.done { color: var(--good); font-weight: 700; }
.modal-row .check.fail { color: var(--danger); font-weight: 700; }
.modal-row .name {
  font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.modal-row .name.missing { color: var(--muted); font-style: italic; font-weight: 500; }
.modal-row .copy-text {
  font-family: var(--font-serif);
  font-size: 13px; color: var(--ink-2);
  line-height: 1.45;
  margin-top: 6px;
}
.modal-row .meta {
  font-size: 11.5px; color: var(--muted);
}
.modal-row .status {
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.modal-row .status.queued { background: var(--surface-3); color: var(--muted); }
.modal-row .status.running { background: var(--info-soft); color: var(--info); }
.modal-row .status.sent { background: var(--good-soft); color: var(--good); }
.modal-row .status.error { background: var(--danger-soft); color: var(--danger); }

.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-foot .summary { flex: 1; min-width: 140px; font-size: 12.5px; color: var(--muted); }
.modal-foot .summary strong { color: var(--ink); font-weight: 600; }
.modal-foot-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
