@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;700&display=swap");

:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --border: #ead9c9;
  --text: #2a2420;
  --text-muted: #86746a;
  --accent: #ff6b5e;
  --accent-2: #ff9a56;
  --accent-text: #ffffff;
  --teal: #19b3ad;
  --sun: #ffc24b;
  --danger: #d6483a;
  --table-header-bg: #fdf1e6;
  --row-hover: #fff3e9;
  --shadow: 0 4px 14px rgba(170, 100, 60, 0.12);
  --header-grad: linear-gradient(120deg, #ff8a65, #ffb74d);
  --header-text: #3a241a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171414;
    --surface: #211c1c;
    --border: #3a3230;
    --text: #f2e9e4;
    --text-muted: #b7a69c;
    --accent: #ff8372;
    --accent-2: #ffb15e;
    --accent-text: #241210;
    --teal: #2cd4cd;
    --sun: #ffd579;
    --danger: #ff7a6b;
    --table-header-bg: #2a2423;
    --row-hover: #2e2724;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    --header-grad: linear-gradient(120deg, #7a3a2e, #4a2f22);
    --header-text: #ffe8d9;
  }
}

* {
  box-sizing: border-box;
}

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

h1, h2, h3, .brand {
  font-family: "Baloo 2", -apple-system, sans-serif;
}

a {
  color: var(--accent);
}

.danger-banner {
  background: #c62828;
  color: #fff;
  text-align: center;
  font-weight: 700;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.danger-banner a {
  color: #fff;
  text-decoration: underline;
}

.danger-banner code {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.75rem;
  background: var(--header-grad);
  color: var(--header-text);
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--header-text);
  letter-spacing: 0.02em;
}

.topbar nav {
  display: flex;
  gap: 1.1rem;
  flex: 1;
}

.topbar nav a {
  text-decoration: none;
  color: var(--header-text);
  opacity: 0.85;
  font-weight: 500;
}

.topbar nav a:hover {
  opacity: 1;
  text-decoration: underline;
}

.user-pill {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.9rem;
}

.user-pill a {
  color: var(--header-text);
  font-weight: 500;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

h1 {
  margin: 0 0 0.3rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.head-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem 0;
}

.flash {
  background: var(--row-hover);
  border: 1px solid var(--border);
  border-left: 4px solid var(--teal);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  display: inline-block;
}

.error {
  color: var(--danger);
  padding: 0;
  margin: 0.5rem 0;
}

.error li {
  margin-left: 1.2rem;
}

.btn,
button,
.btn-sub {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover,
button:hover,
.btn-sub:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn,
form button[type="submit"] {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  border-color: transparent;
}

.btn-sub.disabled {
  opacity: 0.4;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

.link-danger {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  border-radius: 0;
  box-shadow: none !important;
  transform: none !important;
}

.auth-card {
  max-width: 360px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--accent);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 480px;
}

.form-grid fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0 0 0.5rem 0;
  padding: 0.9rem 1rem 1.1rem;
}

.form-grid legend {
  font-weight: 700;
  color: var(--text);
  padding: 0 0.3rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}

input,
select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

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

.simple-table,
.grid-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.simple-table {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.simple-table th,
.simple-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.7rem;
  text-align: left;
}

.simple-table thead th {
  background: var(--table-header-bg);
}

.simple-table tbody tr:hover {
  background: var(--row-hover);
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.row-actions form {
  display: inline;
}

.tier-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* ---- grid table (main price table) ---- */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.grid-table th,
.grid-table td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem;
  text-align: center;
  min-width: 88px;
}

.grid-table thead th {
  background: var(--table-header-bg);
  vertical-align: top;
}

.grid-table .corner {
  min-width: 220px;
  text-align: left;
}

.tier-group-row td {
  text-align: left !important;
  font-weight: 700;
  background: color-mix(in srgb, var(--tier-color, var(--border)) 16%, var(--table-header-bg));
  border-left: 4px solid var(--tier-color, var(--border));
  padding: 0.45rem 0.6rem;
}

.force-scan-popover {
  position: relative;
  display: inline-block;
}

.force-scan-popover summary {
  list-style: none;
}

.force-scan-popover summary::-webkit-details-marker {
  display: none;
}

.force-scan-form {
  position: absolute;
  right: 0;
  z-index: 5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 220px;
  margin-top: 0.4rem;
}

.hotel-cell {
  text-align: left !important;
  border-left: 4px solid var(--tier-color, var(--border)) !important;
  white-space: nowrap;
}

.night-label {
  font-weight: 700;
  font-size: 0.85rem;
}

.notes-box summary {
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.notes-box {
  margin-top: 0.25rem;
  text-align: left;
}

.note-row {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.75rem;
  padding: 0.1rem 0;
}

.note-add {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.note-add input {
  font-size: 0.75rem;
  padding: 0.2rem 0.3rem;
  flex: 1;
  min-width: 0;
  border-radius: 6px;
}

.price-cell {
  cursor: default;
  vertical-align: middle;
}

.price-cell[data-hotel] {
  cursor: pointer;
}

.price-cell .price {
  font-weight: 700;
}

.tag-slot {
  min-height: 1.1em;
  font-size: 0.65rem;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-weight: 600;
}

.tag-low {
  background: var(--sun);
  color: #4a3a00;
}

.color-neutral {
  background: var(--surface);
}

.color-green {
  background: #35a164;
  color: #fff;
}

.color-red {
  background: #d6483a;
  color: #fff;
}

.color-black {
  background: #231f1d;
  color: #fff;
}

.color-cyan {
  background: #1fc9c2;
  color: #043431;
}

.color-gray {
  background: #a79a90;
  color: #231f1d;
}

.color-no_data {
  background: var(--table-header-bg);
}

.near-low {
  animation: pulse-low 1.6s ease-in-out infinite;
  box-shadow: 0 0 0 2px var(--sun) inset;
}

@keyframes pulse-low {
  0%, 100% {
    box-shadow: 0 0 0 2px var(--sun) inset;
  }
  50% {
    box-shadow: 0 0 0 4px #ffe79e inset;
  }
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend .swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 4px;
  margin-right: 0.3rem;
  vertical-align: middle;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.chart-controls {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.stat-kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 1rem 0 1.75rem;
}

.stat-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--teal);
  border-radius: 12px;
  padding: 0.8rem 1.1rem;
  min-width: 160px;
  box-shadow: var(--shadow);
}

.stat-kpi strong {
  display: block;
  font-size: 1.3rem;
  font-family: "Baloo 2", -apple-system, sans-serif;
}

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

/* ---- modal ---- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 20, 10, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  border-top: 5px solid var(--teal);
  padding: 1.25rem;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: none;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 999px;
  box-shadow: none;
}
