/* WellHealth — Admin UI
 *
 * Plain CSS, no build step. Mirrors the muted neutral tokens used elsewhere
 * in the repo so the admin surface is visually a sibling of B2B/B2C.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --hair: #e3e6ea;
  --hair-2: #eef0f3;
  --ink: #1a2230;
  --ink-2: #43505f;
  --ink-3: #6b7785;
  --ink-4: #9aa3b0;
  --accent: #2f6f6f;
  --accent-soft: #e7f1f1;
  --accent-ink: #0f4f4f;
  --add: #2563eb;
  --add-ink: #1d4ed8;
  --warn: #b15c1d;
  --warn-soft: #fbecdb;
  --good: #1e7a4d;
  --good-soft: #e0f2e8;
  --bad: #b1373d;
  --bad-soft: #f8dcde;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --control-height: 34px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg: #11161f;
  --surface: #1a2230;
  --surface-2: #232c3b;
  --hair: #2c3645;
  --hair-2: #232c3b;
  --ink: #e8ecf2;
  --ink-2: #b9c2cf;
  --ink-3: #8b94a1;
  --ink-4: #5e6772;
  --accent: #4ea0a0;
  --accent-soft: #1c3a3a;
  --accent-ink: #9bd1d1;
  --add: #4d8cff;
  --add-ink: #2563eb;
  --warn: #d18545;
  --warn-soft: #3a2818;
  --good: #4caf7d;
  --good-soft: #1a3324;
  --bad: #d96670;
  --bad-soft: #38181d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

html {
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter Tight", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
}

/* ---- top bar ----------------------------------------------------------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
  box-shadow: var(--shadow-sm);
}
.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__center {
  justify-self: center;
}
.topbar__right {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  align-items: center;
}
.brand {
  font-size: 16px;
  letter-spacing: -0.01em;
}
img.brand {
  height: 32px;
  width: auto;
  display: block;
}
.brand__sub {
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
}
.brand__version {
  color: var(--ink-4);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0;
}
.me {
  color: var(--ink-3);
  font-size: 12px;
}
.me[hidden] {
  display: none;
}

/* ---- icon buttons (theme toggle, profile) ----------------------------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-height);
  height: var(--control-height);
  padding: 0;
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.icon-btn__icon {
  width: 18px;
  height: 18px;
}
.icon-btn__icon--sun {
  display: none;
}
html[data-theme="dark"] .icon-btn__icon--moon {
  display: none;
}
html[data-theme="dark"] .icon-btn__icon--sun {
  display: block;
}

/* ---- profile menu ----------------------------------------------------- */

.profile-menu {
  position: relative;
}
.profile-menu[hidden] {
  display: none;
}
.profile-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 240px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 60;
}
.profile-dropdown[hidden] {
  display: none;
}
.profile-dropdown__user {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-dropdown__hint {
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.profile-dropdown__email {
  display: block;
  background: var(--surface-2);
  color: var(--ink);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-all;
}
.profile-dropdown__action {
  align-self: stretch;
}

/* ---- panels ------------------------------------------------------------ */

main {
  max-width: 1180px;
  margin: 24px auto;
  padding: 0 24px 80px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.panel__title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.panel__hint {
  margin: 0 0 14px;
  color: var(--ink-3);
}

/* ---- form primitives --------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field[hidden] {
  display: none;
}
.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-height: var(--control-height);
}
.field--checkbox .field__label {
  flex: 0 0 auto;
}
.field--number {
  width: max-content;
}
.field__label {
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
input[type="text"],
input[type="email"],
input[type="search"],
input[type="url"],
input[type="number"],
input[type="date"],
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  height: var(--control-height);
  min-height: var(--control-height);
  outline: none;
  transition: border-color 120ms ease;
}
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  outline: none;
  transition: border-color 120ms ease;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea {
  min-height: 70px;
  resize: vertical;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
}

.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 6px 14px;
  min-height: var(--control-height);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.btn--primary {
  background: var(--accent);
  color: white;
}
.btn--primary:hover {
  background: var(--accent-ink);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--hair);
}
.btn--ghost:hover {
  background: var(--surface-2);
}
.btn--warn {
  background: var(--warn);
  color: #fff;
  border-color: var(--warn);
}
.btn--warn:hover {
  background: #8e4716;
  border-color: #8e4716;
}
.btn--delete {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}
.btn--delete:hover {
  background: #8e2c31;
  border-color: #8e2c31;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---- list view --------------------------------------------------------- */

.list-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair-2);
  vertical-align: middle;
}
.table thead th {
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table tr.row {
  cursor: pointer;
}
.table tr.row:hover td {
  background: var(--surface-2);
}
.table .row-actions {
  text-align: right;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pagination__nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pagination__label {
  color: var(--ink-2);
  min-width: 110px;
  text-align: center;
}
.pagination__total {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
}

/* ---- badges & chips ---------------------------------------------------- */

.badge {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  color: var(--ink-2);
  background: var(--surface-2);
  font-weight: 500;
}
.badge--published {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good);
}
.badge--reviewed {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
}
.badge--candidate,
.badge--draft {
  background: var(--warn-soft);
  border-color: transparent;
  color: var(--warn);
}
.badge--deprecated,
.badge--archived {
  background: var(--bad-soft);
  border-color: transparent;
  color: var(--bad);
}
.badge--inactive {
  background: var(--surface-2);
  color: var(--ink-3);
}

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--ink-2);
}
.chip__remove {
  margin-left: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1;
}
.chip__remove:hover {
  color: var(--bad);
}
.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  min-height: var(--control-height);
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}
.chip-input input {
  flex: 1;
  min-width: 160px;
  border: none;
  outline: none;
  height: 24px;
  min-height: 24px;
  padding: 0 4px;
}

/* ---- editor ------------------------------------------------------------ */

.editor-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.editor-header .panel__title {
  margin-right: auto;
}

.venue-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
  padding: 8px;
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

.venue-tabs[hidden] {
  display: none;
}

.venue-tabs__button {
  appearance: none;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-3);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  min-height: var(--control-height);
  padding: 7px 12px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.venue-tabs__button:hover {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.venue-tabs__button[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}

.venue-tabs__button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.venue-tabpanel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  min-width: 0;
}
.venue-tabpanel[hidden] {
  display: none;
}
[data-venue-panel-content] {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.form-grid > * {
  min-width: 0;
}

#editor-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
}
#editor-fields > .field--checkbox {
  width: fit-content;
  max-width: 100%;
}

.field-coordinate-group {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 8px;
  max-width: 100%;
}

.card {
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 14px 16px;
  background: var(--surface);
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
}
.card legend {
  padding: 0 6px;
  font-weight: 600;
  color: var(--ink-2);
}

.locale-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair-2);
}
.locale-text:last-child {
  border-bottom: 0;
}
.locale-text__locale {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-size: 12px;
}
.locale-text__fields {
  display: grid;
  gap: 8px;
}

/* ---- relations editor -------------------------------------------------- */

.relation-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.relation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.relation-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) auto minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}
.relation-row--with-source {
  grid-template-columns: minmax(150px, 1.2fr) auto minmax(120px, 1fr) minmax(180px, 1fr) auto;
}
.relation-row--with-source-no-primary {
  grid-template-columns: minmax(150px, 1.2fr) minmax(140px, 1fr) minmax(180px, 1fr) auto;
}
.relation-row__label {
  min-width: 0;
}
.relation-row__primary {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  font-size: 12px;
}
.relation-row__notes {
  min-width: 0;
}
.relation-row__source-url,
.relation-row__source-url-field {
  min-width: 0;
}
.relation-row__remove {
  justify-self: end;
}

.relation-adder {
  display: flex;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  align-items: flex-start;
}
.relation-combobox {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.relation-combobox__control {
  display: flex;
  min-width: 0;
}
.relation-adder__input {
  flex: 1 1 auto;
  min-width: 0;
}
.relation-combobox__control .relation-adder__input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.relation-combobox__toggle {
  width: var(--control-height);
  height: var(--control-height);
  border: 1px solid var(--hair);
  border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  cursor: pointer;
}
.relation-combobox__toggle::before {
  content: "";
  display: inline-block;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  vertical-align: middle;
}
.relation-combobox__toggle[data-open="true"]::before {
  transform: rotate(180deg);
}
.relation-combobox__toggle:disabled {
  cursor: not-allowed;
  color: var(--ink-3);
}
.relation-combobox__menu {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
}
.relation-combobox__menu[hidden] {
  display: none;
}
.relation-combobox__option {
  display: block;
  width: 100%;
  min-height: 30px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.relation-combobox__option:hover,
.relation-combobox__option:focus {
  background: var(--surface-2);
  outline: none;
}
.relation-combobox__empty {
  padding: 7px 8px;
  color: var(--ink-3);
  font-size: 13px;
}
.relation-adder__create {
  flex: 0 0 auto;
  min-width: 32px;
  font-weight: 700;
}

.relation-row__field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 12px;
  min-width: 0;
}
.relation-row__field--integer .relation-row__field-label {
  white-space: nowrap;
}
.relation-row__integer {
  width: 8ch;
  min-width: 0;
}
.relation-row__field--text .relation-row__field-label {
  white-space: nowrap;
}
.relation-row__text {
  min-width: 12ch;
}

.contraindications-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  align-items: start;
}
.contraindications-row .locale-text__locale {
  grid-column: 1 / -1;
}
.contraindications-row__actions {
  display: flex;
  gap: 6px;
}

.editor-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding-top: 14px;
  border-top: 1px solid var(--hair-2);
}
.editor-footer .panel__hint {
  margin: 0;
  margin-right: auto;
}
.editor-footer--main {
  margin-top: 18px;
  z-index: 2;
}

/* ---- candidate suggestions -------------------------------------------- */

#relations-fields,
#suggestions-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.suggestion-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggestion-toolbar {
  display: flex;
  justify-content: flex-start;
}
.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggestion-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}
.suggestion-row__header {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.suggestion-row__source-url-field {
  grid-column: 1 / -1;
  max-width: 720px;
}
.suggestion-row__status {
  margin-left: auto;
}
.suggestion-row__reason,
.suggestion-row__mapped {
  margin: 0;
  font-size: 13px;
}
.suggestion-row__mapped {
  color: var(--accent-ink);
}
.suggestion-row__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.badge--needs_review {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}
.badge--mapped {
  background: var(--good-soft);
  color: var(--good);
  border-color: transparent;
}
.badge--rejected {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: transparent;
}

/* ---- modal ------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal[hidden] {
  display: none;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 26, 34, 0.45);
}
.modal__panel {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 22px;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}
.modal--drawer {
  align-items: stretch;
  justify-content: flex-end;
}
.modal--drawer .modal__backdrop {
  background: rgba(20, 26, 34, 0.35);
}
.drawer__panel {
  width: min(820px, calc(100vw - 24px));
  max-height: none;
  height: 100vh;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.drawer__panel .modal__header {
  flex: 0 0 auto;
}
.drawer__footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--hair);
  padding-top: 12px;
  margin-top: 4px;
}

/* Drawers whose form is a flex column with a separate scrolling fields
   container (package, create-venue): the footer is a sibling of the scroll
   container, not a descendant, so its sticky has no real scroll ancestor
   and Safari mis-anchors it once layout settles (footer briefly visible,
   then disappears). Lay it out as a normal flex item instead. */
.package-editor > .drawer__footer,
.drawer-form > .drawer__footer {
  position: static;
  flex: 0 0 auto;
}
.modal--drawer .form-stack {
  max-width: none;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}
.drawer-form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drawer-form__fields {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}
.admin-permission-row {
  align-items: flex-start;
  gap: 10px;
}
.admin-permission-row > span {
  display: grid;
  gap: 3px;
}
.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---- disease picker --------------------------------------------------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.segmented__button {
  border: 0;
  border-right: 1px solid var(--hair);
  background: transparent;
  color: var(--ink);
  min-width: 42px;
  min-height: 34px;
  padding: 6px 10px;
  cursor: pointer;
}

.segmented__button:last-child {
  border-right: 0;
}

.segmented__button--active {
  background: var(--accent);
  color: #fff;
}

.disease-picker__toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hair);
}

.disease-picker__search {
  margin: 0;
}

.disease-picker__breadcrumb {
  grid-column: 1 / -1;
  min-height: 32px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.disease-picker__crumb {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  padding: 2px 0;
  cursor: pointer;
}

.disease-picker__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 4px 12px 0;
}

.disease-picker__section + .disease-picker__section {
  margin-top: 16px;
}

.disease-picker__section-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-3);
}

.disease-picker__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.disease-picker__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: stretch;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
}

.disease-picker__row--disabled {
  opacity: 0.62;
}

.disease-picker__select,
.disease-picker__drill {
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.disease-picker__select {
  text-align: left;
  padding: 10px 12px;
  display: grid;
  gap: 5px;
}

.disease-picker__select:disabled {
  cursor: not-allowed;
}

.disease-picker__meta,
.disease-picker__codes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--ink-3);
  font-size: 12px;
}

.disease-picker__drill {
  border-left: 1px solid var(--hair);
  font-size: 26px;
}

.disease-picker__empty {
  padding: 10px 0;
}

.field--picker {
  gap: 6px;
}

.disease-picker-field {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.disease-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ---- venue sub-resource CRUD cards ------------------------------------- */

.ops-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ops-card__status {
  min-height: 1.2em;
  margin: 0;
}

.ops-error {
  color: var(--color-error, #c0392b);
}

.ops-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ops-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
}

.ops-row--block {
  flex-direction: column;
  align-items: stretch;
}

.ops-row--block .ops-row__display,
.ops-row--block .ops-row__actions {
  width: 100%;
}

.ops-row--block .ops-row__header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.ops-row--block .ops-row__header[hidden] {
  display: none;
}

.ops-row--block .ops-row__header .ops-row__display,
.ops-row--block .ops-row__header .ops-row__actions {
  width: auto;
}

.ops-row--block .ops-row__header .ops-row__blurb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ops-row--block .ops-row__header .ops-row__blurb .ops-row__display {
  flex: 0 1 auto;
}

.ops-row__display {
  flex: 1;
  min-width: 0;
  font-size: 13px;
}

.ops-row__actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ops-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 0 4px;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.image-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.image-item--cover {
  border-color: var(--accent);
}

.image-thumb-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: zoom-in;
}

.image-thumb-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.image-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface);
}

.image-meta,
.image-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.image-caption,
.image-source-url {
  width: 100%;
  min-width: 0;
}

.image-source-url-row {
  width: 100%;
}

.image-cover-badge {
  align-self: flex-start;
}

.image-preview__panel {
  width: min(1120px, calc(100vw - 32px));
  padding: 14px;
}

.image-preview__header {
  margin-bottom: 10px;
}

.image-preview__img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.image-preview__caption {
  margin: 10px 4px 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.ops-form[hidden] {
  display: none;
}

.ops-form--inline {
  border-top: 1px solid var(--hair-2);
  padding-top: 10px;
  margin-top: 4px;
}

.ops-form__field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--ink-3);
}

.ops-form__field input,
.ops-form__field select,
.ops-form__field textarea {
  font-size: 13px;
  min-width: 80px;
}

.ops-form__field--number,
.field--number {
  flex: 0 0 auto;
}

.ops-form__field--number > span,
.field--number > .field__label {
  white-space: nowrap;
}

.ops-form__field--number input[type="number"],
.field--number input[type="number"] {
  width: var(--number-field-width, 9ch);
  min-width: var(--number-field-width, 9ch);
  max-width: 18ch;
}

.ops-form__break {
  flex-basis: 100%;
  width: 100%;
  height: 0;
}

.ops-form--rate .ops-form__field--amount {
  order: 5;
}

.ops-form--rate .ops-form__field--package_id {
  order: 6;
  flex: 1 1 160px;
  max-width: 260px;
}

.ops-form--rate .ops-form__break--weekdays {
  order: 7;
}

.ops-form--rate .ops-form__field--checkbox {
  order: 8;
}

.ops-form--rate .ops-form__field--guest_count,
.ops-form--rate .ops-form__field--extra_bed_count,
.ops-form--rate .ops-form__field--min_nights,
.ops-form--rate .ops-form__field--max_nights {
  order: 9;
}

.ops-form__actions {
  flex-basis: 100%;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ops-form--rate .ops-form__actions {
  order: 10;
}

.ops-form__field--checkbox {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  min-height: var(--control-height);
}

.ops-form__field--checkbox input[type="checkbox"] {
  min-width: 0;
  width: auto;
}

.ops-add-btn {
  align-self: flex-start;
  background: var(--add);
  color: #fff;
  border-color: var(--add);
}
.ops-add-btn:hover {
  background: var(--add-ink);
  border-color: var(--add-ink);
}

.ops-room-texts {
  width: 100%;
  margin-top: 4px;
}

.ops-room-text {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}

.ops-room-text__locale {
  text-transform: uppercase;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

.ops-season-ranges {
  width: 100%;
  margin-top: 4px;
}

.ops-season-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.ops-season-range input,
.ops-season-range select {
  font-size: 13px;
}

.ops-season-range input[type="number"] {
  width: 64px;
}

.ops-season-range select {
  min-width: 88px;
}

.ops-season-range__eom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-2);
}

.ops-nested-panel {
  border-top: 1px solid var(--hair-2);
  margin-top: 6px;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ops-subpanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-subpanel__heading {
  margin: 0;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

/* ---- package drawer ------------------------------------------------------ */

.package-editor {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#package-drawer-fields {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.package-editor__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.package-editor__grid > .field {
  flex: 1 1 180px;
  min-width: 0;
}

.package-editor__grid > .field--number,
.package-editor__grid > .field--checkbox {
  flex: 0 0 auto;
}

.package-editor__wide {
  flex: 1 1 100%;
}

.package-editor__locales {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.package-locale {
  border: 1px solid var(--hair);
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--surface);
}

.package-locale__title {
  margin: 0 0 10px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
}

.package-locale__fields {
  display: grid;
  gap: 10px;
}

.package-therapy-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.package-therapy-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(86px, 0.45fr)) minmax(0, 1fr) max-content;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.package-therapy-row > .field {
  min-width: 0;
}

.package-therapy-row > .field--number {
  width: auto;
}

.package-therapy-row input,
.package-therapy-row select {
  width: 100%;
  min-width: 0;
}

.package-therapy-row > .btn {
  justify-self: end;
  white-space: nowrap;
}

.package-therapy-row--error {
  border-color: var(--danger, #c0392b);
}

.package-therapy-row__tier {
  grid-column: 1 / -1;
  font-size: 0.85em;
  color: var(--ink-2, #6b7280);
  font-weight: 600;
}

.package-therapy-row__error {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.9em;
  color: var(--danger, #c0392b);
}

/* ---- responsive -------------------------------------------------------- */

@media (max-width: 800px) {
  .filters {
    grid-template-columns: 1fr 1fr;
  }
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }
  .topbar__center,
  .topbar__right {
    justify-self: center;
  }
  .package-therapy-row {
    grid-template-columns: 1fr;
  }
}

/* ---- unsaved-edits modal ---------------------------------------------- */

.modal__panel--narrow {
  width: min(420px, calc(100vw - 32px));
}

.modal__body {
  margin: 0 0 16px;
  color: var(--ink-2);
  font-size: 14px;
}

/* ---- URL field with open-in-new-tab icon ------------------------------ */

.field__input-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.field__input-row > input {
  flex: 1 1 auto;
  min-width: 0;
}

.field__url-open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  min-height: var(--control-height);
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  cursor: pointer;
}

.field__url-open[hidden] {
  display: none;
}

.field__url-open:hover:not([disabled]) {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.field__url-open[disabled] {
  color: var(--ink-4);
  cursor: not-allowed;
  opacity: 0.6;
}

/* CRM lead viewer (read-only) */
.callout {
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--ink-3);
  margin-bottom: 16px;
  font-size: 14px;
}
.callout--phi {
  background: #fff4f4;
  border-color: #d33;
  color: #800;
  font-weight: 500;
}
.lead-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 8px 0 16px;
  font-size: 14px;
}
.lead-meta dt {
  font-weight: 600;
}
.lead-meta dd {
  margin: 0;
  word-break: break-word;
}
.lead-tech {
  margin: 8px 0 16px;
}
.lead-tech > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-2);
}
.lead-submitted h2 {
  font-size: 16px;
  margin-bottom: 8px;
}
.lead-fields {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
}
.lead-fields dt {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.lead-fields dd {
  margin: 0;
}
.lead-fields pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  background: var(--surface-2);
  border: 1px solid var(--ink-3);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
}
