:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #687386;
  --line: #dfe5ec;
  --brand: #136f63;
  --brand-dark: #0b4e45;
  --accent: #c9822b;
  --danger: #c94141;
  --ok: #168a55;
  --warn: #b7791f;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin: 0 0 6px;
}

input, select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.shell {
  min-height: 100vh;
}

.login-view {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(23, 32, 42, 0.08);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel h1, .sidebar h1, .topbar h2 {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.app-view {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #101820;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  justify-content: space-between;
  padding: 22px;
}

.sidebar .eyebrow, .profile-box div + div {
  color: #aeb8c4;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn, .ghost {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: inherit;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
}

.nav-btn.active, .nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.profile-box {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  display: grid;
  gap: 8px;
  padding-top: 16px;
}

.content {
  min-width: 0;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.icon-btn {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.primary {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
}

.primary:hover {
  background: var(--brand-dark);
}

.primary:disabled {
  background: #9aa6b2;
  cursor: wait;
}

.wide {
  grid-column: 1 / -1;
}

.toolbar {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(140px, 1fr));
  margin-bottom: 14px;
}

.metric-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 14px;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  display: block;
  font-size: 24px;
  font-weight: 700;
}

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

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

th {
  background: #f9fafb;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  padding: 3px 9px;
  white-space: nowrap;
}

.status-pending { background: #fff5d6; color: var(--warn); }
.status-confirmed { background: #e4f6ed; color: var(--ok); }
.status-checked_in { background: #dff3ff; color: #12617d; }
.status-checked_out { background: #eceff3; color: #4c5968; }
.status-cancelled, .status-no_show { background: #fde7e7; color: var(--danger); }

.link-btn {
  background: transparent;
  border: 0;
  color: var(--brand);
  padding: 0;
  text-decoration: underline;
}

.form-grid, .action-grid, .detail-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}

.detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-item {
  min-width: 0;
}

.detail-item strong {
  display: block;
  overflow-wrap: anywhere;
}

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

.room-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 14px;
}

.room-tile.maintenance { border-left-color: var(--accent); }
.room-tile.closed { border-left-color: var(--danger); }

.report-toolbar {
  grid-template-columns: minmax(180px, 1.2fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
}

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

.report-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 16px;
}

.report-section h3 {
  font-size: 16px;
  margin: 0 0 12px;
}

.section-head {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.section-head small {
  color: var(--muted);
}

.daily-chart {
  align-items: end;
  display: grid;
  gap: 6px;
  grid-auto-flow: column;
  grid-auto-columns: minmax(20px, 1fr);
  min-height: 180px;
  overflow-x: auto;
  padding-top: 12px;
}

.daily-bar {
  align-items: center;
  display: grid;
  gap: 6px;
  grid-template-rows: 1fr auto;
  min-width: 22px;
}

.daily-bar-fill {
  align-self: end;
  background: linear-gradient(180deg, var(--brand), var(--brand-dark));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  width: 100%;
}

.daily-bar small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

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

.breakdown-item {
  display: grid;
  gap: 6px;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.breakdown-track {
  background: #eef2f5;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.breakdown-fill {
  background: var(--accent);
  height: 100%;
}

.message {
  border-radius: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.message.error { background: #fde7e7; color: var(--danger); }
.message.success { background: #e4f6ed; color: var(--ok); }

dialog {
  border: 0;
  border-radius: 10px;
  max-width: 820px;
  padding: 0;
  width: min(820px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.45);
}

.dialog-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
}

menu {
  margin: 0;
  padding: 0;
}

svg {
  height: 18px;
  width: 18px;
}

@media (max-width: 860px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .toolbar, .metric-row, .form-grid, .action-grid, .detail-grid, .report-grid {
    grid-template-columns: 1fr;
  }
}
