:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #dfe5ee;
  --line-soft: #e9edf4;
  --text: #172033;
  --muted: #667085;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green-soft: #eaf7ef;
  --orange-soft: #fff3e6;
  --gray-soft: #eef1f5;
  --danger: #b42318;
  --surface: #ffffff;
  --surface-2: #f8fafc;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: #111827;
  color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; letter-spacing: .01em; }
.topbar .brand:hover { text-decoration: none; }
.topbar-meta { color: #9ca3af; font-size: 12px; }
.logout-form { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-user { color: #9ca3af; font-size: 12px; }
.logout-form .btn {
  height: 28px;
  border-color: #374151;
  background: transparent;
  color: #e5e7eb;
}
.logout-form .btn:hover { background: #1f2937; }

.page { padding: 12px 16px 22px; max-width: 100%; }

.login-wrap {
  min-height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.login-card input:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.login-card .btn { height: 36px; justify-content: center; }
.login-error { color: var(--danger); font-size: 13px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 7px;
}
.page-head h1 { margin: 0 0 2px; font-size: 21px; line-height: 1.2; }
.breadcrumb { font-size: 12px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.muted { color: var(--muted); }
h2 { font-size: 15px; margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.export-menu { position: relative; display: inline-flex; }
.export-menu .caret { font-size: 9px; margin-left: 2px; }
.export-options {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 170px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
}
.export-options a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}
.export-options a:hover { background: var(--surface-2); text-decoration: none; }
.export-options .fmt { color: var(--muted); font-size: 11px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 720px; }

[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: #1f2937;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--danger); border-color: #f1c0bc; }
.btn.danger:hover { background: #fff5f4; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-soft);
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.pill-draft { background: #fff7e6; color: #9a6700; }
.pill-completed { background: #eaf1ff; color: #1d4ed8; }
.pill-reference { background: #eaf1ff; color: #1d4ed8; }
.pill-locked { background: #eaf7ef; color: #067647; }

.status-lock {
  margin: 0 0 12px;
  padding: 9px 13px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.chip {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 11px;
}
.chip span { color: var(--muted); }
.chip strong { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.chip.muted { color: var(--muted); background: transparent; border-style: dashed; }
.chip.warn { background: #fff7e6; border-color: #fde68a; color: #9a6700; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 7px;
  padding: 7px 9px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  border-bottom: 0;
}
.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.toolbar-right {
  margin-left: auto;
  justify-content: flex-end;
}
.toolbar select,
.toolbar input[type="search"] {
  height: 29px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  padding: 0 9px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
}
.toolbar input[type="search"] { width: 200px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.check input { margin: 0; }
.check.warn { color: #9a6700; }

.formula-note {
  padding: 3px 10px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 235px);
  min-height: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
}

table.report {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
  font-size: 12px;
}
table.report th,
table.report td {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  padding: 2px 5px;
  height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.report thead th {
  background: #eef2f8;
  color: #334155;
  font-weight: 600;
}
table.report thead tr.group-row th {
  height: 21px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  text-align: center;
  border-bottom: 1px solid #d7deea;
}
table.report thead tr.group-row th.grp-master { background: #e8f0fe; color: #1e40af; }
table.report thead tr.group-row th.grp-income { background: #e9f7ee; color: #166534; }
table.report thead tr.group-row th.grp-expense { background: #fff1e3; color: #9a3412; }
table.report thead tr.group-row th.grp-calc { background: #eceff3; color: #475569; }

table.report thead tr.field-row th {
  position: sticky;
  top: 0;
  z-index: 6;
  height: 60px;
  vertical-align: bottom;
  white-space: normal;
  line-height: 1.12;
  font-size: 10px;
  font-weight: 600;
  padding-bottom: 5px;
}
table.report thead tr.field-row th span {
  display: block;
  max-height: 55px;
  overflow: hidden;
}
table.report thead th.col-master { background: #f2f6ff; }
table.report thead th.col-income { background: #f1faf4; }
table.report thead th.col-expense { background: #fff7ee; }
table.report thead th.col-calc { background: #f2f4f7; }

table.report thead th.room-sort {
  cursor: pointer;
  user-select: none;
}
table.report thead th.room-sort::after {
  content: " ↕";
  color: #94a3b8;
  font-size: 9px;
}
table.report thead th.room-sort.asc::after {
  content: " ↑";
  color: #2563eb;
}

table.report td { background: #fff; }
table.report tbody tr:hover td { background: #f8fafc; }
table.report tbody tr.saving td { background: #fffbea; }

.col-hidden { display: none !important; }

.col-no { width: 44px; min-width: 44px; max-width: 44px; }
td.rowno, th.col-no {
  text-align: center;
  color: #98a2b3;
  font-variant-numeric: tabular-nums;
  background: #f8fafc;
}

td.text { color: #344054; }
td.building-cell { font-weight: 500; }
td.room-cell { font-variant-numeric: tabular-nums; }
td.muted { color: #98a2b3; }

td.input-cell { padding: 0; }
input.num {
  width: 100%;
  height: 23px;
  border: 0;
  background: transparent;
  color: #0f172a;
  text-align: right;
  padding: 0 6px;
  font: inherit;
  font-variant-numeric: tabular-nums;
}
input.num:hover { background: #f8fafc; }
input.num:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
  background: #fff;
}

td.calc {
  text-align: right;
  background: #f2f4f7;
  color: #475569;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
tbody tr:hover td.calc { background: #e9edf3; }

select.rental-type {
  width: 100%;
  height: 21px;
  border: 0;
  background: transparent;
  color: #344054;
  font: inherit;
  font-size: 11px;
}

table.report tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: #e9edf3;
  border-top: 1px solid #cbd5e1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
table.report tfoot td.foot { text-align: right; }
table.report tfoot td.foot-master { color: #475569; font-size: 11px; }

.hidden { display: none !important; }
tr.hidden { display: none; }

/* periods page */
.periods { width: 100%; border-collapse: collapse; }
.periods th, .periods td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line-soft); }
.periods th { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.periods td.num, .periods th.num { text-align: right; }
.period-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input[type="month"] {
  height: 32px; border: 1px solid #cbd5e1; border-radius: 7px; padding: 0 9px;
}
.flow { margin: 0; padding-left: 20px; color: #475569; line-height: 1.7; }

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-head h2 { margin: 0; }
.icon-btn {
  border: 0; background: transparent; font-size: 24px; line-height: 1; color: #667085; cursor: pointer;
}
.realloc-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}
.realloc-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.realloc-row label { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.realloc-row select {
  height: 30px; border: 1px solid #cbd5e1; border-radius: 7px;
  padding: 0 8px; background: #fff; font-size: 12px;
}
.realloc-props-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 8px; font-size: 12px; color: var(--muted);
}
.realloc-props-head select {
  height: 28px; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: 0 7px; background: #fff; font-size: 12px;
}
.realloc-tools { display: flex; gap: 5px; }
.mini-btn {
  border: 1px solid #cbd5e1; background: #fff; border-radius: 6px;
  padding: 2px 7px; font-size: 11px; cursor: pointer; color: #475569;
}
.mini-btn:hover { background: #f8fafc; }
.realloc-list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 12px; max-height: 165px; overflow: auto;
  margin-top: 6px; padding: 8px;
  border: 1px solid var(--line-soft); border-radius: 7px; background: #fff;
}
.realloc-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #344054; }
.realloc-item em { margin-left: auto; color: var(--muted); font-style: normal; font-size: 11px; }
.composition {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}
.comp-title { font-size: 11px; color: var(--muted); margin: 0 0 4px; }
.comp-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 10px; color: var(--muted); margin-bottom: 6px; }
.comp-avg-key { color: #b45309; }
.comp-moved-key { color: #b45309; font-weight: 600; }
.comp-fixed-key { color: #64748b; font-weight: 600; }
.comp-row { display: flex; align-items: center; gap: 8px; height: 26px; font-size: 11px; }
.comp-row-fixed .comp-room,
.comp-row-fixed .comp-total { color: #94a3b8; }
.comp-row-fixed .comp-room::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #94a3b8;
  margin-right: 4px;
  vertical-align: 1px;
}
.comp-room { width: 52px; text-align: right; color: #475569; flex: 0 0 52px; }
.comp-track { position: relative; flex: 1; height: 16px; background: #eef1f5; border-radius: 3px; }
.comp-bar { height: 100%; display: flex; border-radius: 3px; overflow: hidden; }
.comp-seg { height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 1px; }
.comp-seg + .comp-seg { border-left: 1px solid rgba(255,255,255,.7); }
.comp-label { font-size: 9px; color: #fff; text-shadow: 0 0 2px rgba(0,0,0,.5); white-space: nowrap; pointer-events: none; }
.comp-zero { background: #7c3aed; border-radius: 1px; }
.comp-avg { position: absolute; top: -2px; bottom: -2px; border-left: 1.5px dashed #d97706; pointer-events: none; }
.comp-total { width: 92px; text-align: right; flex: 0 0 92px; font-variant-numeric: tabular-nums; color: #475569; }
.comp-count { width: 44px; text-align: right; flex: 0 0 44px; color: #98a2b3; }
.comp-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }
.comp-empty-inline { color: #98a2b3; font-size: 10px; padding-left: 4px; }
.comp-tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,.18); padding: 8px 10px;
  font-size: 11.5px; max-width: 320px; opacity: 0; transition: opacity .08s;
}
.comp-tip[data-show] { opacity: 1; }
.comp-tip .t { font-weight: 600; margin-bottom: 3px; color: #172033; }
.comp-tip .r { display: flex; justify-content: space-between; gap: 16px; color: #475569; line-height: 1.6; }
.comp-tip .r b { color: #172033; font-weight: 560; font-variant-numeric: tabular-nums; }
.composition-modal { width: min(980px, 100%); }
.composition-modal .composition { max-height: 62vh; overflow: auto; }

.rates-modal { width: min(900px, 100%); }
.rates-tools { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.rates-tools input[type="search"] { flex: 1; min-width: 160px; }
.rates-head,
.rate-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 76px 82px 100px 120px;
  align-items: center;
  gap: 8px;
}
.rates-head {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.rates-list {
  max-height: 55vh;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.rate-row {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  cursor: pointer;
}
.rate-row:last-child { border-bottom: 0; }
.rate-row:hover { background: var(--surface-2); }
.rate-building { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-room, .rate-type { color: var(--muted); }
.rate-input { width: 90px; padding: 3px 5px; text-align: right; }
.rate-tax { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

.ocr-th { cursor: pointer; }
.ocr-th:hover { background: var(--surface-2); }
.ocr-th.ocr-disabled { cursor: not-allowed; opacity: .55; }
.ocr-th.ocr-disabled:hover { background: transparent; }
.property-fee-th { cursor: pointer; }
.property-fee-th:hover { background: var(--surface-2); }
.property-fee-th.property-fee-disabled { cursor: not-allowed; opacity: .55; }
.property-fee-th.property-fee-disabled:hover { background: transparent; }
.bulk-mark {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: #ecfdf5;
  color: #047857;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: 1px;
}
.property-fee-modal { width: min(560px, 100%); }
.property-fee-fields { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.property-fee-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.property-fee-fields label.check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  align-self: center;
  font-size: 12px;
  color: var(--text);
}
.property-fee-fields select,
.property-fee-fields input[type="number"] { min-width: 210px; height: 32px; padding: 0 8px; }
.property-fee-fields input[type="number"] { width: 150px; }
#propertyFeeIncludeFixed {
  width: 14px;
  height: 14px;
  min-width: 0;
  padding: 0;
  margin: 0;
}

.ocr-mark {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: .04em;
  vertical-align: 1px;
}
.ocr-modal { width: min(1080px, 100%); }
.ocr-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 10px 0; }
.ocr-controls label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ocr-controls select { max-width: 260px; }
.ocr-controls input[type="file"] { flex: 1; min-width: 220px; font-size: 12px; }
.ocr-preview { max-height: 50vh; overflow: auto; border: 1px solid var(--line-soft); border-radius: 6px; }
.ocr-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; }
.ocr-table th, .ocr-table td { padding: 5px 7px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.ocr-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line-soft);
  border-bottom: 0;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
}
.ocr-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ocr-table tr.ocr-unmatched td { background: #fff7ed; }
.ocr-table tr.ocr-duplicate td { background: #fef2f2; }
.ocr-table tr.ocr-empty td { color: var(--muted); }
.ocr-duplicate-warning {
  margin: 6px 0;
  color: #b91c1c;
  font-weight: 600;
  font-size: 12px;
}
.ocr-dup-badge {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 700;
  font-size: 10px;
  white-space: nowrap;
}
.ocr-room-select { max-width: 112px; font-size: 11px; }
.ocr-status { white-space: nowrap; font-weight: 600; }
.columns-modal { width: min(900px, 100%); }
.columns-toolbar { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.columns-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 20px;
  max-height: 55vh;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.columns-group { display: flex; flex-direction: column; gap: 5px; align-content: start; }
.columns-group h3 {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.columns-group label.check { display: flex; align-items: flex-start; white-space: normal; line-height: 1.3; }
.columns-group label.check input { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 1px; }
.ocr-status.matched { color: #15803d; }
.ocr-status.unmatched { color: #b45309; }
.ocr-status.empty { color: var(--muted); }
.ocr-errors { margin: 6px 0 0; padding-left: 18px; color: #b45309; font-size: 11px; }
.ocr-summary { margin: 8px 0; font-size: 12px; }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.preview { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfe; }
.preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.preview-grid div { background: #fff; border: 1px solid var(--line-soft); border-radius: 7px; padding: 8px; }
.preview-grid span { display: block; color: var(--muted); font-size: 11px; }
.preview-grid strong { font-size: 15px; }
.preview-list { max-height: 130px; overflow: auto; font-size: 12px; color: #475569; }
.import-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.import-fields .check { white-space: normal; line-height: 1.35; }
.import-fields .span-2 { grid-column: 1 / -1; }

/* AirHost duplicate screening on the Periods home page. */
.dedupe-upload { flex-wrap: wrap; margin-top: 12px; }
.dedupe-upload input[type="file"] { min-width: 260px; font-size: 12px; }
.dedupe-warn { color: #9a6700; }
.dedupe-error { color: var(--danger); }
.dedupe-summary { margin-top: 14px; }
.dedupe-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.dedupe-summary-grid div {
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  min-width: 0;
}
.dedupe-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 3px;
}
.dedupe-summary-grid strong {
  display: block;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dedupe-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.dedupe-group {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #fff;
}
.dedupe-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line-soft);
}
.dedupe-group-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}
.dedupe-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eaf7ef;
  color: #067647;
  font-size: 10.5px;
  font-weight: 600;
}
.dedupe-badge-direct { background: #eaf1ff; color: #1d4ed8; }
.dedupe-table-wrap { max-height: 420px; overflow: auto; }
table.dedupe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.dedupe-table th,
table.dedupe-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.dedupe-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
table.dedupe-table tbody tr:hover { background: #fbfcfe; }
table.dedupe-table tbody tr.focus-row { background: #f3fbf6; }
table.dedupe-table tbody tr.focus-row:hover { background: #eaf7ef; }
table.dedupe-table tbody tr.to-remove { background: #fff1f0; }
table.dedupe-table tbody tr.to-remove:hover { background: #ffe9e7; }
.dedupe-check-cell { width: 42px; text-align: center !important; }
.dedupe-check-cell input { cursor: pointer; }
.dedupe-booking { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.dedupe-status-off { color: #b45309; }
.dedupe-status-ok { color: #15803d; }
.dedupe-empty {
  margin-top: 12px;
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .25);
}
.toast.err { background: var(--danger); }

/* Distraction-free table mode: hide the page chrome so the grid fills the window. */
body.table-focus .topbar,
body.table-focus .page-head,
body.table-focus .chips,
body.table-focus .formula-note { display: none; }

body.table-focus .page { padding: 0; }
body.table-focus .toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 5px 9px;
  border-radius: 0;
  background: #fff;
}
body.table-focus .table-wrap {
  max-height: calc(100vh - 90px);
  min-height: 0;
  border-radius: 0;
}

@media (max-width: 900px) {
  .page { padding: 14px; }
  .page-head { flex-direction: column; }
  .toolbar input[type="search"] { width: 150px; }
  .table-wrap { max-height: calc(100vh - 340px); }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dedupe-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
