/* ===== X10 Flex Price — คลาสของแอปนี้ (โหลดหลัง brand.css) ===== */
:root {
  --fx-blue: #0f4c83;
  --fx-blue-dark: #0a3763;
  --fx-blue-50: #f2f7fc;
  --fx-blue-100: #e3edf7;
  --fx-orange: #f68a39;
  --fx-line: #e2e9f1;
  --fx-ink: #16283c;
  --fx-ink-soft: #5a6b7d;
}
body {
  font-family: 'Prompt', 'Noto Sans Thai', system-ui, sans-serif;
  background: #f4f7fb;
  color: var(--fx-ink);
}

/* ---- เมนูบน ---- */
.nav-link {
  display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; color: #dbe7f4; white-space: nowrap; text-decoration: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.nav-link.active { background: #fff; color: var(--fx-blue); font-weight: 600; }

/* ---- การ์ด / ตาราง ---- */
.panel {
  background: #fff; border: 1px solid var(--fx-line); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(16, 40, 60, .04);
}
.panel-h {
  padding: 10px 14px; border-bottom: 1px solid var(--fx-line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.panel-h h2 { font-size: 14px; font-weight: 700; color: var(--fx-blue-dark); }
.tile {
  background: #fff; border: 1px solid var(--fx-line); border-radius: 14px; padding: 11px 13px;
}
.tile-label { font-size: 11px; color: var(--fx-ink-soft); font-weight: 500; }
.tile-value { font-size: 21px; font-weight: 700; color: var(--fx-blue-dark); line-height: 1.15; }
.tile-sub { font-size: 10.5px; color: #94a3b8; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  background: var(--fx-blue-50); color: var(--fx-blue-dark); text-align: left;
  padding: 7px 8px; font-weight: 600; font-size: 11.5px; border-bottom: 1px solid var(--fx-line);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.data td { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; }
table.data tbody tr:hover { background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.md-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.md-table td { padding: 4px 7px; border-bottom: 1px solid #eef2f7; }
.md-table tr:first-child td { background: var(--fx-blue-50); font-weight: 600; color: var(--fx-blue-dark); }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; white-space: nowrap;
}

/* ---- ปุ่ม / ฟอร์ม ---- */
.btn-brand { background: var(--fx-blue); }
.btn-brand:hover { background: var(--fx-blue-dark); }
.btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 9px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--fx-blue); color: #fff; }
.btn-primary:hover { background: var(--fx-blue-dark); }
.btn-accent { background: var(--fx-orange); color: #fff; }
.btn-accent:hover { background: #e0752a; }
.btn-ghost { background: #fff; border-color: #cbd5e1; color: #334155; }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 3px 8px; font-size: 11.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.inp, .dlg-inp {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 9px; padding: 6px 9px;
  font-size: 13px; background: #fff; font-family: inherit;
}
.inp:focus, .dlg-inp:focus { outline: 2px solid var(--fx-blue-100); border-color: var(--fx-blue); }
.dlg-inp { margin-top: 3px; }
label.lb { font-size: 11.5px; font-weight: 600; color: var(--fx-ink-soft); display: block; }

/* ---- โมดอล ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 30, 46, .45); z-index: 120;
  display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 10px;
}
.modal-panel {
  background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(10, 30, 50, .3);
  width: 100%; margin-bottom: 40px;
}
.modal-backdrop.hidden { display: none; }

/* ---- ตารางกริดราคา ---- */
.grid-wrap { overflow: auto; max-height: calc(100vh - 250px); }
.grid-tb { border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.grid-tb th, .grid-tb td { border-bottom: 1px solid #eef2f7; border-right: 1px solid #f1f5f9; }
.grid-tb thead th {
  position: sticky; top: 0; z-index: 3; background: var(--fx-blue); color: #fff;
  padding: 5px 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.grid-tb tbody th {
  position: sticky; left: 0; z-index: 2; background: #fff; text-align: left;
  padding: 3px 7px; font-weight: 600; white-space: nowrap; min-width: 108px;
}
.grid-tb tbody tr.we th { background: #fff7ed; }
.grid-tb tbody tr.we td.dcol { background: #fff7ed; }
.cell {
  padding: 2px 4px; text-align: right; cursor: pointer; min-width: 74px;
  font-variant-numeric: tabular-nums;
}
.cell:hover { outline: 2px solid var(--fx-blue); outline-offset: -2px; }
.cell .p { font-weight: 700; font-size: 11.5px; }
.cell .d { font-size: 9.5px; line-height: 1.1; }
.chip { display: inline-block; width: 9px; height: 9px; border-radius: 3px; vertical-align: middle; }

/* ---- แถบตัวคูณ (waterfall) ---- */
.wf-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 3px 0; }
.wf-name { width: 172px; color: var(--fx-ink-soft); flex-shrink: 0; }
.wf-bar { flex: 1; height: 15px; background: #f1f5f9; border-radius: 4px; position: relative; }
.wf-bar > i {
  position: absolute; top: 0; bottom: 0; border-radius: 4px; display: block;
}
.wf-bar > b {
  position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #94a3b8;
}
.wf-val { width: 64px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- เมทริกซ์หัวใจ ---- */
.mx { border-collapse: collapse; font-size: 12px; }
.mx th, .mx td { border: 1px solid #e2e8f0; padding: 4px 6px; text-align: center; }
.mx thead th { background: var(--fx-blue-50); color: var(--fx-blue-dark); font-size: 11px; }
.mx tbody th { background: #f8fafc; text-align: left; font-size: 11px; white-space: nowrap; }
.mx input {
  width: 58px; border: 0; background: transparent; text-align: center; font-weight: 700;
  font-size: 12px; font-family: inherit;
}
.mx input:focus { outline: 2px solid var(--fx-blue); border-radius: 4px; }

/* ---- ป้ายแหล่งข้อมูล ---- */
.src {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.src-ok { background: #d1fae5; color: #065f46; }
.src-wait { background: #fef3c7; color: #92400e; }
.src-err { background: #fee2e2; color: #991b1b; }
.src-idle { background: #f1f5f9; color: #64748b; }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--fx-line); flex-wrap: wrap; }
.tab {
  padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--fx-ink-soft);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
}
.tab.active { color: var(--fx-blue); border-bottom-color: var(--fx-blue); }

.scroll-y { overflow-y: auto; }
.no-print { }
@media print { .no-print { display: none !important; } }
