/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #0f172a;
  --bg2:      #1e293b;
  --bg3:      #334155;
  --border:   #334155;
  --text:     #f1f5f9;
  --text2:    #94a3b8;
  --primary:  #1a56db;
  --primary2: #1d4ed8;
  --accent:   #38bdf8;
  --success:  #22c55e;
  --warn:     #f59e0b;
  --danger:   #ef4444;
  --radius:   8px;
  --shadow:   0 4px 24px rgba(0,0,0,0.4);
}
html { font-size: 15px; }
body { font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); padding: 8px 12px;
  font-family: inherit; font-size: 0.9rem; width: 100%;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }
select { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

/* ─── Navbar ────────────────────────────────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: rgba(15,23,42,0.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand-link { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 900; font-size: 1.1rem; }
.brand-icon { font-size: 1.3rem; }
.brand-sub  { color: var(--primary); }
.nav-links  { display: flex; align-items: center; gap: 16px; }
.nav-link   { color: var(--text2); font-size: 0.85rem; }
.nav-link:hover { color: var(--text); text-decoration: none; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-family: inherit;
  font-size: 0.9rem; font-weight: 500; cursor: pointer; border: none;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary2); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover  { border-color: var(--primary); color: var(--primary); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm       { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg       { padding: 12px 28px; font-size: 1rem; }
.btn-full     { width: 100%; justify-content: center; }
.btn-icon     { padding: 6px 8px; }
.hidden { display: none !important; }

/* ─── App Shell ────────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; padding-top: 56px; }

/* Sidebar */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 56px; bottom: 0; left: 0; overflow-y: auto;
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 20px;
  background: none; border: none; cursor: pointer;
  color: var(--text2); font-family: inherit; font-size: 0.88rem;
  text-align: left; transition: all 0.15s;
}
.sidebar-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-item.active { background: rgba(26,86,219,0.2); color: var(--primary); }
.si-icon { font-size: 1rem; width: 20px; }
.sidebar-user {
  padding: 14px 20px; border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text2);
}
.sidebar-user img { width: 28px; height: 28px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* Main content */
.main-content { margin-left: 220px; flex: 1; padding: 28px; min-height: calc(100vh - 56px); }

/* ─── Page layout ──────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 1.4rem; font-weight: 600; }

/* ─── Filter bar ───────────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-bar select { width: auto; min-width: 160px; }

/* ─── Data table ───────────────────────────────────────────────────────────── */
.data-table { background: var(--bg2); border-radius: var(--radius); overflow: hidden; }
.data-table th {
  background: var(--bg3); padding: 10px 14px;
  font-size: 0.82rem; font-weight: 600; color: var(--text2); text-align: left;
}
.data-table td {
  padding: 10px 14px; font-size: 0.88rem; border-top: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* Status badges */
.badge-status {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 0.76rem; font-weight: 500;
}
.badge-draft     { background: rgba(148,163,184,0.2); color: #94a3b8; }
.badge-sent      { background: rgba(56,189,248,0.2); color: #38bdf8; }
.badge-paid      { background: rgba(34,197,94,0.2);  color: #22c55e; }
.badge-cancelled { background: rgba(239,68,68,0.2);  color: #ef4444; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 0.82rem; color: var(--text2); font-weight: 500; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.input-with-btn { display: flex; gap: 6px; }
.input-with-btn select { flex: 1; }
.section-title { font-weight: 600; font-size: 0.95rem; margin: 20px 0 10px; color: var(--text2); }

/* ─── Items table ───────────────────────────────────────────────────────────── */
.items-wrap { background: var(--bg2); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.items-table { margin-bottom: 10px; }
.items-table th {
  background: var(--bg3); padding: 8px 10px;
  font-size: 0.78rem; font-weight: 600; color: var(--text2);
}
.items-table td {
  padding: 5px 4px; border-top: 1px solid var(--border); vertical-align: middle;
}
.items-table input, .items-table select {
  padding: 5px 7px; font-size: 0.84rem; border-radius: 5px;
}

/* ─── Totals ────────────────────────────────────────────────────────────────── */
.totals-box { background: var(--bg2); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; max-width: 400px; margin-left: auto; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 0.9rem; color: var(--text2); }
.total-row span:last-child { font-variant-numeric: tabular-nums; }
.total-final { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-weight: 900; font-size: 1rem; color: var(--text); }

/* ─── Empty state ───────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty-state p { margin-bottom: 16px; font-size: 1rem; }

/* ─── Stats grid ────────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 900; color: var(--primary); margin: 6px 0; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--text2); }

/* ─── Landing ───────────────────────────────────────────────────────────────── */
.landing { padding-top: 80px; }
.hero { text-align: center; padding: 60px 20px 40px; max-width: 700px; margin: 0 auto; }
.hero-badge { display: inline-block; background: rgba(26,86,219,0.2); color: var(--accent); font-size: 0.78rem; font-weight: 600; padding: 4px 14px; border-radius: 99px; margin-bottom: 18px; border: 1px solid rgba(26,86,219,0.4); }
.hero-title { font-size: 2.6rem; font-weight: 900; line-height: 1.2; margin-bottom: 16px; }
.gradient-text { background: linear-gradient(135deg, #1a56db, #38bdf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-subtitle { color: var(--text2); font-size: 1.05rem; margin-bottom: 28px; line-height: 1.7; }
.hero-note { color: var(--text2); font-size: 0.82rem; margin-top: 12px; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; max-width: 1000px; margin: 0 auto 60px; padding: 0 20px; }
.feature-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.feature-icon { font-size: 2rem; margin-bottom: 10px; }
.feature-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.feature-card p { color: var(--text2); font-size: 0.85rem; line-height: 1.6; }

.pricing-section { max-width: 600px; margin: 0 auto 80px; padding: 0 20px; text-align: center; }
.pricing-section h2 { font-size: 1.6rem; margin-bottom: 24px; }
.pricing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pricing-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; position: relative; }
.pricing-card.featured { border-color: var(--primary); }
.pricing-card .badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--primary); color: #fff; font-size: 0.72rem; padding: 2px 12px; border-radius: 99px; }
.pricing-card h3 { font-size: 1.1rem; font-weight: 900; margin-bottom: 6px; }
.price { font-size: 1.8rem; font-weight: 900; color: var(--primary); margin: 10px 0; }
.price span { font-size: 0.9rem; color: var(--text2); font-weight: 400; }
.pricing-card ul { list-style: none; text-align: left; margin: 14px 0 18px; }
.pricing-card ul li { font-size: 0.87rem; color: var(--text2); padding: 3px 0; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .pricing-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: 1.8rem; }
}

/* ════════════ LIGHT THEME ════════════ */
:root {
  --bg: #ffffff; --bg2: #f8fafc; --bg3: #f1f5f9; --border: #e2e8f0;
  --text: #0f172a; --text2: #64748b;
  --primary: #1a56db; --primary2: #1d4ed8; --accent: #1a56db;
  --success: #16a34a; --warn: #d97706; --danger: #dc2626;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}
body { background: #fff; color: #0f172a; }
a { color: var(--primary); }
input, select, textarea { background: #fff; border-color: #e2e8f0; color: #0f172a; }
.navbar { background: rgba(255,255,255,.97); border-bottom: 1px solid #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.brand-link { color: #0f172a; }
.nav-link { color: #64748b; }
.nav-link:hover { color: #0f172a; text-decoration: none; }
.sidebar { background: #f8fafc; border-color: #e2e8f0; }
.sidebar-item { color: #64748b; }
.sidebar-item:hover { background: #f1f5f9; color: #0f172a; }
.sidebar-item.active { background: rgba(26,86,219,.08); color: #1a56db; }
.sidebar-user { color: #64748b; border-color: #e2e8f0; }
.main-content { background: #fff; }
.card { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card h3 { color: #0f172a; }
.data-table { background: #fff; }
.data-table th { background: #f8fafc; color: #64748b; }
.data-table td { border-color: #e2e8f0; }
.data-table tr:hover td { background: rgba(0,0,0,.02); }
.badge-draft     { background: rgba(100,116,139,.12); color: #475569; }
.badge-sent      { background: rgba(26,86,219,.10);   color: #1a56db; }
.badge-paid      { background: rgba(22,163,74,.10);   color: #16a34a; }
.badge-cancelled { background: rgba(220,38,38,.10);   color: #dc2626; }
.hero-badge { background: rgba(26,86,219,.08); color: #1a56db; border-color: rgba(26,86,219,.25); }
.hero-title { color: #0f172a; }
.hero-subtitle { color: #64748b; }
.gradient-text { background: linear-gradient(135deg,#1a56db,#0ea5e9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.features-grid .feature-card { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.feature-card p { color: #64748b; }
.stats-grid .stat-card, .stat-card { background: #fff; border-color: #e2e8f0; }
.stat-label { color: #64748b; }
.empty-state { color: #94a3b8; }
.items-wrap { background: #f8fafc; }
.items-table th { background: #f1f5f9; color: #64748b; }
.totals-box { background: #f8fafc; }
.total-row { color: #64748b; }
.total-final { color: #0f172a; border-color: #e2e8f0; }
.btn-outline { color: #0f172a; border-color: #e2e8f0; }
.btn-outline:hover { border-color: #1a56db; color: #1a56db; background: rgba(26,86,219,.05); }
.pricing-card { background: #fff; border-color: #e2e8f0; }
.pricing-card.featured { border-color: #1a56db; }
.pricing-card ul li { color: #64748b; }
.pricing-section h2 { color: #0f172a; }

.th-flag {
  background: linear-gradient(90deg,
    #A51931 0%, #A51931 25%,
    #C0C0CC 25%, #C0C0CC 37.5%,
    #2E3192 37.5%, #2E3192 62.5%,
    #C0C0CC 62.5%, #C0C0CC 75%,
    #A51931 75%, #A51931 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  border: none;
  padding: 0;
  text-shadow: none;
  filter: none;
  display: inline;
}

/* ── Cross-service section ────────────────────────────────────────────────── */
.tsb{background:linear-gradient(135deg,#f8fafc 0%,#fff 50%,#f8fafc 100%);border-top:1px solid #e2e8f0;padding:2.75rem 1rem 2.25rem;margin-top:2.5rem}
.tsb-inner{max-width:960px;margin:0 auto}
.tsb-eyebrow{text-align:center;font-size:.72rem;font-weight:800;letter-spacing:1.5px;text-transform:uppercase;color:#a0aec0;margin-bottom:.5rem}
.tsb-headline{text-align:center;font-size:1.1rem;font-weight:800;color:#1a202c;margin-bottom:1.75rem}
.tsb-grid{display:grid;grid-template-columns:repeat(5,1fr);gap:12px}
.tsb-card{display:flex;flex-direction:column;align-items:center;gap:.5rem;padding:1.25rem .75rem 1rem;background:#fff;border:1.5px solid #e2e8f0;border-radius:16px;text-decoration:none;transition:transform .2s,box-shadow .2s,border-color .2s;position:relative;overflow:hidden}
.tsb-card::after{content:"";position:absolute;top:0;left:0;right:0;height:3.5px;background:var(--tc,#e53e3e);border-radius:16px 16px 0 0;opacity:0;transition:opacity .2s}
.tsb-card:hover{transform:translateY(-5px);box-shadow:0 12px 32px rgba(0,0,0,.1);border-color:var(--tc,#e53e3e)}
.tsb-card:hover::after,.tsb-card.tsb-now::after{opacity:1}
.tsb-card.tsb-now{border-color:var(--tc,#e53e3e);background:var(--tb,#fff5f5)}
.tsb-badge{position:absolute;top:8px;right:8px;background:var(--tc,#e53e3e);color:#fff;font-size:.58rem;font-weight:800;padding:2px 7px;border-radius:999px}
.tsb-icon{font-size:2rem;line-height:1;filter:drop-shadow(0 2px 4px rgba(0,0,0,.1))}
.tsb-name{font-size:.78rem;font-weight:800;color:#1a202c;text-align:center;line-height:1.3}
.tsb-desc{font-size:.67rem;color:#718096;text-align:center}
.tsb-home{display:flex;justify-content:center;margin-top:1.25rem}
.tsb-home-link{display:inline-flex;align-items:center;gap:.4rem;color:#718096;text-decoration:none;font-size:.8rem;font-weight:600;padding:.4rem 1rem;border:1px solid #e2e8f0;border-radius:999px;transition:all .15s}
.tsb-home-link:hover{color:#e53e3e;border-color:#feb2b2;background:#fff5f5}
@media(max-width:600px){.tsb-grid{grid-template-columns:repeat(3,1fr)}.tsb-card:nth-child(n+4){display:none}}
