* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  letter-spacing: 0;
  scrollbar-gutter: stable;
}

body[data-theme="dark"] {
  background: var(--page-bg);
}

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;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.sync-control {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 132px;
  color: var(--muted);
}

.sync-icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  padding: 0;
}

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

.sync-control[data-sync-state="uploading"] .sync-icon-button svg {
  animation: sync-spin 0.9s linear infinite;
}

.sync-control[data-sync-state="saved"] .sync-icon-button,
.sync-control[data-online="false"] .sync-icon-button {
  color: var(--gold);
}

.sync-control[data-sync-state="failed"] .sync-icon-button,
.sync-control[data-sync-state="failed"] .sync-copy strong {
  color: var(--danger);
}

.sync-control[data-sync-state="synced"] .sync-copy strong {
  color: var(--complete);
}

.sync-copy {
  display: grid;
  min-width: 0;
}

.sync-copy strong,
.sync-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-copy strong {
  color: var(--ink);
  font-size: 0.75rem;
}

.sync-copy small {
  margin-top: 2px;
  font-size: 0.65rem;
}

.sync-count {
  position: absolute;
  top: -5px;
  left: 29px;
  display: none;
  min-width: 18px;
  min-height: 18px;
  place-items: center;
  border: 2px solid var(--paper);
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
}

.sync-count:not(:empty) {
  display: grid;
}

@keyframes sync-spin {
  to { transform: rotate(360deg); }
}

.field-notification-button {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-strong);
  padding: 0;
}

.field-notification-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.field-notification-button.has-notifications {
  border-color: rgba(241, 90, 36, 0.7);
  color: var(--accent);
}

.field-notification-button span {
  position: absolute;
  top: -7px;
  right: -7px;
  display: none;
  min-width: 19px;
  height: 19px;
  place-items: center;
  border: 2px solid var(--paper);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 900;
}

.field-notification-button span:not(:empty) {
  display: grid;
}

.field-notification-panel {
  position: fixed;
  top: max(82px, calc(env(safe-area-inset-top) + 64px));
  left: 50%;
  z-index: 18;
  width: min(432px, calc(100% - 28px));
  max-height: min(520px, calc(100vh - 112px));
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 18px 48px rgba(11, 67, 111, 0.26);
}

.field-notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.field-notification-header strong {
  color: var(--ink);
}

.field-notification-close {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
}

.field-notification-list {
  display: grid;
  max-height: min(450px, calc(100vh - 170px));
  overflow-y: auto;
}

.field-notification-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 13px 14px;
  text-align: left;
}

.field-notification-item.unread {
  border-left: 4px solid var(--accent);
  background: rgba(241, 90, 36, 0.08);
  padding-left: 10px;
}

.field-notification-item strong { color: var(--accent); }
.field-notification-item span { font-weight: 800; }
.field-notification-item small { color: var(--muted); font-weight: 700; }
.field-notification-item .field-notification-time {
  color: var(--ink);
  font-size: 0.75rem;
}
.field-notification-empty { color: var(--muted); padding: 18px 14px; }

.field-notification-target {
  animation: field-notification-pulse 2.2s ease-out;
}

@keyframes field-notification-pulse {
  0%, 35% { box-shadow: 0 0 0 3px rgba(241, 90, 36, 0.58), var(--shadow); }
  100% { box-shadow: var(--shadow); }
}

@media (max-width: 430px) {
  .topbar { align-items: flex-start; gap: 10px; }
  .app-brand { grid-template-columns: minmax(104px, 132px); }
  .topbar-actions { gap: 6px; }
  .sync-control { min-width: 118px; }
  .sync-copy small { max-width: 82px; }
  .issue-section > .section-title { align-items: stretch; flex-direction: column; }
  .issue-actions { width: 100%; flex: none; }
  .issue-actions .issue-sort { min-width: 0; flex: 1; }
}

.app-brand {
  display: grid;
  grid-template-columns: minmax(128px, 172px);
  align-items: center;
  gap: 12px;
}

.brand-home-link {
  display: block;
  color: inherit;
  line-height: 0;
  text-decoration: none;
}

.app-logo {
  width: 100%;
  height: 58px;
  border: 0;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
  object-fit: contain;
  object-position: left center;
}

body[data-theme="dark"] .app-logo {
  border: 0;
  background: #ffffff;
}

.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: var(--panel);
  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) repeat(4, 44px);
  gap: 8px;
  align-items: center;
}

.report-option-row > button:not(.report-open-button) {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 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;
  right: 0;
  left: 0;
  bottom: 0;
  z-index: 11;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  width: min(100%, 460px);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 -6px 20px rgba(16, 24, 32, 0.12);
  padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
  transform: translateY(0);
  transition: transform 180ms ease;
  will-change: transform;
}

.bottom-nav.is-hidden {
  transform: translateY(calc(100% + env(safe-area-inset-bottom) + 8px));
}

body[data-theme="dark"] .bottom-nav {
  border-top-color: var(--line);
  background: var(--panel);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.34);
}

.bottom-tab {
  display: grid;
  grid-template-rows: 22px 12px;
  gap: 2px;
  min-height: 48px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  min-width: 0;
  padding: 4px 2px;
}

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

.bottom-tab span {
  display: block;
  width: 100%;
  overflow: hidden;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-tab.active {
  border: 1px solid rgba(21, 90, 144, 0.16);
  background: var(--secondary);
  color: var(--accent-strong);
}

body[data-theme="dark"] .bottom-tab.active {
  border: 1px solid #125ea8;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"] .bottom-tab:not(.active) {
  border: 1px solid rgba(18, 94, 168, 0.3);
  background: rgba(14, 25, 36, 0.7);
  color: #c9d9e7;
}

.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(248, 251, 254, 0.92), rgba(237, 244, 250, 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: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

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

.password-visibility-field {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.lock-panel > .password-visibility-field {
  margin-top: 14px;
}

.lock-panel .password-visibility-field > input {
  margin-top: 0;
}

.password-visibility-field > input {
  padding-right: 50px !important;
}

.password-visibility-button {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  width: 36px;
  height: 36px;
  min-height: 36px;
  place-items: center;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.password-visibility-button:hover,
.password-visibility-button:focus-visible {
  background: var(--secondary);
  color: var(--accent-strong);
}

.password-visibility-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

#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;
}

.auth-link-button {
  border: 0;
  background: transparent;
  color: #0b65c2;
  font: inherit;
  font-weight: 700;
  padding: 8px;
  cursor: pointer;
}

body[data-theme="dark"] .auth-link-button {
  color: #1f67ad;
}

.panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  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: var(--panel);
  box-shadow: var(--shadow-sm);
}

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

.form-panel.is-editing {
  border-color: #ee6a2f;
  box-shadow: 0 0 0 2px rgba(238, 106, 47, 0.2), var(--shadow);
}

body[data-theme="dark"] .form-panel.is-editing {
  border-color: #ee6a2f;
  box-shadow: 0 0 0 2px rgba(238, 106, 47, 0.34), 0 18px 44px rgba(0, 0, 0, 0.52);
}

.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;
}

body[data-theme="dark"] .card-action-button,
body[data-theme="dark"] .mini-button,
body[data-theme="dark"] .photo-button,
body[data-theme="dark"] .photo-button.secondary,
body[data-theme="dark"] .pdf-button,
body[data-theme="dark"] .action-icon,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .status-button.secondary,
body[data-theme="dark"] .status-button.undo {
  border: 1px solid #125ea8;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
}

body[data-theme="dark"] .mini-button.danger,
body[data-theme="dark"] .remove-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.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;
}

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

#downloadHomesitesButton,
#saveContactsButton {
  grid-template-rows: 19px minmax(22px, auto);
  align-content: center;
  justify-items: center;
  flex-basis: 68px;
  width: 68px;
  padding-inline: 4px;
}

#downloadHomesitesButton span,
#saveContactsButton span {
  display: flex;
  width: 100%;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  text-align: center;
}

.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: rgba(5, 9, 14, 0.82);
  color: var(--ink);
}

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(21, 90, 144, 0.14);
}

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

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.inline-site-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.inline-site-form label,
.site-custom-field-row {
  display: grid;
  gap: 6px;
}

.site-custom-fields {
  display: grid;
  gap: 8px;
}

.site-custom-field-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 76px;
  align-items: center;
}

.site-form-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.homesite-details {
  display: grid;
  gap: 10px;
}

.site-detail-fields,
.site-document-shortcuts,
.site-info-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.site-info-actions {
  margin-top: 14px;
}

.site-detail-fields > span,
.site-detail-link,
.site-document-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--secondary);
  color: var(--ink);
  padding: 8px 11px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  text-align: left;
  text-decoration: none;
}

.site-detail-link,
.site-document-button {
  cursor: pointer;
  color: var(--accent-strong);
}

.site-info-actions .site-document-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.site-document-button.blueprint {
  border-color: rgba(21, 90, 144, 0.46);
  background: #125ea8;
  color: #ffffff;
}

.site-document-button.quick-access {
  border-color: rgba(19, 121, 92, 0.52);
  background: #13795c;
  color: #ffffff;
}

body.modal-open {
  overflow: hidden;
}

.document-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 13, 0.78);
  padding: 18px;
}

.document-modal-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  width: min(900px, 100%);
  max-height: min(820px, calc(100vh - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.document-modal-header,
.document-toolbar,
.document-form-actions,
.document-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.document-modal-header {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.document-modal-header h2 {
  margin: 3px 0 0;
  font-size: 1.18rem;
}

.document-icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--secondary);
  color: var(--ink);
  font-size: 1.55rem;
}

.document-toolbar {
  padding: 12px 18px;
}

.document-toolbar input {
  min-width: 0;
}

.document-toolbar .mini-button {
  min-width: 130px;
}

.document-upload-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow-y: auto;
  border-block: 1px solid var(--line);
  background: rgba(21, 90, 144, 0.04);
  padding: 14px 18px;
}

.document-upload-form label {
  display: grid;
  gap: 6px;
}

.document-upload-form .document-checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 9px 12px;
}

.document-checkbox-field input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin: 0;
}

.document-checkbox-field > span {
  display: grid;
  gap: 2px;
}

.document-checkbox-field small {
  color: var(--muted);
  font-weight: 600;
}

.document-file-field input[type="file"] {
  min-height: 56px;
  padding: 9px 11px;
  line-height: 36px;
}

.document-file-field input[type="file"]::file-selector-button {
  min-height: 36px;
  margin: 0 10px 0 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--secondary);
  color: var(--accent-strong);
  font-weight: 800;
  padding: 0 14px;
  cursor: pointer;
}

.document-upload-form .wide {
  grid-column: 1 / -1;
}

.document-form-actions {
  justify-content: flex-end;
}

.mini-button.primary {
  background: var(--accent);
  color: #ffffff;
}

.document-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  padding: 0 18px 8px;
}

.document-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 0 18px 18px;
}

.document-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 13px;
}

.document-card-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.document-card-main span,
.document-card-main small,
.document-card-main p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.document-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

@media (max-width: 640px) {
  .document-modal {
    align-items: end;
    padding: 0;
  }

  .document-modal-panel {
    width: 100%;
    max-height: 94vh;
    border-radius: 8px 8px 0 0;
  }

  .document-upload-form,
  .document-card {
    grid-template-columns: 1fr;
  }

  .document-card-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.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;
}

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

.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"] .info-grid div {
  background: var(--secondary);
}

body[data-theme="dark"] .info-grid div {
  border: 1px solid rgba(18, 94, 168, 0.4);
  background: rgba(14, 25, 36, 0.92);
}

body[data-theme="dark"] .menu-item {
  border: 1px solid #125ea8;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.3);
}

body[data-theme="dark"] .menu-item:hover {
  border-color: #0b4c89;
  background: #0b4c89;
  color: #ffffff;
}

body[data-theme="dark"] .menu-item.active {
  background: #125ea8;
  color: #ffffff;
}

body[data-theme="dark"] .menu-item.danger {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
}

.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-photo-button {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  aspect-ratio: 1;
  background: var(--secondary);
}

.preview-photo,
.issue-photo-button {
  position: relative;
}

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

.issue-photo-button {
  width: 100%;
  min-width: 0;
  cursor: zoom-in;
  padding: 0;
}

.issue-photo-entry,
.preview-photo-entry {
  min-width: 0;
}

.issue-photo-caption {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 5px 2px 0;
  text-align: center;
}

body.photo-viewer-open {
  overflow: hidden;
}

.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  background: rgba(2, 7, 11, 0.94);
  padding: 58px 18px 24px;
}

.photo-lightbox img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 90px);
  object-fit: contain;
  touch-action: pinch-zoom;
}

.photo-lightbox-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(5, 18, 28, 0.88);
  color: #ffffff;
  padding: 0;
}

.photo-lightbox-close svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.photo-lightbox-label {
  position: fixed;
  top: max(17px, calc(env(safe-area-inset-top) + 5px));
  left: 16px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.preview-photo span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(63, 174, 232, 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;
}

body:not([data-theme="dark"]) .primary-button,
body:not([data-theme="dark"]) .email-button,
body:not([data-theme="dark"]) .photo-button,
body:not([data-theme="dark"]) .card-action-button,
body:not([data-theme="dark"]) .mini-button,
body:not([data-theme="dark"]) .secondary-action,
body:not([data-theme="dark"]) .bottom-tab.active,
body:not([data-theme="dark"]) .menu-item.active,
body:not([data-theme="dark"]) .status-button.secondary,
body:not([data-theme="dark"]) .status-button.undo,
body:not([data-theme="dark"]) .status-button:not(.undo):not(.secondary),
body:not([data-theme="dark"]) .home-group-header,
body:not([data-theme="dark"]) .summary-band div {
  border: 1px solid rgba(21, 90, 144, 0.24);
  background: #125ea8;
  color: #ffffff;
}

body[data-theme="dark"] .primary-button,
body[data-theme="dark"] .email-button,
body[data-theme="dark"] .photo-button,
body[data-theme="dark"] .card-action-button,
body[data-theme="dark"] .mini-button,
body[data-theme="dark"] .pdf-button,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .status-button.secondary,
body[data-theme="dark"] .status-button.undo,
body[data-theme="dark"] .status-button:not(.undo):not(.secondary),
body[data-theme="dark"] .home-group-header,
body[data-theme="dark"] .summary-band div {
  border: 1px solid #125ea8;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 9px 20px rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"] .mini-button.danger,
body[data-theme="dark"] .remove-button {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

body[data-theme="dark"] .summary-band small,
body[data-theme="dark"] .home-group-header span {
  color: rgba(4, 16, 26, 0.74);
}

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

.primary-button,
.email-button,
.pdf-button,
.photo-button,
.status-button:not(.undo):not(.secondary),
.card-action-button,
.mini-button,
.secondary-action,
.bottom-tab.active,
.menu-item.active,
.home-group-header,
.summary-band div {
  color: #ffffff;
}

.primary-button svg,
.email-button svg,
.pdf-button svg,
.photo-button svg,
.status-button:not(.undo):not(.secondary) svg,
.card-action-button svg,
.mini-button svg,
.secondary-action svg,
.bottom-tab.active svg,
.menu-item.active svg {
  color: #ffffff;
  stroke: currentColor;
}

body:not([data-theme="dark"]) .bottom-tab:not(.active) svg,
body:not([data-theme="dark"]) .menu-item:not(.active) svg,
body:not([data-theme="dark"]) .action-icon:not(.email-button):not(.pdf-button) svg {
  color: #0b436f;
  stroke: currentColor;
  stroke-width: 2.4;
}

.action-icon.email-button,
.action-icon.email-button span,
.action-icon.email-button svg,
.action-icon.pdf-button,
.action-icon.pdf-button span,
.action-icon.pdf-button svg {
  color: #ffffff;
  stroke: currentColor;
}

.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);
}

body[data-theme="dark"] .text-button {
  border: 1px solid #125ea8;
  border-radius: 8px;
  background: #125ea8;
  color: #ffffff;
  padding: 7px 10px;
}

body[data-theme="dark"] .text-button.danger {
  border-color: rgba(255, 132, 111, 0.45);
  background: rgba(74, 23, 18, 0.72);
  color: #ffb0a1;
}

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

.clear-home-button {
  display: inline-grid;
  flex: 0 0 54px;
  width: 54px;
  min-width: 54px;
  place-items: center;
  font-size: 0.78rem;
  padding-inline: 4px;
  text-align: center;
  white-space: nowrap;
}

.settings-actions {
  display: grid;
  gap: 8px;
}

.settings-account-status {
  min-height: 20px;
  margin: 8px 2px 0;
  color: #13795c;
  font-size: 0.84rem;
  font-weight: 750;
}

.account-password-panel {
  grid-template-rows: auto minmax(0, 1fr);
  width: min(560px, 100%);
}

.account-password-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 18px;
}

.account-password-form label {
  display: grid;
  gap: 6px;
}

.account-password-form .wide {
  grid-column: 1 / -1;
}

.account-password-form .helper,
.account-password-form .pin-error {
  margin: 0;
}

@media (max-width: 560px) {
  .account-password-form {
    grid-template-columns: 1fr;
  }

  .account-password-form .wide {
    grid-column: 1;
  }
}

.settings-list {
  display: grid;
  gap: 5px;
}

.settings-section-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.settings-section-title.settings-collapsible-title {
  min-height: 40px;
}

.settings-section-title .mini-button {
  min-height: 38px;
}

.settings-collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0 4px;
  text-align: left;
}

.settings-collapse-toggle:hover,
.settings-collapse-toggle:focus-visible {
  background: rgba(18, 94, 168, 0.08);
}

.settings-collapse-heading {
  overflow: hidden;
  font-family: inherit;
  font-size: 1.08rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-collapse-chevron {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}

.settings-panel.is-collapsed .settings-collapse-chevron {
  transform: rotate(-45deg);
}

.settings-panel.is-collapsed .settings-section-title {
  margin-bottom: 0;
}

.settings-collapsible-content[hidden] {
  display: none;
}

.settings-select {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  padding: 3px 5px 3px 9px;
}

body[data-theme="dark"] .settings-row {
  background: rgba(5, 9, 14, 0.78);
}

.settings-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
}

.settings-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.settings-icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  min-height: 30px;
  place-items: center;
  border: 1px solid #1f67ad;
  border-radius: 8px;
  background: #1f67ad;
  color: #ffffff;
  padding: 0;
}

.settings-icon-button:hover {
  border-color: #175995;
  background: #175995;
  color: #ffffff;
}

.settings-icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.settings-icon-button.danger {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
}

.settings-icon-button.danger:hover {
  border-color: #d95620;
  background: #d95620;
  color: #ffffff;
}

.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: var(--panel);
  padding: 10px;
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .issue-section > .section-title {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.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(20, 50, 79, 0.1);
}

.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: var(--panel);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(20, 50, 79, 0.1);
}

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

.issue-details {
  display: grid;
  gap: 5px;
}

.issue-detail-row {
  display: grid;
  grid-template-columns: minmax(108px, 0.42fr) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 0.9rem;
  line-height: 1.32;
}

.issue-detail-label {
  color: var(--accent-strong);
  font-weight: 800;
}

.issue-detail-value {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.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 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: var(--danger);
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
  padding: 0;
  text-align: center;
}

.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;
}

/* Main app brand treatment. Keep this final so shared controls stay consistent. */
body:not([data-theme="dark"]) #addIssueButton,
body:not([data-theme="dark"]) #addRoomButton,
body:not([data-theme="dark"]) #addTradeButton {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(238, 106, 47, 0.24);
}

body[data-theme="dark"] #addIssueButton,
body[data-theme="dark"] #addRoomButton,
body[data-theme="dark"] #addTradeButton,
body[data-theme="dark"] .crew-report-button {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(238, 106, 47, 0.28);
}

body[data-theme="dark"] #addIssueButton:hover,
body[data-theme="dark"] #addRoomButton:hover,
body[data-theme="dark"] #addTradeButton:hover,
body[data-theme="dark"] .crew-report-button:hover {
  border-color: #d95720;
  background: #d95720;
  color: #ffffff;
}

body:not([data-theme="dark"]) .summary-band > div:first-child {
  border-color: #125ea8;
  background: #125ea8;
  color: #ffffff;
}

body:not([data-theme="dark"]) .summary-band > div:nth-child(2) {
  border-color: #125ea8;
  background: #125ea8;
  color: #ffffff;
}

body:not([data-theme="dark"]) .issue-card .remove-button {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
}

body[data-theme="dark"] .issue-card .remove-button {
  border-color: #ee6a2f;
  background: #ee6a2f;
  color: #ffffff;
}

body:not([data-theme="dark"]) .sync-control {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  min-width: 142px;
  border: 1px solid rgba(18, 94, 168, 0.22);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(20, 50, 79, 0.12);
  padding: 5px 9px 5px 5px;
}

body:not([data-theme="dark"]) .sync-icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(18, 94, 168, 0.24);
}

body:not([data-theme="dark"]) .sync-icon-button:hover {
  background: #0b4c89;
}

body:not([data-theme="dark"]) .sync-copy strong {
  color: #125ea8;
  font-size: 0.72rem;
  font-weight: 900;
}

body:not([data-theme="dark"]) .sync-copy small {
  color: #536575;
  font-weight: 700;
}

body:not([data-theme="dark"]) .sync-control[data-sync-state="saved"] .sync-icon-button,
body:not([data-theme="dark"]) .sync-control[data-online="false"] .sync-icon-button {
  background: #ee6a2f;
  color: #ffffff;
}

body:not([data-theme="dark"]) .sync-control[data-sync-state="saved"] .sync-copy strong,
body:not([data-theme="dark"]) .sync-control[data-online="false"] .sync-copy strong {
  color: #c74c18;
}

body:not([data-theme="dark"]) .sync-control[data-sync-state="failed"] .sync-icon-button {
  background: #d9363e;
  color: #ffffff;
}

body:not([data-theme="dark"]) .sync-control[data-sync-state="failed"] .sync-copy strong {
  color: #c52631;
}

body:not([data-theme="dark"]) .sync-control[data-sync-state="synced"] .sync-copy strong {
  color: #125ea8;
}

body:not([data-theme="dark"]) .sync-count {
  top: -7px;
  left: 27px;
  border-color: #ffffff;
  background: #ee6a2f;
  color: #ffffff;
}

body[data-theme="dark"] .sync-control {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 7px;
  min-width: 142px;
  border: 1px solid rgba(18, 94, 168, 0.58);
  border-radius: 10px;
  background: #0d1823;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 5px 9px 5px 5px;
}

body[data-theme="dark"] .sync-icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: #125ea8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(18, 94, 168, 0.38);
}

body[data-theme="dark"] .sync-icon-button:hover {
  background: #0b4c89;
}

body[data-theme="dark"] .sync-copy strong {
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 900;
}

body[data-theme="dark"] .sync-copy small {
  color: #b8c1ca;
  font-weight: 700;
}

body[data-theme="dark"] .sync-control[data-sync-state="saved"] .sync-icon-button,
body[data-theme="dark"] .sync-control[data-online="false"] .sync-icon-button {
  background: #ee6a2f;
  color: #ffffff;
}

body[data-theme="dark"] .sync-control[data-sync-state="saved"] .sync-copy strong,
body[data-theme="dark"] .sync-control[data-online="false"] .sync-copy strong {
  color: #ff9b70;
}

body[data-theme="dark"] .sync-control[data-sync-state="failed"] .sync-icon-button {
  background: #d9363e;
  color: #ffffff;
}

body[data-theme="dark"] .sync-control[data-sync-state="failed"] .sync-copy strong {
  color: #ff7b82;
}

body[data-theme="dark"] .sync-control[data-sync-state="synced"] .sync-copy strong {
  color: #ffffff;
}

body[data-theme="dark"] .sync-count {
  top: -7px;
  left: 27px;
  border-color: #0d1823;
  background: #ee6a2f;
  color: #ffffff;
}

.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;
  color: #ffffff;
}

.pdf-button {
  min-height: 42px;
  border: 1px solid rgba(21, 90, 144, 0.24);
  background: #125ea8;
  color: #ffffff;
  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;
  flex: 0 0 54px;
  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: flex;
  width: 100%;
  max-width: 100%;
  min-height: 18px;
  align-items: center;
  justify-content: center;
  color: inherit;
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 0.95;
  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;
  }

  .field-with-action,
  .site-custom-field-row,
  .site-form-actions {
    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 .report-option-row {
  grid-template-columns: minmax(180px, 1fr) 42px 72px 42px;
  align-items: center;
}

.all-report-links .menu-item,
.all-report-links .action-icon {
  border: 1px solid rgba(21, 90, 144, 0.24);
  background: #125ea8;
  color: #ffffff;
}

.all-report-links .report-open-button {
  min-height: 44px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.all-report-links .report-option-row > .report-text-action {
  width: 100%;
  height: 38px;
  min-width: 0;
  padding: 4px 6px;
  white-space: normal;
  font-size: 0.68rem;
  line-height: 1.05;
}

.all-report-links .report-option-row > .report-icon-action {
  width: 42px;
  height: 42px;
  min-width: 0;
  padding: 9px;
}

.all-report-links .report-text-action span {
  display: block;
}

.all-report-links .action-icon svg {
  color: #ffffff;
  stroke: currentColor;
}

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

@media (max-width: 760px) {
  .all-report-links .report-option-row {
    grid-template-columns: minmax(0, 1fr) 40px 64px 40px;
    gap: 6px;
  }

  .all-report-links .report-open-button {
    grid-column: auto;
    min-width: 0;
    min-height: 46px;
    padding: 4px 5px;
    font-size: 0.64rem;
    line-height: 1.05;
  }

  .all-report-links .report-option-row > .report-text-action {
    height: 42px;
    padding: 3px;
    font-size: 0.62rem;
  }

  .all-report-links .report-option-row > .report-icon-action {
    width: 40px;
    height: 42px;
    padding: 9px;
  }
}

.contact-card,
.info-card {
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  box-shadow: 0 8px 20px rgba(20, 50, 79, 0.1);
}

.info-card {
  position: relative;
  margin-bottom: 16px;
  border: 1px solid rgba(11, 67, 111, 0.22);
  border-top: 6px solid var(--accent);
  border-left: 1px solid rgba(11, 67, 111, 0.22);
  background: var(--panel);
  box-shadow: 0 14px 30px rgba(20, 50, 79, 0.14);
  padding: 16px;
}

body[data-theme="dark"] .info-card {
  border-color: var(--line);
  border-top-color: var(--accent);
  background: var(--panel);
}

.info-card + .info-card {
  margin-top: 18px;
}

.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,
.site-info-address-link {
  display: block;
}

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

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

.site-info-address-link {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

@media (min-width: 430px) {
  .app-shell {
    padding-inline: 22px;
  }
}
@media (max-width: 768px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Shared visual system: presentation only; workflows and layout hooks stay unchanged. */
h1,
h2,
h3,
h4,
p {
  letter-spacing: 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
}

button,
a,
input,
select,
textarea {
  letter-spacing: 0;
}

input,
select,
textarea {
  border-color: var(--line);
  background: var(--input-bg);
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.9;
}

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sync-control {
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 5px 8px 5px 5px;
  box-shadow: var(--shadow-sm);
}

.sync-icon-button {
  border: 0;
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: none;
}

.sync-status,
.sync-last-time,
.count-pill,
.summary-band span {
  font-variant-numeric: tabular-nums;
}

.panel,
.menu-panel,
.issue-section > .section-title,
.issue-card,
.contact-card,
.info-card,
.empty-state,
.document-modal-panel {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.issue-card,
.contact-card,
.info-card {
  box-shadow: 0 2px 8px rgba(16, 24, 32, 0.08);
}

.document-modal {
  background: rgba(3, 8, 13, 0.72);
}

.document-modal-panel {
  box-shadow: var(--shadow-md);
}

.primary-button,
.email-button,
.pdf-button,
.photo-button,
.status-button,
.card-action-button,
.mini-button,
.secondary-action,
.menu-item,
.bottom-tab,
.document-icon-button,
.icon-button {
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

:where(
    .primary-button,
    .email-button,
    .pdf-button,
    .photo-button,
    .status-button,
    .card-action-button,
    .mini-button,
    .secondary-action,
    .menu-item,
    .document-icon-button,
    .icon-button
  ):hover {
  box-shadow: var(--shadow-md);
}

:where(
    .primary-button,
    .email-button,
    .pdf-button,
    .photo-button,
    .status-button,
    .card-action-button,
    .mini-button,
    .secondary-action,
    .menu-item,
    .document-icon-button,
    .icon-button
  ):active {
  transform: translateY(1px);
}

.bottom-tab.active {
  border-color: var(--brand-orange);
  background: var(--brand-orange);
  color: #ffffff;
}

body:not([data-theme="dark"]) .bottom-tab:not(.active) {
  color: var(--accent-strong);
}

body[data-theme="dark"] .bottom-tab:not(.active) {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

body[data-theme="dark"] .bottom-tab.active {
  border-color: var(--brand-orange);
  background: var(--brand-orange);
  color: #ffffff;
  box-shadow: none;
}

body[data-theme="dark"] .summary-band small,
body[data-theme="dark"] .home-group-header span {
  color: rgba(255, 255, 255, 0.82);
}

body[data-theme="dark"] .primary-button,
body[data-theme="dark"] .email-button,
body[data-theme="dark"] .photo-button,
body[data-theme="dark"] .card-action-button,
body[data-theme="dark"] .mini-button,
body[data-theme="dark"] .pdf-button,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .status-button.secondary,
body[data-theme="dark"] .status-button.undo,
body[data-theme="dark"] .status-button:not(.undo):not(.secondary),
body[data-theme="dark"] .home-group-header,
body[data-theme="dark"] .summary-band div {
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
