/* SellerCalc TH — Mobile-First Production Stylesheet (Zero External Dependencies) */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-soft: #ccfbf1;
  --accent: #2563eb;
  --profit: #059669;
  --profit-bg: #ecfdf5;
  --loss: #dc2626;
  --loss-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --shopee: #ee4d2d;
  --tiktok: #111827;
  --lazada: #0f146d;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --font: 'Prompt', 'Noto Sans Thai', 'Sarabun', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
}

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

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 10px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0f766e, #0284c7);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-soft);
  line-height: 1.1;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.pill-green {
  background: var(--profit-bg);
  color: var(--profit);
  border-color: #a7f3d0;
}

.pill-amber {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #fde68a;
}

.pill-blue {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

/* Hero */
.hero {
  padding: 22px 0 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.38rem, 3.2vw, 2rem);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 78ch;
}

.gp-banner {
  background: linear-gradient(90deg, #ecfdf5 0%, #eff6ff 100%);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.84rem;
  color: #065f46;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Main Tabs */
.tool-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0 16px;
}

.tab-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: var(--shadow-sm);
}

.tab-btn small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-soft);
}

.tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22);
}

.tab-btn.active small { color: #ccfbf1; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Cards & Grid */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  align-items: end;
}

@media (min-width: 768px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Form Controls */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.field input[type="number"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.field-hint {
  font-size: 0.74rem;
  color: var(--text-soft);
}

/* Toggle Switches */
.toggles-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.toggle-chip input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.toggle-chip.highlight {
  background: var(--profit-bg);
  border-color: #6ee7b7;
  color: #065f46;
}

.alert-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  border: 1px solid;
}

.alert-warn {
  background: var(--warn-bg);
  border-color: #fcd34d;
  color: #92400e;
}

.alert-danger {
  background: var(--loss-bg);
  border-color: #fca5a5;
  color: #991b1b;
}

.alert-success {
  background: var(--profit-bg);
  border-color: #6ee7b7;
  color: #065f46;
}

.hidden { display: none !important; }

/* Platform Result Cards */
.platform-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.platform-card.winner {
  border-color: var(--profit);
  box-shadow: 0 8px 22px rgba(5, 150, 105, 0.14);
}

.platform-head {
  padding: 12px 16px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.platform-head.shopee { background: linear-gradient(135deg, #ee4d2d, #f97316); }
.platform-head.tiktok { background: linear-gradient(135deg, #111827, #334155); }
.platform-head.lazada { background: linear-gradient(135deg, #0f146d, #2563eb); }

.platform-name {
  font-weight: 800;
  font-size: 1rem;
}

.winner-badge {
  background: rgba(255, 255, 255, 0.95);
  color: #047857;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}

.platform-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.kpi-main {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  text-align: center;
}

.kpi-main.profit { background: var(--profit-bg); }
.kpi-main.loss { background: var(--loss-bg); }

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

.kpi-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 2px 0;
}

.kpi-main.profit .kpi-value { color: var(--profit); }
.kpi-main.loss .kpi-value { color: var(--loss); }

.kpi-sub-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mini-stat {
  background: var(--surface-alt);
  border-radius: 8px;
  padding: 8px 10px;
}

.mini-stat span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-soft);
}

.mini-stat strong {
  font-size: 0.95rem;
  color: var(--text);
}

.breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.84rem;
}

.breakdown-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}

.breakdown-list li:last-child { border-bottom: none; }

.breakdown-list li.total-row {
  font-weight: 700;
  color: var(--text);
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  margin-top: 4px;
  padding-top: 8px;
}

.rate-tag {
  font-size: 0.72rem;
  color: var(--text-soft);
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: 6px;
}

/* Custom Override Accordion */
details.override-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 16px;
}

details.override-box summary {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.override-box summary::-webkit-details-marker { display: none; }

.override-inner {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.override-platform {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}

.override-platform h4 {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

.btn-outline {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* Tax & VAT Progress Bar */
.vat-meter {
  margin-top: 10px;
}

.vat-bar-track {
  width: 100%;
  height: 16px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.vat-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
  background: var(--profit);
}

.vat-bar-fill.warning { background: #f59e0b; }
.vat-bar-fill.exceeded { background: var(--loss); }

.tax-compare-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}

.tax-compare-card.recommended {
  border-color: var(--profit);
  background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 35%);
}

/* Data Table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

table.data-table th,
table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

table.data-table th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 700;
}

table.data-table td.num,
table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Monetization & SEO Links */
.pro-box {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #ffffff;
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .pro-box { grid-template-columns: 1.6fr 1fr; }
}

.pro-box h3 { margin: 0 0 6px; font-size: 1.2rem; }
.pro-box p { margin: 0 0 10px; color: #cbd5e1; font-size: 0.88rem; }
.pro-features {
  margin: 0;
  padding-left: 18px;
  font-size: 0.84rem;
  color: #e2e8f0;
}

.pro-cta {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.supply-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .supply-grid { grid-template-columns: repeat(2, 1fr); }
}

.supply-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.supply-card h4 { margin: 4px 0 4px; font-size: 0.94rem; line-height: 1.35; }
.supply-card p { margin: 0; font-size: 0.81rem; color: var(--text-muted); }

.supply-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.supply-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--shopee);
}

.affiliate-disclosure {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-soft);
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.seo-link-card {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.seo-link-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  text-decoration: none;
}

.seo-link-card .seo-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.seo-link-card strong {
  display: block;
  font-size: 0.86rem;
  line-height: 1.35;
}

/* FAQ */
.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.faq-item:last-child { border-bottom: none; }
.faq-item summary { font-weight: 700; font-size: 0.92rem; cursor: pointer; }
.faq-item p { margin: 8px 0 0; font-size: 0.86rem; color: var(--text-muted); }

/* Footer */
.site-footer {
  margin-top: 28px;
  padding: 22px 0 36px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--text-soft);
}

.disclaimer-box {
  background: var(--surface-alt);
  border-left: 4px solid var(--primary);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 14px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .brand { font-size: 1rem; white-space: nowrap; }
  .header-badges .pill:not(.pill-green) { display: none; }
  .input-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-tabs { gap: 6px; }
  .tab-btn { padding: 10px 6px; font-size: 0.8rem; }
  .tab-btn small { display: none; }
  .card { padding: 14px; }
  .kpi-value { font-size: 1.45rem; }
}
