:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #172b29;
  background: #eef4f2;
  line-height: 1.55;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 68rem; margin: 0 auto; padding: 3.5rem 1.5rem; }
header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.75rem; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.12; letter-spacing: -.045em; }
header p { margin: .5rem 0 0; color: #4b625e; }
a { color: #08624d; font-weight: 650; }
a:focus-visible { outline: 2px solid #08624d; outline-offset: 4px; }
.refresh, nav a, nav [aria-disabled] {
  border: 1px solid #b8cbc6;
  border-radius: .55rem;
  padding: .5rem .85rem;
  text-decoration: none;
  font-size: .9rem;
  background: #fff;
}
.refresh:hover, nav a:hover { background: #e2f3eb; }
.panel { background: white; border: 1px solid #cddbd7; border-radius: .85rem; overflow: hidden; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead { background: #e2eeea; color: #304b45; }
th, td { padding: .95rem 1.25rem; text-align: left; vertical-align: top; }
th { font-size: .9rem; }
th:first-child { width: 24%; }
th:last-child { width: 25%; }
tr + tr, nav { border-top: 1px solid #e1ebe8; }
.phone { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
time { color: #4b625e; font-size: .875rem; }
.origin { display: inline-block; color: #075844; background: #e2f3eb; border-radius: .4rem; padding: .12rem .45rem; font-size: .875rem; overflow-wrap: anywhere; }
.origin.muted, nav [aria-disabled] { color: #536762; background: #f1f5f4; }
.source { display: block; width: fit-content; margin-top: .25rem; font-size: .875rem; }
.empty { padding: 2.6rem 1.25rem; text-align: center; color: #4b625e; }
nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .85rem 1.25rem; }
.page { color: #4b625e; font-size: .9rem; }

@media (max-width: 42rem) {
  main { padding: 1.5rem .85rem; }
  header { align-items: flex-start; flex-wrap: wrap; }
  table, tbody, tr, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { padding: .6rem 1rem; }
  td { padding: .3rem 0; }
  td::before { content: attr(data-label); display: block; color: #4b625e; font-size: .875rem; }
  nav { padding-inline: .75rem; }
}

.history-link { display: block; width: fit-content; margin-top: .3rem; font-size: .875rem; }
.history { display: grid; gap: .9rem; margin: 0; padding: clamp(.9rem, 3vw, 2rem); list-style: none; }
.history-message { justify-self: start; width: fit-content; min-width: min(15rem, 100%); max-width: min(42rem, 90%); padding: .75rem 1rem; border-radius: .65rem; background: #eef4f2; }
.history-message.outbound { justify-self: end; background: #dff2e8; }
.message-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .15rem 1rem; margin-bottom: .25rem; }
.message-meta strong { font-size: .875rem; }

.contact-form { display: grid; gap: .55rem; max-width: 31rem; padding: clamp(1rem, 4vw, 2rem); }
.contact-form label { font-weight: 650; }
.contact-form input, .contact-form select, .contact-form button {
  padding: .55rem .75rem; border: 1px solid #b8cbc6; border-radius: .5rem; font: inherit;
}
.contact-form input, .contact-form select { margin-bottom: .6rem; background: #fff; color: inherit; }
.contact-form button { justify-self: start; background: #08624d; color: white; cursor: pointer; font-weight: 650; }
.contact-form button:hover { background: #074e3e; }
.contact-form :focus-visible { outline: 2px solid #08624d; outline-offset: 3px; }
.form-feedback { margin: 0 0 .45rem; color: #075844; }

.history-settings { margin-bottom: 1rem; }
.contact-form .checkbox { display: flex; align-items: center; gap: .45rem; }
.contact-form .checkbox input { margin: 0; accent-color: #08624d; }
.contact-flags { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem .75rem; margin-bottom: .5rem; }
.contact-flags .checkbox { font-size: .875rem; }
.contact-form textarea { width: 100%; resize: vertical; padding: .55rem .75rem; color: inherit; border: 1px solid #b8cbc6; border-radius: .5rem; font: inherit; }
.form-help { margin: 0; font-size: .875rem; color: #4b625e; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .85rem; margin-bottom: 1rem; padding: 1rem 1.25rem; }
.filters label { display: grid; gap: .3rem; min-width: 0; font-size: .9rem; font-weight: 650; }
.filters input, .filters select, .filters button {
  width: 100%; min-width: 0; padding: .5rem .55rem; border: 1px solid #b8cbc6; border-radius: .5rem; background: #fff; color: inherit; font: inherit;
}
.filter-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; }
.filters button { width: auto; padding-inline: .9rem; background: #08624d; color: white; cursor: pointer; font-weight: 650; }
.filters button:hover { background: #074e3e; }
.filters :focus-visible { outline: 2px solid #08624d; outline-offset: 3px; }
.filter-error { grid-column: 1 / -1; margin: 0; color: #942c28; }

.login { max-width: 32rem; margin: 2rem auto; padding: clamp(1.25rem, 5vw, 2.5rem); }
.login p { margin: .8rem 0 1.4rem; color: #4b625e; }
.login a { display: inline-block; }
.session-bar { display: flex; justify-content: flex-end; margin-bottom: 1rem; }
.session-bar button { cursor: pointer; color: #08624d; font: inherit; background: #fff; border: 1px solid #b8cbc6; border-radius: .55rem; padding: .35rem .75rem; }

.contact-history { margin-top: 1rem; }
.contact-history h2 { margin: 0; padding: 1rem 1.25rem; font-size: 1.2rem; }
.contact-history-list { margin: 0; padding: 0; list-style: none; }
.contact-history-list > li { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; padding: .85rem 1.25rem; border-top: 1px solid #e1ebe8; }
.contact-history-list .message { margin-top: .25rem; }
.contact-history-list .origin { flex-shrink: 0; }
.conversation-labels { display: flex; flex-wrap: wrap; gap: .35rem; margin: .45rem 0 0; padding: 0; list-style: none; }
.conversation-labels li { padding: .12rem .45rem; border-radius: .4rem; background: #eef4f2; color: #304b45; font-size: .875rem; overflow-wrap: anywhere; }
.contact-history-empty { margin: 0; padding: 0 1.25rem 1rem; color: #4b625e; }

.classification form { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; padding: 0 1.25rem 1rem; }
.classification button { padding: .55rem .75rem; border: 1px solid #08624d; border-radius: .5rem; background: #08624d; color: white; font: inherit; font-weight: 650; cursor: pointer; }
.classification button:disabled { opacity: .6; cursor: default; }
.classification-feedback, .classification details { margin: 0; padding: .7rem 1.25rem; }
.classification pre { overflow: auto; }

.appointment-panel .contact-form { padding-top: 0; }
.appointment-when { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .85fr) minmax(0, 1fr); gap: .65rem; }
.appointment-when label { display: grid; gap: .3rem; min-width: 0; }
.appointment-when input { width: 100%; min-width: 0; }
@media (max-width: 36rem) {
  .appointment-when { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-when label:first-child { grid-column: 1 / -1; }
}
.appointment-notice { padding: 0 1.25rem; color: #075844; }
.appointment-notice[role="alert"] { color: #942c28; }
.appointment-panel .origin { margin-top: .3rem; }
.retry-calendar { padding: .4rem .6rem; border: 1px solid #b8cbc6; border-radius: .5rem; background: #fff; color: #08624d; font: inherit; cursor: pointer; }
.appointment-actions { display: grid; justify-items: end; gap: .4rem; }
.appointment-status-form { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .4rem; }
.appointment-status-form select { padding: .35rem .45rem; border: 1px solid #b8cbc6; border-radius: .4rem; background: #fff; color: inherit; font: inherit; }
@media (max-width: 36rem) {
  .appointment-panel .contact-history-list > li { flex-wrap: wrap; }
  .appointment-actions { justify-items: start; }
  .appointment-status-form { justify-content: flex-start; }
}

.session-bar { justify-content: space-between; align-items: center; }
.main-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding: 0; border: 0; }
.main-menu .menu-card { padding: clamp(1rem, 3vw, 1.75rem); background: #fff; text-decoration: none; border-radius: .85rem; }
.main-menu .menu-card:hover { background: #e2f3eb; }
.menu-card h2 { margin: 0; font-size: 1.35rem; }
.menu-card p { margin: .4rem 0 0; color: #4b625e; font-size: 1rem; font-weight: 400; }
@media (max-width: 34rem) { .main-menu { grid-template-columns: 1fr; } }

.agenda-filter { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; margin-bottom: 1rem; padding: .85rem 1.25rem; }
.agenda-filter label { font-weight: 650; }
.agenda-filter select { padding: .35rem .5rem; border: 1px solid #b8cbc6; border-radius: .4rem; background: #fff; color: inherit; font: inherit; }
.agenda-day { margin-bottom: .2rem; color: #4b625e; font-size: .875rem; }

@media (min-width: 48rem) { .main-menu { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.contact-search { display: grid; gap: .5rem; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.contact-search label { font-weight: 650; }
.contact-search > div { display: flex; flex-wrap: wrap; gap: .55rem; }
.contact-search input, .contact-search button { padding: .5rem .7rem; border-radius: .45rem; border: 1px solid #b8cbc6; font: inherit; }
.contact-search input { flex: 1 1 14rem; min-width: 0; max-width: 32rem; }
.contact-search button { background: #08624d; color: #fff; font-weight: 650; cursor: pointer; }

.reminder-actions { display: flex; justify-content: flex-end; padding: .85rem 1.25rem; border-top: 1px solid #e1ebe8; }
.reminder-actions button { background: #08624d; color: #fff; font-weight: 650; }
td[data-label="Mandar recordatorio"] input { accent-color: #08624d; }

.calendar-import-table th:first-child { width: 12%; }
.calendar-import-table th:last-child { width: 25%; }
.calendar-import-table input[type="text"], .calendar-import-table select, .agenda-filter input[type="date"] {
  width: 100%; min-width: 0; padding: .4rem .5rem; border: 1px solid #b8cbc6;
  border-radius: .4rem; background: #fff; color: inherit; font: inherit;
}
.calendar-import-table input[type="checkbox"] { accent-color: #08624d; }

.contact-form.contact-merge { max-width: 42rem; }
.contact-merge .contact-history-list > li { align-items: center; flex-wrap: wrap; padding-inline: 0; }
.contact-form.contact-merge .retry-calendar { background: #fff; color: #08624d; }

.calendar-color-picker { --calendar-color: #616161; position: relative; }
.calendar-color-picker:has(option[value="3"]:checked), #turno-color option[value="3"] { --calendar-color: #8e24aa; }
.calendar-color-picker:has(option[value="1"]:checked), #turno-color option[value="1"] { --calendar-color: #7986cb; }
.calendar-color-picker::before, #turno-color option::before {
  content: ""; display: inline-block; width: .85rem; height: .85rem; border-radius: 50%;
  background: var(--calendar-color); border: 1px solid rgb(0 0 0 / 15%);
}
.calendar-color-picker::before { position: absolute; left: .8rem; top: .9rem; pointer-events: none; }
.contact-form #turno-color { width: 100%; padding-inline-start: 2.1rem; }
@supports (appearance: base-select) and selector(::picker(select)) {
  #turno-color, #turno-color::picker(select) { appearance: base-select; }
  #turno-color::picker(select) { border: 1px solid #b8cbc6; border-radius: .5rem; background: #fff; }
  #turno-color option { padding: .45rem .75rem; gap: .55rem; }
  #turno-color option[value="8"] { --calendar-color: #616161; }
}

.inbox-unread { display: block; width: fit-content; margin-top: .3rem; padding: .12rem .45rem; border-radius: .4rem; background: #dff2e8; color: #075844; font-size: .875rem; font-weight: 650; }
.inbox-history-action { padding: .85rem clamp(1rem, 4vw, 2rem) 0; }

.import-add-contact { margin-top: .4rem; }
#import-contact-dialog {
  width: min(32rem, calc(100% - 2rem));
  padding: 0;
  border: 1px solid #b8cbc6;
  border-radius: .8rem;
  color: inherit;
}
#import-contact-dialog::backdrop { background: rgba(0, 0, 0, .45); }
#import-contact-dialog h2 { margin: 0 0 .5rem; }
#import-contact-dialog [data-close] { background: #fff; color: #08624d; }
#import-contact-dialog button:disabled, #import-submit:disabled { opacity: .55; cursor: wait; }
