/* PSC Truck Price Book — Corporate Design System (Paisan Capital Co., Ltd.)
 * Official Brand CI:
 *   Paisan Blue  : #21409A
 *   Paisan Green : #39B54A
 *   Pure White   : #FFFFFF
 */
:root {
  --psc-blue-950: #142761;
  --psc-blue-900: #19327a;
  --psc-blue: #21409a;
  --psc-blue-500: #2f54bd;
  --psc-blue-50: #eef2ff;
  --psc-green: #39b54a;
  --psc-green-600: #2d9a3c;
  --psc-green-50: #ecfdf3;
  --navy-950: #142761;
  --navy-900: #21409a;
  --navy-800: #19327a;
  --blue-600: #21409a;
  --blue-500: #2f54bd;
  --blue-50: #eef2ff;
  --gold-500: #39b54a;
  --gold-400: #39b54a;
  --gold-50: #ecfdf3;
  --emerald-600: #2d9a3c;
  --emerald-50: #ecfdf3;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --rose-600: #e11d48;
  --rose-50: #fff1f2;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f7f9fc;
  --white: #ffffff;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(33, 64, 154, 0.08);
  --shadow-md: 0 8px 24px rgba(33, 64, 154, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'TH Sarabun New', 'THSarabunNew', 'TH SarabunPSK', 'THSarabunPSK', 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 17px;
  background: var(--slate-50);
  color: var(--slate-900);
  line-height: 1.45;
}

/* Header & Navigation */
.topbar {
  background: linear-gradient(135deg, var(--psc-blue) 0%, var(--psc-blue-900) 100%);
  color: var(--white);
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--psc-green);
  box-shadow: 0 2px 12px rgba(33, 64, 154, 0.22);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-pill {
  background: var(--white);
  padding: 4px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.brand-logo-pill img {
  height: 36px;
  width: auto;
  display: block;
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: #dbeafe;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.role-tag {
  background: var(--psc-green);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}

.nav-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  padding: 0 24px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.nav-tab {
  border: none;
  background: transparent;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.nav-tab:hover { color: var(--navy-900); }
.nav-tab.active {
  color: var(--blue-600);
  border-bottom-color: var(--blue-600);
}

/* Main Container */
.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
}

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

/* Cards & Grids */
.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-title {
  margin: 0 0 14px 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid-2 { display: grid; grid-template-columns: 420px 1fr; gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

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

/* Form Elements */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 5px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--slate-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--slate-900);
  background: var(--white);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary { background: var(--psc-blue); color: var(--white); }
.btn-primary:hover { background: var(--psc-blue-900); }
.btn-gold { background: var(--psc-green); color: var(--white); }
.btn-gold:hover { background: var(--psc-green-600); }
.btn-outline { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); }
.btn-outline:hover { background: var(--slate-100); }
.btn-danger { background: var(--rose-600); color: var(--white); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

/* KPI & Price Display */
.kpi-card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--psc-blue);
}

.kpi-label { font-size: 13px; color: var(--slate-500); font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; color: var(--psc-blue); margin-top: 4px; }
.kpi-sub { font-size: 12px; color: var(--slate-500); margin-top: 2px; }

.price-hero {
  background: linear-gradient(135deg, var(--psc-blue) 0%, var(--psc-blue-950) 100%);
  color: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  border-bottom: 4px solid var(--psc-green);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.price-box {
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 12px 14px;
}

.price-box.highlight {
  background: rgba(57, 181, 74, 0.24);
  border-color: rgba(57, 181, 74, 0.85);
}

.price-box .lbl { font-size: 12px; color: #dbeafe; }
.price-box .val { font-size: 22px; font-weight: 800; margin-top: 2px; }
.price-box.highlight .val { color: #bbf7d0; }

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge-high, .badge-exact { background: var(--psc-green-50); color: var(--psc-green-600); border: 1px solid #86efac; }
.badge-medium, .badge-near { background: var(--amber-50); color: var(--amber-600); border: 1px solid #fde68a; }
.badge-low, .badge-insufficient, .badge-none { background: var(--rose-50); color: var(--rose-600); border: 1px solid #fecdd3; }
.badge-info { background: var(--psc-blue-50); color: var(--psc-blue); border: 1px solid #c7d2fe; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--slate-200); }
th { background: var(--slate-50); color: var(--slate-700); font-weight: 700; font-size: 13px; white-space: nowrap; }
tr:hover td { background: #f8fafc; }
.text-right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* Spec Pills */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.spec-item .k { font-size: 11.5px; color: var(--slate-500); }
.spec-item .v { font-size: 14px; font-weight: 700; color: var(--navy-900); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 38, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 14px;
  max-width: 780px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(7, 20, 38, 0.35);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy-900);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 200;
}
.toast.show { display: block; }
.hidden { display: none !important; }

/* Print Appraisal Sheet */
@media print {
  .topbar, .nav-tabs, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .modal-backdrop { position: static; background: none; padding: 0; display: block !important; }
  .modal-box { box-shadow: none; max-width: 100%; max-height: none; padding: 0; }
}
