@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;650;700&family=Manrope:wght@500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #1b3049;
  --muted: #506176;
  --blue: #1d5ca8;
  --line: #d7e1ec;
  --surface: #f2f6fa;
  --white: #fff;
  font: 16px 'DM Sans', system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button, summary, select { cursor: pointer; }
:focus-visible { outline: 3px solid #5494d4; outline-offset: 3px; }
.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .7rem max(5vw, 1rem);
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.wordmark { display: flex; gap: .65rem; align-items: center; font: 800 1.08rem 'Manrope', sans-serif; }
.wordmark img { width: 42px; height: 42px; object-fit: contain; }
.top-actions { display: flex; gap: .8rem; align-items: center; }
.top-actions a { color: var(--blue); font-weight: 650; }
main { max-width: 1200px; margin: 0 auto; padding: clamp(1rem, 4vw, 3rem); }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: 'Manrope', system-ui, sans-serif; }
h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.15; letter-spacing: -.04em; }
.access {
  max-width: 460px;
  margin: clamp(1.5rem, 11vh, 7rem) auto 0;
  padding: clamp(1.25rem, 5vw, 2.35rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .8rem;
  box-shadow: 0 18px 48px #243e5812;
}
.access p { margin: .9rem 0 1.4rem; color: var(--muted); line-height: 1.55; }
.access form, .account-form { display: grid; gap: 1rem; }
.security-form { display: grid; gap: .8rem; }
#security-panel { margin-top: 1rem; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fit,minmax(10rem,1fr)); gap: .5rem; padding-left: 1.3rem; }
.operations-alerts { background: #fff3cc; border: 1px solid #ebd58d; color: #533a06; border-radius: .45rem; padding: .8rem 1rem; margin-bottom: 1rem; }
.activity-list { display: grid; gap: .6rem; margin: 0; padding-left: 1.35rem; overflow-wrap: anywhere; }
.activity-list small { color: var(--muted); }
.image-field, .image-picker { display: grid; gap: .55rem; min-width: 0; }
.image-picker { background: var(--surface); padding: .6rem; border-radius: .5rem; }
.image-picker input[type="file"] { max-width: 100%; padding: .4rem; }
.image-picker [role="status"] { font-size: .85rem; color: var(--muted); }
.image-picker [role="status"]:empty { display: none; }
.history-grid { display: grid; gap: 1rem; }
.history-grid section { background: white; padding: clamp(1rem, 3vw, 1.5rem); border: 1px solid var(--line); border-radius: .65rem; }
.history-grid h2 { margin-bottom: .8rem; }
.history-empty { color: var(--muted); }
.history-message { white-space: pre-wrap; margin: .35rem 0; }
.customer-security { margin-top: 1.5rem; max-width: 34rem; }
.history-action { margin-top: .35rem; }
#customer-library { margin-top: 1.5rem; }
#library-preferences { display: grid; gap: .65rem; }
.inventory-preview { padding-left: 1.3rem; display: grid; gap: .55rem; max-height: 20rem; overflow: auto; }
.inventory-preview p { margin: .15rem 0; }
.access button { justify-self: start; }
.account-form { max-width: 34rem; background: var(--white); border: 1px solid var(--line); border-radius: .65rem; padding: 1.25rem; }
.session-identity { color: var(--muted); font-size: .9rem; margin: -.8rem 0 1.25rem; }
.access-group { margin-bottom: 1.5rem; }
.access-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .65rem; margin-bottom: .65rem; }
.access-heading h2 { font-size: 1.25rem; }
.access-group .item h3 { font-size: 1rem; }
.access-permissions { border: 1px solid var(--line); border-radius: .45rem; padding: .75rem; display: grid; gap: .6rem; }
#account-status:empty { display: none; }
.workspace nav {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--white);
  width: fit-content;
  margin-bottom: 1.65rem;
}
.workspace nav button { border-color: transparent; }
.workspace nav [aria-current] { color: var(--blue); background: #e8f1fb; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-header p { margin-top: .45rem; color: var(--muted); }
label { display: grid; gap: .38rem; font-size: .9rem; font-weight: 650; }
input, textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid #bbcbdc;
  border-radius: .4rem;
  background: var(--white);
  padding: .65rem .75rem;
  font-size: 1rem;
  font-weight: 400;
}
input[type="color"] { min-height: 43px; padding: .25rem; cursor: pointer; }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--blue); }
.check { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
textarea { resize: vertical; }
button, .primary {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: .4rem;
  padding: .68rem .85rem;
  font-weight: 650;
  font-size: .9rem;
  min-height: 42px;
}
button:hover { border-color: var(--blue); }
.primary { display: inline-flex; align-items: center; justify-content: center; background: var(--blue); color: var(--white); border-color: var(--blue); }
.primary:hover { background: #134b91; }
button:disabled { opacity: .65; cursor: wait; }
.filters {
  display: grid;
  grid-template-columns: minmax(14ch, 2fr) repeat(2, minmax(13ch, 1fr)) auto;
  align-items: end;
  gap: .9rem;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .65rem;
}
.items { display: grid; gap: .55rem; }
.item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .95rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.item-main { flex: 1; min-width: 12ch; overflow-wrap: anywhere; }
.item h2 { font-size: 1rem; }
.item p { color: var(--muted); font-size: .88rem; margin-top: .25rem; }
.thumbnail { width: 3.5rem; height: 3.5rem; object-fit: cover; border-radius: .35rem; }
.pill { background: #edf2f6; color: #324b67; font-size: .82rem; font-weight: 650; border-radius: 1rem; padding: .28rem .62rem; }
.pill[data-status="nuevo"] { background: #e5efff; color: #1e4e87; }
.pill[data-status="en_proceso"] { background: #f9edcc; color: #604508; }
.pill[data-status="cerrado"] { background: #dff2e8; color: #23543f; }
.property-search { max-width: 30rem; margin-bottom: 1rem; }
.pagination { display: flex; gap: .6rem; margin-top: 1rem; }
.notice { color: var(--blue); margin-bottom: .7rem; }
.notice:empty { display: none; }
.empty { padding: 2rem 1rem; text-align: center; background: var(--white); border: 1px solid var(--line); border-radius: .6rem; }
details { background: var(--white); border: 1px solid var(--line); border-radius: .55rem; margin-bottom: .6rem; }
summary { padding: 1rem; font-weight: 700; }
.group-fields { padding: 0 1rem 1rem; display: grid; gap: .85rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.hint { font-size: .88rem; color: var(--muted); }
.save-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.save-bar span { color: var(--muted); }
dialog { width: min(42rem, 94vw); max-height: 90vh; padding: 1.25rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--ink); }
dialog::backdrop { background: #14263bc9; }
.dialog-top { display: flex; align-items: start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.dialog-top h2 { font-size: 1.45rem; overflow-wrap: anywhere; }
#editor-content { display: grid; gap: .85rem; }
.order-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin: 0; }
.order-details dt { color: var(--muted); font-size: .85rem; margin-bottom: .2rem; }
.order-details dd { margin: 0; overflow-wrap: anywhere; }
.message { background: var(--surface); padding: .75rem; white-space: pre-wrap; overflow-wrap: anywhere; border-radius: .4rem; }
@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .item { flex-wrap: wrap; gap: .6rem; }
  .item-main { flex-basis: 55%; }
}
@media (max-width: 460px) {
  .fields, .order-details { grid-template-columns: 1fr; }
  .section-header { align-items: start; flex-direction: column; }
  .top-actions { font-size: .86rem; }
  .workspace nav button { padding-inline: .55rem; }
}

dialog[data-kind="order"][open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(56rem, 94vw);
  max-height: 92dvh;
  padding: 0;
  border-radius: .85rem;
  box-shadow: 0 20px 65px #10233845;
}
dialog[data-kind="order"] .dialog-top {
  align-items: center;
  margin: 0;
  padding: .9rem clamp(.85rem, 3vw, 1.4rem);
  border-bottom: 1px solid var(--line);
}
dialog[data-kind="order"] .dialog-top h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); }
dialog[data-kind="order"] #editor-form {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
}
dialog[data-kind="order"] #editor-content {
  display: grid;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  padding: clamp(.75rem, 2.5vw, 1.35rem);
}
dialog[data-kind="order"] .save-bar {
  justify-content: flex-end;
  min-height: 3.9rem;
  margin: 0;
  padding: .65rem clamp(.85rem, 3vw, 1.4rem);
  border-top: 1px solid var(--line);
}
dialog[data-kind="order"] #editor-status { order: -1; margin-right: auto; color: var(--muted); font-size: .875rem; }
dialog[data-kind="order"] #editor-status:empty, #order-history-status:empty { display: none; }
.order-overview, .order-card {
  min-width: 0;
  padding: clamp(.85rem, 2vw, 1.15rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: .55rem;
}
.order-overview { display: flex; align-items: start; justify-content: space-between; gap: .65rem; }
.order-overview strong { font-size: 1rem; }
.order-overview p { margin: .2rem 0 0; color: var(--muted); font-size: .875rem; }
.order-overview .pill { flex-shrink: 0; white-space: nowrap; }
.order-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: .85rem; align-items: start; }
.order-card h3 { margin: 0 0 .75rem; font-size: 1.1rem; }
.order-card .order-details dt { font-size: .875rem; }
.order-card .order-details a { color: var(--blue); text-decoration: underline; text-underline-offset: .16em; }
.order-message { margin-top: .95rem; }
.order-message h4 { margin: 0 0 .35rem; font-size: .9rem; }
.order-message p { margin: 0; }
.order-reference { display: grid; gap: .2rem; margin: .85rem 0 0; font-size: .875rem; color: var(--muted); overflow-wrap: anywhere; }
.order-reference code { color: var(--ink); font-size: .8125rem; }
.order-followup { display: grid; gap: .65rem; }
.order-followup h3 { margin: 0; }
.order-followup textarea { min-height: 5rem; }
.order-history .hint { margin: 0; }
.order-timeline { list-style: none; margin: 0; padding: 0 0 0 .4rem; }
.order-timeline-entry {
  position: relative;
  padding: .15rem 0 .9rem .95rem;
  border-left: 2px solid var(--line);
  overflow-wrap: anywhere;
}
.order-timeline-entry:last-child { padding-bottom: .15rem; }
.order-timeline-entry::before {
  content: '';
  position: absolute;
  top: .45rem;
  left: -.375rem;
  width: .625rem;
  height: .625rem;
  background: var(--blue);
  border: 2px solid var(--white);
  border-radius: 50%;
}
.order-event-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .85rem; }
.order-event-header time { color: var(--muted); font-size: .875rem; }
.order-changes { list-style: none; margin: .35rem 0 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; }
.order-changes > li > strong { padding-right: .3rem; }
.order-change-arrow { color: var(--muted); }
.order-note-change { margin: 0; }
.order-note-change summary { padding: .45rem .65rem; font-weight: 600; }
.order-note-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; margin: 0; padding: 0 .65rem .6rem; }
.order-note-values dt { color: var(--muted); font-weight: 600; margin-bottom: .25rem; }
.order-note-values dd { margin: 0; padding: .5rem; border-radius: .35rem; background: var(--surface); white-space: pre-wrap; }
.order-history-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem; }
.order-history-actions:has(button:not([hidden])), .order-history-actions:has(p:not(:empty)) { margin-top: .75rem; }
@media (max-width: 640px) {
  .order-layout, .order-note-values { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .order-event-header { flex-direction: column; }
}

.property-photo-fields {
  display: grid;
  gap: .9rem;
  padding: .95rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.property-photo-fields h3, .property-photo-fields h4 { margin: 0; }
.property-photo-group { display: grid; gap: .45rem; }
.property-photo-preview {
  display: grid;
  gap: .35rem;
  align-content: start;
  width: 100%;
  max-width: 14rem;
}
.property-photo-preview img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: .35rem; background: var(--surface); }
.property-photo-preview button { justify-self: start; min-height: 2.25rem; padding-block: .25rem; }
.property-photo-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .65rem; margin: 0; padding: 0; }
.property-photo-grid:empty { display: none; }
.property-photo-addresses { margin: 0; }
button.danger-button { color: #942d31; border-color: #deb8ba; }
button.danger-button:hover { background: #fff0f0; border-color: #ae4a4f; }
button.danger-button.primary { color: white; background: #a83439; border-color: #a83439; }
button.danger-button.primary:hover { background: #87262b; }
