:root {
  --bg: #0e2e2b;
  --bg-soft: #123a36;
  --surface: #fbfaf7;
  --ink: #102422;
  --muted: #9fb8b3;
  --muted-on-surface: #5b7c77;
  --accent: #f2a93b;
  --accent-dark: #c97d1a;
  --accent-ink: #4a2f08;
  --danger: #e2645a;
  --success: #3bbd6a;
  --border-on-surface: rgba(16, 36, 34, 0.14);
  --radius: 16px;
  --maxw: 880px;
  font-size: 16px;
}

[data-theme="light"] {
  --bg: #e6f5ef;
  --bg-soft: #c4e8d8;
  --surface: #ffffff;
  --ink: #102422;
  --muted: #5a8078;
  --muted-on-surface: #4a6e68;
  --accent: #c97d1a;
  --accent-dark: #a85f0e;
  --accent-ink: #4a2f08;
  --danger: #c94040;
  --success: #2d9e58;
  --border-on-surface: rgba(16, 36, 34, 0.15);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 12% 0%, var(--bg-soft), var(--bg) 55%);
  color: var(--surface);
  font-family: "Noto Sans Lao", "Be Vietnam Pro", "IBM Plex Sans Thai", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

html[lang="th"] body { font-family: "IBM Plex Sans Thai", system-ui, sans-serif; }
html[lang="vi"] body { font-family: "Be Vietnam Pro", system-ui, sans-serif; line-height: 1.65; }
html[lang="en"] body { font-family: system-ui, sans-serif; line-height: 1.55; }

[data-theme="light"] body { color: var(--ink); }

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  color: var(--surface);
  margin: 0;
}
[data-theme="light"] h1,
[data-theme="light"] h2 { color: var(--ink); }

a { color: inherit; }

/* ====== TOPBAR ====== */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.brand__controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.brand__mark {
  font-family: "Fraunces", Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

.brand__tag {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
  display: block;
}

[data-theme="light"] .brand__tag { color: var(--muted-on-surface); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding-top: 4px;
}

.topbar-email {
  font-size: 13px;
  opacity: 0.75;
}

.role-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.lang-select {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: inherit;
  cursor: pointer;
}
[data-theme="light"] .lang-select {
  border-color: var(--border-on-surface);
  background: rgba(0,0,0,0.05);
}
.lang-select:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.btn--icon {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
[data-theme="light"] .btn--icon {
  border-color: var(--border-on-surface);
  background: rgba(0,0,0,0.05);
}
.btn--icon:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* topbar auth buttons (logged-out state) */
.btn--topbar-login {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(255,255,255,0.35);
  background: transparent;
  color: var(--surface);
  cursor: pointer;
}
[data-theme="light"] .btn--topbar-login {
  border-color: var(--ink);
  color: var(--ink);
}
.btn--topbar-login:hover { background: rgba(255,255,255,0.1); }
[data-theme="light"] .btn--topbar-login:hover { background: rgba(0,0,0,0.05); }

.btn--topbar-register {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.btn--topbar-register:hover { background: var(--accent-dark); color: #fff; }

/* ====== HERO LANDING ====== */

.hero-landing {
  background: linear-gradient(155deg, #f7c940 0%, #f2a93b 45%, #e07510 100%);
  padding: 64px 24px 60px;
  text-align: center;
}

.hero-landing__content {
  max-width: 640px;
  margin: 0 auto;
}

.hero-landing__title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  color: #2c1500;
  margin: 0 0 16px;
  line-height: 1.2;
}

.hero-landing__sub {
  font-size: clamp(15px, 2.2vw, 17px);
  color: #5a3000;
  margin: 0 0 36px;
  line-height: 1.6;
}

.hero-landing__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn--hero-primary {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 32px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: #2c1500;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn--hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.22);
}

.btn--hero-ghost {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 14px 32px;
  border-radius: 999px;
  border: 2px solid rgba(44,21,0,0.4);
  background: transparent;
  color: #2c1500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn--hero-ghost:hover { background: rgba(255,255,255,0.25); }

/* ====== STEPS SECTION ====== */

.steps-section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px 24px 60px;
}

.steps-section__title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  text-align: center;
  margin: 0 0 40px;
  color: var(--surface);
}
[data-theme="light"] .steps-section__title { color: var(--ink); }

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.step-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 28px 22px 24px;
  text-align: center;
  box-shadow: 0 8px 32px -12px rgba(0,0,0,0.45);
  position: relative;
}

.step-icon {
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}

.step-num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted-on-surface);
  margin-bottom: 10px;
}

.step-card__title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 10px;
}

.step-card__desc {
  font-size: 14px;
  color: var(--muted-on-surface);
  margin: 0;
  line-height: 1.55;
}

/* ====== AUTH MODAL ====== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 32px 80px rgba(0,0,0,0.45);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 18px;
  line-height: 1;
  background: none;
  border: none;
  color: var(--muted-on-surface);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--border-on-surface); color: var(--ink); }

/* Two-column split: login (left) | register (right) */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0 32px;
  align-items: start;
}

.auth-split__divider {
  background: var(--border-on-surface);
  align-self: stretch;
  min-height: 260px;
}

.auth-col__title {
  font-family: "Fraunces", Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 18px;
}

/* Forgot / Reset full-width alt panels */
.auth-alt {
  max-width: 380px;
  margin: 0 auto;
}
.auth-alt .auth-col__title { text-align: center; }

@media (max-width: 600px) {
  .auth-split {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .auth-split__divider {
    height: 1px;
    min-height: auto;
    width: 100%;
    margin: 24px 0;
    align-self: auto;
  }
}

/* ====== APP SHELL — page wrapper ====== */

.app-page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 64px;
}

#app-shell {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 24px 64px;
}

/* ====== HERO (shorten form) ====== */

.hero { margin-bottom: 40px; }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 10px;
}

.hero h1 {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 600;
  margin-bottom: 20px;
}

.hero__intro { margin-bottom: 20px; }

.ticket-form {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  gap: 16px;
  box-shadow: 0 14px 40px -20px rgba(0,0,0,0.6);
}

.field { display: grid; gap: 6px; }

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-on-surface);
}

input[type="url"],
input[type="text"],
input[type="email"],
input[type="password"],
.input-select {
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border-on-surface);
  background: #fff;
  color: var(--ink);
}

.input-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b7c77' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

input:focus-visible,
.input-select:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.alias-input {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border-on-surface);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.alias-input__prefix {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: #f1efe9;
  color: var(--muted-on-surface);
  white-space: nowrap;
}
.alias-input input { border: none; border-radius: 0; flex: 1; }
.alias-input:has(input:focus-visible) { outline: 2.5px solid var(--accent); outline-offset: 1px; }

/* ====== BUTTONS ====== */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  justify-self: start;
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: #1f3e3a; }
.btn--ghost {
  background: transparent;
  border: 1.5px solid var(--border-on-surface);
  color: var(--ink);
}
.btn--small { padding: 8px 14px; font-size: 13px; }
.btn--full { width: 100%; justify-self: stretch; text-align: center; }
.btn:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* ====== FORM HELPERS ====== */

.form-error {
  color: var(--danger);
  font-size: 13.5px;
  margin: 0;
  min-height: 1em;
}
.form-hint {
  font-size: 13px;
  color: var(--muted-on-surface);
  margin: -4px 0 0;
}
.link-muted {
  font-size: 13px;
  color: var(--muted-on-surface);
  text-decoration: none;
  margin-top: -4px;
}
.link-muted:hover { text-decoration: underline; }
.divider-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted-on-surface);
  font-size: 13px;
  margin: 0;
}
.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-on-surface);
}

/* ====== TICKET STUB ====== */

.ticket-stub {
  position: relative;
  background: var(--surface);
  color: var(--ink);
  border-radius: 14px;
  margin-top: 18px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  box-shadow: 0 14px 30px -18px rgba(0,0,0,0.55);
}
.ticket-stub--inactive { opacity: 0.6; }
.ticket-stub::before {
  content: "";
  position: absolute;
  top: 12px; bottom: 12px;
  left: var(--split, 62%);
  border-left: 2px dashed var(--border-on-surface);
}
.ticket-stub__notch {
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg);
  left: calc(var(--split, 62%) - 9px);
}
.ticket-stub__notch--top { top: -9px; }
.ticket-stub__notch--bottom { bottom: -9px; }
.ticket-stub__from,
.ticket-stub__to { display: grid; gap: 4px; min-width: 0; }
.ticket-stub__to { text-align: right; justify-content: end; }
.ticket-stub__label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted-on-surface);
}
.ticket-stub__url {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-stub__short {
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}
.ticket-stub__meta { font-size: 12px; color: var(--muted-on-surface); }

.status-tag {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  justify-self: end;
}
.status-tag--expired { background: rgba(226,100,90,0.15); color: var(--danger); }
.status-tag--disabled { background: rgba(159,184,179,0.2); color: var(--muted-on-surface); }

/* ====== PANELS ====== */

.panel {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 26px;
  margin-bottom: 28px;
}
.panel__tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.panel__tab {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--muted-on-surface);
  cursor: pointer;
}
.panel__tab.is-active { background: var(--ink); color: #fff; }
.panel__tab:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

.stack-form { display: grid; gap: 14px; }

.panel__head { margin-bottom: 18px; }
.panel__head h2 { font-size: 20px; margin-bottom: 4px; }

.muted { color: var(--muted-on-surface); font-size: 14px; margin: 0; }
.stub-grid { display: grid; gap: 14px; }
.empty-note { color: var(--muted-on-surface); font-size: 14px; }

/* ====== ADMIN TABLE ====== */

.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-on-surface);
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--border-on-surface);
}
.user-table td { padding: 10px; border-bottom: 1px solid var(--border-on-surface); vertical-align: middle; }
.audit-ip { font-family: "IBM Plex Mono", monospace; font-size: 12px; white-space: nowrap; }
.user-table code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  background: rgba(16,36,34,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.role-select {
  font: inherit;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--border-on-surface);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

/* ====== TOAST ====== */

.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--surface);
  color: var(--ink);
  border-radius: 14px;
  padding: 16px 22px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.30);
  border-left: 4px solid var(--success);
  z-index: 2000;
  font-size: 14px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}
.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast--error { border-left-color: var(--danger); }

/* ====== PHONE FIELD ====== */

.phone-field {
  display: flex;
  border: 1.5px solid var(--border-on-surface);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.phone-code-select {
  font: inherit;
  font-size: 14px;
  padding: 12px 8px;
  border: none;
  border-right: 1.5px solid var(--border-on-surface);
  background: #f1efe9;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  width: 88px;
  flex-shrink: 0;
  text-align: center;
}
.phone-code-select:focus { outline: none; }

.phone-field input[type="tel"] {
  border: none;
  border-radius: 0;
  flex: 1;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
}
.phone-field input[type="tel"]:focus { outline: none; }
.phone-field:focus-within {
  outline: 2.5px solid var(--accent);
  outline-offset: 1px;
}

/* ====== CHECKBOX FIELD ====== */

.field--checkbox { gap: 0; }

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label span {
  font-size: 13px;
  color: var(--muted-on-surface);
  line-height: 1.5;
}

/* ====== FOOTER ====== */

.site-footer {
  text-align: center;
  color: #888;
  font-size: 12px;
  font-weight: 500;
  padding: 40px 24px 10px;
}
[data-theme="light"] .site-footer { color: #888; }

/* ====== RESPONSIVE ====== */

@media (max-width: 640px) {
  .topbar { padding: 16px 16px; }
  .hero-landing { padding: 48px 16px 44px; }
  .steps-section { padding: 40px 16px 48px; }
  .steps-grid { grid-template-columns: 1fr; }
  #app-shell { padding: 20px 16px 48px; }
  .ticket-stub {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .ticket-stub__to { text-align: left; justify-content: start; }
  .ticket-stub::before,
  .ticket-stub__notch { display: none; }
  .user-table { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
