:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1f2733;
  --muted: #667085;
  --line: #dce1e3;
  --soft: #eef1f3;
  --accent: #25675a;
  --accent-strong: #184b41;
  --gold: #c98318;
  --green: #25745b;
  --red: #a13f3c;
  --orange: #ad6425;
  --shadow: 0 12px 28px rgba(31, 39, 51, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
}

.brand strong {
  font-size: 1rem;
}

.brand span,
.panel-heading p,
.subtle,
small {
  color: var(--muted);
}

.top-actions,
.module-tabs,
.detail-actions,
.inline-actions,
.dialog-actions,
.section-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.module-tabs { margin-left: auto; }
.module-tab.active { border-color: var(--accent); color: var(--accent-strong); background: #e8f2ef; }
.people-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.people-toolbar nav { display: flex; gap: 8px; }
.people-toolbar .active { color: var(--accent-strong); border-color: var(--accent); }
.notification-button { position: relative; width: 32px; height: 32px; }
.notification-button strong { position: absolute; top: -2px; right: -3px; font-size: 10px; line-height: 15px; min-width: 15px; border-radius: 8px; color: white; background: #b83b47; }
.housing-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.housing-section:first-child { padding-top: 0; }
.housing-section h3 { margin: 0 0 12px; }
.room-editor-row { display: flex; align-items: end; gap: 12px; margin-bottom: 10px; }
.room-editor-row label { flex: 1; }
.room-editor-row button { margin-bottom: 4px; }
.checkbox-field { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }
.departure-links { display: grid; gap: 12px; margin-top: 16px; }
.departure-links .checkbox-field { align-items: flex-start; }
button:disabled { cursor: not-allowed; opacity: .45; }
#dormDialog input[readonly] { background: var(--soft); color: var(--muted); }
.lease-summary { font-size: 13px; color: var(--muted); }
.change-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.change-table th, .change-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.approval-row > div:first-child { min-width: 0; flex: 1; }
.access-tree { list-style: none; padding-left: 20px; }
.access-tree li { padding: 7px 0; }
.access-tree small { margin-left: 20px; color: var(--muted); }
#personSearch { max-width: 320px; margin-bottom: 16px; }
#peopleWorkspace table { width: 100%; border-collapse: collapse; }
#peopleWorkspace th, #peopleWorkspace td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
@media (max-width: 680px) { .people-toolbar { align-items: stretch; flex-direction: column; } .app-topbar .brand { width: 100%; } .app-topbar .module-tabs { width: auto; flex: 1; } .app-topbar .top-actions { margin-left: auto; } .module-tab { padding: 8px; } }

.module-workspace { padding: 14px; }
.module-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.module-head p { margin: 0; color: var(--muted); }
.dorm-block, .module-section { padding: 16px; margin-top: 12px; background: var(--panel); border-top: 1px solid var(--line); }
.dorm-head, .dorm-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dorm-head p, .dorm-foot { color: var(--muted); }
.dorm-finance { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin: 12px 0; padding: 10px 0; border-block: 1px solid var(--line); }
.dorm-finance dd { margin-top: 3px; }
.room-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 12px 0; }
.room-item { padding: 12px; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.room-item > strong, .room-item > span { display: block; margin-bottom: 7px; }
.room-item p { min-height: 24px; margin: 8px 0; overflow-wrap: anywhere; }
.room-select { display: flex; align-items: center; gap: 5px; float: right; color: var(--muted); font-size: .78rem; }
.room-select input { width: 16px; }
.room-occupied { background: #dff0e8; color: var(--green); }
.room-cleaning { background: #faead3; color: var(--orange); }
.room-exception { background: #f9e1dc; color: var(--red); }
.dorm-foot { align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
.approval-table { display: grid; gap: 10px; padding: 14px 0; }
.approval-row { display: flex; justify-content: space-between; gap: 16px; padding: 14px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.approval-row strong, .approval-row span, .approval-row small { display: block; }
.approval-row pre { max-height: 260px; overflow: auto; padding: 10px; background: #f3f6f7; white-space: pre-wrap; overflow-wrap: anywhere; }
.media-dialog img, .media-dialog video { display: block; width: 100%; max-height: 75vh; object-fit: contain; background: #111; }

.button,
.icon-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.button {
  padding: 7px 12px;
  font-weight: 650;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

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

.button.ghost:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.button.tiny {
  min-height: 30px;
  padding: 4px 8px;
  font-size: 0.875rem;
}

.icon-button {
  width: 36px;
  font-size: 1.5rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.list-panel,
.detail-panel {
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: var(--panel);
}

.list-panel {
  overflow: hidden;
}

.detail-panel {
  padding: 16px;
}

.panel-heading,
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
}

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

h1 {
  margin-bottom: 4px;
  font-size: 1.35rem;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.25rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(88px, 1fr));
  gap: 6px;
  min-width: 220px;
}

.stat-strip span {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f3f6f7;
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1.05rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(100px, 120px) minmax(100px, 120px) 86px;
  gap: 10px;
  padding: 0 16px 14px;
  border-bottom: 1px solid var(--line);
}

label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

label span,
dt {
  color: #445064;
  font-size: 0.875rem;
  font-weight: 650;
}

label b {
  color: var(--red);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

.table-wrap {
  overflow: auto;
}

.artist-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f3f5;
  color: #4a5568;
  font-size: 0.86rem;
}

td strong,
td span,
td small {
  display: block;
}

tr.selected td {
  background: #eef6f7;
}

.empty-row,
.empty-inline,
.empty-detail {
  color: var(--muted);
}

.empty-detail {
  display: grid;
  align-content: center;
  min-height: 320px;
  padding: 12px;
}

.status {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 700;
}

.status.expired {
  background: #f9e1dc;
  color: var(--red);
}

.status.expiring {
  background: #faead3;
  color: var(--orange);
}

.status.active {
  background: #dff0e8;
  color: var(--green);
}

.status.notStarted {
  background: #e1ecf4;
  color: var(--accent-strong);
}

.status.dateMissing,
.status.noContract {
  background: #eef1f3;
  color: #5c6470;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 800;
}

.detail-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.detail-section:first-of-type {
  border-top: 0;
}

.section-title-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

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

.info-grid > div {
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.info-grid .wide,
.form-grid .wide {
  grid-column: 1 / -1;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.list-item,
.team-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
}

.list-item strong,
.team-row strong,
.list-item span,
.team-row span,
.list-item small,
.team-row small {
  display: block;
  overflow-wrap: anywhere;
}

.item-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 120px;
}

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

.ops-grid span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: #445064;
  background: #fbf8f0;
  text-align: center;
}

.editor-dialog {
  width: min(940px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.editor-dialog.small {
  width: min(680px, calc(100vw - 28px));
}

.editor-dialog::backdrop {
  background: rgba(31, 39, 51, 0.36);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #f2f5f6;
}

.dialog-head p {
  margin-bottom: 0;
  color: var(--muted);
}

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

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

.field-action {
  display: grid;
  align-content: end;
  gap: 5px;
}

.field-action span {
  color: var(--muted);
  font-size: 0.82rem;
}

.form-errors {
  color: var(--red);
}

.form-errors ul {
  margin: 0;
  padding: 12px 32px 0;
}

.draft-banner,
.duplicate-ack {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 10px;
  border: 1px solid #e5c27a;
  border-radius: 6px;
  background: #fff8df;
}

.duplicate-ack input {
  width: auto;
}

.dialog-actions {
  justify-content: flex-end;
  padding: 14px 16px 16px;
}

.team-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
button:disabled { opacity: 0.55; cursor: wait; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.button svg, .icon-button svg { width: 17px; height: 17px; flex: 0 0 17px; }
.icon-button { display: inline-grid; place-items: center; flex: 0 0 36px; }
.field-group { border-bottom: 1px solid var(--line); padding: 0 0 12px; margin-bottom: 14px; }
.field-group > summary { padding: 12px 0; cursor: pointer; font-weight: 700; color: var(--accent-strong); }
.form-section:has(> .field-group) { padding-top: 0; }
.check-label { display: flex; align-items: center; gap: 8px; margin: 12px 0; }
.check-label input { width: 17px; height: 17px; flex: 0 0 17px; }
.import-dialog { width: min(1500px, calc(100vw - 24px)); }
.import-toolbar { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.import-toolbar > label:not(.check-label) { flex: 1; min-width: 180px; }
#importStatus { flex: 2; min-width: 200px; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; }
.import-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; padding: 18px; }
.import-fields { min-width: 0; }
.import-fields > section { margin-bottom: 22px; }
.import-fields .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pdf-preview { align-self: start; position: sticky; top: 0; min-width: 0; background: #eef1f3; padding: 10px; }
.preview-toolbar { display: flex; align-items: center; justify-content: center; gap: 12px; padding-bottom: 12px; }
.preview-toolbar label { width: 92px; }
canvas { display: block; max-width: 100%; height: auto; }
.source-link { padding: 3px 0; border: 0; background: none; color: var(--accent); text-align: left; font-size: 0.8rem; cursor: pointer; }
.review-notice { padding: 0 18px; color: #8a5a17; overflow-wrap: anywhere; }
.review-notice:empty { display: none; }
.review-issue { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review-issue p { margin: 5px 0; font-size: 0.875rem; color: var(--muted); }
.merge-row { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.merge-row .button { justify-self: start; }
.pending-text { color: #8a5a17; }
.monthly-fields { padding: 16px; }
.source-dialog { width: min(780px, calc(100vw - 24px)); }
.source-dialog canvas { margin: auto; }
.source-dialog .preview-toolbar { padding: 12px; }
.contract-parent-field { margin: 14px 16px; }
.import-view { display: none; }
#importDraftStatus { margin-right: auto; font-size: 0.82rem; color: var(--muted); }
.form-errors { white-space: pre-wrap; overflow-wrap: anywhere; }
.import-dialog .form-errors:not(:empty), .monthly-fields + .form-errors { padding: 12px 18px; }
.list-item > div:first-child { min-width: 0; }
.list-item details { font-size: 0.85rem; overflow-wrap: anywhere; margin-top: 6px; }
.list-item summary { cursor: pointer; color: var(--accent); }
.list-item details p { margin: 8px 0; }
.identity-details summary { cursor: pointer; font-weight: 700; padding: 4px 0 12px; }

@media (max-width: 1200px) and (min-width: 1081px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-heading { flex-direction: column; }
}
@media (max-width: 900px) {
  .import-layout { grid-template-columns: 1fr; }
  .pdf-preview { position: static; }
  .import-view { display: flex; gap: 12px; border: 0; padding: 10px 18px; margin: 0; background: var(--panel); position: sticky; top: 58px; z-index: 2; }
  .import-view legend { position: absolute; width: 1px; height: 1px; overflow: hidden; }
  .import-view label { display: flex; align-items: center; gap: 6px; }
  .import-view input { width: 16px; height: 16px; }
  #importForm:has(input[name="importView"][value="fields"]:checked) .pdf-preview { display: none; }
  #importForm:has(input[name="importView"][value="source"]:checked) .import-fields { display: none; }
}
@media (max-width: 560px) {
  .import-fields .form-grid { grid-template-columns: 1fr; }
  .import-layout { padding: 12px; }
  .import-toolbar { padding: 12px; }
  .dialog-head { position: sticky; top: 0; z-index: 3; }
  .dialog-head h2 { font-size: 1.1rem; }
  .form-grid { gap: 14px; }
  .import-dialog .dialog-actions { flex-wrap: wrap; }
  #importDraftStatus { width: 100%; }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    min-height: 360px;
  }
  .room-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .app-topbar,
  .panel-heading,
  .detail-head,
  .list-item,
  .team-row {
    align-items: stretch;
    flex-direction: column;
  }

  .module-tabs { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .app-topbar .top-actions { width: auto; flex-wrap: nowrap; gap: 4px; }
  .app-topbar { gap: 8px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .app-topbar .brand { grid-column: 1 / -1; }
  .app-topbar .module-tabs { flex: 1; width: auto; gap: 4px; }
  .app-topbar .module-tab { padding: 7px; font-size: 13px; white-space: nowrap; }
  .room-grid, .dorm-finance { grid-template-columns: 1fr; }
  .module-head, .dorm-head, .dorm-foot, .approval-row { flex-direction: column; align-items: stretch; }

  .workspace {
    padding: 8px;
  }

  .filters,
  .form-grid,
  .info-grid,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .stat-strip {
    width: 100%;
    min-width: 0;
  }

  .item-actions {
    justify-items: start;
  }

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

  .dialog-actions .button {
    flex: 1;
  }
}
