:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e1e5ea;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-dark: #15803d;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
}

main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

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

label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 4px;
}

input, select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}

button {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: #eef0f3;
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: #e2e5ea; }

.btn-notify-new {
  background: #dcfce7;
  color: var(--green-dark);
}
.btn-notify-new:hover:not(:disabled) { background: #bbf7d0; }

.btn-notify-edit {
  background: #fef3c7;
  color: var(--amber);
}
.btn-notify-edit:hover:not(:disabled) { background: #fde68a; }

.btn-small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

.status-msg {
  font-size: 0.85rem;
  min-height: 1.2em;
}
.status-msg.ok { color: var(--green-dark); }
.status-msg.err { color: var(--red); }

.mode-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e0e7ff;
  color: var(--primary-dark);
  margin-inline-start: 8px;
  vertical-align: middle;
}
.mode-badge.edit { background: #fef3c7; color: var(--amber); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--card);
}

tbody tr:hover {
  background: #f9fafb;
}

.table-wrap {
  overflow-x: auto;
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.confirmed { background: #dcfce7; color: var(--green-dark); }
.badge.cancelled { background: #fee2e2; color: var(--red); }
.badge.sent { background: #e0e7ff; color: var(--primary-dark); }

.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters-row label {
  min-width: 140px;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.login-card .muted {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 20px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.login-card label {
  text-align: left;
}

.login-card .actions {
  margin-top: 4px;
  justify-content: stretch;
}

.login-card .btn-primary {
  width: 100%;
}

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

/* Header navigation and signed-in user */
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 2px;
  border-bottom: 2px solid transparent;
}

.nav a:hover {
  color: var(--text);
}

.nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--text);
}

.role-badge.admin { background: #dbeafe; color: #1e40af; }
.role-badge.support { background: #dcfce7; color: #166534; }
.role-badge.finance { background: #fef3c7; color: #92400e; }
.role-badge.reporting { background: #ede9fe; color: #5b21b6; }

.row-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}

/* Roles without money access: hide price, currency and payment status. */
.no-money .money-col,
.no-money .money-field {
  display: none;
}

/* Hotel Rates page */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form input {
  flex: 1;
  min-width: 0;
}

.name-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.name-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.name-list li.off {
  color: var(--muted);
}

/* Read-only roles (e.g. reporting) don't get the add/edit forms. */
.read-only [data-edit] {
  display: none;
}

/* Rates grid: a spreadsheet-like table with editable cells */
main.wide {
  max-width: none;
  padding: 0 16px 48px;
}

.sheet-card {
  padding: 16px;
}

.sheet-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.sheet-head h2 {
  margin: 0;
}

.sheet-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.sheet-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 200px;
}

.sheet-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 1.4em;
  font-size: 0.85rem;
}

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  min-height: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table.sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.85rem;
}

table.sheet th,
table.sheet td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

table.sheet th:last-child,
table.sheet td:last-child {
  border-right: 0;
}

table.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f1f4f8;
  padding: 8px 8px;
  text-align: left;
  font-weight: 600;
  user-select: none;
}

table.sheet thead th[data-sort] {
  cursor: pointer;
}

table.sheet thead th[data-sort]:hover {
  background: #e7ecf3;
}

table.sheet thead th.sorted::after {
  content: " " attr(data-dir);
  color: var(--primary);
  font-size: 0.7rem;
}

/* The "new rate" row stays pinned under the header while the table scrolls. */
table.sheet thead tr.new-row td {
  position: sticky;
  top: 37px;
  z-index: 2;
  background: #eef5ff;
  border-bottom: 2px solid var(--primary);
}

table.sheet tbody tr:hover td {
  background: #f8fafc;
}

table.sheet td.hotel-cell {
  padding: 0 10px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

table.sheet td.col-id,
table.sheet th.col-id {
  width: 52px;
  text-align: right;
  padding: 0 10px;
}

table.sheet td.col-nights,
table.sheet th.col-nights {
  text-align: right;
  padding: 0 8px;
  width: 52px;
}

table.sheet td.col-changed {
  padding: 0 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

table.sheet td[data-computed="status"] {
  padding: 0 10px;
}

table.sheet td.col-actions {
  padding: 3px 8px;
  display: table-cell;
}

.cell {
  display: block;
  width: 100%;
  min-width: 0;
  height: 34px;
  margin: 0;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}

select.cell {
  width: 156px;
  min-width: 0;
}

select.cell.plan {
  width: 206px;
}

table.sheet td.hotel-cell {
  width: 150px;
  max-width: 150px;
}

input.cell[type="number"] {
  width: 68px;
  text-align: right;
}

input.cell.amount {
  width: 100px;
  font-variant-numeric: tabular-nums;
}

input.cell[type="date"] {
  width: 118px;
  padding: 0 4px;
}

.cell:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: #fff;
}

.cell:disabled {
  opacity: 1;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  appearance: none;
}

.read-only select.cell:disabled {
  background-image: none;
}

.cell.saving { background: #fef9c3; }
.cell.saved { background: #dcfce7; transition: background 1s; }
.cell.error { background: #fee2e2; outline: 2px solid var(--red); outline-offset: -2px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pill.active { background: #dcfce7; color: var(--green-dark); }
.pill.upcoming { background: #dbeafe; color: #1e40af; }
.pill.expired { background: #e5e7eb; color: var(--muted); }

.sheet-help {
  margin: 10px 0 0;
  font-size: 0.8rem;
}

.read-only .new-row,
.read-only td.col-actions,
.read-only th.col-actions {
  display: none;
}

/* The action buttons stay visible while the table scrolls sideways. */
table.sheet td.col-actions,
table.sheet th.col-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  border-left: 1px solid var(--border);
}

table.sheet thead th.col-actions {
  z-index: 4;
  background: #f1f4f8;
}

table.sheet thead tr.new-row td.col-actions {
  z-index: 3;
  background: #eef5ff;
}

table.sheet tbody tr:hover td.col-actions {
  background: #f8fafc;
}

table.sheet td.col-actions .btn-small {
  padding: 4px 8px;
}

table.sheet th.col-changed,
table.sheet td.col-changed {
  min-width: 215px;
}

table.sheet th.col-status,
table.sheet td[data-computed="status"] {
  min-width: 84px;
}

/* Hotel match (Bookings page) */
.badge.amber { background: #fef3c7; color: #92400e; }

button.match-badge {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
}

.match-what {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
  max-width: 220px;
  white-space: normal;
}

.no-match [data-match] {
  display: none;
}

.match-dialog {
  width: min(640px, 94vw);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
}

.match-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.match-dialog h2 {
  margin: 0 0 4px;
}

.match-preview {
  margin: 12px 0;
}

.match-preview .table-wrap {
  max-height: 220px;
  overflow: auto;
}

.match-preview .missing {
  color: var(--red);
  font-weight: 600;
}

.match-nights td.num,
.match-nights th:last-child {
  text-align: right;
}

.match-override {
  margin: 12px 0;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fffbeb;
}

.match-override .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.match-override .check input {
  width: auto;
}

/* An element marked hidden stays hidden even where a class sets display. */
[hidden] {
  display: none !important;
}

.match-override label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.match-override label.check input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* Finance dashboard */
.fin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.fin-toolbar h2 {
  margin: 0;
}

.fin-period {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.fin-period label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.fin-basis {
  margin: 0 0 8px;
  font-size: 0.85rem;
}

.fin-alert {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.kpi.strong {
  border-color: var(--primary);
  background: #f5f9ff;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.kpi-forecast {
  grid-column: 1 / -1;
  font-size: 0.85rem;
}

table.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.fin-table th,
table.fin-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.fin-table th {
  background: #f1f4f8;
  font-weight: 600;
  white-space: nowrap;
}

table.fin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

table.fin-table td.loss {
  color: var(--red);
  font-weight: 600;
}

table.fin-table td.guest {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table.fin-table tr.voided td {
  color: var(--muted);
  text-decoration: line-through;
}

table.fin-table tr.voided td.col-pay {
  text-decoration: none;
}

.fin-bookings {
  max-height: 520px;
  overflow: auto;
}

.fin-bookings thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.fin-note {
  margin: 10px 0 0;
  font-size: 0.8rem;
}

.pill.ok { background: #dcfce7; color: var(--green-dark); }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.info { background: #dbeafe; color: #1e40af; }
.pill.off { background: #e5e7eb; color: var(--muted); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chip-n {
  opacity: 0.75;
  margin-left: 4px;
}

.read-only .col-pay,
.read-only [data-edit] {
  display: none;
}

.pill.plain { background: #f1f5f9; color: var(--text); }

button.rg-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
}

.rg-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.rg-options label.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.rg-options label.check input {
  width: auto;
  margin: 0;
}

/* Hotel Rates, tree view: hotels are groups, values are text until clicked */
.sheet-filters .spacer {
  flex: 1;
}

.add-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #bfd4f6;
  border-radius: 8px;
  background: #eef5ff;
}

.add-bar .add-title {
  align-self: center;
  font-weight: 700;
  margin-right: 4px;
}

.add-bar label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.75rem;
  color: var(--muted);
}

.add-bar select,
.add-bar input {
  height: 32px;
  font-size: 0.85rem;
}

.add-bar select {
  min-width: 150px;
}

.add-bar select.plan {
  min-width: 200px;
}

.add-bar input[type="number"] {
  width: 90px;
}

.add-bar input[type="date"] {
  width: 130px;
}

table.sheet tr.group td {
  background: #eef2f7;
  padding: 9px 12px;
  cursor: pointer;
  border-top: 1px solid var(--border);
  user-select: none;
}

table.sheet tr.group:hover td {
  background: #e4eaf3;
}

table.sheet tr.group .twisty {
  display: inline-block;
  width: 18px;
  color: var(--primary);
}

table.sheet tr.group .muted {
  margin-left: 10px;
  font-size: 0.8rem;
  font-weight: 400;
}

table.sheet tr.group .group-add {
  margin-left: 12px;
  visibility: hidden;
}

table.sheet tr.group:hover .group-add {
  visibility: visible;
}

table.sheet tr.rate-row td.col-id {
  padding-left: 26px;
  border-left: 3px solid #cbd5e1;
}

table.sheet td.c {
  padding: 0 10px;
  height: 34px;
  cursor: text;
}

table.sheet td.c:hover {
  background: #eef5ff;
  box-shadow: inset 0 0 0 1px #bfd4f6;
}

table.sheet td.c.ro,
table.sheet td.c.ro:hover {
  cursor: default;
  background: transparent;
  box-shadow: none;
}

table.sheet td.c.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.sheet td.c.editing {
  padding: 0;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--primary);
}

table.sheet td.c.editing .cell {
  width: 100%;
  min-width: 120px;
  height: 34px;
  background: #fff;
}

table.sheet td.c.editing select.cell {
  min-width: 190px;
}

table.sheet td.c.editing input.cell[type="number"] {
  text-align: right;
}

table.sheet td.c.saving {
  background: #fef9c3;
}

table.sheet td.c.saved {
  background: #dcfce7;
  transition: background 1s;
}

table.sheet td.c.error {
  background: #fee2e2;
  box-shadow: inset 0 0 0 2px var(--red);
}

table.sheet tr.flash td {
  background: #fef9c3;
}

table.sheet td.col-actions {
  white-space: nowrap;
}

table.sheet td.col-actions [data-edit] {
  display: inline;
}

.history-dialog {
  width: min(620px, 94vw);
}

.history-body {
  max-height: 55vh;
  overflow: auto;
  margin: 8px 0 12px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-list > li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.h-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.h-changes {
  margin: 0;
  padding-left: 18px;
  font-size: 0.88rem;
}

.h-field {
  display: inline-block;
  min-width: 86px;
  color: var(--muted);
}

.h-changes s {
  color: var(--red);
}

/* Bookings page, tree view (shares the sheet styles of Hotel Rates) */
.add-details {
  margin: 0 0 12px;
}

.add-details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  padding: 4px 0;
  user-select: none;
}

.add-bar-booking {
  margin-top: 8px;
}

.add-bar-booking input[type="text"],
.add-bar-booking input:not([type]) {
  min-width: 150px;
}

.add-bar-booking label.money-field {
  display: flex;
}

.no-money .add-bar-booking .money-field {
  display: none;
}

table.sheet td.c.wrap {
  white-space: normal;
  min-width: 130px;
  max-width: 230px;
  line-height: 1.25;
  padding-top: 4px;
  padding-bottom: 4px;
}

table.sheet td.c.hotelcol {
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warn-text {
  color: #92400e;
  font-weight: 600;
}

.bookings-wrap {
  max-height: calc(100vh - 330px);
}

table.sheet td[data-computed="match"] {
  padding: 3px 10px;
  min-width: 150px;
}

table.sheet td[data-computed="notif"] {
  padding: 3px 10px;
  white-space: nowrap;
}

/* Long guest and room names break inside their cell instead of running over the next one. */
table.sheet td.c.wrap {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#bookings-tbody td[data-field="guest_name"] {
  min-width: 170px;
  max-width: 215px;
}

#bookings-tbody td[data-field="room"] {
  min-width: 115px;
  max-width: 150px;
}

/* tighter number columns and headers so the whole table fits a wide screen */
#bookings-tbody td.c.num {
  padding-left: 5px;
  padding-right: 5px;
}

#sheet thead th {
  padding-left: 6px;
  padding-right: 6px;
}

#bookings-tbody td.rate-col {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding: 0 10px;
  min-width: 90px;
}

/* RateGain and Profit columns of the Bookings page */
#bookings-tbody td.rg-col {
  min-width: 78px;
  padding: 3px 8px;
  white-space: nowrap;
}

.rg-amt {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

#bookings-tbody td.profit-col {
  text-align: right;
  white-space: nowrap;
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
}

#bookings-tbody td.profit-col b.loss {
  color: var(--red);
}

.h-origin .h-head {
  margin-bottom: 0;
}

/* Bookings columns: tighter so everything fits on a normal wide screen */
#bookings-tbody td.col-id,
#sheet thead th.col-id {
  width: 44px;
  padding-left: 8px;
  padding-right: 6px;
}

#bookings-tbody tr.rate-row td.col-id {
  padding-left: 14px;
}

#bookings-tbody td.c.hotelcol {
  max-width: 105px;
}

#bookings-tbody td.col-nights,
#sheet thead th.col-nights {
  width: 46px;
  padding: 0 6px;
}

#bookings-tbody td.c {
  padding-left: 7px;
  padding-right: 7px;
}

table.sheet td.c.wrap {
  min-width: 110px;
  max-width: 180px;
}

#bookings-tbody td[data-computed="match"] {
  min-width: 128px;
}

#bookings-tbody td.col-actions,
#sheet thead th.col-actions {
  width: 72px;
}

/* Match dialog v2: suggestions first, manual choice second */
.match-dialog.match-v2 {
  width: min(780px, 95vw);
  max-height: 92vh;
  overflow: auto;
  padding: 0;
}

.match-v2 .md-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px;
}

.match-v2 .md-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.match-v2 .md-x {
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
}

.match-v2 .md-x:hover {
  background: #eef2f7;
  color: var(--text);
}

.match-v2 > :not(.md-head) {
  margin-left: 22px;
  margin-right: 22px;
}

.md-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 18px;
  padding: 12px 14px;
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.md-facts .fact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.92rem;
}

.md-facts .fact-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.md-facts .fact-room {
  grid-column: 1 / -1;
}

.room-chip {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #bfd4f6;
  color: #1e3a8a;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.md-current {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.md-current.state-needs_rate,
.md-current.state-override {
  background: #fffbeb;
  border-color: #fcd34d;
}

.md-current.state-stale {
  background: #fef2f2;
  border-color: #fecaca;
}

.md-section {
  margin-top: 16px;
}

.md-section-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.md-section-title .muted {
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 6px;
}

.sug {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
}

.sug.top {
  border: 2px solid var(--primary);
  background: #f5f9ff;
}

.sug-main {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.sug-title {
  font-weight: 700;
  font-size: 1rem;
}

.sug-plan {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 6px;
}

.sug-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reason {
  font-size: 0.75rem;
  background: #eef2f7;
  color: #374151;
  padding: 2px 8px;
  border-radius: 999px;
}

.sug-rate {
  font-size: 0.82rem;
}

.sug-rate.ok {
  color: var(--green-dark);
}

.sug-rate.warn {
  color: #92400e;
}

.sug-side {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 150px;
  text-align: center;
}

.conf {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conf.high { color: var(--green-dark); }
.conf.medium { color: #1e40af; }
.conf.low { color: var(--muted); }

.btn-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  padding: 2px;
}

.btn-link:hover {
  text-decoration: underline;
}

.md-none {
  margin: 0 0 6px;
  padding: 10px 12px;
  background: #f6f8fb;
  border-radius: 8px;
}

.md-manual > summary {
  cursor: pointer;
  font-weight: 700;
  padding: 6px 0;
  user-select: none;
}

.md-manual[open] > summary {
  margin-bottom: 8px;
}

.md-similar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 8px;
  font-size: 0.88rem;
}

.md-similar input {
  width: auto;
  margin-top: 3px;
}

.md-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 18px;
}

.md-footer .spacer {
  flex: 1;
}

.md-manual-actions {
  margin-top: 8px;
}

@media (max-width: 640px) {
  .sug {
    flex-direction: column;
    align-items: stretch;
  }
}

#bookings-tbody td.mr-col {
  min-width: 76px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* Manual hotel rate dialog */
.mr-dialog { max-width: 760px; width: 92vw; }
.mr-facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0 14px; }
.mr-facts div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mr-facts span { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.mr-facts b { font-weight: 600; word-break: break-word; }
.mr-facts .mr-nights-tile b { font-size: 1.5rem; line-height: 1.1; color: var(--primary); }
.mr-ref { margin-bottom: 14px; }
.mr-ref h3 { font-size: 0.9rem; margin: 0 0 6px; }
.mr-room { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 8px; }
.mr-room-name { font-weight: 600; margin-bottom: 4px; }
.mr-plans { width: 100%; border-collapse: collapse; }
.mr-plans td { padding: 3px 8px 3px 0; font-size: 0.85rem; vertical-align: middle; }
.mr-plans td.num { white-space: nowrap; text-align: right; }
.mr-chip { border: 1px solid var(--primary); background: var(--card); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.mr-chip:hover { background: var(--primary); color: #fff; }
.mr-calc { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 2px solid var(--primary); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.mr-calc .mr-rate { flex: 1 1 190px; display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.mr-calc .mr-rate input { font-size: 1.2rem; font-weight: 600; }
.mr-op { font-size: 1.3rem; color: var(--muted); }
.mr-factor, .mr-total-box { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.mr-factor b { font-size: 1.6rem; line-height: 1.1; }
.mr-factor span, .mr-total-box span { font-size: 0.7rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.mr-total-box b { font-size: 1.6rem; line-height: 1.1; color: var(--green-dark); font-variant-numeric: tabular-nums; }
.mr-reason { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.mr-hint { font-size: 0.8rem; margin: 6px 0; }
@media (max-width: 640px) { .mr-facts { grid-template-columns: 1fr 1fr; } }

.profit-pct { margin: 0 0 1px; text-align: right; }
.profit-pct.loss { color: var(--red); }

/* On / off toggle (Withdrawn, Collected) */
.toggle { position: relative; width: 38px; height: 22px; border: 0; border-radius: 999px; background: #cbd2dc; cursor: pointer; padding: 0; transition: background 0.15s; vertical-align: middle; }
.toggle i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: left 0.15s; }
.toggle.on { background: var(--green-dark); }
.toggle.on i { left: 19px; }
.toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
#bookings-tbody td.step-col { text-align: center; }

/* Bookings page: statistics, filter bar, hotel dropdown, quick filters */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-top: 3px solid var(--border); }
.stat.warn { border-top-color: var(--amber); }
.stat.good { border-top-color: var(--green-dark); }
.stat.bad { border-top-color: var(--red); }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.stat-value { font-size: 1.5rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat.bad .stat-value { color: var(--red); }
.stat-sub { font-size: 0.75rem; color: var(--muted); }

.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.filter-bar .field { display: flex; flex-direction: column; gap: 3px; min-width: 150px; position: relative; }
.filter-bar .field.grow { flex: 1 1 200px; }
.filter-bar .field > label { font-size: 0.75rem; color: var(--muted); }
.filter-bar input { height: 36px; width: 100%; box-sizing: border-box; }
.combo { min-width: 240px !important; }
.combo-box { position: relative; }
.combo-box input { padding-right: 52px; }
.combo-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.combo-clear { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; padding: 2px 4px; }
.combo-clear:hover { color: var(--red); }
.combo-list { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 100%; max-height: 320px; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); margin-top: 4px; padding: 4px; }
.combo-opt { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.combo-opt:hover, .combo-opt.hi { background: var(--bg); }
.combo-opt.sel { font-weight: 600; color: var(--primary); }
.combo-n { margin-left: auto; font-size: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.combo-n.zero { opacity: 0.5; }
.combo-empty { padding: 10px; color: var(--muted); font-size: 0.85rem; }

.quick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.quick-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); min-width: 86px; }
.quick-row .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.quick-row .presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-group { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 2px 0 10px; }
.chip.zero { opacity: 0.5; }
.chip .chip-n { margin-left: 6px; font-size: 0.72rem; opacity: 0.75; font-variant-numeric: tabular-nums; }
.quick-row .spacer { flex: 1; }

/* ---------- Bookings page: compact three-line header (2026-11-21) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.compact-head { gap: 8px; margin-bottom: 8px; }

/* Line 1: figures, one row; scrolls sideways when the screen is narrow */
.kpi-strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.kpi { flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; gap: 0; padding: 5px 9px; border: 1px solid var(--border); border-left: 3px solid var(--border); border-radius: 8px; background: var(--card); }
.kpi.warn { border-left-color: var(--amber); }
.kpi.good { border-left-color: var(--green-dark); }
.kpi.bad { border-left-color: var(--red); }
.kpi-l { font-size: 0.62rem; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); white-space: nowrap; }
.kpi-v { font-size: 1rem; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi.bad .kpi-v { color: var(--red); }
.kpi-s { font-size: 0.66rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Line 2: filters */
.filter-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-line .field { position: relative; min-width: 0; }
.filter-line .field.combo { min-width: 170px !important; flex: 0 1 200px; }
.filter-line .field.grow { flex: 1 1 160px; }
.filter-line input, .filter-line select { height: 34px; box-sizing: border-box; }
.filter-line .field input { width: 100%; }
.filter-line .date-group { display: flex; align-items: center; gap: 6px; }
.filter-line .date-group input { width: 132px; }
.filter-line .date-group select { width: auto; }
.filter-line .inline-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.filter-line .spacer { flex: 1; }

/* Line 3: quick filters in one row (sideways scroll) + count on the right */
.chip-line { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chip-line .chips { flex: 1; min-width: 0; display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin: 0; overflow-x: auto; scrollbar-width: thin; padding: 2px 0; }
.chip-line .chip { white-space: nowrap; flex-shrink: 0; padding: 3px 10px; }
.chip-line .chip-group { white-space: nowrap; margin-left: 8px; }
.chip-line .sheet-summary { flex-shrink: 0; gap: 8px; white-space: nowrap; }
.icon-btn { min-width: 30px; padding-left: 6px; padding-right: 6px; font-size: 1rem; line-height: 1; }
@media (max-width: 700px) {
  .chip-line { flex-wrap: wrap; }
  .filter-line .date-group { flex-wrap: wrap; }
}

/* ---------- Dashboard page (2026-11-21) ---------- */
main.dash { gap: 14px; margin-top: 18px; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.dash-bar .date-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dash-bar .date-group input { width: 140px; }
.dash-bar input, .dash-bar select { height: 34px; box-sizing: border-box; }
.dash-bar .inline-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.dash-note { font-size: 0.8rem; }

.dash-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.dash-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; border-top: 3px solid var(--border); }
.dash-kpi.good { border-top-color: var(--green-dark); }
.dash-kpi.warn { border-top-color: var(--amber); }
.dash-kpi.bad { border-top-color: var(--red); }
.dash-kpi-l { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.dash-kpi-v { font-size: 1.45rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.dash-kpi.bad .dash-kpi-v { color: var(--red); }
.dash-kpi-s { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 0.75rem; color: var(--muted); min-height: 1.2em; }
.dlt { font-weight: 600; font-variant-numeric: tabular-nums; }
.dlt.up { color: var(--green-dark); }
.dlt.down { color: var(--red); }
.dlt.flat { color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
.dash-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dash-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dash-card-head h2 { margin: 0; font-size: 0.95rem; }
.dash-card-head.dash-sub { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.dash-link { font-size: 0.8rem; color: var(--primary); text-decoration: none; }
.dash-link:hover { text-decoration: underline; }

.dash-legend { display: flex; gap: 12px; font-size: 0.75rem; color: var(--muted); }
.dash-legend .lg { display: flex; align-items: center; gap: 5px; }
.dash-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dash-legend .s1 i, .dash-chart .bar.s1 { background: #4f46e5; fill: #4f46e5; }
.dash-legend .s2 i, .dash-chart .bar.s2 { background: #10b981; fill: #10b981; }
.dash-chart .bar.neg { fill: var(--red); }
.dash-chart svg { width: 100%; height: auto; display: block; }
.dash-chart .grid { stroke: var(--border); stroke-dasharray: 3 3; }
.dash-chart .zero { stroke: #9ca3af; }
.dash-chart .axis { font-size: 10px; fill: var(--muted); }
.dash-chart .hl { fill: #eef2ff; }

.dash-list { display: flex; flex-direction: column; }
.dash-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 0.87rem; }
.dash-line:last-child { border-bottom: 0; }
.dash-line small { display: block; font-size: 0.72rem; color: var(--muted); }
.dash-line b { font-variant-numeric: tabular-nums; }
.dash-line.warn b { color: var(--amber); }
.dash-line.bad b { color: var(--red); }
.dash-line.ok b { color: var(--green-dark); }

.dash-table-wrap { overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dash-table th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.dash-table td { padding: 7px 8px; border-bottom: 1px solid #f0f2f5; }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-table .loss { color: var(--red); }
.dash-table .name-cell { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 110px; }
.dash-table .share { display: block; height: 3px; border-radius: 2px; background: #c7d2fe; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
