:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f5f6f8;
  --line: #e2e5e9;
  --text: #252d36;
  --muted: #626d79;
  --brand: #22755b;
  --brand-dark: #195a45;
  --brand-bright: #10a36f;
  --brand-soft: #eaf4ef;
  --accent: #d86628;
  --accent-soft: #fff0e7;
  --info: #2f6fdf;
  --info-soft: #eaf1ff;
  --warn: #bd3545;
  --warn-soft: #ffedf0;
  --ok: #07875b;
  --focus: rgba(8, 122, 85, 0.22);
  --shadow: 0 12px 32px rgba(27, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  letter-spacing: 0;
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  background: #fff;
  color: var(--text);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}

.brand-copy {
  min-width: 0;
  white-space: nowrap;
}

.mobile-menu-button {
  display: none;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.brand-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 5px;
}

.nav button {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  text-align: left;
  white-space: nowrap;
}

.nav button:hover {
  color: var(--text);
  background: var(--panel-soft);
}

.nav button.active {
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-weight: 700;
}

.nav-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
}

.tabler-icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.session-box {
  margin-top: auto;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.session-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.session-icon {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
}

.user-icon {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--panel-soft);
  color: var(--muted);
}
.user-icon img { width: 100%; height: 100%; object-fit: cover; }
.user-icon:not(.has-image) img, .user-icon.has-image svg { display: none; }
.user-icon.session-icon { flex-basis: 22px; width: 22px; height: 22px; }
.user-icon.session-icon svg { width: 22px; height: 22px; }
.user-icon-editor { flex-basis: 72px; width: 72px; height: 72px; }
.user-icon-editor svg { width: 36px; height: 36px; }
.user-icon-field, .user-identity { display: flex; align-items: center; gap: 12px; }
.user-icon-controls { display: grid; gap: 8px; min-width: 0; }
.user-icon-controls .toolbar { flex-wrap: wrap; }

.session-copy {
  min-width: 0;
}

.session-name {
  font-size: 13px;
  font-weight: 700;
}

.session-role {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-logout {
  width: 100%;
  height: 36px;
  margin-top: 10px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.sidebar-logout .tabler-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
}

/* Stable, labelled navigation: no hover expansion over the workspace. */
@media (min-width: 1041px) {
  .sidebar { overflow-y: auto; overscroll-behavior: contain; }
  .sidebar > .brand,
  .sidebar > .nav,
  .sidebar > .session-box { flex-shrink: 0; }
}

.main {
  min-width: 0;
  padding: 22px 28px 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.scope-readonly-banner {
  margin: -6px 0 18px;
  padding: 9px 12px;
  border-left: 3px solid #e0a000;
  background: #fff8dd;
  color: #765000;
  font-size: 13px;
  font-weight: 700;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
}


.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  font-size: 22px;
}

.login-panel p {
  margin: 8px 0 22px;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.honorific-row { align-items: start; }

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.calendar-workspace {
  min-width: 0;
  height: calc(100vh - 132px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
}

.calendar-main-panel,
.calendar-detail-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.calendar-main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 14px;
}

.calendar-action-bar {
  min-height: 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.calendar-legend {
  min-height: 28px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-legend-mark {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--brand);
}

.calendar-legend-mark.schedule {
  background: var(--accent);
}

.month-calendar {
  --fc-today-bg-color: transparent;
  min-width: 0;
  min-height: 0;
}

.month-calendar .fc {
  height: 100%;
}

.month-calendar .fc-toolbar-title {
  font-size: 20px;
}

.month-calendar .fc-button-primary {
  border-color: var(--brand);
  background: var(--brand);
}

.month-calendar .fc-button-primary:hover,
.month-calendar .fc-button-primary:focus {
  border-color: var(--brand-dark);
  background: var(--brand-dark);
}

.month-calendar .fc-header-toolbar { padding-top: 16px; }
.month-calendar .fc-prev-button,
.month-calendar .fc-next-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.month-calendar .fc-prev-button:hover,
.month-calendar .fc-prev-button:focus,
.month-calendar .fc-next-button:hover,
.month-calendar .fc-next-button:focus {
  background: var(--panel-soft);
  border-color: var(--muted);
  color: var(--text);
}
.month-calendar .fc-currentDay-button,
.month-calendar .fc-currentDay-button:disabled {
  background: #fff2df;
  border-color: #edc995;
  color: #86571a;
  opacity: 1;
}
.month-calendar .fc-currentDay-button:hover,
.month-calendar .fc-currentDay-button:focus {
  background: #fbe8cc;
  border-color: #ddb779;
  color: #754711;
}
.calendar-datetime-fields { grid-template-columns: minmax(0, 1fr); }
.calendar-event-fields .field { min-width: 0; }
.calendar-event-fields input { min-width: 0; max-width: 100%; }

.month-calendar .fc-daygrid-day-number {
  margin: 3px;
  min-width: 26px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  text-align: center;
}

.month-calendar.fc td { background: transparent; }
.month-calendar .fc-daygrid-day:hover { background: var(--panel-soft); }

.month-calendar .calendar-day-selected .fc-daygrid-day-number {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.panel-title-link { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.panel-title-link:hover { color: var(--brand); }

.month-calendar .fc-col-header-cell-cushion {
  color: var(--muted);
  text-decoration: none;
}

.month-calendar .calendar-visit-event {
  border-color: var(--brand);
  background: var(--brand);
}

.month-calendar .calendar-schedule-all-day {
  border-color: var(--calendar-event-color) !important;
  background: var(--calendar-event-color) !important;
}

.month-calendar .calendar-schedule-timed {
  border: 0 !important;
  background: transparent !important;
  color: var(--text) !important;
}

.month-calendar .calendar-schedule-timed:hover {
  background: var(--panel-soft) !important;
}

.month-calendar .calendar-schedule-timed .fc-daygrid-event-dot {
  border-color: var(--calendar-event-color) !important;
}

.calendar-detail-panel {
  display: flex;
  flex-direction: column;
}

.calendar-detail-list {
  min-height: 0;
  overflow: auto;
}

.calendar-karte-link {
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.calendar-karte-link:hover {
  background: var(--panel-soft);
}

.calendar-karte-link span:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.calendar-karte-link small {
  color: var(--muted);
}

.calendar-event-form {
  min-height: 0;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

.calendar-event-fields {
  min-height: 0;
  overflow: auto;
}

.calendar-all-day-control {
  min-height: 36px;
  width: fit-content;
}

.calendar-color-field input[type="color"] {
  width: 64px;
  height: 38px;
  padding: 3px;
  cursor: pointer;
}

.calendar-event-fields textarea {
  min-height: 150px;
}

.calendar-event-danger-zone {
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.dashboard-schedule-list {
  min-height: 0;
}

.dashboard-schedule-item {
  width: 100%;
  min-height: 66px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.dashboard-schedule-item:hover {
  background: var(--panel-soft);
}

.dashboard-schedule-date {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-schedule-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.dashboard-schedule-copy strong,
.dashboard-schedule-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-schedule-copy small {
  color: var(--muted);
}

@media (max-width: 1040px) {
  .calendar-workspace {
    height: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .calendar-main-panel {
    height: 720px;
  }

  .calendar-detail-panel {
    max-height: 420px;
  }
}

@media (max-width: 680px) {
  .calendar-workspace {
    gap: 12px;
  }

  .calendar-main-panel {
    height: 620px;
    padding: 8px;
  }

  .calendar-legend {
    justify-content: flex-start;
  }

  .calendar-action-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }

  .month-calendar .fc-header-toolbar {
    align-items: center;
    gap: 8px;
  }

  .month-calendar .fc-toolbar-title {
    font-size: 16px;
  }

  .month-calendar .fc-button {
    min-height: 34px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .month-calendar .fc-daygrid-day-number,
  .month-calendar .fc-col-header-cell-cushion,
  .month-calendar .fc-event-title {
    font-size: 11px;
  }

  .month-calendar .fc-daygrid-event {
    margin-inline: 1px;
  }

  .dashboard-schedule-item {
    grid-template-columns: 1fr auto;
  }

  .dashboard-schedule-date {
    grid-column: 1 / -1;
  }
}

.horse-list-view,
.horse-detail-workspace,
.karte-list-view,
.karte-detail-workspace {
  min-width: 0;
}

.horse-detail-workspace {
  display: block;
}

.karte-detail-workspace {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.karte-detail-workspace > *,
.karte-detail-workspace .panel-body,
.karte-detail-workspace .grid > * {
  min-width: 0;
}

.karte-horse-selector {
  min-width: 0;
}

.karte-horse-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.karte-horse-choice {
  min-width: 0;
  min-height: 66px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.karte-horse-choice:hover,
.karte-horse-choice:focus-visible {
  border-color: var(--brand);
  background: var(--panel-soft);
}

.karte-horse-choice span {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.audit-log-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.audit-log-table-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.audit-log-table {
  min-width: 1120px;
}

.audit-log-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.audit-log-table td {
  max-width: 260px;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.karte-history-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(120px, 1fr) minmax(0, 2fr);
  gap: 16px;
}

.karte-history-panel,
.karte-timeline-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.karte-history-panel > .panel-head,
.karte-timeline-panel > .panel-head {
  flex: 0 0 auto;
}

.karte-history-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.karte-history-panel .karte-history-scroll {
  padding: 6px;
  gap: 2px;
  align-content: start;
  grid-auto-rows: min-content;
}

.karte-history-panel .list-item.current {
  border-color: rgba(8, 122, 85, 0.38);
  background: var(--brand-soft);
}

.karte-history-markers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.karte-media-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 22px;
  border: 1px solid #f1b28f;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.karte-timeline {
  display: grid;
  align-content: start;
  gap: 0;
  padding: 12px;
}

.karte-timeline-entry {
  width: 100%;
  position: relative;
  display: grid;
  gap: 7px;
  padding: 4px 0 16px 18px;
  border: 0;
  border-left: 2px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: default;
}

.karte-timeline-entry::before {
  content: "";
  width: 10px;
  height: 10px;
  position: absolute;
  top: 7px;
  left: -6px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--muted);
}

.karte-timeline-entry.selected {
  border-left-color: var(--brand);
}

.karte-timeline-entry.selected::before {
  background: var(--brand);
}

.karte-timeline-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.karte-timeline-heading strong {
  font-size: 12px;
}

.karte-timeline-text {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.karte-timeline-details {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.karte-timeline-details span {
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
}

.karte-timeline-details .diagnosis {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.karte-timeline-details .treatment {
  background: var(--accent-soft);
  color: #a34416;
}

.karte-timeline-details .inspection {
  background: var(--info-soft);
  color: #285bb7;
}

.karte-timeline-details .weight {
  background: #f2edff;
  color: #6547a8;
}

.karte-timeline-media-note {
  width: fit-content;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.panel-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.editor-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.editor-back-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 21px;
  line-height: 1;
}

.editor-back-button:hover {
  background: var(--panel-soft);
}

.editor-back-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.mobile-list-back {
  display: none;
}

.panel-body {
  padding: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: none;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.field textarea {
  min-height: 122px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--focus);
}

.readonly-field {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  font-weight: 700;
}

.field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--brand);
  box-shadow: none;
}

.checkbox-field {
  align-content: start;
}

.checkbox-control {
  width: fit-content;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  cursor: pointer;
}

.checkbox-control.compact {
  min-height: auto;
  font-weight: 600;
}

.field-label-row {
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.storage-status {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.facility-scope-control {
  min-width: 240px;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.facility-scope-control select {
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 30px 0 9px;
  font: inherit;
}

.session-facility {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.storage-status::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  content: "";
}

.storage-status.connected::before {
  background: var(--ok);
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
  white-space: nowrap;
}

.button:hover {
  background: var(--brand-dark);
}

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

.button.secondary:hover {
  background: var(--panel-soft);
}

.button.warn {
  background: var(--warn);
}

.button.warn:hover {
  background: #873737;
}

.button.accent {
  background: var(--accent);
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.breed-master-table {
  min-width: 0;
  table-layout: fixed;
}

.master-sort-input {
  min-width: 76px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #f8f9fb;
}

tr:hover td {
  background: #f6f8fa;
}

tr.selected td {
  background: var(--brand-soft);
}

tr.is-hidden td {
  color: var(--muted);
  background: #f5f5f5;
}

tr.is-hidden.selected td {
  background: #ecefed;
}

.hidden-label {
  margin-left: 4px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 800;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.master-delete-actions {
  display: flex;
  justify-content: flex-start;
  padding-top: 20px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.user-delete-zone {
  justify-content: flex-start;
}

.user-master-layout,
.master-workspace,
.people-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 20px;
  align-items: start;
}

.user-list-pane,
.master-list-pane,
.person-list-pane {
  min-width: 0;
}

.user-editor-pane,
.master-editor-pane,
.person-editor-pane {
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.master-workspace.yayoi-wide-workspace {
  grid-template-columns: minmax(280px, 0.75fr) minmax(520px, 1.25fr);
}

@media (min-width: 1041px) {
  .main {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .topbar {
    flex: 0 0 auto;
  }

  .split-workspace,
  .master-page-panel,
  .horse-list-view,
  .horse-detail-workspace,
  .people-list-view,
  .person-detail-workspace,
  .karte-list-view,
  .karte-horse-selector,
  .audit-log-panel,
  .karte-detail-workspace {
    min-height: 0;
    flex: 1 1 auto;
  }

  .horse-list-view,
  .people-list-view,
  .karte-list-view {
    overflow: auto;
  }

  .karte-detail-workspace > #karteForm {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .karte-entry-form > .panel-head {
    min-height: 66px;
    padding: 8px 12px;
  }

  .karte-entry-form .karte-horse-image {
    width: 56px;
    flex-basis: 56px;
  }

  .karte-entry-form .karte-horse-copy {
    max-width: 240px;
  }

  .karte-entry-form .karte-horse-copy .muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .karte-entry-columns {
    height: 100%;
    display: grid;
    grid-template-columns: minmax(340px, 1.3fr) minmax(285px, 0.85fr);
    overflow: hidden;
  }

  .karte-record-fields,
  .karte-clinical-column,
  .karte-clinical-pages,
  .karte-clinical-fields,
  .karte-entry-page {
    min-height: 0;
    height: 100%;
  }

  .karte-record-fields,
  .karte-clinical-pages,
  .karte-clinical-fields,
  .karte-entry-page,
  .karte-clinical-page {
    overflow: hidden;
  }

  .karte-record-page {
    height: 100%;
    padding: 14px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  }

  .karte-record-page .karte-core-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .karte-clinical-column {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-left: 1px solid var(--line);
  }

  .karte-clinical-page,
  .karte-treatment-stack {
    height: 100%;
    min-height: 0;
  }

  .karte-treatment-stack {
    padding: 10px;
    display: grid;
    grid-template-rows: minmax(0, 0.65fr) minmax(0, 1.35fr);
    gap: 10px;
  }

  .karte-text-field textarea {
    height: 100%;
    min-height: 0;
    resize: none;
  }

  .karte-treatment-stack > .panel,
  .karte-single-panel-page > .panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .karte-treatment-stack > .panel > .panel-head,
  .karte-single-panel-page > .panel > .panel-head {
    flex: 0 0 auto;
  }

  .karte-treatment-stack > .panel > .panel-body,
  .karte-single-panel-page > .panel > .panel-body {
    min-height: 0;
    overflow: auto;
  }

  .karte-history-page .weight-chart {
    min-height: 220px;
  }

  .horse-detail-workspace {
    overflow: hidden;
  }

  .person-detail-workspace {
    overflow: hidden;
  }

  .horse-detail-workspace > #horseForm {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .horse-editor-layout {
    flex: 1 1 auto;
  }

  .horse-editor-main {
    min-height: 0;
    overflow: auto;
  }

  .person-detail-workspace > #personForm {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .person-editor-layout {
    flex: 1 1 auto;
  }

  .person-editor-main {
    overflow: auto;
  }

  .horse-list-view > .panel-head,
  .people-list-view > .panel-head,
  .horse-detail-workspace > #horseForm > .panel-head,
  .karte-list-view > .panel-head,
  .karte-detail-workspace > #karteForm > .panel-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--panel);
  }

  .split-workspace {
    align-items: stretch;
  }

  .split-workspace > .panel {
    min-height: 0;
    overflow: auto;
  }

  .split-workspace > .panel > .panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
  }

  .master-page-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .master-page-panel > .panel-head {
    flex: 0 0 auto;
  }

  .master-page-panel > .panel-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .master-workspace,
  .user-master-layout {
    height: 100%;
    align-items: stretch;
  }

  .master-list-pane,
  .master-editor-pane,
  .user-list-pane,
  .user-editor-pane {
    min-height: 0;
    overflow: auto;
  }

  .master-editor-pane .compact-head,
  .user-editor-pane .compact-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--panel);
  }
}

.fee-category-row th,
.diagnosis-category-row th {
  padding-top: 15px;
  border-bottom-color: #a9d0bd;
  background: #dff3e9;
  color: var(--text);
  font-size: 13px;
}

.fee-type-row th {
  padding-left: 22px;
  background: #eff8f4;
  color: var(--brand-dark);
}

.fee-item-master-table tbody tr[data-select-master] td:first-child {
  padding-left: 32px;
}

.diagnosis-master-table tbody tr[data-select-master] td:first-child {
  padding-left: 22px;
}

.horse-image-section {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.horse-image-preview {
  width: 160px;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.horse-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.horse-image-controls {
  min-width: 0;
  display: grid;
  gap: 12px;
}


.horse-editor-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.horse-editor-main {
  min-width: 0;
}

.horse-editor-rail {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: var(--panel-soft);
}

.horse-side-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.horse-side-head {
  flex: 0 0 auto;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.horse-side-scroll {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px 12px;
}

.horse-side-list {
  margin-top: 10px;
}

.horse-name-history-item {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.horse-name-history-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.horse-name-history-item summary::-webkit-details-marker { display: none; }
.horse-name-history-item summary:focus-visible { outline: 2px solid var(--brand); }
.horse-name-history-copy .list-title,
.horse-name-history-copy .list-meta { display: block; overflow-wrap: anywhere; }
.horse-name-history-copy small { font-weight: 400; color: var(--muted); font-size: 11px; }
.horse-name-edit-label { flex: 0 0 auto; color: var(--brand); font-size: 11px; }
.horse-name-add summary { cursor: pointer; color: var(--brand); font-size: 12px; }
.horse-name-add .horse-name-form { margin-top: 8px; }

.horse-name-history-copy {
  min-width: 0;
}

.horse-name-date-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 7px;
  padding-top: 8px;
}

.horse-name-date-editor .field {
  gap: 4px;
  font-size: 11px;
}
.horse-name-date-editor input { min-width: 0; padding: 5px; font-size: 12px; }

.horse-related-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.horse-karte-open {
  min-width: 64px;
  align-self: center;
  flex: 0 0 auto;
}

.horse-editor-rail .inline-form.horse-name-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.horse-affiliations-editor {
  display: grid;
  gap: 8px;
}

#horseAffiliationRows {
  display: grid;
  gap: 7px;
}

.horse-affiliation-row {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr) 32px;
  gap: 7px;
  align-items: center;
}

.horse-affiliation-row input,
.horse-affiliation-row select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

@media screen and (max-width: 680px) {
  .horse-affiliation-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .horse-affiliation-row input { grid-column: 1; }
  .horse-affiliation-row select { grid-column: 1; grid-row: 2; }
  .horse-affiliation-row button { grid-column: 2; grid-row: 1 / 3; }
}

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

.horse-media-item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.horse-media-thumbnail {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.horse-media-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.horse-media-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 6px;
}

.horse-media-copy strong,
.horse-media-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horse-media-copy strong {
  font-size: 11px;
}

.horse-media-copy span {
  color: var(--muted);
  font-size: 10px;
}

.karte-horse-summary {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.karte-horse-image {
  width: 72px;
  aspect-ratio: 4 / 3;
  flex: 0 0 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-soft);
}

.karte-horse-copy {
  min-width: 0;
}

.karte-lock-note {
  grid-column: 1 / -1;
  grid-row: 1;
  margin: 0;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.karte-header-status {
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.karte-status-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.karte-editor-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.karte-entry-tabs {
  min-height: 48px;
  margin: 0;
  padding: 7px 12px;
  flex-wrap: nowrap;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.karte-entry-tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.karte-tab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #dfe9e4;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.karte-entry-tabs .tab.active .karte-tab-count {
  background: var(--brand);
  color: #fff;
}

.karte-entry-columns,
.karte-clinical-column,
.karte-clinical-pages {
  min-width: 0;
  min-height: 0;
}

.karte-entry-page[hidden],
.karte-edit-fields[hidden] {
  display: none !important;
}

.karte-entry-page {
  min-width: 0;
  min-height: 0;
}

.karte-column-title {
  margin: 0;
  font-size: 15px;
}

.karte-record-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.karte-core-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.karte-template-field {
  align-self: start;
}

.karte-text-field {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.karte-text-field textarea {
  min-height: 160px;
  flex: 1 1 auto;
}

.karte-update-note {
  margin: 0;
  font-size: 12px;
}

.karte-treatment-stack {
  display: grid;
  gap: 14px;
}

.karte-treatment-stack .karte-diagnosis-head {
  flex-direction: row;
  align-items: center;
}

.diagnosis-history-dialog { position: fixed; inset: 0; margin: auto; padding: 0; width: 960px; max-width: calc(100vw - 32px); height: min(680px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--panel); box-shadow: 0 12px 40px rgba(27, 39, 51, .18); }
.diagnosis-history-dialog[open] { display: flex; flex-direction: column; }
.diagnosis-history-dialog::backdrop { background: rgba(27, 39, 51, .18); }
.diagnosis-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.diagnosis-history-heading > div { min-width: 0; }
.diagnosis-history-heading h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.diagnosis-history-heading .icon-button { flex-shrink: 0; }
.diagnosis-history-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.diagnosis-history-scroll { flex: 1; min-height: 0; overflow: auto; }
.diagnosis-history-table { width: 100%; table-layout: fixed; }
.diagnosis-history-table th:nth-child(1) { width: 128px; }
.diagnosis-history-table th:nth-child(3) { width: 200px; }
.diagnosis-history-table th:nth-child(4) { width: 160px; }
.diagnosis-history-table th { position: sticky; top: 0; z-index: 1; background: var(--panel-soft); }
.diagnosis-history-table td { padding: 10px 16px; overflow-wrap: anywhere; }
.diagnosis-history-table time { display: grid; gap: 2px; font-size: 12px; }
.diagnosis-history-table time small { color: var(--muted); }
.diagnosis-history-mobile-meta { display: none; }
@media (max-width: 680px) {
  .diagnosis-history-heading { padding: 14px 16px; }
  .diagnosis-history-heading h3 { font-size: 16px; }
  .diagnosis-history-table th:nth-child(n+3), .diagnosis-history-table td:nth-child(n+3) { display: none; }
  .diagnosis-history-table th:nth-child(1) { width: 110px; }
  .diagnosis-history-table td { padding: 10px 12px; }
  .diagnosis-history-mobile-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
}

.karte-single-panel-page > .panel,
.karte-treatment-stack > .panel {
  min-width: 0;
  min-height: 0;
}

.karte-edit-fields {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.karte-edit-fields.panel-body {
  padding: 16px;
}

.karte-edit-fields:disabled input,
.karte-edit-fields:disabled select,
.karte-edit-fields:disabled textarea {
  background: #f3f5f4;
  color: var(--muted);
  cursor: not-allowed;
}

.karte-view-sections {
  border-top: 1px solid var(--line);
}

[data-select-user],
[data-select-master],
[data-select-person],
[data-select-horse],
[data-select-karte],
[data-history-karte] {
  cursor: pointer;
}

.keyboard-list-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

tr.keyboard-list-item:focus-visible td {
  background: var(--panel-soft);
}

.postal-lookup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.customer-person-import {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border-left: 3px solid var(--brand);
  background: var(--panel-soft);
}

.customer-person-import .button {
  min-height: 42px;
}

.postal-lookup-row .button {
  min-height: 42px;
}

.list-switcher {
  min-width: 0;
  flex: 0 0 auto;
  gap: 6px;
  margin: 0;
  padding: 8px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.master-list-switcher .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.master-list-switcher .tabler-icon {
  width: 18px;
  height: 18px;
}

.set-master-tooltip {
  position: fixed;
  z-index: 100;
  width: min(300px, calc(100vw - 16px));
  padding: 10px 12px;
  border: 1px solid #263f38;
  border-radius: 6px;
  background: #172b26;
  color: #fff;
  box-shadow: 0 8px 24px rgba(13, 33, 28, 0.24);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-line;
  pointer-events: none;
}

.people-list-view,
.person-detail-workspace {
  min-width: 0;
}

.person-editor-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
}

.person-editor-layout.single {
  grid-template-columns: 1fr;
}

.person-editor-main,
.person-editor-rail {
  min-width: 0;
  min-height: 0;
}

.person-editor-rail {
  overflow: auto;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: var(--panel-soft);
}

.compact-tabs {
  margin-bottom: 0;
}

.related-animals-section {
  box-shadow: none;
}

.related-animal-tabs {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

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

.section-heading h4 {
  margin: 0;
  font-size: 14px;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.related-animal-list {
  display: grid;
}

.related-animal-row {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.related-animal-row:last-child {
  border-bottom: 0;
}

.related-animal-link {
  min-width: 0;
  min-height: 44px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.related-animal-row:hover {
  background: var(--panel-soft);
}

.related-animal-row.selection-mode:hover {
  background: #fff;
}

.related-animal-link:disabled {
  color: var(--text);
  cursor: default;
  opacity: 1;
}

.related-animal-link span {
  color: var(--muted);
  font-size: 12px;
}

.animal-select-control {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding-left: 12px;
}

.animal-select-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.vaccine-workflow {
  display: grid;
  gap: 12px;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.vaccine-option-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.vaccine-option {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.vaccine-option:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.vaccine-option input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin: 0;
  accent-color: var(--brand);
}

.vaccine-option span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.vaccine-option strong,
.vaccine-option small {
  overflow-wrap: anywhere;
}

.vaccine-option small {
  color: var(--muted);
  font-size: 12px;
}

.button.secondary.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compact-empty {
  padding: 18px 10px;
}

@media (max-width: 680px) {
  .vaccine-option-list {
    grid-template-columns: 1fr;
  }
}

.price-history-section {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.price-history-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.price-history-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}

.price-history-row span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.compact-head {
  min-height: 0;
  padding: 0 0 12px;
}

.master-action-toolbar,
.yayoi-master-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.yayoi-master-actions {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.yayoi-mode-control {
  min-height: 34px;
  white-space: nowrap;
}

.yayoi-fields-section {
  display: grid;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.yayoi-field-group {
  display: grid;
  gap: 10px;
}

.yayoi-field-group h4 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.yayoi-field-grid {
  gap: 10px 12px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.permission-option {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text) !important;
  background: #fff;
  cursor: pointer;
}

.permission-option input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.password-actions {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.password-change-pane {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.password-change-pane h4 {
  margin: 0;
  font-size: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--panel-soft);
  color: var(--brand-dark);
}

.status.done {
  background: var(--brand-soft);
  color: var(--ok);
}

.status.open {
  background: var(--accent-soft);
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.empty {
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.list-main {
  min-width: 0;
}

.list-title {
  font-weight: 800;
}

.list-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 8px;
  align-items: end;
}

.inline-form.horse-name-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 128px auto;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
}

.media-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.media-preview {
  height: 110px;
  display: grid;
  place-items: center;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 800;
  overflow: hidden;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-caption {
  padding: 9px;
  font-size: 12px;
}

.media-caption > strong {
  display: block;
  overflow-wrap: anywhere;
}

.media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.media-actions .button {
  min-height: 30px;
}

.weight-chart {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 220px;
  min-height: 220px;
  overflow: hidden;
}

.weight-chart canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  display: block;
}

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

.inspection-result-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.inspection-result-head {
  min-height: 54px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-soft);
  cursor: pointer;
}

.inspection-result-head::marker {
  color: var(--muted);
}

.inspection-result-toolbar {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.inspection-result-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.karte-set-picker {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.karte-set-picker summary {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.karte-set-menu {
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.karte-set-option {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.karte-set-option:last-child {
  border-bottom: 0;
}

.karte-set-option strong,
.karte-set-option span {
  display: block;
}

.karte-set-option span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-line;
}

.karte-set-option:hover,
.karte-set-option:focus-visible {
  background: var(--panel-soft);
}

.inspection-result-table {
  display: grid;
}

.inspection-result-row {
  min-width: 0;
  min-height: 54px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(145px, 0.8fr) minmax(120px, 0.7fr) auto;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.inspection-item-choice {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspection-item-choice input {
  flex: 0 0 auto;
}

.inspection-value-control {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.inspection-value-control input {
  width: 100%;
  min-width: 0;
}

.inspection-value-control span,
.inspection-reference {
  color: var(--muted);
  font-size: 12px;
}

.inspection-comparison-panel {
  padding: 12px;
  border: 2px solid #f0a36f;
  border-radius: 6px;
  background: #fff8f3;
}

.inspection-date-selector {
  margin-top: 10px;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.inspection-comparison-chart {
  position: relative;
  width: 100%;
  height: 240px;
  min-height: 240px;
}

.inspection-comparison-chart canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.analytics-filter-row {
  display: flex;
  align-items: end;
  gap: 10px;
}

.analytics-filter-row .compact-field {
  width: min(190px, 100%);
}

.analytics-mode-switcher {
  overflow-x: auto;
}

.analytics-target-select {
  width: min(460px, 100%);
}

.analytics-export-actions {
  margin-left: auto;
  display: flex;
  gap: 7px;
}

.analytics-print-heading {
  display: none;
}

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

.analytics-summary {
  min-height: 96px;
  padding: 14px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.analytics-summary span {
  align-self: flex-start;
  margin-right: auto;
  color: var(--muted);
  font-size: 12px;
}

.analytics-summary strong {
  font-size: 25px;
}

.analytics-summary small {
  color: var(--muted);
}

.analytics-report-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: start;
  gap: 12px;
}

.analytics-print-area,
.analytics-report-section {
  min-width: 0;
}

.analytics-report-section .table-wrap {
  max-height: calc(100vh - 360px);
  overflow: auto;
}

.analytics-report-section table {
  min-width: 420px;
}

.analytics-report-section:nth-child(2) table {
  min-width: 640px;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

.karte-master-picker {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.karte-master-select-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #0b3026;
  color: #fff;
  box-shadow: var(--shadow);
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 35, 28, 0.54);
}

.modal-panel {
  width: min(100%, 440px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-body,
.modal-actions {
  padding: 16px 18px;
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-head h3,
.modal-body p {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.form-error {
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.inspection-items-editor {
  display: grid;
  gap: 10px;
}

.inspection-item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.5fr) minmax(90px, .7fr) minmax(100px, 1fr) minmax(100px, 1fr) 36px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.inspection-item-row .icon-button {
  margin-bottom: 1px;
}

.set-master-items-editor,
#setMasterItems {
  display: grid;
  gap: 10px;
}

.set-master-item-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px 36px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.set-master-item-row .icon-button {
  margin-bottom: 1px;
}

.document-workspace {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  overflow: hidden;
  align-items: stretch;
}

.document-workspace-head { grid-column: 1 / -1; display: flex; justify-content: flex-start; align-items: center; }
.document-console {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.document-type-tabs {
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  flex-wrap: nowrap;
}

.document-type-tabs .tab {
  min-width: 88px;
  min-height: 36px;
  padding: 6px 16px;
  border: 0;
  background: transparent;
  font-size: 13px;
}
.document-type-tabs .tab.active { background: var(--brand); color: #fff; }
.document-console-tabs { display: flex; padding: 0 16px; gap: 20px; border-bottom: 1px solid var(--line); }
.document-console-tabs button { min-height: 50px; border: 0; border-bottom: 2px solid transparent; padding: 0 2px; background: #fff; color: var(--muted); font-weight: 600; font-size: 13px; }
.document-console-tabs button.active { border-bottom-color: var(--brand); color: var(--brand-dark); }
.document-console-tabs button span { border-radius: 12px; background: var(--panel-soft); padding: 2px 6px; margin-left: 4px; font-size: 11px; }

.document-builder {
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.document-builder-heading { margin-bottom: 16px; flex-shrink: 0; }
.document-builder-heading h3 { margin: 0 0 6px; font-size: 16px; }
.document-builder-heading p { margin: 0; font-size: 12px; line-height: 1.65; }

.document-form { display: flex; min-height: 0; flex: 1; }
.document-form-fields { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; margin: 0; padding: 0; border: 0; }
.document-form-content { display: grid; align-content: start; min-height: 0; flex: 1; gap: 16px; overflow: auto; padding: 0 2px 4px; }
.document-address-fields { display: grid; grid-template-columns: minmax(0, 1fr) 145px; gap: 12px; }
.document-address-fields input, .document-address-fields select { min-width: 0; width: 100%; }
.document-estimate-lines { display: grid; gap: 12px; }
.document-estimate-line { padding: 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 10px; }
.document-estimate-line-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.document-estimate-line-head .icon-button { width: 26px; height: 26px; }
.document-estimate-line .field input, .document-estimate-line .field select { min-width: 0; width: 100%; }
.document-estimate-quantity-row { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: end; gap: 12px; }
.document-line-amount { display: grid; justify-items: end; gap: 4px; padding-bottom: 8px; }
.document-line-amount small { color: var(--muted); font-size: 11px; }
.document-issue-footer { flex-shrink: 0; margin-top: 12px; padding-top: 16px; background: #fff; border-top: 1px solid var(--line); display: grid; gap: 12px; }
.document-issue-footer .button { width: 100%; }
.document-selection-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.document-selection-summary > span { color: var(--muted); font-size: 12px; display: grid; gap: 4px; }
.document-selection-summary small { font-size: 11px; }
.document-selection-summary > strong { font-size: 22px; }

.document-candidate-list {
  border: 1px solid var(--line);
  border-radius: 8px;
}
.document-candidate-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.document-candidate-row:last-child { border-bottom: 0; }
.document-candidate-row:hover { background: var(--panel-soft); }
.document-candidate-row.selected { background: var(--brand-soft); }
.document-candidate-row input { width: 16px; height: 16px; accent-color: var(--brand); }
.document-candidate-copy { display: grid; min-width: 0; gap: 3px; }
.document-candidate-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.document-candidate-copy small { color: var(--muted); font-size: 11px; }
.document-candidate-amount { font-size: 13px; white-space: nowrap; }

.document-selection-head,
.document-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.document-history {
  min-height: 0;
  padding: 14px 16px 16px;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: auto;
}

.document-history .section-heading {
  margin-bottom: 10px;
}

.document-history > .search-input {
  margin-bottom: 10px;
}

.document-history-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 4px;
  margin-top: 12px;
}

.document-history-row {
  width: 100%;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.document-history-row:hover,
.document-history-row.selected {
  border-color: var(--line);
  background: var(--panel-soft);
}

.document-history-row > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.document-history-row > span:last-child {
  text-align: right;
}

.document-history-row small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-preview-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 16px;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef1f4;
}

.document-preview-toolbar {
  width: min(100%, 210mm);
  justify-content: space-between;
}
.document-preview-toolbar > div { display: grid; gap: 4px; font-size: 13px; }
.document-preview-toolbar small { color: var(--muted); font-size: 11px; }

.document-delete-actions {
  position: sticky;
  bottom: 0;
  width: min(100%, 210mm);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.document-delete-actions .field-help { margin: 0; }

.document-preview-toolbar .tabler-icon {
  width: 20px;
  height: 20px;
}

.document-empty-preview {
  width: min(100%, 210mm);
  min-height: 420px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
}
.document-empty-preview p { margin: 0; text-align: center; font-size: 13px; }
.document-draft-preview { width: min(100%, 210mm); padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 18px rgba(24, 45, 39, 0.05); }
.document-draft-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 20px; }
.document-draft-heading h2 { margin: 6px 0 0; font-size: 24px; }
.document-draft-heading .muted { font-size: 12px; }
.document-draft-label { padding: 4px 10px; border-radius: 6px; background: var(--panel-soft); color: var(--muted); font-size: 12px; white-space: nowrap; }
.document-draft-meta { display: grid; gap: 12px; margin: 24px 0; }
.document-draft-meta > div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 12px; }
.document-draft-meta dt { color: var(--muted); font-size: 12px; }
.document-draft-meta dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.document-draft-lines > div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.document-draft-lines > div > span { display: grid; gap: 5px; min-width: 0; }
.document-draft-lines strong { font-size: 14px; overflow-wrap: anywhere; }
.document-draft-lines small { color: var(--muted); font-size: 12px; }
.document-draft-lines > div > strong { white-space: nowrap; }
.document-draft-total { margin-top: 16px; padding: 18px; border-radius: 8px; background: var(--brand-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--brand-dark); }
.document-draft-total strong { font-size: 26px; }
.document-draft-preview > p { margin: 20px 0 0; font-size: 12px; }
.document-draft-empty { min-height: 230px; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; color: var(--muted); }
.document-draft-empty .tabler-icon { width: 40px; height: 40px; }
.document-draft-empty p { margin: 0; font-size: 12px; }

.document-empty-preview .tabler-icon {
  width: 42px;
  height: 42px;
}

.document-sheet {
  width: min(100%, 210mm);
  min-height: 297mm;
  padding: 18mm 16mm;
  border: 1px solid #ccd4d0;
  background: #fff;
  color: #17211f;
  box-shadow: 0 10px 28px rgba(24, 45, 39, 0.12);
}

.document-sheet-head {
  min-height: 70px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 12px;
}

.document-sheet-head h1 {
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 2px solid #17211f;
  font-size: 27px;
  text-align: center;
}

.document-sheet-meta {
  justify-self: end;
  text-align: right;
  color: #4e5b57;
  font-size: 11px;
  line-height: 1.7;
}

.document-number {
  white-space: nowrap;
}

.document-parties {
  min-height: 150px;
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.68fr);
  gap: 40px;
}

.document-recipient,
.document-issuer {
  font-size: 12px;
  line-height: 1.75;
}

.document-recipient > strong {
  display: block;
  margin-top: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid #76817e;
  font-size: 18px;
}

.document-recipient p {
  margin: 18px 0 0;
}

.document-issuer {
  padding-top: 26px;
  justify-self: end;
  text-align: right;
  width: 100%;
}

.document-issuer > strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.document-total {
  width: 58%;
  margin: 8px 0 24px;
  padding: 8px 10px;
  border-bottom: 2px solid #17211f;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.document-total span {
  font-size: 13px;
}

.document-total strong {
  font-size: 22px;
}

.document-detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.document-detail-table th,
.document-detail-table td {
  padding: 7px 6px;
  border: 1px solid #6f7b77;
  text-align: right;
  vertical-align: top;
}

.document-detail-table th {
  background: #eef2f0;
  font-weight: 700;
}

.document-detail-table th:nth-child(1),
.document-detail-table td:nth-child(1) {
  width: 19%;
  text-align: left;
}

.document-detail-table th:nth-child(2),
.document-detail-table td:nth-child(2) {
  width: 35%;
  text-align: left;
}

.document-detail-table th:nth-child(3),
.document-detail-table td:nth-child(3) {
  width: 12%;
}

.document-detail-table td small {
  display: block;
  color: #59635f;
}

.document-detail-table.is-estimate :is(th, td):nth-child(1) { width: 44%; }
.document-detail-table.is-estimate :is(th, td):nth-child(2) { width: 14%; text-align: right; }
.document-detail-table.is-estimate :is(th, td):nth-child(3) { width: 21%; }

.document-note {
  margin-top: 22px;
  padding: 10px;
  border: 1px solid #aeb8b4;
  font-size: 11px;
}

.document-note p {
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .layout-two,
  .user-master-layout,
  .master-workspace,
  .people-workspace,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .master-workspace.yayoi-wide-workspace {
    grid-template-columns: 1fr;
  }

  .user-editor-pane,
  .master-editor-pane,
  .person-editor-pane {
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .karte-detail-workspace {
    grid-template-columns: 1fr;
  }

  .karte-header-status {
    margin-left: 0;
  }

  .karte-entry-columns,
  .karte-record-page {
    grid-template-columns: 1fr;
  }

  .karte-record-page {
    grid-template-rows: auto;
  }

  .karte-core-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .karte-clinical-column {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .karte-treatment-stack {
    grid-template-rows: auto;
  }

  .karte-text-field textarea {
    min-height: 220px;
  }

  .document-workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .document-workspace-head { flex-wrap: wrap; }
  .document-form-content { overflow: visible; }
  .document-history-list { max-height: 450px; }

  .inspection-item-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .set-master-item-row {
    grid-template-columns: minmax(0, 1fr) 90px 36px;
  }

  .inspection-item-row .icon-button {
    grid-column: 2;
    justify-self: end;
  }

  .document-preview-pane {
    overflow: auto;
  }

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

  .person-editor-rail {
    max-height: 520px;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .karte-history-rail {
    grid-template-rows: 160px 320px;
  }

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

  .horse-editor-rail {
    grid-template-rows: repeat(3, minmax(220px, 320px));
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  body {
    min-width: 0;
    background: #fff;
  }

  .sidebar,
  .topbar,
  .document-console,
  .document-workspace-head,
  .document-draft-preview,
  .document-empty-preview,
  .document-preview-toolbar,
  .document-delete-actions,
  .toast {
    display: none !important;
  }

  .app-shell,
  .main,
  .document-workspace,
  .document-preview-pane {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .document-sheet {
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .document-preview-pane { border: 0; border-radius: 0; background: #fff; }

  body.printing-analytics .main > :not(.analytics-page),
  body.printing-analytics .analytics-filter {
    display: none !important;
  }

  body.printing-analytics .analytics-print-heading {
    display: block;
    margin-bottom: 8mm;
  }

  body.printing-analytics .analytics-summary-grid,
  body.printing-analytics .analytics-report-grid {
    grid-template-columns: 1fr;
  }

  body.printing-analytics .analytics-summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  body.printing-analytics .analytics-summary,
  body.printing-analytics .analytics-report-section {
    break-inside: avoid;
    box-shadow: none;
  }

  body.printing-analytics .analytics-report-section .table-wrap {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .main {
    width: 100%;
    padding: 14px 12px 24px;
  }

  .analytics-filter-row,
  .analytics-export-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .analytics-export-actions {
    margin-left: 0;
  }

  .analytics-filter-row .compact-field {
    width: 100%;
  }

  .analytics-summary-grid,
  .analytics-report-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    top: 0;
    padding: 10px 12px;
    gap: 10px;
    box-shadow: 0 1px 0 var(--line);
  }

  .brand {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border-bottom: 0;
  }

  .brand-title {
    font-size: 19px;
  }

  .brand-subtitle {
    display: none;
  }

  .mobile-menu-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-size: 25px;
    line-height: 1;
  }

  .sidebar .nav,
  .sidebar .session-box {
    display: none;
  }

  .sidebar.menu-open .nav {
    display: grid;
  }

  .sidebar.menu-open .session-box {
    display: block;
    margin-top: 0;
  }

  .sidebar.menu-open .nav {
    grid-template-columns: 1fr;
  }

  .nav button {
    min-height: 44px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: none;
  }

  .page-title {
    font-size: 21px;
  }

  .topbar > .toolbar {
    display: none;
  }

  .horse-list-view > .panel-head,
  .karte-list-view > .panel-head {
    min-height: 52px;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .horse-list-view > .panel-head .search-input,
  .karte-list-view > .panel-head .search-input {
    min-width: 0;
    flex: 1 1 auto;
  }

  .person-list-head {
    min-height: 52px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .list-switcher {
    padding: 7px 8px;
  }

  .danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .horse-image-section {
    grid-template-columns: 1fr;
  }

  .horse-image-preview {
    width: min(100%, 240px);
  }

  .panel-body {
    padding: 12px;
  }

  .panel-head {
    min-height: 0;
    padding: 12px;
  }

  .mobile-detail-workspace {
    display: block;
  }

  .mobile-detail-workspace > .mobile-editor-pane {
    display: none;
  }

  .mobile-detail-workspace.mobile-editor-open > .mobile-list-pane {
    display: none;
  }

  .mobile-detail-workspace.mobile-editor-open > .mobile-editor-pane {
    width: 100%;
    display: block;
  }

  .mobile-list-back {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 40px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 21px;
    line-height: 1;
  }

  .editor-heading {
    width: 100%;
  }

  .karte-horse-summary {
    flex: 1 1 auto;
  }

  .karte-horse-image {
    width: 60px;
    flex-basis: 60px;
  }

  .karte-header-status {
    width: 100%;
    justify-content: space-between;
  }

  .karte-status-badges {
    justify-content: flex-start;
  }

  .karte-core-fields {
    grid-template-columns: 1fr;
  }

  .weight-chart {
    height: 190px;
    min-height: 190px;
  }

  .inspection-result-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .inspection-result-row > .inspection-item-choice {
    grid-column: 1 / -1;
  }

  .inspection-value-control,
  .inspection-reference {
    grid-column: 1;
  }

  .inspection-result-row > .button {
    grid-column: 2;
    grid-row: 2 / span 2;
  }

  .inspection-comparison-chart {
    height: 200px;
    min-height: 200px;
  }

  .karte-history-rail {
    grid-template-rows: 140px 280px;
  }

  .karte-horse-choice-list {
    grid-template-columns: 1fr;
  }

  .horse-list-table th:nth-child(2),
  .horse-list-table td:nth-child(2),
  .horse-list-table th:nth-child(3),
  .horse-list-table td:nth-child(3),
  .horse-list-table th:nth-child(4),
  .horse-list-table td:nth-child(4),
  .horse-list-table th:nth-child(7),
  .horse-list-table td:nth-child(7),
  .horse-list-table th:nth-child(8),
  .horse-list-table td:nth-child(8),
  .horse-list-table th:nth-child(10),
  .horse-list-table td:nth-child(10),
  .people-list-table th:nth-child(2),
  .people-list-table td:nth-child(2),
  .people-list-table th:nth-child(3),
  .people-list-table td:nth-child(3),
  .karte-list-table th:nth-child(3),
  .karte-list-table td:nth-child(3),
  .karte-list-table th:nth-child(4),
  .karte-list-table td:nth-child(4),
  .karte-list-table th:nth-child(5),
  .karte-list-table td:nth-child(5),
  .karte-list-table th:nth-child(6),
  .karte-list-table td:nth-child(6) {
    display: none;
  }

  .horse-list-table,
  .people-list-table,
  .karte-list-table {
    table-layout: fixed;
  }

  .horse-list-table th,
  .horse-list-table td,
  .people-list-table th,
  .people-list-table td,
  .karte-list-table th,
  .karte-list-table td {
    padding: 12px 8px;
    overflow-wrap: anywhere;
  }

  .master-list-switcher {
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .master-list-switcher .tab {
    min-width: max-content;
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar > .button {
    min-height: 40px;
  }

  .master-action-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .yayoi-master-actions {
    width: 100%;
    padding-top: 8px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .topbar .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .facility-scope-control {
    width: 100%;
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .search-input,
  .field input,
  .field select,
  .field textarea {
    max-width: 100%;
  }

  .card-grid,
  .media-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form.horse-name-form {
    grid-template-columns: 1fr;
  }

  .postal-lookup-row {
    grid-template-columns: 1fr;
  }

  .customer-person-import {
    grid-template-columns: 1fr;
  }
}

/* Shared interaction hierarchy. */
:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
.nav { gap: 6px; }
.nav button { min-height: 42px; font-size: 14px; }
.nav-divider { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.brand { align-items: center; }
.brand-mark { color: var(--brand); }
.brand-copy { flex: 1; }
.sidebar-logout { background: transparent; color: var(--muted); }
.sidebar-logout:hover { background: #fff; color: var(--text); }
.panel { border-radius: 10px; }
.panel-head { border-radius: 10px 10px 0 0; }
.button { font-size: 13px; font-weight: 600; }
.button .tabler-icon { width: 18px; height: 18px; }
.button.small { min-height: 32px; }
.field input, .field select, .field textarea, .search-input { font-size: 14px; }
.field input:hover, .field select:hover, .field textarea:hover, .search-input:hover { border-color: #b6bec7; }
.status { font-weight: 600; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.status.status-diagnosis-done,
.status.status-billing-done,
.status.status-payment-done { background: #e6efff; color: #2456a4; }
.status.status-billing-open { background: #fff0df; color: #985311; }
.status.status-payment-open { background: #fde9eb; color: #a53a45; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--muted); font-size: 20px; line-height: 1;
}
.icon-button:hover { background: #fff; border-color: var(--brand); color: var(--brand-dark); }
.storage-status { font-weight: 400; }
.storage-status.connected { font-size: 11px; }
.karte-entry-tabs { padding: 0 12px; gap: 16px; flex-wrap: nowrap; overflow-x: auto; }
.karte-entry-tabs .tab {
  flex: 0 0 auto;
  min-height: 46px; border: 0; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 0 2px; background: transparent; font-size: 13px;
}
.karte-entry-tabs .tab.active { border-bottom-color: var(--brand); color: var(--brand-dark); }
.karte-entry-tabs .tab:hover { color: var(--brand-dark); }
.karte-entry-form > .panel-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; padding: 14px 16px; }
.karte-editor-actions .button { min-width: 72px; min-height: 36px; }
.karte-horse-copy .panel-title { font-size: 18px; }
.karte-history-panel .list-item { border-radius: 6px; padding: 4px 6px; min-height: 32px; gap: 6px; align-items: center; }
.karte-history-panel .list-main { min-width: 0; }
.karte-history-panel .list-title { font-size: 12px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.karte-history-markers .status { min-height: 20px; padding: 0 6px; }
.karte-column-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.karte-record-page { background: #fff; }
@media screen and (min-width: 1041px) and (max-width: 1390px) {
  .main { padding: 22px 20px 28px; }
  .karte-detail-workspace { grid-template-columns: 200px minmax(0, 1fr); gap: 12px; }
}
@media screen and (min-width: 1041px) and (max-width: 1279px) {
  .karte-entry-columns { display: block; overflow: auto; }
  .karte-record-fields, .karte-record-page, .karte-clinical-column,
  .karte-clinical-pages, .karte-clinical-fields, .karte-clinical-page,
  .karte-treatment-stack { height: auto; overflow: visible; }
  .karte-record-page { grid-template-rows: auto; }
  .karte-text-field textarea { min-height: 220px; resize: vertical; }
  .karte-clinical-column { border-left: 0; border-top: 1px solid var(--line); }
  .karte-treatment-stack { display: grid; grid-template-rows: auto; }
}
@media screen and (min-width: 681px) and (max-width: 1040px) {
  .sidebar { padding: 16px 24px; gap: 12px; border-bottom: 1px solid var(--line); }
  .brand { min-height: 40px; padding: 0; border: 0; }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .nav-divider { display: none; }
  .session-box { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 12px; }
  .sidebar-logout { width: auto; margin: 0; }
}
@media screen and (max-width: 680px) {
  .nav-divider { margin-top: 8px; }
  .document-workspace-head { align-items: stretch; flex-direction: column; }
  .document-type-tabs .tab { flex: 1; min-width: 0; }
  .document-address-fields { grid-template-columns: minmax(0, 1fr); }
  .document-preview-pane { padding: 12px; }
  .document-draft-preview { padding: 20px; }
  .document-draft-total strong { font-size: 22px; }
  .document-preview-toolbar { flex-wrap: wrap; }
  .document-sheet { padding: 24px 14px; min-height: 0; }
  .document-sheet-head { grid-template-columns: 1fr; }
  .document-head-spacer { display: none; }
  .document-sheet-meta { grid-row: 1; }
  .document-sheet-head h1 { justify-self: center; font-size: 24px; letter-spacing: 0.1em; }
  .document-parties { grid-template-columns: 1fr; }
  .document-detail-table th, .document-detail-table td { padding: 8px 4px; font-size: 10px; }
  .document-detail-table { table-layout: fixed; }
  .document-detail-table th:nth-child(1), .document-detail-table td:nth-child(1) { width: 22%; }
  .document-detail-table th:nth-child(2), .document-detail-table td:nth-child(2) { width: 28%; }
  .document-detail-table th:nth-child(3), .document-detail-table td:nth-child(3) { width: 12%; }
  .document-detail-table td { overflow-wrap: anywhere; }
  .karte-entry-tabs { gap: 12px; }
  .karte-entry-form > .panel-head { grid-template-columns: minmax(0, 1fr) auto; padding: 12px; }
  .karte-entry-form > .panel-head > .editor-heading { grid-column: 1 / -1; }
  .karte-header-status { flex-wrap: wrap; }
  .karte-edit-fields.panel-body { padding: 12px; }
  .karte-editor-actions { justify-content: flex-end; }
}

@media screen and (max-width: 1040px) {
  .karte-detail-workspace > #karteForm { grid-row: 1; }
  .karte-detail-workspace > .karte-history-rail { grid-row: 2; }
}
.karte-history-markers { flex-shrink: 0; }

/* Draw navigation chevrons without FullCalendar's embedded icon font,
   which is blocked by the application's self-only font CSP. */
.month-calendar .fc-icon-chevron-left,
.month-calendar .fc-icon-chevron-right {
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.month-calendar .fc-icon-chevron-left::before,
.month-calendar .fc-icon-chevron-right::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(135deg);
}
.month-calendar .fc-icon-chevron-right::before { transform: rotate(-45deg); }
.sidebar-toggle { display: none; }
@media screen and (min-width: 1041px) {
  .sidebar-toggle {
    position: absolute;
    top: 94px;
    left: 20px;
    z-index: 35;
    display: grid;
    place-items: center;
    align-self: flex-end;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
  }
  .sidebar-toggle:hover { background: var(--panel-soft); color: var(--text); }
  .sidebar-collapsed { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar-collapsed .sidebar { padding-inline: 14px; }
  .sidebar-collapsed .brand-copy,
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .session-copy,
  .sidebar-collapsed .sidebar-logout-label { display: none; }
  .sidebar .session-box { padding: 8px 0; }
  .sidebar .session-summary { min-height: 64px; padding-inline: 8px; }
  .sidebar .sidebar-logout { padding-inline: 8px; }
  .sidebar .nav { margin-top: 24px; }
}

/* Shared list geometry: primary action and search stay in the same position. */
.horse-list-view,
.people-list-view,
.karte-list-view,
.master-page-panel {
  width: 100%;
  min-width: 0;
}
.horse-list-view > .panel-head,
.people-list-view > .panel-head,
.karte-list-view > .panel-head,
.master-page-panel > .panel-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  grid-auto-rows: 38px;
  gap: 12px;
  min-height: 67px;
  padding: 14px 16px;
  flex: 0 0 auto;
}
#newHorseBtn, #newPersonBtn, #newKarteBtn, #newMasterBtn, #newCalendarEventBtn {
  width: 112px;
  min-width: 112px;
  height: 38px;
  padding: 0 10px;
  flex-shrink: 0;
}
.horse-list-view > .panel-head .search-input,
.people-list-view > .panel-head .search-input,
.karte-list-view > .panel-head .search-input {
  min-width: 0;
  width: 100%;
  height: 38px;
}
.person-list-head > .checkbox-control { grid-column: 1 / -1; }
.person-list-head > .button.secondary { justify-self: start; }
.master-action-toolbar {
  grid-column: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.master-page-panel > .panel-head { grid-template-columns: auto minmax(0, 1fr); }
.master-page-panel > .panel-head .search-input { height: 38px; min-width: 0; }
.calendar-main-panel { padding: 0; }
.calendar-action-bar {
  border-bottom: 1px solid var(--line);
  min-height: 67px;
  padding: 14px 16px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
}
.month-calendar { margin: 0 16px 16px; }
@media screen and (min-width: 1041px) {
  .horse-list-view, .people-list-view, .karte-list-view {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .horse-list-view > .table-wrap,
  .people-list-view > .table-wrap,
  .karte-list-view > .table-wrap {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    scrollbar-gutter: stable;
  }
  .master-workspace.yayoi-wide-workspace {
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  }
}
@media screen and (max-width: 680px) {
  .horse-list-view > .panel-head,
  .people-list-view > .panel-head,
  .karte-list-view > .panel-head,
  .master-page-panel > .panel-head {
    min-height: 59px;
    padding: 10px;
    gap: 8px;
  }
  .calendar-action-bar { min-height: 59px; padding: 10px; }
  .month-calendar { margin: 0 10px 10px; }
}
@media screen and (max-width: 1040px) {
  .app-shell { align-content: start; }
}
#newHorseBtn, #newPersonBtn, #newKarteBtn, #newMasterBtn, #newCalendarEventBtn {
  min-height: 38px;
}

.search-control { position: relative; min-width: 0; width: 100%; }
.search-control .search-input { height: 38px; padding-left: 36px; padding-right: 52px; }
.search-control-icon { position: absolute; left: 12px; top: 10px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search-control-icon::before { content: ""; position: absolute; width: 12px; height: 12px; border: 1.7px solid currentColor; border-radius: 50%; }
.search-control-icon::after { content: ""; position: absolute; width: 7px; height: 1.7px; top: 13px; left: 11px; background: currentColor; transform: rotate(45deg); }
.search-options-toggle { position: absolute; top: 4px; right: 6px; width: 34px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px; color: var(--muted); background: transparent; }
.search-options-icon { display: grid; gap: 4px; width: 18px; }
.search-options-icon i { position: relative; display: block; height: 1.5px; background: currentColor; }
.search-options-icon i::before { content: ""; position: absolute; left: 4px; top: -1.5px; width: 4.5px; height: 4.5px; border-radius: 50%; background: currentColor; }
.search-options-icon i:nth-child(2)::before { left: 11px; }
.search-options-icon i:nth-child(3)::before { left: 6px; }
.search-options-toggle:hover, .search-options-toggle.has-filters { background: var(--brand-soft); color: var(--brand-dark); }
.search-filter-count { position: absolute; top: -3px; right: -3px; min-width: 15px; height: 15px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 10px; line-height: 15px; }
.search-options-host { flex: 0 0 auto; min-width: 0; }
.search-options-dialog { position: fixed; inset: 0; margin: auto; padding: 0; width: 560px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--panel); box-shadow: 0 12px 40px rgba(27, 39, 51, .18); overflow: auto; }
.search-options-dialog::backdrop { background: rgba(27, 39, 51, .08); }
.search-options-heading { position: sticky; top: 0; z-index: 1; background: var(--panel); display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 10px; }
.search-options-heading h3 { margin: 0; font-size: 18px; font-weight: 600; }
.search-options-fields { display: grid; gap: 12px; padding: 12px 20px 20px; }
.search-options-group { border-top: 1px solid var(--line); padding-top: 8px; }
.search-options-group > summary { padding: 6px 0; cursor: pointer; font-size: 13px; font-weight: 600; }
.search-options-group > div { display: grid; gap: 12px; padding: 10px 0 4px; }
.search-option-row { grid-template-columns: 120px minmax(0, 1fr); align-items: center; gap: 16px; }
.search-option-row > span { color: var(--muted); font-size: 13px; }
.search-options-dialog .field input, .search-options-dialog .field select { min-width: 0; min-height: 36px; padding: 6px 9px; }
.search-options-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.search-options-footer .button { min-width: 88px; }
.search-options-dialog .form-error { margin: 0; padding: 0 20px 12px; }
.search-options-dialog .form-error:empty { display: none; }
.search-filter-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.search-filter-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid #cbded3; border-radius: 16px; padding: 4px 10px; max-width: 100%; overflow-wrap: anywhere; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; }
.search-filters-clear { border: 0; background: transparent; color: var(--muted); padding: 4px 6px; font-size: 12px; }
.search-filters-clear:hover { color: var(--brand-dark); }
@media screen and (max-width: 680px) {
  .search-option-row { grid-template-columns: 1fr; gap: 6px; }
  .search-options-heading { padding: 12px 16px 8px; }
  .search-options-fields { padding: 10px 16px 16px; }
  .search-options-footer { padding: 12px 16px; }
  .search-options-footer .button { min-height: 40px; }
  .search-filter-chips { padding: 0 10px 10px; }
  .master-page-panel > .panel-head { grid-template-columns: 1fr; grid-auto-rows: auto; }
}
@media print { .search-options-host, .search-control { display: none; } }



.breed-bulk-toolbar { display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); font-size: 12px; background: var(--panel); }
.breed-bulk-toolbar .button:disabled { opacity: .45; cursor: default; }
/* Keep list controls outside the scrolling rows and column labels visible. */
@media screen {
  .table-wrap > table > thead > tr > th {
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: inset 0 -1px 0 var(--line);
  }
  .master-list-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .master-list-pane > .table-wrap {
    min-height: 0;
    flex: 1 1 auto;
    overflow: auto;
    scrollbar-gutter: stable;
  }
  .analytics-report-section .table-wrap,
  .layout-two .table-wrap { max-height: 65dvh; }
}
@media screen and (max-width: 1040px) {
  .master-list-pane,
  .user-list-pane,
  .horse-list-view > .table-wrap,
  .people-list-view > .table-wrap,
  .karte-list-view > .table-wrap,
  .audit-log-table-wrap { max-height: 65dvh; }
}
.breed-master-table .breed-select-cell { width: 36px; padding: 10px 8px; text-align: center; }
.breed-master-table .breed-name-cell { width: 30%; }
.breed-master-table .breed-status-cell { width: 80px; }
.breed-master-table td { overflow-wrap: anywhere; }
.breed-select-cell input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--brand); cursor: pointer; }
.breed-display-status { display: inline-block; white-space: nowrap; padding: 3px 7px; border-radius: 4px; font-size: 12px; }
.breed-display-status.displayed { color: #21654a; background: #e6f4ed; }
.breed-display-status.not-displayed { color: #5c626a; background: #edf0f3; }

/* Compact horse editor; preserve comfortable controls on small screens. */
.horse-profile-row { display: flex; min-width: 0; gap: 16px; align-items: center; }
.horse-target-control { flex: 0 0 auto; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-weight: 600; white-space: nowrap; cursor: pointer; }
.horse-target-control input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.horse-name-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.horse-basic-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.horse-editor-main > .panel-body { gap: 6px; padding: 10px 16px; }
.horse-editor-main .grid { gap: 8px; }
.horse-editor-main .field { gap: 4px; min-width: 0; }
.horse-editor-main .field input,
.horse-editor-main .field select { min-height: 34px; padding: 5px 8px; }
.horse-editor-main .field input[type="checkbox"] { min-height: 16px; padding: 0; }
.horse-editor-main .field textarea { min-height: 44px; height: 44px; padding: 6px 8px; }
.horse-editor-main .horse-image-section { flex: 0 1 auto; width: 390px; max-width: calc(100% - 148px); min-width: 0; grid-template-columns: 180px minmax(0, 1fr); padding: 8px; gap: 12px; }
.horse-editor-main .horse-image-preview { width: 180px; height: 112px; aspect-ratio: auto; font-size: 12px; }
.horse-editor-main .horse-image-preview img { object-fit: contain; }
.horse-editor-main .horse-image-controls { gap: 8px; font-size: 13px; }
.horse-image-controls .toolbar { gap: 4px; }
.horse-image-controls .button { min-height: 32px; padding: 4px 8px; font-size: 12px; }
.horse-affiliations-editor .section-heading { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
.horse-affiliations-editor .section-heading h4 { margin-right: auto; }
.horse-affiliations-editor .section-heading small { font-size: 11px; font-weight: 400; }
.horse-management-actions > summary { color: var(--muted); cursor: pointer; font-size: 12px; }
.horse-management-actions .danger-zone { margin-top: 8px; }
.horse-side-head { padding: 9px 12px; }
.horse-side-head .panel-title { font-size: 14px; }
.horse-side-scroll { padding: 8px 12px; }
.horse-side-list { gap: 0; margin-top: 6px; }
.horse-name-history-copy .list-meta { margin-top: 2px; }
.horse-editor-rail .compact-empty { padding: 12px; }

@media screen and (min-width: 1041px) {
  .horse-editor-rail { padding: 10px; gap: 10px; }
  .horse-editor-layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 350px); }
}
@media screen and (min-width: 1041px) and (max-height: 760px) {
  .horse-editor-main > .panel-body { padding-block: 8px; }
  .horse-editor-main .grid { gap: 6px; }
  .horse-editor-main .horse-image-preview { height: 96px; }
  .horse-editor-main .field textarea { min-height: 36px; height: 36px; }
}
@media screen and (max-width: 1040px) {
  .horse-editor-rail { grid-template-rows: auto; align-content: start; }
  .horse-side-scroll { max-height: 260px; }
}
@media screen and (max-width: 680px) {
  .horse-profile-row { gap: 8px; flex-wrap: wrap; }
  .horse-editor-main .horse-image-section { flex-basis: 100%; max-width: 100%; grid-template-columns: 150px minmax(0, 1fr); gap: 8px; }
  .horse-editor-main .horse-image-preview { width: 150px; height: 110px; }
  .horse-editor-main > .panel-body { padding: 12px; }
  .horse-basic-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .horse-editor-main .field input, .horse-editor-main .field select { min-height: 40px; }
}
