:root {
  --bg: #f7f4ef;
  --ink: #241d1a;
  --muted: #75665e;
  --line: #e2d8cc;
  --surface: #ffffff;
  --brand: #8a1717;
  --brand-dark: #681010;
  --accent: #d8b65a;
  --danger: #b43c35;
  --warn: #b98113;
  --repair: #596579;
  --shadow: 0 16px 38px rgba(58, 28, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.hidden {
  display: none !important;
}

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

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--brand);
}

.primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  font-weight: 700;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #7f1414, #4f0b0b);
}

.login-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-logo {
  width: min(220px, 70vw);
  height: auto;
  justify-self: center;
  border-radius: 8px;
  object-fit: contain;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 100px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #7f1414, #4f0b0b);
  color: white;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
}

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

.brand-logo {
  width: auto;
  height: 68px;
  border-radius: 8px;
  object-fit: contain;
  border: 1px solid rgba(246, 222, 145, 0.65);
}

.brand-copy {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
}

.brand-copy strong {
  color: white;
  font-size: clamp(17px, 1.5vw, 24px);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-copy span {
  color: white;
  font-size: clamp(14px, 1.2vw, 19px);
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  color: #f4df9c;
  font-size: 13px;
  text-transform: uppercase;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.userbox span {
  color: #f9e7b2;
  font-weight: 700;
}

.rolebox select,
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto 36px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.tab {
  white-space: nowrap;
  border-radius: 999px;
  min-width: 92px;
}

.tab.active,
.chip.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric,
.report-card,
.form-panel,
.table-wrap,
.shift-panel,
.chart-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric,
.report-card {
  padding: 16px;
}

.metric span,
.report-card h3 {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
}

.metric strong,
.report-card strong {
  font-size: clamp(22px, 3vw, 28px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 24px;
}

.section-head p {
  color: var(--muted);
  margin: 5px 0 0;
}

.filters,
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  min-height: 36px;
  border-radius: 999px;
}

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

.room-grid.list-mode {
  grid-template-columns: 1fr;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--brand);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.room-card.occupied {
  border-left-color: var(--accent);
}

.room-card.dirty {
  border-left-color: var(--warn);
}

.room-card.repair {
  border-left-color: var(--repair);
}

.room-card.free {
  border-left-color: var(--brand);
}

.room-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.room-title h3 {
  margin: 0;
  font-size: 22px;
}

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  background: #e8eee9;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.badge.occupied {
  background: #fff0df;
  color: #7a4112;
}

.badge.dirty {
  background: #fff7d9;
  color: #7a5510;
}

.badge.repair {
  background: #eef1f6;
  color: #434d5d;
}

.room-card p {
  margin: 8px 0;
  color: var(--muted);
}

.room-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.list-mode .room-card {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
}

.list-mode .room-title {
  display: grid;
  justify-content: start;
  gap: 6px;
}

.list-mode .room-card p {
  margin: 0;
}

.list-mode .room-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 0;
  min-width: 360px;
}

.list-mode .room-actions button {
  min-height: 36px;
}

.form-panel {
  padding: 18px;
}

.shift-panel,
.chart-card {
  padding: 16px;
  margin-bottom: 16px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.compact {
  margin-bottom: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

.grid-form button[type="submit"] {
  align-self: end;
}

.table-wrap {
  overflow-x: auto;
}

.flat {
  box-shadow: none;
  border-color: #d8d8d8;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 13px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.danger {
  color: var(--danger);
  border-color: #efc4c1;
}

.date-filter {
  min-width: 160px;
}

.paper-report {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.report-title {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 14px;
}

.report-logo {
  width: auto;
  height: 120px;
  object-fit: contain;
  border-radius: 8px;
}

.report-date-line {
  text-align: center;
  margin: 8px 0 16px;
  color: var(--muted);
}

.mini-title {
  margin: 18px 0 8px;
  font-size: 17px;
}

.signature-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
  color: var(--muted);
}

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

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

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.refund-card strong {
  color: var(--danger);
}

.bar-chart {
  min-height: 230px;
  display: flex;
  align-items: end;
  gap: 10px;
  overflow-x: auto;
  padding: 16px 6px 4px;
}

.bar-item {
  min-width: 58px;
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  width: 34px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #d8b65a, #8a1717);
}

.bar-value {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 82px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(19, 28, 23, 0.55);
  z-index: 20;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(480px, 100%);
  background: white;
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #17392b;
  color: white;
  border-radius: 8px;
  padding: 12px 16px;
  transition: 0.2s ease;
  max-width: min(460px, calc(100% - 28px));
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 820px) {
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

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

  .grid-form,
  .two-column,
  .payment-split,
  .refund-fields {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .list-mode .room-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .list-mode .room-actions {
    min-width: 0;
    justify-content: stretch;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .tabs,
  .actions,
  .toast,
  .shift-panel,
  #managerDashboard {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    margin: 0;
  }

  .view {
    display: none !important;
  }

  #reports {
    display: block !important;
  }

  .paper-report {
    box-shadow: none;
    border: 0;
    padding: 0;
  }

  .report-logo {
    width: auto;
    height: 90px;
  }
}

@media (max-width: 520px) {
  .brand-logo {
    height: 54px;
  }

  .brand-copy {
    display: grid;
    gap: 1px;
    white-space: normal;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .brand-copy span {
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .metrics,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .room-actions {
    grid-template-columns: 1fr;
  }
}
