:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #666a6f;
  --paper: #f6f3ed;
  --panel: #ffffff;
  --line: #ded7cd;
  --accent: #1e4d60;
  --accent-strong: #143947;
  --gold: #c28b2c;
  --danger: #b24535;
  --complete: #1f7a45;
  --secondary: #eef1f2;
  --shadow: 0 14px 34px rgba(42, 36, 28, 0.12);
}

body[data-theme="dark"] {
  --ink: #f4f6f5;
  --muted: #b7c1be;
  --paper: #101816;
  --panel: #17211f;
  --line: #33423e;
  --accent: #2d6f89;
  --accent-strong: #79c4dc;
  --gold: #d9a742;
  --danger: #b24535;
  --complete: #1f7a45;
  --secondary: #263238;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f4;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body[data-theme="dark"] {
  background: #0f171a;
}

body:has(.lock-screen.visible),
body:has(.auth-screen.visible) {
  overflow: hidden;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.8rem;
  line-height: 1.05;
}

h2 {
  font-size: 1rem;
}

.icon-button,
.remove-button {
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
}

.icon-button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  background: var(--accent);
  color: white;
  font-size: 1.8rem;
  line-height: 1;
  box-shadow: var(--shadow);
}

.menu-icon {
  gap: 5px;
}

.menu-icon span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: white;
}

.menu-panel {
  display: none;
  gap: 8px;
  margin: -6px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
  box-shadow: var(--shadow);
}

.popup-panel {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 12;
  width: min(432px, calc(100% - 28px));
  transform: translateX(-50%);
  margin: 0;
}

.menu-panel.open {
  display: grid;
}

.popup-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.popup-options {
  display: grid;
  gap: 8px;
}

.report-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.report-open-button {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-report-button {
  display: inline-grid;
  place-items: center;
  text-align: center;
  padding-inline: 8px;
}

.copy-report-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.copy-report-button.copied {
  background: var(--complete);
  color: white;
}

.action-icon.copied {
  background: var(--complete);
  color: white;
}

.popup-empty {
  border-radius: 8px;
  background: var(--secondary);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 12px;
}

.menu-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
}

.menu-item.active {
  background: var(--accent);
  color: white;
}

.menu-item.danger {
  color: var(--danger);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 11;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  width: min(100%, 460px);
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 24px rgba(42, 36, 28, 0.12);
  padding: 5px 8px calc(5px + env(safe-area-inset-bottom));
  backdrop-filter: blur(16px);
}

body[data-theme="dark"] .bottom-nav {
  background: rgba(16, 24, 22, 0.96);
}

.bottom-tab {
  display: grid;
  gap: 2px;
  min-height: 48px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 800;
}

.bottom-tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-tab.active {
  background: var(--secondary);
  color: var(--accent-strong);
}

.app-page {
  display: none;
}

.app-page.active {
  display: block;
}

.lock-screen,
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(245, 242, 236, 0.94), rgba(245, 242, 236, 0.98)),
    url("https://images.unsplash.com/photo-1503387762-592deb58ef4e?auto=format&fit=crop&w=1200&q=80");
  background-position: center;
  background-size: cover;
}

.lock-screen.visible,
.auth-screen.visible {
  display: grid;
}

.lock-panel {
  width: min(100%, 380px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 18px;
  box-shadow: var(--shadow);
}

.lock-panel h1 {
  margin-bottom: 8px;
}

.lock-panel input {
  margin-top: 14px;
  letter-spacing: 0;
}

#pinInput {
  font-size: 1.2rem;
  text-align: center;
}

.hidden {
  display: none !important;
}

.pin-error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.panel {
  margin-bottom: 14px;
  border: 1px solid rgba(222, 215, 205, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .panel,
body[data-theme="dark"] .menu-panel,
body[data-theme="dark"] .lock-panel,
body[data-theme="dark"] .issue-card,
body[data-theme="dark"] .contact-card,
body[data-theme="dark"] .info-card,
body[data-theme="dark"] .empty-state {
  border-color: var(--line);
  background: rgba(23, 33, 31, 0.96);
}

.community-panel,
.homesite-panel,
.form-panel,
.email-panel {
  padding: 14px;
}

.panel-header,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.button-pair {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.card-action-pair {
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.card-action-button {
  display: grid;
  gap: 3px;
  flex: 0 0 54px;
  width: 54px;
  min-width: 0;
  height: 52px;
  min-height: 52px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-size: 0.64rem;
  font-weight: 800;
  padding: 6px 8px;
  text-align: center;
}

.card-action-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-action-button span {
  line-height: 1.05;
}

.homesite-panel .card-action-button {
  flex-basis: 60px;
  width: 60px;
  height: 56px;
  min-height: 56px;
  padding-inline: 4px;
}

.issue-sort {
  display: grid;
  gap: 2px;
  width: 94px;
  min-width: 94px;
  margin-right: auto;
}

.issue-sort span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.issue-sort select {
  min-height: 34px;
  padding: 0 6px;
  font-size: 0.76rem;
}

.homesite-details {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

label,
.field-grid span,
.notes-field span,
.photo-field span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
}

body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] input {
  background: #101816;
}

select,
input {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 11px 12px;
}

select:focus,
textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 100, 0.16);
}

.field-grid {
  display: grid;
  gap: 12px;
}

.custom-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.mini-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-size: 0.8rem;
  font-weight: 800;
}

.field-grid label,
.notes-field,
.photo-field {
  display: grid;
  gap: 6px;
}

.notes-field,
.photo-field {
  margin-top: 12px;
}

.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.photo-button {
  display: grid;
  min-height: 46px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
}

.photo-button.secondary {
  background: var(--secondary);
  color: var(--accent-strong);
}

body[data-theme="dark"] .photo-button.secondary,
body[data-theme="dark"] .menu-item,
body[data-theme="dark"] .mini-button,
body[data-theme="dark"] .pdf-button,
body[data-theme="dark"] .info-grid div,
body[data-theme="dark"] .remove-button {
  background: var(--secondary);
}

body[data-theme="dark"] .menu-item.active {
  background: var(--accent);
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.photo-preview,
.issue-photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.preview-photo,
.issue-photos img {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 1;
  background: var(--secondary);
}

.preview-photo {
  position: relative;
}

.preview-photo img,
.issue-photos img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-photo span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(31, 111, 100, 0.92);
  color: white;
  font-size: 0.76rem;
  font-weight: 800;
}

.primary-button,
.email-button,
.pdf-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.primary-button {
  margin-top: 14px;
}

.secondary-action {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-weight: 800;
}

.primary-button:active,
.email-button:active,
.pdf-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 6px 0;
}

.text-button.danger {
  color: var(--danger);
}

.issue-actions .text-button {
  min-height: 42px;
  padding: 0 4px;
}

.clear-home-button {
  font-size: 0.78rem;
  white-space: nowrap;
}

.summary-band {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 6px 0 18px;
}

.summary-band div {
  min-height: 78px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
}

.summary-band span {
  font-size: 1.65rem;
  font-weight: 800;
}

.summary-band small {
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.issue-section {
  margin-bottom: 14px;
}

.issue-section > .section-title {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  padding: 10px;
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .issue-section > .section-title {
  background: rgba(23, 33, 31, 0.96);
}

.issue-actions {
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 7px;
  margin-left: 0;
  flex: 1;
}

.issue-list {
  display: grid;
  gap: 10px;
}

.home-issue-group {
  display: grid;
  gap: 9px;
}

.home-issue-group + .home-issue-group {
  margin-top: 24px;
}

.home-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(42, 36, 28, 0.08);
}

.home-group-header strong,
.home-group-header span {
  display: block;
}

.home-group-header strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.home-group-header span {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.home-group-header b {
  display: grid;
  flex: 0 0 34px;
  min-width: 34px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.88rem;
}

.issue-card {
  display: grid;
  grid-template-columns: 1fr 36px;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 10px solid var(--danger);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(42, 36, 28, 0.08);
}

.issue-card.trade-complete {
  border-left-color: var(--complete);
}

.issue-meta {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.issue-card h3 {
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.24;
}

.issue-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.issue-card.completed {
  border-left-color: var(--danger);
  opacity: 0.82;
}

.issue-card.completed.trade-complete {
  border-left-color: var(--complete);
}

body[data-theme="dark"] .issue-card,
body[data-theme="dark"] .issue-card.completed {
  border-left-color: var(--danger);
}

body[data-theme="dark"] .issue-card.trade-complete,
body[data-theme="dark"] .issue-card.completed.trade-complete {
  border-left-color: var(--complete);
}

.status-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  padding: 0 14px;
}

.status-button.undo {
  background: var(--secondary);
  color: var(--accent-strong);
}

.status-button.secondary {
  background: var(--secondary);
  color: var(--accent-strong);
}

.issue-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.trade-complete-label {
  color: var(--complete);
  font-size: 0.84rem;
  font-weight: 800;
}

.shared-note-field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.shared-note-field span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.shared-note-field textarea {
  min-height: 66px;
  resize: vertical;
}

.completed-section {
  margin-top: 18px;
}

.completed-section.minimized .issue-list {
  display: none;
}

.completed-section.empty {
  display: none;
}

.remove-button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f3e8e5;
  color: var(--danger);
  font-size: 1.25rem;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.helper {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.email-actions {
  display: grid;
  gap: 10px;
}

.email-row {
  display: grid;
  grid-template-columns: 1fr repeat(4, 42px);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.email-button {
  display: grid;
  place-items: center;
  min-height: 42px;
  text-decoration: none;
}

.pdf-button {
  min-height: 42px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-size: 0.8rem;
}

.action-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  padding: 0;
}

.issue-actions > .action-icon {
  gap: 2px;
  width: 54px;
  height: 50px;
  min-height: 50px;
  align-content: center;
  padding: 3px 4px;
}

.issue-actions > .action-icon svg {
  width: 18px;
  height: 18px;
}

.issue-actions > .action-icon span {
  display: block;
  max-width: 100%;
  color: inherit;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.action-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.email-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.email-field input {
  min-height: 42px;
  font-size: 0.88rem;
}

.email-button.disabled {
  pointer-events: none;
  background: #a8aaa8;
}

body[data-theme="dark"] .email-button.disabled {
  color: #000000;
}

.contacts-panel,
.contact-form-panel,
.info-panel,
.all-reports-panel {
  padding: 14px;
}

.contact-filter {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.contact-form-panel form {
  display: grid;
  gap: 12px;
}

.contact-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.contact-form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.contact-form-grid .wide-field {
  grid-column: 1 / -1;
}

.contact-form-panel .primary-button {
  margin-top: 2px;
}

@media (max-width: 380px) {
  .contact-form-grid {
    grid-template-columns: 1fr;
  }
}

.info-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.info-filters label {
  display: grid;
  gap: 6px;
}

.count-pill {
  display: inline-grid;
  min-width: 34px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.84rem;
  font-weight: 800;
}

.contact-list,
.homesite-info-list {
  display: grid;
  gap: 10px;
}

.all-report-links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.all-report-links .popup-empty {
  grid-column: 1 / -1;
}

.contact-card,
.info-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(42, 36, 28, 0.08);
}

.contact-topline {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.contact-card h2 {
  margin-top: 4px;
}

.info-card h2 {
  margin-top: 4px;
  font-size: 1rem;
  line-height: 1.25;
}

.contact-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.contact-detail {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
  margin-top: 9px;
  font-size: 0.9rem;
}

.contact-detail strong {
  color: var(--muted);
}

.contact-detail a {
  color: var(--accent-strong);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.info-grid div {
  border-radius: 8px;
  background: var(--secondary);
  padding: 9px;
}

.info-grid strong,
.info-grid span {
  display: block;
}

.info-grid strong {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.info-grid span {
  margin-top: 3px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@media (min-width: 430px) {
  .app-shell {
    padding-inline: 22px;
  }
}
