:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --line: #d9e1dd;
  --line-strong: #b9c7c1;
  --text: #18201d;
  --muted: #68736e;
  --accent: #00979a;
  --accent-strong: #007a7c;
  --accent-soft: #d9f2f1;
  --warning: #b87503;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(32, 45, 40, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

.home-body {
  min-height: 100vh;
  background: #1f6f8f;
  color: #fff;
}

.home-hero {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #2f8faf url("/assets/home-mountain.png") center bottom / cover no-repeat;
  isolation: isolate;
}

.home-hero::before,
.home-hero::after {
  content: "";
  position: absolute;
  inset: -12% auto auto -8%;
  width: 55vw;
  height: 145vh;
  transform: rotate(-42deg);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  z-index: -1;
}

.home-hero::after {
  inset: -18% -18% auto auto;
  width: 38vw;
  background: rgba(255, 255, 255, 0.05);
}

.home-hero-shade {
  position: absolute;
  inset: 0;
  background: rgba(16, 52, 65, 0.18);
  z-index: -1;
}

.home-content {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 82px 0 118px;
  text-align: center;
}

.home-kicker {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.home-content h1 {
  color: #fff;
  font-size: clamp(46px, 8vw, 86px);
  line-height: 1.05;
  font-weight: 850;
  text-shadow: 0 8px 28px rgba(0, 39, 54, 0.22);
}

.home-subtitle {
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 650;
}

.home-entry-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(18px, 3vw, 36px);
  margin-top: 54px;
}

.home-entry {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 96px;
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  font-weight: 780;
}

.home-entry-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 12px 34px rgba(0, 43, 58, 0.18);
  font-size: 24px;
  font-weight: 850;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.home-entry:hover .home-entry-icon,
.home-entry:focus-visible .home-entry-icon {
  transform: translateY(-4px);
  border-color: #fff;
  background: rgba(255, 255, 255, 0.22);
}

.home-footer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.home-footer a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
}

.home-footer a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.2;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.manager-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.manager-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
  font-weight: 650;
  text-align: center;
  white-space: normal;
}

.manager-link[type="button"] {
  appearance: none;
}

.manager-link[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.manager-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  font-weight: 750;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  grid-template-areas:
    "calendar visit"
    "tasks visit";
  gap: 18px;
  align-items: start;
}

.calendar-pane,
.visit-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-pane {
  grid-area: calendar;
  padding: 20px;
}

.visit-pane {
  grid-area: visit;
  position: sticky;
  top: 16px;
  padding: 20px;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.calendar-toolbar h2 {
  font-size: 30px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

#monthSummary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.view-switch {
  display: inline-flex;
  gap: 0;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.view-switch-button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.view-switch-button:last-child {
  border-right: 0;
}

.view-switch-button.is-active {
  background: var(--accent);
  color: #fff;
}

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

.icon-button,
.text-button,
.link-button,
.primary-button,
.record-action {
  border-radius: 6px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 32px;
  line-height: 1;
}

.text-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

.weekdays span {
  padding: 12px 8px;
  text-align: center;
}

.calendar-grid {
  border-left: 1px solid var(--line);
}

.day-cell {
  position: relative;
  min-height: 108px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px;
  text-align: left;
  cursor: pointer;
}

.calendar-grid.is-week-view .day-cell {
  min-height: 172px;
}

.day-cell.has-many-visits {
  min-height: 142px;
}

.calendar-grid.is-week-view .day-cell.has-many-visits {
  min-height: 190px;
}

.day-cell:hover {
  background: #f7fbfa;
}

.day-cell:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.day-cell.is-muted {
  color: #9aa49f;
  background: #fafbfb;
}

.day-cell.is-selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  background: var(--accent-soft);
}

.day-cell.is-today .day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.date-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.day-number {
  font-size: 20px;
  font-weight: 720;
  line-height: 1;
}

.lunar-text {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: #fff2d7;
  color: #6f4700;
  font-size: 12px;
  font-weight: 800;
}

.visit-preview {
  display: grid;
  gap: 3px;
  margin-top: 8px;
}

.preview-item {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  border: 0;
  border-radius: 4px;
  background: transparent;
  padding: 1px 2px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #33413b;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
}

.preview-item:hover,
.preview-item:focus-visible {
  background: rgba(0, 151, 154, 0.1);
  outline: 0;
}

.preview-time {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.preview-client {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-more {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.selected-day {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.selected-day p {
  color: var(--accent-strong);
  font-weight: 750;
}

.selected-day h2 {
  margin-top: 5px;
  font-size: 25px;
}

.records-section,
.visit-form {
  padding-top: 18px;
}

.task-section {
  display: grid;
  gap: 10px;
}

.manager-task-pane {
  grid-area: tasks;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.task-notice {
  border: 1px solid rgba(0, 151, 154, 0.28);
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.45;
  outline: 0;
}

.task-notice:focus {
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.16);
}

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

.section-heading h3 {
  font-size: 17px;
}

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

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

.empty-record {
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfc;
}

.record-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.record-card h4 {
  margin: 0;
  font-size: 16px;
}

.record-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.record-period {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}

.record-field {
  margin-top: 6px;
  color: #2f3c37;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.record-field strong {
  color: var(--muted);
  font-weight: 700;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.record-action,
.link-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 750;
}

.record-action.danger {
  color: var(--danger);
}

.visit-form {
  display: grid;
  gap: 13px;
}

.period-field {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.period-field legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
  color: #34423d;
  font-size: 14px;
  font-weight: 760;
}

.visit-form .period-field label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

.visit-form .period-field input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.visit-form .period-field label span {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.visit-form .period-field label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.customer-field {
  position: relative;
}

.customer-suggestions {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.customer-suggestion {
  width: 100%;
  display: grid;
  gap: 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.customer-suggestion:last-child {
  border-bottom: 0;
}

.customer-suggestion:hover,
.customer-suggestion:focus {
  background: var(--accent-soft);
}

.customer-suggestion span {
  color: var(--muted);
  font-size: 12px;
}

.visit-form label {
  display: grid;
  gap: 7px;
}

.visit-form label span {
  color: #34423d;
  font-size: 14px;
  font-weight: 760;
}

.visit-form input,
.visit-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: 0;
}

.visit-form textarea {
  resize: vertical;
  min-height: 96px;
}

.visit-form input:focus,
.visit-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.16);
}

.primary-button {
  min-height: 46px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover,
.manager-link[aria-current="page"]:hover {
  background: var(--accent-strong);
}

.form-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.form-message.is-error {
  color: var(--danger);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-shell {
  width: min(420px, 100%);
}

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

.login-panel h1 {
  margin-bottom: 22px;
}

.login-form,
.password-panel {
  display: grid;
  gap: 14px;
}

.login-form label,
.password-panel label,
.admin-filters label,
.task-form label {
  display: grid;
  gap: 7px;
}

.login-form label span,
.password-panel label span,
.admin-filters label span,
.task-form label span {
  color: #34423d;
  font-size: 14px;
  font-weight: 760;
}

.login-form input,
.login-form select,
.password-panel input,
.password-panel select,
.password-panel textarea,
.admin-filters input,
.admin-filters select,
.task-form input,
.task-form select,
.task-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: 0;
}

.login-form input:focus,
.login-form select:focus,
.password-panel input:focus,
.password-panel select:focus,
.password-panel textarea:focus,
.admin-filters input:focus,
.admin-filters select:focus,
.task-form input:focus,
.task-form select:focus,
.task-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.16);
}

.password-input-wrap {
  position: relative;
  display: block;
}

.login-form .password-input-wrap input {
  padding-right: 48px;
}

.password-eye-button {
  position: absolute;
  right: 8px;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.password-eye-button:hover,
.password-eye-button.is-active {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.password-eye-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-panel textarea,
.task-form textarea {
  resize: vertical;
  min-height: 88px;
}

.password-dialog {
  width: 420px;
  max-width: calc(100% - 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.task-edit-dialog {
  width: 620px;
}

.task-edit-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.visit-detail-dialog {
  width: 620px;
  max-width: calc(100% - 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  box-shadow: var(--shadow);
}

.visit-detail-dialog::backdrop {
  background: rgba(12, 18, 16, 0.42);
}

.visit-detail-panel {
  padding: 22px;
  background: var(--surface);
}

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

.visit-detail-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.visit-detail-panel h3.is-editable,
.visit-detail-item.is-editable {
  cursor: text;
}

.visit-detail-panel h3.is-editable:hover,
.visit-detail-item.is-editable:hover {
  border-color: rgba(0, 151, 154, 0.36);
  background: #f8fffe;
}

.visit-detail-item.is-wide {
  grid-column: 1 / -1;
}

.visit-detail-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.visit-detail-item strong,
.visit-detail-item p {
  margin: 0;
  color: #26332e;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.visit-detail-editor {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.12);
}

.visit-detail-item.is-editing {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.08);
}

.visit-detail-item.is-editing .visit-detail-editor {
  margin-top: 8px;
}

h3 .visit-detail-editor {
  font-size: 22px;
  font-weight: 850;
}

.password-dialog::backdrop {
  background: rgba(12, 18, 16, 0.42);
}

.password-panel {
  padding: 22px;
  background: var(--surface);
}

.password-panel .section-heading .link-button,
.visit-detail-panel .section-heading .link-button {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
}

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

.reset-manager-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
}

.reset-manager-option input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

.admin-workspace {
  display: grid;
  gap: 18px;
}

.admin-workspace > * {
  min-width: 0;
}

.admin-global-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px;
  gap: 10px 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.admin-global-search label {
  display: grid;
  gap: 7px;
}

.admin-global-search label span {
  color: #34423d;
  font-size: 14px;
  font-weight: 800;
}

.admin-global-search input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 9px 12px;
  color: var(--text);
  outline: 0;
}

.admin-global-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.12);
}

.admin-global-search > p {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.admin-filters {
  display: grid;
  grid-template-columns: minmax(140px, 180px) repeat(2, minmax(150px, 180px)) minmax(220px, 1fr) 110px;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.admin-table-wrap .admin-filters {
  margin-bottom: 14px;
  border: 0;
  box-shadow: none;
  background: var(--surface-soft);
  padding: 14px;
}

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

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.mini-list {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.mini-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mini-list-row strong {
  margin: 0;
  font-size: 18px;
}

.admin-task-wrap,
.admin-backup-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.backup-note {
  color: #2f3c37;
  font-size: 14px;
  line-height: 1.65;
}

.backup-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

.backup-actions .primary-button {
  min-width: 160px;
  padding: 0 18px;
}

.backup-actions .text-button {
  min-width: 160px;
}

.backup-actions .form-message {
  flex: 1;
}

.backup-weekly-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.backup-weekly-summary h4 {
  margin: 0;
  font-size: 15px;
}

.backup-weekly-summary .mini-list {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.weekly-count-item {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  padding: 9px 11px;
}

.weekly-count-item > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.weekly-count-item strong {
  flex: 0 0 auto;
  color: var(--accent-strong);
}

.admin-monitor-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.monitor-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 850;
  list-style: none;
}

.monitor-summary::-webkit-details-marker {
  display: none;
}

.monitor-summary::before {
  content: "+";
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.admin-monitor-wrap[open] .monitor-summary::before {
  content: "−";
}

.monitor-summary > span:first-of-type {
  margin-right: auto;
}

.monitor-risk-badge,
.online-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf1ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.monitor-risk-badge.is-normal,
.monitor-status-card.is-online .online-indicator,
.online-indicator.is-online {
  background: #dff5e8;
  color: #147a42;
}

.monitor-risk-badge.is-notice {
  background: #fff2d7;
  color: #8a5700;
}

.monitor-risk-badge.is-attention {
  background: #ffe1df;
  color: var(--danger);
}

.monitor-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

.monitor-body > .section-heading {
  margin-top: 18px;
}

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

.monitor-status-card,
.monitor-history-card,
.security-event-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 12px;
}

.monitor-status-card.is-online {
  border-color: rgba(20, 122, 66, 0.32);
  background: #f7fdf9;
}

.monitor-status-head,
.monitor-history-main,
.security-event-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.monitor-status-card p,
.monitor-history-card p,
.security-event-card p,
.monitor-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.monitor-subsection {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.monitor-history-list,
.security-event-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

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

.security-metrics span {
  display: grid;
  gap: 3px;
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.security-metrics strong {
  color: var(--text);
  font-size: 20px;
}

.security-event-card.is-high {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff8f7;
}

.security-event-card > div span {
  color: var(--muted);
  font-size: 12px;
}

.security-path {
  font-family: Consolas, monospace;
}

.task-form {
  display: grid;
  grid-template-columns: minmax(150px, 180px) minmax(260px, 1fr) minmax(150px, 180px) minmax(130px, 160px) 120px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.task-details-field {
  grid-column: 1 / -2;
}

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

.task-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.task-card-collapsible {
  cursor: default;
}

.task-card-collapsible:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.14);
  outline: 0;
}

.task-title-row {
  min-height: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 24px;
}

.task-title-row h4 {
  min-width: 0;
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.task-title-content {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.task-title-content h4 {
  flex: 0 1 auto;
}

.task-title-summary {
  flex: 1 1 180px;
  min-width: 80px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-title-manager {
  justify-self: end;
  padding-top: 2px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: nowrap;
}

.task-card-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.task-card.is-overdue {
  border-color: rgba(180, 35, 24, 0.38);
  background: #fff8f7;
}

.task-card.is-highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.16);
}

.task-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.task-card h4 {
  margin: 7px 0 0;
  font-size: 16px;
  line-height: 1.35;
}

.task-badge,
.task-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 850;
}

.task-badge {
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.task-badge.urgent {
  background: #ffe1df;
  color: var(--danger);
}

.task-status {
  flex: 0 0 auto;
  background: #fff2d7;
  color: #6f4700;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.task-line {
  margin-top: 8px;
  color: #2f3c37;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.task-line strong {
  color: var(--muted);
}

.task-progress-history {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.task-progress-history > strong {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.task-progress-history .task-line {
  display: grid;
  grid-template-columns: 88px 150px minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
  align-items: start;
}

.progress-event-type {
  color: var(--accent-strong);
  font-weight: 850;
}

.task-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.task-section > .text-button {
  width: 100%;
}

.office-section {
  padding-top: 18px;
}

.office-section .text-button {
  width: 100%;
}

.office-section .text-button:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: #f2f5f4;
}

.guidance-field {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

.admin-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.visit-filter-bar {
  display: grid;
  grid-template-columns: minmax(140px, 170px) minmax(150px, 180px) minmax(150px, 180px) minmax(180px, 260px) 110px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.visit-filter-bar label {
  display: grid;
  gap: 7px;
}

.visit-filter-bar label span {
  color: #34423d;
  font-size: 14px;
  font-weight: 760;
}

.visit-filter-bar input,
.visit-filter-bar select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}

.visit-filter-bar input:focus,
.visit-filter-bar select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.12);
  outline: 0;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-table-wrap .table-scroll {
  max-height: 70vh;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.admin-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: collapse;
}

.admin-table .col-date {
  width: 7%;
}

.admin-table .col-period {
  width: 4.5%;
}

.admin-table .col-manager {
  width: 6.5%;
}

.admin-table .col-client {
  width: 10%;
}

.admin-table .col-project {
  width: 12.5%;
}

.admin-table .col-handler {
  width: 10%;
}

.admin-table .col-purpose {
  width: 14%;
}

.admin-table .col-result {
  width: 12%;
}

.admin-table .col-guidance {
  width: 17%;
}

.admin-table .col-actions {
  width: 6.5%;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 6px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.45;
}

.admin-table thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

.admin-table th {
  color: var(--muted);
  background: #f7fbfa;
  box-shadow: 0 1px 0 var(--line);
  font-size: 12px;
  font-weight: 800;
}

.admin-table td[data-label="操作"] {
  white-space: nowrap;
}

.visit-delete-button {
  min-width: 0;
  padding: 3px 4px;
  font-size: 12px;
}

.admin-column-filters th {
  padding: 8px 10px;
  background: #fbfdfc;
}

.admin-column-filters input,
.admin-column-filters select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
}

.admin-column-filters input:focus,
.admin-column-filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 151, 154, 0.12);
  outline: 0;
}

.filter-stack {
  display: grid;
  gap: 6px;
}

.table-filter-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.admin-table td {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 18px;
  }

  h1 {
    font-size: 30px;
  }

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

  .manager-nav {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "calendar"
      "visit"
      "tasks";
  }

  .visit-pane {
    position: static;
  }

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

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

  .admin-filters .primary-button {
    grid-column: 1 / -1;
  }

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

  .task-form .primary-button,
  .task-details-field {
    grid-column: 1 / -1;
  }

  .monitor-status-grid,
  .monitor-history-list,
  .security-event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .backup-weekly-summary .mini-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
  }

  h1 {
    font-size: 26px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 12px;
  }

  .manager-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .manager-link,
  .manager-pill {
    width: 100%;
    min-height: 40px;
    padding: 8px 9px;
    font-size: 14px;
  }

  .calendar-pane,
  .visit-pane {
    padding: 12px;
  }

  .calendar-toolbar {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
    margin-bottom: 12px;
  }

  .toolbar-actions .text-button {
    display: none;
  }

  .toolbar-actions {
    justify-content: flex-end;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    font-size: 28px;
  }

  .calendar-toolbar h2 {
    font-size: 24px;
  }

  #monthSummary {
    font-size: 13px;
  }

  .weekdays span {
    padding: 8px 2px;
    font-size: 13px;
  }

  .day-cell {
    min-height: 86px;
    padding: 6px 4px;
  }

  .calendar-grid.is-week-view .day-cell,
  .calendar-grid.is-week-view .day-cell.has-many-visits {
    min-height: 118px;
  }

  .day-cell.has-many-visits {
    min-height: 104px;
  }

  .day-number {
    font-size: 17px;
  }

  .day-cell.is-today .day-number {
    width: 28px;
    height: 28px;
  }

  .visit-preview {
    gap: 2px;
    margin-top: 6px;
  }

  .preview-item {
    font-size: 11px;
  }

  .preview-item:nth-child(n+3) {
    display: none;
  }

  .preview-time {
    min-width: 26px;
    padding: 1px 3px;
    font-size: 10px;
  }

  .count-badge {
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    font-size: 11px;
  }

  .selected-day h2 {
    font-size: 21px;
  }

  .record-actions {
    justify-content: stretch;
  }

  .record-action {
    flex: 1;
    min-height: 38px;
    border: 1px solid var(--line);
    background: #fff;
  }

  .login-panel {
    padding: 22px;
  }

  .task-edit-dialog {
    position: fixed;
    inset: auto;
    top: 50dvh;
    left: 50vw;
    box-sizing: border-box;
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: 0;
    transform: translate(-50%, -50%);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .task-edit-row,
  .task-title-row {
    grid-template-columns: 1fr;
  }

  .task-title-manager {
    justify-self: start;
    padding-top: 0;
    white-space: normal;
  }

  .task-title-content {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .task-title-summary {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  .visit-detail-dialog {
    position: fixed;
    inset: auto;
    top: 50dvh;
    left: 50vw;
    box-sizing: border-box;
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: 0;
    transform: translate(-50%, -50%);
    overflow-x: hidden;
    overflow-y: auto;
  }

  .visit-detail-panel {
    min-width: 0;
    padding: 14px;
  }

  .visit-detail-panel .section-heading {
    align-items: flex-start;
  }

  .visit-detail-panel .section-heading > div {
    min-width: 0;
  }

  .visit-detail-panel h3 {
    font-size: 19px;
    overflow-wrap: anywhere;
  }

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

  .visit-detail-item.is-wide {
    grid-column: auto;
  }

  .visit-detail-item,
  .visit-detail-item strong,
  .visit-detail-item p {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .admin-filters,
  .admin-global-search,
  .visit-filter-bar,
  .stats-grid,
  .task-form {
    grid-template-columns: 1fr;
  }

  .admin-global-search > p {
    grid-column: auto;
  }

  .task-actions {
    justify-content: stretch;
  }

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

  .task-actions .record-action {
    min-width: 0;
  }

  .backup-actions .primary-button,
  .backup-actions .text-button,
  .backup-actions .form-message {
    width: 100%;
  }

  .admin-workspace {
    gap: 10px;
  }

  .admin-backup-wrap,
  .admin-task-wrap,
  .admin-table-wrap,
  .monitor-body,
  .monitor-summary {
    padding: 12px;
  }

  .admin-backup-wrap .section-heading,
  .admin-table-wrap .section-heading,
  .monitor-body .section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .backup-note,
  #databaseSummary {
    overflow-wrap: anywhere;
  }

  .backup-weekly-summary .mini-list,
  .monitor-status-grid,
  .monitor-history-list,
  .security-event-list,
  .security-metrics {
    grid-template-columns: 1fr;
  }

  .backup-weekly-summary .mini-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-scroll {
    width: 100%;
    overflow: visible;
  }

  .admin-table-wrap .table-scroll {
    max-height: none;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .admin-table {
    min-width: 0;
    table-layout: auto;
  }

  .admin-table colgroup,
  .admin-table thead {
    display: none;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table tbody {
    display: grid;
    gap: 12px;
  }

  .admin-table tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
    overflow: hidden;
  }

  .admin-table td {
    display: grid;
    grid-template-columns: minmax(84px, 105px) minmax(0, 1fr);
    gap: 10px;
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
  }

  .admin-table td:last-child {
    border-bottom: 0;
  }

  .admin-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .admin-table .empty-table {
    display: block;
    padding: 18px;
  }

  .admin-table .empty-table::before {
    content: none;
  }

  .home-content {
    width: min(100% - 24px, 520px);
    padding: 72px 0 118px;
  }

  .home-entry-grid {
    gap: 18px;
    margin-top: 38px;
  }

  .home-entry {
    min-width: 84px;
  }

  .home-entry-icon {
    width: 62px;
    height: 62px;
    font-size: 21px;
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 8px;
  }

  .calendar-pane,
  .visit-pane,
  .admin-filters,
  .visit-filter-bar,
  .admin-table-wrap,
  .admin-task-wrap,
  .admin-backup-wrap,
  .stat-card {
    border-radius: 6px;
  }

  .calendar-pane,
  .visit-pane {
    padding: 10px;
  }

  .manager-nav {
    grid-template-columns: 1fr;
  }

  .weekdays span {
    font-size: 12px;
  }

  .day-cell {
    min-height: 78px;
    padding: 5px 3px;
  }

  .calendar-grid.is-week-view .day-cell,
  .calendar-grid.is-week-view .day-cell.has-many-visits {
    min-height: 110px;
  }

  .day-cell.has-many-visits {
    min-height: 96px;
  }

  .day-number {
    font-size: 16px;
  }

  .count-badge {
    position: absolute;
    top: 4px;
    right: 4px;
  }

  .login-panel {
    padding: 20px 16px;
  }

  .reset-manager-list {
    grid-template-columns: 1fr;
  }

  .auth-body {
    align-items: start;
    padding: 14px 10px;
  }
}

/* Reimbursement module */
body.modal-open {
  overflow: hidden;
}

.reimbursement-shell > .topbar {
  align-items: flex-end;
}

.reimbursement-access-monitor {
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #bfd9d3;
  border-radius: 8px;
  background: #f8fcfb;
  box-shadow: 0 6px 18px rgba(23, 48, 42, 0.05);
}

.reimbursement-access-monitor[hidden] {
  display: none;
}

.reimbursement-access-monitor summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 16px;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.reimbursement-access-monitor summary::-webkit-details-marker {
  display: none;
}

.reimbursement-access-monitor summary::before {
  content: "▸";
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 18px;
  transition: transform 160ms ease;
}

.reimbursement-access-monitor[open] summary::before {
  transform: rotate(90deg);
}

.reimbursement-access-monitor-title {
  margin-right: auto;
  color: var(--accent-strong);
  font-weight: 900;
}

.reimbursement-access-monitor-badge {
  padding: 5px 9px;
  border-radius: 999px;
  color: #17604f;
  background: #e5f4ef;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.reimbursement-access-monitor.has-alert {
  border-color: #e7b1a8;
  background: #fffafa;
}

.reimbursement-access-monitor.has-alert .reimbursement-access-monitor-badge {
  color: #9e2f23;
  background: #fee8e4;
}

.reimbursement-access-monitor-body {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--line);
}

.reimbursement-permission-roles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 14px;
}

.reimbursement-permission-role {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.reimbursement-permission-role-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.reimbursement-permission-role-heading h2,
.reimbursement-denied-heading h2 {
  font-size: 15px;
}

.reimbursement-permission-role-heading span,
.reimbursement-denied-heading span {
  color: var(--muted);
  font-size: 12px;
}

.reimbursement-permission-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.55;
}

.reimbursement-permission-line strong {
  color: #17604f;
}

.reimbursement-permission-line.is-restricted strong {
  color: var(--danger);
}

.reimbursement-access-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 0.32fr)) minmax(260px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.reimbursement-access-metrics > div,
.reimbursement-access-metrics > p {
  min-width: 0;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.reimbursement-access-metrics > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reimbursement-access-metrics span,
.reimbursement-access-metrics p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.reimbursement-access-metrics strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.reimbursement-denied-section {
  min-width: 0;
}

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

.reimbursement-denied-events {
  display: grid;
  gap: 7px;
  max-height: 230px;
  overflow-y: auto;
}

.reimbursement-denied-event {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid #efc6bf;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.reimbursement-denied-event > div {
  display: grid;
  gap: 2px;
}

.reimbursement-denied-event > div span,
.reimbursement-denied-outcome {
  color: var(--muted);
}

.reimbursement-denied-event p {
  margin: 0;
  line-height: 1.5;
}

.reimbursement-denied-outcome {
  white-space: nowrap;
}

.reimbursement-denied-empty {
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.visit-detail-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(21, 35, 32, 0.46);
}

.visit-detail-modal.hidden {
  display: none;
}

.reimbursement-workspace {
  display: grid;
  gap: 18px;
}

.reimbursement-filter-band {
  display: grid;
  grid-template-columns:
    minmax(120px, 0.72fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(120px, 0.68fr)
    minmax(250px, 1.45fr)
    auto;
  gap: 10px;
  align-items: end;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 48, 42, 0.05);
}

body:not(.reimbursement-private-visible) .reimbursement-admin-only,
.reimbursement-private-hidden .reimbursement-admin-only {
  display: none !important;
}

.reimbursement-private-hidden .reimbursement-filter-band {
  grid-template-columns:
    minmax(120px, 0.72fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(150px, 0.9fr)
    minmax(250px, 1.45fr)
    auto;
}

.reimbursement-filter-band label,
.reimbursement-form label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-weight: 700;
}

.reimbursement-filter-band label > span {
  color: var(--muted);
  font-size: 13px;
}

.reimbursement-filter-band input,
.reimbursement-filter-band select,
.reimbursement-form input,
.reimbursement-form select,
.reimbursement-form textarea {
  width: 100%;
  min-width: 0;
}

.reimbursement-filter-band input,
.reimbursement-filter-band select {
  height: 46px;
  padding-top: 0;
  padding-bottom: 0;
}

.reimbursement-filter-band .text-button {
  height: 46px;
  padding-inline: 18px;
}

.reimbursement-summary-section,
.reimbursement-list-section {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 48, 42, 0.05);
}

.reimbursement-summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
}

.reimbursement-summary-heading::-webkit-details-marker {
  display: none;
}

.reimbursement-summary-heading::before {
  content: "▸";
  color: var(--accent-strong);
  font-size: 18px;
  transition: transform 160ms ease;
}

.reimbursement-summary-section[open] .reimbursement-summary-heading::before {
  transform: rotate(90deg);
}

.reimbursement-summary-collapse-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reimbursement-summary-controls {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px 0;
}

.reimbursement-summary-heading h2 {
  margin: 0;
  font-size: 20px;
}

.reimbursement-summary-tabs {
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f6f5;
}

.reimbursement-summary-tabs button {
  min-height: 38px;
  padding: 7px 15px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.reimbursement-summary-tabs button.is-active {
  color: var(--teal-dark);
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 56, 48, 0.09);
}

.reimbursement-summary-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.reimbursement-summary-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  table-layout: fixed;
}

.reimbursement-summary-table th,
.reimbursement-summary-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reimbursement-summary-table th {
  color: var(--muted);
  background: #f4f7f6;
  font-size: 13px;
}

.reimbursement-summary-table th:first-child,
.reimbursement-summary-table td:first-child {
  width: 42%;
  text-align: left;
}

.reimbursement-summary-table tr:last-child td {
  border-bottom: 0;
}

.reimbursement-summary-total td {
  font-weight: 900;
}

.reimbursement-summary-group {
  cursor: pointer;
}

.reimbursement-summary-group:hover,
.reimbursement-summary-group:focus-visible {
  background: #f5faf9;
  outline: none;
}

.summary-chevron {
  display: inline-block;
  width: 18px;
  color: var(--teal-dark);
  font-size: 18px;
}

.reimbursement-list-section {
  padding: 18px;
}

.reimbursement-list-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.reimbursement-list-tools {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

.reimbursement-table-wrap {
  width: 100%;
  margin-top: 16px;
  max-height: min(64vh, 700px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.reimbursement-table {
  width: 100%;
  min-width: 1860px;
  border-collapse: collapse;
  table-layout: fixed;
}

.reimbursement-private-hidden .reimbursement-table {
  min-width: 1450px;
}

.reimbursement-table th,
.reimbursement-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.reimbursement-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #f4f8f7;
  font-size: 13px;
}

.reimbursement-table tbody tr {
  cursor: pointer;
}

.reimbursement-table tbody tr:hover,
.reimbursement-table tbody tr:focus-visible {
  background: #f4faf9;
  outline: none;
}

.reimbursement-table th:nth-child(1) { width: 100px; }
.reimbursement-table th:nth-child(2) { width: 110px; }
.reimbursement-table th:nth-child(3) { width: 95px; }
.reimbursement-table th:nth-child(4) { width: 115px; }
.reimbursement-table th:nth-child(5) { width: 130px; }
.reimbursement-table th:nth-child(6) { width: 210px; }
.reimbursement-table th:nth-child(7) { width: 125px; }
.reimbursement-table th:nth-child(8) { width: 190px; }
.reimbursement-table th:nth-child(9) { width: 260px; }
.reimbursement-table th:nth-child(10) { width: 105px; }
.reimbursement-table th:nth-child(11) { width: 120px; }
.reimbursement-table th:nth-child(12) { width: 210px; }
.reimbursement-table th:nth-child(13) { width: 86px; }

.reimbursement-note-cell {
  white-space: pre-wrap;
}

.reference-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  padding: 3px 7px;
  border: 1px solid #c9dfda;
  border-radius: 6px;
  color: var(--muted);
  background: #eaf5f2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-chip.has-value {
  color: var(--ink);
  background: #f4faf8;
}

.reimbursement-inline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}

.reimbursement-inline-status input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.reimbursement-inline-note {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.money-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.reimbursement-detail-panel,
.reimbursement-form-panel {
  width: min(960px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  overflow-y: auto;
}

.reimbursement-detail-sections {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.reimbursement-detail-section {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.reimbursement-detail-section h4 {
  width: fit-content;
  margin: -27px 0 12px -6px;
  padding: 0 6px;
  background: #fff;
  font-size: 15px;
  font-weight: 900;
}

.reimbursement-detail-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.reimbursement-detail-section-grid .visit-detail-item.is-wide {
  grid-column: 1 / -1;
}

.reimbursement-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.reimbursement-form fieldset {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.reimbursement-form legend {
  padding: 0 6px;
  font-weight: 900;
}

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

.reimbursement-form-grid .is-wide {
  grid-column: 1 / -1;
}

.reimbursement-field-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

.reimbursement-field-hint.is-error {
  color: var(--danger);
}

.reimbursement-form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}

.reimbursement-form-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

@media (max-width: 1320px) {
  .reimbursement-shell > .topbar {
    flex-wrap: wrap;
  }

  .reimbursement-access-monitor {
    width: 100%;
    max-width: none;
  }

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

  .reimbursement-private-hidden .reimbursement-filter-band {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .reimbursement-query-field {
    grid-column: span 3;
  }
}

@media (max-width: 780px) {
  .reimbursement-shell > .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .reimbursement-access-monitor {
    min-width: 0;
    width: 100%;
  }

  .reimbursement-access-monitor summary {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
  }

  .reimbursement-access-monitor-badge {
    margin-left: 26px;
  }

  .reimbursement-permission-roles,
  .reimbursement-access-metrics,
  .reimbursement-denied-event {
    grid-template-columns: 1fr;
  }

  .reimbursement-denied-outcome {
    white-space: normal;
  }

  .reimbursement-filter-band,
  .reimbursement-form-grid,
  .reimbursement-detail-section-grid {
    grid-template-columns: 1fr;
  }

  .reimbursement-query-field {
    grid-column: auto;
  }

  .reimbursement-filter-band .text-button,
  .reimbursement-list-heading .primary-button {
    width: 100%;
  }

  .reimbursement-list-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .reimbursement-list-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .reimbursement-summary-heading {
    align-items: stretch;
    flex-direction: row;
    padding: 14px;
  }

  .reimbursement-summary-controls {
    justify-content: flex-start;
    width: 100%;
    padding: 10px 14px 0;
  }

  .reimbursement-summary-tabs {
    overflow-x: auto;
  }

  .reimbursement-summary-tabs button {
    flex: 0 0 auto;
  }

  .reimbursement-summary-table {
    min-width: 0;
  }

  .reimbursement-summary-table th,
  .reimbursement-summary-table td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .reimbursement-list-section {
    padding: 12px;
  }

  .reimbursement-table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  .reimbursement-table {
    min-width: 0;
    table-layout: auto;
  }

  .reimbursement-table thead {
    display: none;
  }

  .reimbursement-table,
  .reimbursement-table tbody,
  .reimbursement-table tr,
  .reimbursement-table td {
    display: block;
    width: 100%;
  }

  .reimbursement-table tbody {
    display: grid;
    gap: 10px;
  }

  .reimbursement-table tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfc;
  }

  .reimbursement-table td {
    display: grid;
    grid-template-columns: minmax(82px, 98px) minmax(0, 1fr);
    gap: 10px;
    padding: 8px 10px;
  }

  .reimbursement-inline-note {
    height: 42px;
  }

  .reimbursement-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }

  .reimbursement-table .empty-table::before {
    content: none;
  }

  .reimbursement-detail-panel,
  .reimbursement-form-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 14px;
  }

  .reimbursement-detail-section-grid .visit-detail-item.is-wide,
  .reimbursement-form-grid .is-wide {
    grid-column: auto;
  }

  .reimbursement-form fieldset {
    padding: 11px;
  }
}
