* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1c1f;
  display: flex;
  flex-direction: column;
}
header {
  position: relative;
  background: #1f2937;
  color: #f9fafb;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid #111;
}
header h1 { margin: 0; font-size: 20px; font-weight: 600; }
.legend { color: #cbd5e1; font-size: 13px; }
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-btn {
  background: rgba(255,255,255,.08);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.14);
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.header-btn:hover { background: rgba(255,255,255,.16); }
.header-btn:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

.project-name-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  text-align: center;
}
.project-name-center:empty { display: none; }

/* --- Admin tab (main view) --- */
#view-admin {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
}
.admin-side {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-side-tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  color: #374151;
  font-size: 14px;
  font-weight: 600;
}
.admin-side-tab:hover { background: #eef2ff; }
.admin-side-tab.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.admin-content {
  padding: 20px 24px;
  overflow: auto;
}
.admin-page-title {
  margin: 0 0 12px 0;
  font-size: 22px;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
}
.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.1;
}
.stat-label {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}
.stat-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #9ca3af;
}
.admin-list-meta {
  color: #6b7280;
  font-size: 12px;
  margin: 12px 0 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-empty {
  padding: 40px;
  text-align: center;
  color: #6b7280;
}
.admin-empty-row {
  text-align: center;
  color: #9ca3af;
  font-style: italic;
  padding: 20px;
}
.admin-loading {
  padding: 20px;
  color: #6b7280;
  font-style: italic;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th, .admin-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  vertical-align: top;
}
.admin-table th {
  font-weight: 700;
  color: #374151;
  background: #f9fafb;
  position: sticky;
  top: 0;
}
.admin-table th.num, .admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .menu-role {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.admin-cell-muted { color: #9ca3af; font-style: italic; }
.proj-chip {
  display: inline-block;
  background: #eff6ff;
  color: #1e40af;
  padding: 1px 8px;
  border-radius: 999px;
  margin-right: 4px;
  margin-bottom: 2px;
  font-size: 12px;
}

/* --- User badge + dropdown --- */
.user-badge-wrap { position: relative; display: inline-flex; }
.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,.08);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.user-badge:hover { background: rgba(255,255,255,.16); }
.user-badge:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }
.user-badge .user-avatar,
.user-badge .user-avatar-initial {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #6b7280;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}
.user-badge .user-avatar { object-fit: cover; }
.user-badge .user-badge-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-badge .user-badge-caret { font-size: 10px; color: #cbd5e1; }

.user-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 260px;
  background: #ffffff;
  color: #1f2937;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
  padding: 6px 0;
  z-index: 700;
  font-size: 13px;
}
.user-menu-section {
  padding: 8px 14px 4px 14px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.user-menu-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: #1f2937;
}
.user-menu-item:hover { background: #eff6ff; }
.user-menu-item.is-current { background: #f9fafb; }
.user-menu-item .menu-icon { color: #6b7280; }
.user-menu-item .menu-check { color: #1d4ed8; font-weight: 700; }
.user-menu-item .menu-role {
  color: #6b7280;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.user-menu-empty {
  padding: 6px 14px 10px 14px;
  color: #9ca3af;
  font-style: italic;
  font-size: 12px;
}
.user-menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}

/* --- Users tab --- */
.users-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.users-header h2 { margin: 0 0 4px 0; font-size: 22px; }
.users-help { margin: 0; color: #4b5563; font-size: 14px; }

.role-legend {
  margin: 14px 0 0 0;
  padding: 14px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 16px;
  row-gap: 8px;
  font-size: 13px;
  color: #1f2937;
  line-height: 1.5;
}
.role-legend dt {
  font-weight: 700;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 12px;
  align-self: baseline;
  padding-top: 1px;
}
.role-legend dd { margin: 0; color: #374151; }
.role-legend code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
}

/* Viewer read-only score/reason inputs */
.row-readonly .score-input,
.row-readonly .reason-input {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.row-readonly .score-input:hover,
.row-readonly .reason-input:hover {
  background: transparent;
  border-color: transparent;
}
.row-readonly .score-input:focus,
.row-readonly .reason-input:focus {
  outline: none;
}
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.users-table th, .users-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.users-table th { font-weight: 600; color: #374151; background: #f9fafb; }
.users-table .member-added { color: #6b7280; font-size: 12px; }
.users-table .member-actions { text-align: right; }
.users-table .member-self {
  color: #6b7280;
  font-size: 12px;
  font-style: italic;
}
.member-role-input {
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}
.users-error {
  padding: 12px 14px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 6px;
}
.users-add-form {
  border-top: 1px solid #f1f5f9;
  padding-top: 16px;
  display: grid;
  grid-template-columns: 1fr 140px auto auto;
  gap: 10px;
  align-items: end;
}
.users-add-form .modal-input { margin-bottom: 0; }
.users-add-form .recalc-status { padding-bottom: 8px; }
.users-add-form h3 {
  margin: 0;
  grid-column: 1 / -1;
  font-size: 14px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Login page --- */
body.login-page {
  background: #0b1220;
  color: #e5e7eb;
  display: block;
}
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: #ffffff;
  color: #1f2937;
  border-radius: 12px;
  padding: 36px 40px 24px 40px;
  min-width: 380px;
  max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-card h1 { margin: 0 0 8px 0; font-size: 24px; font-weight: 700; }
.login-tagline { margin: 0 0 24px 0; color: #4b5563; font-size: 14px; }
.g-signin { display: flex; justify-content: center; margin-bottom: 12px; min-height: 44px; }
.login-error {
  margin: 8px 0 0 0;
  padding: 10px 12px;
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 13px;
}
.login-error code {
  background: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.dev-login {
  margin-top: 16px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
}
.dev-login summary { cursor: pointer; color: #4b5563; font-weight: 600; }
.dev-login form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.dev-login input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font: inherit;
}
.login-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  color: #6b7280;
  font-size: 12px;
  text-align: center;
}
.login-footer a { color: #1d4ed8; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }

.tabs {
  display: flex;
  gap: 4px;
}
.tabs .tab {
  background: rgba(255,255,255,.08);
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,.14);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.tabs .tab:hover { background: rgba(255,255,255,.16); }
.tabs .tab.active {
  background: #f9fafb;
  color: #1f2937;
  border-color: #f9fafb;
}
.tabs .tab:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

main {
  flex: 1;
  padding: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.view { flex: 1; min-height: 0; display: flex; }
[hidden] { display: none !important; }
#view-rankings {
  display: grid;
  grid-template-columns: var(--left-width, 340px) 12px 1fr;
  gap: 0;
}
.col-resizer {
  align-self: stretch;
  cursor: col-resize;
  position: relative;
  background: transparent;
}
.col-resizer::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 5px;
  width: 2px;
  background: #cbd5e1;
  border-radius: 2px;
  transition: background 120ms ease-out, width 120ms ease-out, left 120ms ease-out;
}
.col-resizer:hover::before,
.col-resizer:focus-visible::before { background: #1d4ed8; width: 3px; left: 4.5px; }
.col-resizer:focus-visible { outline: none; }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing .col-resizer::before { background: #1d4ed8; width: 3px; left: 4.5px; }
#view-factors { display: block; }
body[data-tab="rankings"] #view-factors { display: none; }
body[data-tab="factors"] #view-rankings { display: none; }
.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: auto;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
#list { padding: 6px; display: flex; flex-direction: column; }
.list-toolbar {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 6px 4px 8px 4px;
  border-bottom: 1px solid #f1f5f9;
  margin: -6px -6px 6px -6px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.add-house-btn {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
}
.house-search {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
  color: #1f2937;
  box-sizing: border-box;
}
.house-search::placeholder { color: #9ca3af; }
.house-search:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
}
.list-empty {
  padding: 20px 12px;
  color: #6b7280;
  font-size: 13px;
  text-align: center;
}
.house-row {
  display: grid;
  grid-template-columns: 30px 1fr 116px 40px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.house-row + .house-row { margin-top: 2px; }
.house-row:hover { background: #eef2ff; }
.house-row.selected { background: #dbeafe; border-color: #93c5fd; }
.house-row .rank {
  font-size: 12px;
  color: #6b7280;
}
.house-row .addr { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.house-row .status-cell {
  min-width: 0;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 2px;
  position: relative;
}
.status-chevron {
  flex: 0 0 auto;
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,.12);
  color: #4b5563;
  padding: 0 4px;
  font-size: 10px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
  align-self: center;
  height: 20px;
}
.status-chevron:hover { background: #e5e7eb; border-color: rgba(0,0,0,.35); color: #1f2937; }
.status-chevron:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }

.status-menu {
  position: absolute;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  min-width: 140px;
  max-height: 260px;
  overflow-y: auto;
  box-shadow: 0 10px 24px rgba(0,0,0,.15);
  z-index: 200;
  font-size: 13px;
}
.status-menu li {
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2937;
  cursor: pointer;
  outline: none;
}
.status-menu li:hover,
.status-menu li:focus,
.status-menu li.active {
  background: #eff6ff;
}
.status-menu .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  flex: 0 0 auto;
}
.status-menu .dot.s-interested { background: #16a34a; }
.status-menu .dot.s-uninterested { background: #b91c1c; }
.status-menu .dot.s-unavailable { background: #78716c; }
.status-menu .dot.s-see { background: #0284c7; }
.house-row .total {
  justify-self: end;
  font-weight: 700;
  color: #1f2937;
  background: #e5e7eb;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
}

.status-input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.12);
  background: #fff;
  color: #374151;
  text-align: left;
  cursor: text;
}
.status-input::placeholder { color: #9ca3af; font-weight: 400; }
.status-input:hover { border-color: rgba(0,0,0,.35); }
.status-input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-color: transparent;
}
.status-input.s-interested { background: #16a34a; color: #fff; border-color: #14803a; }
.status-input.s-uninterested { background: #b91c1c; color: #fff; border-color: #9a1616; }
.status-input.s-unavailable { background: #78716c; color: #fff; border-color: #5f5854; }
.status-input.s-see { background: #0284c7; color: #fff; border-color: #026aa2; }
.status-input.s-empty { background: #f3f4f6; }

#detail { padding: 20px; position: relative; }
#detail .empty { color: #6b7280; }
#detail .zillow-corner {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
}
#detail .zillow-corner:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
#detail h2 { margin: 0 0 4px 0; font-size: 22px; }
#detail .city { color: #4b5563; margin-bottom: 12px; }
#detail .photo-block { margin-bottom: 16px; }
#detail .photo-tabs {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
#detail .tab-group {
  display: flex;
  gap: 4px;
}
#detail .photo-tab {
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #374151;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
#detail .photo-tab:hover { background: #e5e7eb; }
#detail .photo-tab.active {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}
#detail .photo-tab.tab-empty {
  color: #9ca3af;
}
#detail .photo-fetch {
  border: 1px solid #d1d5db;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}
#detail .photo-fetch:hover:not(:disabled) { background: #dbeafe; }
#detail .photo-fetch:disabled { opacity: .55; cursor: default; }

#detail img.hero {
  width: 100%;
  height: 380px;
  object-fit: cover;
  border-radius: 8px;
  background: #e5e7eb;
  display: block;
}
#detail .hero-empty {
  height: 380px;
  border-radius: 8px;
  background: #f3f4f6;
  border: 1px dashed #d1d5db;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 14px;
  box-sizing: border-box;
}
#detail .facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}
#detail .facts .k { color: #6b7280; font-size: 12px; }
#detail .facts .v { font-weight: 600; }

.scores-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 4px;
}
.scores-header h3 {
  margin: 0;
  font-size: 15px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.scores {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
}
table.scores th, table.scores td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
}
table.scores th { font-weight: 600; color: #374151; background: #f9fafb; }
table.scores td.col-weight, table.scores th.col-weight {
  width: 60px;
  text-align: center;
  color: #6b7280;
  font-weight: 600;
  font-size: 13px;
}
.factor-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  user-select: none;
  vertical-align: middle;
}
.factor-info:hover, .factor-info:focus-visible {
  background: #dbeafe;
  border-color: #93c5fd;
  outline: none;
}
.factor-tooltip {
  position: fixed;
  background: #1f2937;
  color: #f9fafb;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-line;
  min-width: 260px;
  max-width: 480px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  pointer-events: none;
}

/* --- Add House modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #ffffff;
  border-radius: 10px;
  padding: 24px 26px 20px 26px;
  width: 480px;
  max-width: 100%;
  box-shadow: 0 24px 48px rgba(0,0,0,.28);
}
.modal h2 { margin: 0 0 8px 0; font-size: 20px; font-weight: 600; }
.modal-help { margin: 0 0 14px 0; color: #4b5563; font-size: 14px; }
.modal-help code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.modal-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  margin-bottom: 14px;
  box-sizing: border-box;
  color: #1f2937;
}
.modal-input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
}
.modal-input:disabled {
  background: #f9fafb;
  color: #6b7280;
}
.add-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.add-progress .recalc-bar { max-width: none; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal-confirm { width: 440px; }
.modal-confirm .modal-message {
  margin: 0 0 16px 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-line;
}
.about-modal { width: 420px; }
.about-tagline {
  margin: 0 0 16px 0;
  color: #4b5563;
  font-size: 14px;
}
.about-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  row-gap: 6px;
  margin: 0 0 18px 0;
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
}
.about-meta dt {
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
  align-self: center;
}
.about-meta dd { margin: 0; color: #1f2937; }
.about-meta a { color: #1d4ed8; text-decoration: none; }
.about-meta a:hover { text-decoration: underline; }
table.scores td.score {
  width: 56px;
  text-align: center;
  font-weight: 700;
  border-radius: 6px;
  padding: 4px;
}
td.score.s3 { background: #d1fae5; color: #065f46; }
td.score.s2 { background: #fef3c7; color: #92400e; }
td.score.s1 { background: #fee2e2; color: #991b1b; }
td.score .score-input {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 4px;
  background: rgba(255,255,255,.6);
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: center;
}
td.score .score-input:hover { background: #fff; border-color: rgba(0,0,0,.35); }
td.score .score-input:focus {
  background: #fff;
  outline: 2px solid #3b82f6;
  outline-offset: 1px;
  border-color: transparent;
}
.saving { opacity: .55; }
.save-error {
  outline: 2px solid #dc2626 !important;
  background: #fee2e2 !important;
}

#detail .detail-total {
  font-size: 16px;
  background: #1f2937;
  color: #fff;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: 6px;
}

#detail .notes-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 12px 0 8px 0;
  padding: 10px 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  color: #374151;
}

/* --- Notes / comments section --- */
#detail .notes-section {
  margin: 12px 0 8px 0;
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
#detail .notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
#detail .comment-add-toggle {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#detail .comment-add-toggle:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
#detail .comment-add-toggle:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}
#detail .notes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
#detail .comment-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  color: #1f2937;
  min-height: 22px;
}
#detail .comment-author {
  font-weight: 700;
  color: #4b5563;
  white-space: nowrap;
}
#detail .comment-text { flex: 1; word-break: break-word; }
#detail .comment-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 100ms ease-out;
}
#detail .comment-row:hover .comment-actions,
#detail .comment-row:focus-within .comment-actions { opacity: 1; }
#detail .comment-edit, #detail .comment-delete {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #4b5563;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}
#detail .comment-edit:hover, #detail .comment-delete:hover {
  background: #f3f4f6;
  border-color: #6b7280;
  color: #1f2937;
}
#detail .comment-empty {
  color: #9ca3af;
  font-size: 13px;
  font-style: italic;
}
#detail .comment-add {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}
#detail .comment-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  font-size: 14px;
}
#detail .comment-input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
}
#detail .comment-add-btn {
  font-size: 13px;
  padding: 6px 14px;
}
#detail .comment-editing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex: 1;
}
#detail .comment-edit-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
}
.btn-small { padding: 4px 10px; font-size: 12px; }
#detail .notes-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#detail .notes-input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(0,0,0,.15);
  background: rgba(255,255,255,.6);
  color: inherit;
  font: inherit;
  padding: 5px 8px;
  border-radius: 4px;
}
#detail .notes-input:hover { background: #fff; border-color: rgba(0,0,0,.35); }
#detail .notes-input:focus {
  background: #fff;
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
}

/* --- Reason column (editable) --- */
table.scores td.reason {
  padding: 4px 8px;
  color: #374151;
  vertical-align: middle;
}
table.scores td.reason .reason-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(255,255,255,.5);
  border-radius: 4px;
  font: inherit;
  color: inherit;
}
table.scores td.reason .reason-input:hover {
  background: #fff;
  border-color: rgba(0,0,0,.35);
}
table.scores td.reason .reason-input:focus {
  background: #fff;
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
}

/* --- Override indicators --- */
table.scores tr.row-overridden td.score.overridden {
  box-shadow: inset 0 0 0 2px #1d4ed8;
}
table.scores td.reason.overridden .reason-input {
  border-color: #1d4ed8;
  background: #eff6ff;
}
table.scores td.col-revert {
  width: 40px;
  text-align: center;
  padding: 4px;
}
.revert-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.revert-btn:hover { background: #dbeafe; border-color: #93c5fd; }
.revert-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

/* --- Factors editor panel --- */
.factors-panel {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}
.factors-header h2 { margin: 0 0 4px 0; font-size: 22px; }
.factors-header .factors-help {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
  max-width: 780px;
}
#factors-md {
  flex: 1;
  min-height: 320px;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fafafa;
  resize: vertical;
  color: #1f2937;
}
#factors-md:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 0;
  border-color: transparent;
  background: #fff;
}
.factors-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn-primary {
  background: #1d4ed8;
  color: #fff;
  border: 1px solid #1e40af;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-primary:focus-visible { outline: 2px solid #93c5fd; outline-offset: 2px; }

.recalc-status { font-size: 13px; color: #4b5563; }
.recalc-status.ok { color: #065f46; }
.recalc-status.err { color: #991b1b; }

.recalc-bar {
  flex: 1;
  max-width: 320px;
  height: 10px;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.recalc-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6);
  transition: width 250ms ease-out;
}

.admin-sep {
  border: 0;
  border-top: 1px solid #e5e7eb;
  margin: 8px 0 0 0;
}
.admin-section {
  padding-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-header h3 {
  margin: 0 0 4px 0;
  font-size: 15px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-header p {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
  max-width: 780px;
}
.btn-secondary {
  background: #f9fafb;
  color: #1f2937;
  border: 1px solid #d1d5db;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.btn-secondary:hover:not(:disabled) { background: #f3f4f6; border-color: #9ca3af; }
.btn-secondary:disabled { opacity: .6; cursor: default; }
.btn-secondary:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

.danger-zone {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.btn-danger {
  background: #ffffff;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.btn-danger:hover { background: #fee2e2; border-color: #b91c1c; }
.btn-danger:focus-visible { outline: 2px solid #ef4444; outline-offset: 2px; }
