:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2434;
  --muted: #6b7688;
  --line: #dfe4ec;
  --brand: #1c5fd8;
  --brand-dark: #12439c;
  --ok: #1a7f4b;
  --warn: #a86500;
  --err: #c02525;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Sarabun", "Leelawadee UI", Tahoma, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
header.topbar {
  background: var(--ink);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}
header.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
header.topbar .brand span { color: #7fb0ff; }
header.topbar nav { display: flex; gap: 4px; height: 100%; }
header.topbar nav a {
  color: #c9d2e0;
  padding: 0 14px;
  display: flex;
  align-items: center;
  border-bottom: 3px solid transparent;
}
header.topbar nav a:hover { color: #fff; text-decoration: none; background: #2a3245; }
header.topbar nav a.active { color: #fff; border-bottom-color: #7fb0ff; }

main { max-width: 1180px; margin: 24px auto 60px; padding: 0 24px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 16px; margin: 0 0 14px; }

/* ---------- tables ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th {
  text-align: left;
  background: #eef1f6;
  color: #445;
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td { padding: 9px 12px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
table.grid tr:hover td { background: #fafbfd; }
table.grid td.actions { text-align: right; white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], input[type=tel], select, textarea {
  width: 100%;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
  color: var(--ink);
  box-sizing: border-box;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d0f7; border-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }
.checkline { display: flex; align-items: center; gap: 8px; }
.checkline input { width: auto; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #f2f4f8; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--err); border-color: #f0c6c6; background: #fff; }
.btn.danger:hover { background: #fdf1f1; }
.btn.sm { padding: 4px 10px; font-size: 13px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.economy  { background: #eef1f6; color: #47536b; border-color: #d8dee9; }
.badge.premium  { background: #eaf3ff; color: #1f5aa8; border-color: #c4dcfb; }
.badge.business { background: #e8f5ed; color: #1a7f4b; border-color: #bfe3cd; }
.badge.first    { background: #fdf1e0; color: #a05a00; border-color: #f2d9b4; }
.badge.scope    { background: #f1eefc; color: #5b46a8; border-color: #ddd5f5; }
.badge.muted    { background: #f2f4f8; color: var(--muted); border-color: var(--line); }
.badge.off      { background: #fdf1f1; color: var(--err); border-color: #f3cccc; }

/* ---------- alerts ---------- */
.alert { padding: 11px 15px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert.ok  { background: #e8f5ed; color: #15633b; border: 1px solid #bfe3cd; }
.alert.err { background: #fdf1f1; color: #971f1f; border: 1px solid #f3cccc; }
.alert.info{ background: #eaf3ff; color: #1c4f96; border: 1px solid #c4dcfb; }
.field-error { color: var(--err); font-size: 12px; margin-top: 4px; }
.validation-summary { color: var(--err); font-size: 13px; }
.validation-summary ul { margin: 0; padding-left: 18px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ---------- filter bar ---------- */
.filterbar {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
}
.filterbar .form-row { margin: 0; min-width: 0; }
.filterbar input[type=date] { width: 160px; }
.filterbar select { width: 210px; }
.filterbar .btn { height: 38px; display: inline-flex; align-items: center; }

/* ---------- trace ---------- */
.trace { border-collapse: collapse; width: 100%; font-size: 13px; }
.trace th { background: #eef1f6; padding: 8px 12px; text-align: left; }
.trace td { padding: 8px 12px; border-bottom: 1px solid #eef0f4; }
.trace tr.winner td { background: #e8f5ed; font-weight: 600; }
.trace tr.skipped td { color: #98a1b1; }
.result-box {
  border: 1px solid #bfe3cd; background: #e8f5ed;
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
}
.result-box.fallback { border-color: #f2d9b4; background: #fdf6ea; }
.result-box.error { border-color: #f3cccc; background: #fdf1f1; }
.result-box .cabin { font-size: 26px; font-weight: 700; }
.result-box .why { color: #40506a; margin-top: 6px; font-size: 14px; }

/* ---------- landing ---------- */
.landing {
  min-height: calc(100vh - 56px);
  display: flex; align-items: center; justify-content: center;
}
.landing .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 46px 54px; text-align: center; max-width: 520px;
}
.landing h1 { margin: 0 0 6px; font-size: 26px; }
.landing .tag { color: var(--muted); margin-bottom: 26px; font-size: 14px; }
.landing .btn { padding: 12px 40px; font-size: 16px; }
.landing .note { margin-top: 22px; font-size: 12px; color: var(--muted); }

code.mono { font-family: Consolas, "Courier New", monospace; background: #eef1f6; padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---------- brand / logo ----------
   The logo is a transparent PNG whose artwork is light (mean luminance 152/255),
   so it only reads against a dark backdrop. The topbar is already dark; the
   landing card is darkened to match. Sized by height with width:auto so the
   1.22:1 artwork is never cropped or squashed.
   Both <img> tags self-remove if the file is missing, leaving the wordmark. */
header.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
header.topbar .brand:hover { text-decoration: none; }
.brand-logo { height: 32px; width: auto; display: block; }
.brand-text { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.brand-text span { color: #7fb0ff; }
.brand-sub { color: #8d99ac; font-weight: 400; font-size: 14px; }

/* landing card goes dark so the light logo is visible */
.landing .card {
  background: radial-gradient(120% 120% at 50% 0%, #33405c 0%, #1c2434 60%, #141a26 100%);
  border-color: #2c3648;
  box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.landing h1 { color: #fff; }
.landing .tag { color: #9fadc4; }
.landing .note { color: #6f7d93; }
.landing-logo {
  height: 132px;
  width: auto;
  display: block;
  margin: 0 auto 18px;
}
