:root {
  color-scheme: light;
  --green-900: #064e3b;
  --green-800: #066044;
  --green-700: #087f5b;
  --green-100: #dff7ec;
  --green-50: #f0fbf6;
  --ink: #172033;
  --muted: #64748b;
  --line: #d8e2df;
  --surface: #ffffff;
  --background: #f3f7f5;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 14px 36px rgba(15, 55, 43, 0.09);
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 92, 211, 0.32);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.offline-banner {
  padding: 9px 16px;
  background: #7a2e0e;
  color: #fff;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 750;
}

.account-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(6, 78, 59, 0.18);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.account-brand-group,
.account-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-brand {
  display: inline-flex;
  align-items: center;
}

.account-brand img {
  border-radius: 12px;
}

.account-current {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(8, 127, 91, 0.2);
  border-radius: 12px;
  background: var(--green-100);
  color: var(--green-900);
  font-weight: 850;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.button.primary {
  background: var(--green-700);
  color: #fff;
}

.button.secondary {
  border-color: rgba(8, 127, 91, 0.28);
  background: var(--green-50);
  color: var(--green-900);
}

.button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.button.compact {
  min-height: 40px;
  padding: 8px 12px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.account-shell {
  width: 100%;
  margin: 0;
  padding: 0 0 40px;
}

.state-card,
.account-card,
.account-hero {
  border: 0;
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.state-card {
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
}

.state-card h1,
.state-card p {
  margin: 0 0 12px;
}

.error-card {
  background: var(--danger-bg);
}

.spinner {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 4px solid var(--green-100);
  border-top-color: var(--green-700);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.account-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 0;
  padding: 26px max(28px, env(safe-area-inset-right)) 26px max(28px, env(safe-area-inset-left));
  background: linear-gradient(135deg, #ffffff, var(--green-50));
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-700);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.account-hero h1,
.section-heading h2 {
  margin: 0;
  color: var(--green-900);
}

.account-hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
}

.account-greeting {
  margin: 8px 0 0;
  color: var(--muted);
}

.account-status,
.number-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 850;
}

.account-status {
  padding: 8px 13px;
  background: var(--green-100);
  color: var(--green-900);
  white-space: nowrap;
}

.account-card {
  margin-top: 0;
  padding: 24px max(28px, env(safe-area-inset-right)) 24px max(28px, env(safe-area-inset-left));
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.number-badge {
  padding: 7px 11px;
  background: #edf2f7;
  color: #334155;
  font-size: 0.82rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.profile-field {
  min-width: 0;
  padding: 14px;
  border: 1px solid #e4ebe8;
  border-radius: 14px;
  background: #fbfdfc;
}

.profile-field-wide {
  grid-column: span 2;
}

.profile-field dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.profile-editor-card .section-heading {
  margin-bottom: 10px;
}

.profile-editor-help {
  max-width: 1050px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-editor-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.profile-editor-form legend,
.profile-editor-form h3 {
  margin: 0 0 12px;
  padding: 0;
  color: var(--green-900);
  font-size: 1rem;
  font-weight: 850;
}

.profile-editor-form h3 {
  margin-top: 22px;
}

.profile-edit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.profile-edit-field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.profile-edit-field label {
  color: var(--green-900);
  font-size: 0.86rem;
  font-weight: 800;
}

.profile-edit-field input,
.profile-edit-field select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid #b7cbbf;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.profile-edit-field input:focus-visible,
.profile-edit-field select:focus-visible {
  border-color: var(--green-700);
  outline: 3px solid rgba(8, 127, 91, 0.15);
}

.profile-editor-form fieldset:disabled {
  opacity: 0.68;
}

.profile-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-editor-form .inline-status {
  margin-bottom: 0;
}

.delivery-heading {
  margin-bottom: 8px;
}

.delivery-intro {
  max-width: 920px;
  margin: 0 0 18px;
  color: var(--muted);
}

.delivery-editor {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(480px, 1.25fr);
  gap: 18px;
  align-items: stretch;
}

.delivery-controls {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: var(--green-50);
}

.delivery-search-form {
  display: grid;
  gap: 8px;
}

.delivery-search-form label {
  color: var(--green-900);
  font-weight: 850;
}

.delivery-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.delivery-search-field {
  position: relative;
  min-width: 0;
}

.delivery-search-row input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #b7cbbf;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.delivery-search-row input:focus {
  border-color: var(--green-700);
  outline: 3px solid rgba(8, 127, 91, 0.15);
}

.delivery-search-row input:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.delivery-suggestions {
  position: absolute;
  z-index: 1100;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  display: grid;
  max-height: min(310px, 48vh);
  overflow-y: auto;
  border: 1px solid #b7cbbf;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(15, 55, 43, 0.16);
}

.delivery-suggestions[hidden] {
  display: none;
}

.delivery-suggestion {
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid #e4ebe8;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  line-height: 1.3;
  text-align: left;
}

.delivery-suggestion:first-child {
  border-radius: 11px 11px 0 0;
}

.delivery-suggestion:last-child {
  border-bottom: 0;
  border-radius: 0 0 11px 11px;
}

.delivery-suggestion:hover,
.delivery-suggestion.active,
.delivery-suggestion[aria-selected="true"] {
  background: var(--green-100);
  color: var(--green-900);
}

.delivery-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.selected-delivery {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-left: 5px solid var(--green-700);
  background: #fff;
}

.selected-delivery span,
.selected-delivery small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.selected-delivery strong {
  overflow-wrap: anywhere;
  color: var(--green-900);
}

.delivery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.delivery-actions .danger {
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--danger);
}

.delivery-actions .danger:hover:not(:disabled) {
  background: var(--danger-bg);
}

.delivery-status {
  margin: 0;
}

.delivery-map-shell {
  position: relative;
  min-width: 0;
  min-height: clamp(340px, 38vw, 520px);
  overflow: hidden;
  background: #eaf2ee;
}

.delivery-map,
.delivery-map-placeholder {
  width: 100%;
  min-height: clamp(340px, 38vw, 520px);
}

.delivery-map-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  color: var(--green-900);
  text-align: center;
}

.delivery-map-placeholder span,
.delivery-map-placeholder small {
  max-width: 560px;
  color: var(--muted);
}

.delivery-map-placeholder small {
  font-size: 0.76rem;
}

.pety-delivery-marker {
  border: 0;
  background: transparent;
}

.pety-delivery-marker span {
  position: relative;
  display: block;
  width: 30px;
  height: 30px;
  margin: 3px 0 0 4px;
  border: 4px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--green-700);
  box-shadow: 0 3px 9px rgba(6, 78, 59, 0.38);
  transform: rotate(-45deg);
}

.pety-delivery-marker span::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transform: translate(-50%, -50%);
}

.delivery-map .leaflet-control-attribution {
  max-width: calc(100% - 12px);
  padding: 2px 5px;
  font-size: 10px;
  white-space: normal;
}

.history-heading {
  align-items: flex-end;
}

.history-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.history-columns h3 {
  margin: 0 0 10px;
  color: var(--green-900);
  font-size: 1rem;
}

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

.history-item,
.empty-state {
  padding: 14px;
  border: 1px solid #e4ebe8;
  border-radius: 14px;
  background: #fbfdfc;
}

.history-item-header,
.history-item-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.history-item h4 {
  margin: 0;
  font-size: 0.98rem;
}

.history-date,
.history-summary,
.empty-state span {
  color: var(--muted);
  font-size: 0.86rem;
}

.history-date,
.history-summary {
  margin: 4px 0 0;
}

.history-summary {
  margin-block: 10px;
}

.status-pill {
  max-width: 48%;
  padding: 5px 8px;
  background: #fff3d6;
  color: #8a4b09;
  font-size: 0.72rem;
  line-height: 1.15;
  text-align: center;
}

.status-pill.completed {
  background: var(--green-100);
  color: var(--green-900);
}

.status-pill.cancelled {
  background: var(--danger-bg);
  color: var(--danger);
}

.inline-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #edf2f7;
  color: #334155;
  font-weight: 700;
}

.inline-status.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 15px;
  border-radius: 12px;
  background: var(--green-900);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 750;
}

@media (max-width: 800px) {
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-columns {
    grid-template-columns: 1fr;
  }

  .delivery-editor {
    grid-template-columns: 1fr;
  }

  .delivery-map-shell,
  .delivery-map,
  .delivery-map-placeholder {
    min-height: clamp(300px, 72vw, 400px);
  }
}

@media (max-width: 640px) {
  .account-header {
    min-height: 64px;
    flex-wrap: wrap;
    gap: 8px;
    padding-block: 8px;
  }

  .account-header-actions {
    margin-left: auto;
  }

  .account-header-actions .button {
    min-height: 38px;
    padding: 7px 9px;
    font-size: 0.86rem;
  }

  .account-shell {
    padding-bottom: 32px;
  }

  .account-hero {
    align-items: flex-start;
    padding: 20px max(14px, env(safe-area-inset-right)) 20px max(14px, env(safe-area-inset-left));
  }

  .account-card {
    padding: 18px max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .profile-field-wide {
    grid-column: auto;
  }

  .history-heading {
    align-items: center;
  }

  .delivery-controls {
    padding: 14px;
  }
}

@media (max-width: 390px) {
  .account-current {
    min-height: 38px;
    padding-inline: 9px;
    font-size: 0.9rem;
  }

  .account-header-actions .secondary {
    font-size: 0;
  }

  .account-header-actions .secondary::after {
    content: "Catálogo";
    font-size: 0.86rem;
  }

  .account-hero {
    flex-direction: column;
  }

  .delivery-search-row {
    grid-template-columns: 1fr;
  }

  .delivery-search-row .button,
  .delivery-actions .button {
    width: 100%;
  }

  .delivery-map-shell,
  .delivery-map,
  .delivery-map-placeholder {
    min-height: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .spinner { animation: none; }
}
