:root {
  color-scheme: dark;
  --brand-blue: #024c80;
  --brand-aqua: #53c7d6;
  --brand-orange: #f7931d;
  --bg: #071923;
  --surface: #0d2838;
  --surface-strong: #12384c;
  --surface-hover: #164d61;
  --tab: #0f3f58;
  --tab-strong: #146173;
  --tab-pressed: #1b7180;
  --tab-border: #53c7d6;
  --control: #041018;
  --control-strong: #082131;
  --text: #f8fcfb;
  --muted: #bed7dc;
  --line: #29586b;
  --accent: var(--brand-aqua);
  --accent-strong: #a9f1f7;
  --accent-deep: var(--brand-blue);
  --warning: var(--brand-orange);
  --danger: #fb7185;
  --focus: var(--brand-orange);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #082338 0%, var(--bg) 320px);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 40px);
  background: rgba(2, 29, 45, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.app-header h1 {
  margin: 0;
  letter-spacing: 0;
}

.app-header h1 {
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  line-height: 1.15;
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(248, 252, 251, 0.86);
  background: var(--brand-aqua);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.34);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-orange);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-tools,
.header-actions,
.account-panel,
.section-meta,
.field-row,
.generated-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-tools {
  justify-content: flex-end;
}

.account-panel {
  position: relative;
  justify-content: flex-end;
}

.account-menu {
  position: relative;
}

.profile-trigger {
  list-style: none;
  cursor: pointer;
}

.profile-trigger::-webkit-details-marker {
  display: none;
}

.profile-avatar {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(169, 241, 247, 0.56);
  background: var(--brand-orange);
  color: #201104;
  font-weight: 900;
}

.account-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 230px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.account-menu-email {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.muted {
  color: var(--muted);
  background: var(--control-strong);
}

.status-pill.offline {
  color: var(--warning);
  background: #35200a;
  border-color: #9d5d0d;
}

.app-main {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.visit-flow {
  display: grid;
  gap: 12px;
}

.cloud-panel {
  margin-bottom: 12px;
}

.home-main {
  width: min(860px, calc(100% - 24px));
}

.home-page,
.visit-page-toolbar {
  display: grid;
  gap: 12px;
}

.visit-page-toolbar {
  margin-bottom: 12px;
  justify-items: start;
}

.auth-main {
  width: min(620px, calc(100% - 24px));
}

.cloud-card,
.home-card,
.auth-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cloud-card-header,
.home-card-header,
.home-actions,
.cloud-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cloud-card h2,
.home-card h2,
.auth-card h2,
.cloud-visit-list-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.cloud-subtitle,
.cloud-message {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.cloud-message {
  padding: 10px 12px;
  margin: 0;
  background: var(--control-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  align-items: end;
  gap: 10px;
}

.auth-form.stacked {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.auth-page,
.button-row {
  display: grid;
  gap: 10px;
}

.button-row {
  grid-template-columns: repeat(auto-fit, minmax(150px, max-content));
  align-items: center;
}

.account-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.account-details div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-strong);
}

.account-details dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.account-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-weight: 700;
}

.sync-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.sync-details div,
.sync-conflict {
  min-width: 0;
  padding: 10px 12px;
  background: var(--control-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sync-details dt {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sync-details dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.sync-conflict {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-color: #7f303a;
}

.sync-conflict p {
  margin: 0;
}

.cloud-visit-section {
  display: grid;
  gap: 8px;
}

.cloud-visit-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-strong);
  color: var(--accent-strong);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-strong);
}

.cloud-visit-list {
  display: grid;
  gap: 8px;
}

.cloud-visit-row {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-strong);
  color: var(--text);
  text-align: left;
}

.cloud-visit-row:hover {
  background: var(--surface-strong);
}

.cloud-visit-row small {
  color: var(--muted);
}

.status-pill.synced-status {
  color: #bbf7d0;
  background: #0f2d20;
  border-color: #27845a;
}

.status-pill.pending-status {
  color: #fde68a;
  background: #352b0a;
  border-color: #a16207;
}

.status-pill.danger-status {
  color: var(--danger);
  background: #32191e;
  border-color: #7f303a;
}

.visit-section {
  overflow: clip;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-header {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--tab-border);
  background: linear-gradient(180deg, var(--tab-strong), var(--tab));
  box-shadow: inset 0 1px 0 rgba(169, 241, 247, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.42);
}

.section-toggle {
  min-width: 0;
  width: 100%;
  display: block;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.section-toggle:active,
.section-chevron-button:active,
.section-header:has(.section-toggle:active) {
  background: var(--tab-pressed);
}

.section-toggle:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.section-title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.section-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-chevron {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--control);
  border: 1px solid rgba(169, 241, 247, 0.42);
  color: var(--accent-strong);
  font-size: 1.1rem;
  font-weight: 800;
}

.section-chevron-button {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.section-body {
  display: grid;
  gap: 16px;
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 7px;
  padding-top: 16px;
}

.field label,
.field legend {
  color: var(--text);
  font-weight: 700;
}

.hint,
.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--control);
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #82a4ad;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

.address-autocomplete {
  position: relative;
}

.address-suggestion-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  display: grid;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.address-suggestion-list[hidden] {
  display: none;
}

.address-suggestion {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.address-suggestion:hover,
.address-suggestion.active {
  background: var(--tab-pressed);
  color: var(--accent-strong);
}

.checkbox-line,
.multiselect-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 34px;
  color: var(--text);
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.segmented-field {
  border: 0;
  margin: 0;
}

.section-presence {
  align-self: stretch;
  min-width: 244px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}

.section-presence legend {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.segmented-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 420px;
}

.segmented-option {
  min-height: 41px;
  display: grid;
  place-items: center;
  padding: 8px 11px;
  border: 1px solid rgba(83, 199, 214, 0.58);
  border-radius: 8px;
  background: var(--control-strong);
  color: var(--accent-strong);
  font-weight: 800;
}

.segmented-option.selected {
  color: #201104;
  background: var(--brand-orange);
  border-color: var(--brand-orange);
}

.multiselect-grid {
  display: grid;
  gap: 8px;
}

.photo-prompts {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  margin: 0;
  background: var(--surface-strong);
  border: 1px solid rgba(83, 199, 214, 0.34);
  border-radius: 8px;
  list-style-position: inside;
  color: var(--muted);
}

.photo-input {
  display: grid;
  gap: 10px;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 10px;
}

.photo-card {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-strong);
}

.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--control);
}

.attachment-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--control);
  border: 1px dashed var(--line);
  color: var(--accent-strong);
  font-weight: 900;
}

.photo-card figcaption {
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.attachment-meta,
.attachment-sync-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
}

.attachment-sync-summary {
  padding: 10px 12px;
  background: var(--control-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attachment-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}

.attachment-status.synced-status {
  color: #bbf7d0;
  background: #0f2d20;
  border-color: #27845a;
}

.attachment-status.pending-status {
  color: #fde68a;
  background: #352b0a;
  border-color: #a16207;
}

.attachment-status.danger-status,
.danger-text,
.attachment-error {
  color: var(--danger);
}

.attachment-status.danger-status {
  background: #32191e;
  border-color: #7f303a;
}

.attachment-error {
  margin: 0;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.attachment-link {
  justify-content: center;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  color: #201104;
  background: var(--brand-orange);
}

.primary-button:hover {
  background: #ffad3f;
}

.secondary-button {
  color: var(--accent-strong);
  background: var(--surface-strong);
  border-color: rgba(83, 199, 214, 0.58);
}

.danger-button,
.text-button.danger {
  color: var(--danger);
  background: #32191e;
  border-color: #7f303a;
}

.text-button {
  min-height: 34px;
  padding: 6px 9px;
  color: var(--accent-strong);
  background: transparent;
  border-color: var(--line);
}

.generated-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.generated-list li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-strong);
  line-height: 1.4;
}

.generated-list strong {
  display: block;
  margin-bottom: 2px;
}

.collapsed .section-body {
  display: none;
}

@media (max-width: 760px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-tools,
  .account-panel {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions > *,
  .account-panel > * {
    flex: 1 1 auto;
    justify-content: center;
  }

  .account-panel > .account-menu {
    flex: 0 0 auto;
  }

  .auth-form,
  .sync-details,
  .account-details,
  .button-row {
    grid-template-columns: 1fr;
  }

  .cloud-card-header,
  .home-card-header,
  .home-actions,
  .cloud-actions,
  .sync-conflict {
    align-items: stretch;
    flex-direction: column;
  }

  .home-actions > *,
  .cloud-actions > *,
  .sync-conflict > * {
    width: 100%;
  }

  .section-toggle {
    padding: 14px;
  }

  .section-header.has-header-fields {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 8px;
  }

  .section-presence {
    grid-column: 1 / -1;
    padding: 0 14px 14px;
  }

  .section-chevron-button {
    padding-right: 14px;
  }

  .section-presence .segmented-choice {
    flex: 1 1 auto;
  }

  .section-body {
    padding: 0 14px 16px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }
}