:root {
  --grad-1: #6d5bd0;   /* indigo */
  --grad-2: #8b5cf6;   /* violet */
  --accent: #6d5bd0;
  --accent-ink: #4c3fb0;
  --first: #5b3e92;    /* First availability (purple) */
  --business: #c4188d; /* Business availability (pink) */
  --bg: #eef1fb;
  --card: rgba(255, 255, 255, 0.92);
  --line: #e5e8f5;
  --text: #1c1d27;
  --muted: #6b6f80;
  --ok: #1e9e6a;
  --err: #d94141;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(63, 55, 130, 0.10);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -10%, #dfe4ff 0%, rgba(223, 228, 255, 0) 55%),
    radial-gradient(1000px 500px at -10% 0%, #f3e8ff 0%, rgba(243, 232, 255, 0) 50%),
    var(--bg);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* Header */
header {
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2));
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.menu-btn {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; margin: 0; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px; flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.18);
}
header h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Layout */
.wrap { padding: 16px; max-width: 1100px; margin: 0 auto; }
.card {
  background: var(--card);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.auth-card { max-width: 380px; margin: 8vh auto 0; }
h2 { font-size: 16px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

/* Fields */
.field { margin-top: 12px; }
.field > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1 1 140px; }

input, select, button, .btn-outline, .btn-primary {
  font-size: 16px; /* >=16px stops iOS zoom-on-focus */
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  font-family: inherit;
}
input, select {
  width: 100%;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.15);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

button, .btn-primary, .btn-outline { cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; text-align: center; }
.btn-primary {
  background: linear-gradient(120deg, var(--grad-1), var(--grad-2));
  color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(109, 91, 208, 0.35);
  transition: transform .08s, box-shadow .15s, opacity .15s;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:hover { box-shadow: 0 6px 18px rgba(109, 91, 208, 0.45); }
.btn-outline { background: #fff; color: var(--accent-ink); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: #f6f4ff; }
.btn-outline.sm, button.sm { font-size: 13px; padding: 6px 10px; border-radius: 9px; }
.link { background: none; color: var(--muted); border: none; padding: 6px; }
.link:hover { color: var(--accent-ink); }

.badge { font-size: 13px; color: var(--accent-ink); background: #eeeaff; padding: 5px 10px; border-radius: 999px; font-weight: 600; }
.pill { font-size: 11px; background: linear-gradient(120deg, var(--grad-1), var(--grad-2)); color: #fff; padding: 3px 9px; border-radius: 999px; font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }
.msg { font-size: 13px; color: var(--muted); margin: 8px 0 0; min-height: 1em; }
.error { color: var(--err); }
.hidden { display: none !important; }

/* Route search */
.route { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.route select { flex: 1 1 160px; }
.route .arrow { color: var(--accent); font-weight: 700; font-size: 18px; }
.route button { flex: 1 1 100%; margin-top: 4px; }
@media (min-width: 620px) { .route button { flex: 0 0 auto; margin-top: 0; } }

/* Admin */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.grid-form button { grid-column: 1 / -1; }
@media (min-width: 620px) { .grid-form { grid-template-columns: 1fr 1fr 1fr auto auto; } .grid-form button { grid-column: auto; } }
.admin-table td .btn-outline { white-space: nowrap; }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.chk input { width: auto; }

/* Progress */
.bar { background: var(--line); border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--grad-1), var(--grad-2)); height: 100%; width: 0; transition: width .3s; }
.otp { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: center; white-space: nowrap; }
th { background: #f5f3ff; color: var(--accent-ink); position: sticky; top: 0; font-weight: 700; }
tbody tr:nth-child(even) td { background: #fbfaff; }
.row-first td { background: var(--first); color: #fff; }
.row-business td { background: var(--business); color: #fff; }
.admin-table th, .admin-table td { text-align: left; }

/* Top line (account badge + setup hint) */
.topline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

/* Account-setup drawer (hamburger) */
.drawer { position: fixed; inset: 0; z-index: 50; }
.scrim { position: absolute; inset: 0; background: rgba(28, 29, 39, 0.45); backdrop-filter: blur(2px); }
.drawer-panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(440px, 92vw);
  background: var(--bg);
  box-shadow: -8px 0 30px rgba(28, 29, 39, 0.25);
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top));
  overflow-y: auto;
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; }
.setup-block {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.setup-block h3 { margin: 0 0 10px; font-size: 14px; color: var(--accent-ink); }
.mini { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#method-step .btn-primary, #method-step .btn-outline { width: 100%; }

/* Results: search tools + mobile flight cards */
.result-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.result-tools input[type="search"] { flex: 1 1 220px; }
.menu-btn.sm { width: auto; }

.results { display: grid; gap: 10px; }
.flt {
  border: 1px solid var(--line); border-left: 5px solid var(--line);
  border-radius: 12px; padding: 12px 14px; background: #fff;
}
.flt-first { border-left-color: var(--first); }
.flt-business { border-left-color: var(--business); }
.flt-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.flt-route { font-weight: 700; font-size: 15px; }
.flt-date { color: var(--muted); font-size: 13px; }
.flt-meta { color: var(--muted); font-size: 12.5px; margin: 4px 0 10px; }
.cabins { display: flex; gap: 8px; flex-wrap: wrap; }
.cab {
  font-size: 12.5px; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  background: #f1f2f8; color: var(--muted); border: 1px solid var(--line);
}
.cab.on.first { background: var(--first); color: #fff; border-color: var(--first); }
.cab.on.business { background: var(--business); color: #fff; border-color: var(--business); }
.cab.on.py { background: #2c7be5; color: #fff; border-color: #2c7be5; }
.cab.on.eco { background: var(--ok); color: #fff; border-color: var(--ok); }
.cab.off { opacity: .55; }
