:root {
  --ink: #1c2433;
  --ink-2: #4a5568;
  --ink-3: #7a8494;
  --line: #dde2e7;
  --paper: #eef1f3;
  --panel: #ffffff;
  --lake: #1f5f8b;
  --lake-soft: #e3eef6;
  --foc: #2f7d5b;
  --foc-free: #cfe6da;
  --paid: #b86e1e;
  --paid-free: #f1dfc7;
  --special: #6b4fa0;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn-soft: #fff4dc;
  --radius: 10px;
  --radius-sm: 6px;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--lake); }
code { background: var(--lake-soft); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
:focus-visible { outline: 2px solid var(--lake); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side {
  background: var(--ink);
  color: #d6dce5;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px; }
.brand strong { display: block; color: #fff; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.brand small { color: #93a0b3; font-size: 12px; }
.brand-mark { display: grid; grid-template-columns: repeat(2, 11px); gap: 3px; }
.brand-mark span { width: 11px; height: 11px; border-radius: 2px; background: var(--foc-free); }
.brand-mark span:nth-child(2) { background: var(--foc); }
.brand-mark span:nth-child(3) { background: var(--paid); }
.brand-mark span:nth-child(4) { background: #5d84a8; }
.brand-mark.big { grid-template-columns: repeat(2, 16px); gap: 4px; margin-bottom: 14px; }
.brand-mark.big span { width: 16px; height: 16px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  color: #c3cbd7;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.active { background: rgba(255, 255, 255, .1); color: #fff; box-shadow: inset 3px 0 0 #7fb3d9; }
.logout { margin-top: auto; color: #93a0b3; padding: 0 10px; font-size: 13px; }

main { padding: 28px 34px 60px; min-width: 0; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); max-width: 70ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-side { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- stat row ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 18px; overflow: hidden; }
.stat { padding: 14px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .v { font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .v small { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.stat .l { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

/* ---------- the room strip (signature) ---------- */
.hotel-strips { display: flex; flex-direction: column; gap: 16px; }
.strip-row { display: grid; grid-template-columns: 230px minmax(0, 1fr) 150px; gap: 16px; align-items: start; }
.strip-row .hn { font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1.25; }
.strip-row .hn small { display: block; font-family: var(--sans); font-size: 12px; color: var(--ink-3); font-weight: 400; }
.strip-row.inactive { opacity: .45; }
.rooms { display: flex; flex-wrap: wrap; gap: 3px; padding-top: 3px; }
.rooms i { width: 12px; height: 12px; border-radius: 2px; display: block; }
.rooms i.fu { background: var(--foc); }
.rooms i.ff { background: var(--foc-free); }
.rooms i.pu { background: var(--paid); }
.rooms i.pf { background: var(--paid-free); }
.rooms i.gap { width: 8px; background: none; }
.strip-row .nums { font-size: 13px; color: var(--ink-2); text-align: right; }
.strip-row .nums b { color: var(--ink); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); }
input, select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid #c9d0d8;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: #fff;
  min-width: 0;
}
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--lake); }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lake-soft); border-color: var(--lake); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid #c9d0d8;
  background: #fff;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--lake); border-color: var(--lake); color: #fff; }
.btn.primary:hover { background: #184e73; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: none; padding: 5px 8px; }
.btn.ghost:hover { background: var(--lake-soft); }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: progress; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-2);
  background: #f6f8f9;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid #edf0f2; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfc; }
td.num, th.num { text-align: right; }
td .sub { display: block; color: var(--ink-3); font-size: 12px; }
td.nowrap { white-space: nowrap; }
td .sub.reason { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td select { max-width: 300px; padding: 4px 6px; font-size: 13px; }
td input.room { width: 70px; padding: 3px 6px; font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.filters input[type=search] { min-width: 220px; }
.filters .count { margin-left: auto; color: var(--ink-3); font-size: 13px; }

/* ---------- tags ---------- */
.tag { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.tag.fto { background: #e3eef6; color: #1f5f8b; }
.tag.dto { background: #eceff3; color: #3e4a5c; }
.tag.special { background: #efe9f7; color: var(--special); }
.tag.foc { background: var(--foc-free); color: #1e5a40; }
.tag.paid { background: var(--paid-free); color: #7d4a12; }
.tag.pending { background: var(--bad-soft); color: var(--bad); }
.tag.lock { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.tag.vip { background: #fbeec9; color: #7a5a08; }
.tag.plus { background: #e6f4f1; color: #1e6b5e; }

.notice { padding: 10px 14px; border-radius: var(--radius-sm); margin: 10px 0; font-size: 13px; }
.notice.ok { background: #e6f4ec; color: #1e5a40; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.warn { background: var(--warn-soft); color: #6b4c00; }
.notice.info { background: var(--lake-soft); color: #174a6d; }

/* ---------- hotels page ---------- */
.hotel-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 14px; }
.hotel-card header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hotel-card header .prio {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.hotel-card header h3 { flex: 1; min-width: 180px; }
.hotel-card header .meta { color: var(--ink-2); font-size: 13px; }
.hotel-card .remark { padding: 8px 18px; background: #fafbfc; color: var(--ink-2); font-size: 12.5px; border-bottom: 1px solid var(--line); }
.hotel-card table { border: 0; }
.hotel-card.inactive header h3 { color: var(--ink-3); text-decoration: line-through; }

/* ---------- rules ---------- */
.rule { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: start; }
.rule:first-of-type { border-top: 0; }
.rule .t { font-weight: 600; }
.rule .j { color: var(--ink-3); font-size: 12px; word-break: break-word; }
.rule.off .t, .rule.off .j { opacity: .45; }
.ai-box textarea { width: 100%; }
.ai-preview { margin-top: 12px; border: 1px dashed var(--lake); border-radius: var(--radius-sm); padding: 12px; background: #f7fbfe; }
.ai-preview ol { margin: 8px 0; padding-left: 20px; }
.ai-preview li { margin-bottom: 6px; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.examples button { font: inherit; font-size: 12px; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 3px 10px; cursor: pointer; color: var(--ink-2); }
.examples button:hover { border-color: var(--lake); color: var(--lake); }

.pending-list { max-height: 260px; overflow: auto; font-size: 13px; margin: 8px 0 0; padding-left: 18px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(28, 36, 51, .45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: var(--radius); width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 22px 24px; box-shadow: 0 20px 50px rgba(28, 36, 51, .25); }
.modal-card h2 { margin-bottom: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--bad); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty h3 { margin-bottom: 6px; }
.loading { padding: 40px; color: var(--ink-3); }

/* ---------- auth ---------- */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 30px; width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth-card h1 { font-size: 26px; }
.auth-card p { margin: -8px 0 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-side { grid-template-columns: 1fr; }
  .strip-row { grid-template-columns: 1fr; gap: 6px; }
  .strip-row .nums { text-align: left; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px; gap: 12px; }
  #nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin-top: 0; }
  main { padding: 20px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- hotel priority list ---------- */
.prio-list { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.prio-list li { display: grid; grid-template-columns: 18px 30px minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--line); background: #fff; }
.prio-list li:first-child { border-top: 0; }
.prio-list .grip { color: var(--ink-3); cursor: grab; letter-spacing: -3px; user-select: none; }
.prio-list .rank { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.prio-list .pn { font-weight: 600; }
.prio-list .pn small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.prio-list li.off .pn, .prio-list li.off .rank { opacity: .45; }
.prio-list li.dragging { opacity: .5; background: var(--lake-soft); }

/* ---------- AI desk ---------- */
.page-head .undo-box { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 320px; text-align: right; }
.ai-desk { margin-bottom: 16px; border-color: #bcd3e4; }
.chat { max-height: 520px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 10px; }
.chat-empty { margin: 0; }
.msg { max-width: min(860px, 92%); padding: 10px 14px; border-radius: 10px; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--lake); color: #fff; border-bottom-right-radius: 3px; white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: #f6f9fb; border: 1px solid var(--line); border-bottom-left-radius: 3px; width: 100%; }
.msg.ai.err { background: var(--bad-soft); color: var(--bad); border-color: #f1c4bf; }
.msg.ai.thinking .msg-text { color: var(--ink-3); }
.msg-text { white-space: pre-wrap; }
.plan-log { margin: 8px 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.plan-sum { margin: 8px 0; font-weight: 600; font-size: 13px; }
.plan-table { max-height: 300px; overflow: auto; margin-top: 6px; }
.plan-actions { margin-top: 10px; }
.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; margin-top: 8px; }
.chat-input textarea { min-height: 52px; }
@media (max-width: 760px) { .chat-input { grid-template-columns: 1fr; } .page-head .undo-box { align-items: flex-start; text-align: left; } }
