:root {
  --bg: #070a12;
  --bg-elev: #0d1220;
  --bg-card: rgba(15, 21, 37, 0.88);
  --bg-card-solid: #101728;
  --bg-input: #0a0f1c;
  --border: rgba(148, 163, 184, 0.15);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #eef2ff;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-glow: rgba(56, 189, 248, 0.18);
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.14);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.14);
  --purple: #a855f7;
  --purple-bg: rgba(168, 85, 247, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --font-sans: 'Noto Sans Thai', 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', 'Noto Sans Thai', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(56, 189, 248, 0.13), transparent 60%),
    radial-gradient(800px 500px at 90% 5%, rgba(99, 102, 241, 0.14), transparent 60%);
  z-index: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.mono {
  font-family: var(--font-mono);
}

.hidden {
  display: none !important;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: rgba(7, 10, 18, 0.78);
  border-bottom: 1px solid var(--border);
}

.navbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  color: #060912;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-pill.online .status-dot {
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.status-pill.online {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.32);
}

.status-pill.offline .status-dot {
  background: var(--red);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(51, 65, 85, 0.78);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  border-color: rgba(56, 189, 248, 0.45);
  color: #ffffff;
  box-shadow: 0 6px 22px rgba(56, 189, 248, 0.22);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
}

.btn-danger {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.38);
  color: #fda4af;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(244, 63, 94, 0.25);
}

.btn-success {
  background: var(--green-bg);
  border-color: rgba(16, 185, 129, 0.38);
  color: #6ee7b7;
}

.btn-amber {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.38);
  color: #fcd34d;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 7px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-active, .badge-ok {
  background: var(--green-bg);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.badge-unused {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.28);
}

.badge-paused, .badge-maintenance {
  background: var(--amber-bg);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.badge-revoked, .badge-expired, .badge-disabled, .badge-deny {
  background: var(--red-bg);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.28);
}

.badge-tier {
  background: var(--purple-bg);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.28);
}

/* Cards & Inputs */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 13px;
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.textarea {
  resize: vertical;
  min-height: 78px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Hero & Public Page */
.announcement-bar {
  margin-top: 22px;
  padding: 11px 16px;
  border-radius: 11px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hero {
  padding: 46px 0 32px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: start;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.14);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.hero h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.025em;
  background: linear-gradient(120deg, #ffffff 10%, #bae6fd 65%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p.lead {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 22px;
  max-width: 540px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.metric-box {
  background: rgba(15, 21, 37, 0.72);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
}

.metric-box .label {
  font-size: 0.76rem;
  color: var(--text-dim);
}

.metric-box .val {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2px;
}

.checker-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.checker-result {
  margin-top: 16px;
  padding: 15px;
  border-radius: 11px;
  background: rgba(10, 15, 28, 0.85);
  border: 1px solid var(--border);
}

.checker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 12px;
  font-size: 0.86rem;
}

.checker-kv .k {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.checker-kv .v {
  color: var(--text);
  font-weight: 600;
}

.section {
  padding: 26px 0;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

/* Storefront Pricing Cards */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}

.pricing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 22px;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.pricing-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
}

.pricing-card.featured {
  background: linear-gradient(180deg, rgba(16, 28, 52, 0.96) 0%, rgba(13, 18, 34, 0.96) 100%);
  border: 1.5px solid rgba(56, 189, 248, 0.62);
  box-shadow: 0 22px 60px rgba(14, 165, 233, 0.2), 0 0 0 1px rgba(99, 102, 241, 0.22) inset;
}

.pricing-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pricing-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.34);
  white-space: nowrap;
}

.pricing-card.featured .pricing-badge {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.26), rgba(244, 63, 94, 0.26));
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.55);
}

.price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 14px;
}

.price-now {
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.price-currency {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
}

.price-old {
  font-size: 0.95rem;
  color: var(--text-dim);
  text-decoration: line-through;
}

.price-save {
  font-size: 0.74rem;
  font-weight: 700;
  color: #6ee7b7;
  background: var(--green-bg);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.feature-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 0.86rem;
  color: #cbd5e1;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.feature-check {
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

.map-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(99, 102, 241, 0.12));
  border: 1px solid rgba(56, 189, 248, 0.28);
  margin-bottom: 18px;
}

@media (max-width: 960px) {
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

.product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.product-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.product-card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}

.code-wrap {
  position: relative;
  background: #060911;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  font-size: 0.78rem;
  color: var(--text-muted);
}

pre.code-block {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #cbd5e1;
}

.footer {
  margin-top: 40px;
  padding: 24px 0 38px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.84rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* =========================================================
   ADMIN LAYOUT
   ========================================================= */
.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
}

.admin-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: rgba(10, 14, 25, 0.94);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 4px 10px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.14s;
}

.side-btn:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
}

.side-btn.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.3);
  color: #e0f2fe;
  font-weight: 600;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-main {
  padding: 24px 28px 46px;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.admin-topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px;
}

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

.kpi-card .num {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 4px;
}

.kpi-card .sub {
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar .grow {
  flex: 1;
  min-width: 200px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 11px 13px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: rgba(10, 14, 25, 0.75);
  white-space: nowrap;
}

tbody tr:hover {
  background: rgba(56, 189, 248, 0.04);
}

tbody tr:last-child td {
  border-bottom: none;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Chart */
.chart-bars {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  height: 150px;
  padding-top: 12px;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-stack {
  width: 100%;
  max-width: 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  height: 112px;
}

.bar-ok {
  background: linear-gradient(180deg, #38bdf8, #10b981);
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
}

.bar-deny {
  background: #f43f5e;
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
}

.chart-day {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 6, 14, 0.76);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.modal-lg {
  max-width: 820px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* Toast */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: #131c31;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.86rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  max-width: 360px;
}

.toast.ok {
  border-color: rgba(16, 185, 129, 0.55);
}

.toast.err {
  border-color: rgba(244, 63, 94, 0.55);
}

.split-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .hero, .split-2 {
    grid-template-columns: 1fr;
  }
  .admin-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .side-btn {
    width: auto;
  }
}

@media (max-width: 600px) {
  .checker-form, .form-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
  .hero-metrics {
    grid-template-columns: 1fr;
  }
  .nav-links .hide-sm {
    display: none;
  }
}
