html { font-size: 14px; position: relative; min-height: 100%; }

@media (min-width: 768px) {
  html { font-size: 16px; }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

body {
  margin-bottom: 60px;
  background: #f5f7fa;
  color: #1f2937;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

.navbar { background: #fff; }
.navbar-brand { font-weight: 700; color: #1c4e80 !important; }
.nav-user { display: flex; align-items: center; padding: .5rem .75rem; color: #475569; }
.page-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin: 1.25rem 0; }
.page-heading h1, .portal-panel h1 { font-size: 1.8rem; margin: 0; font-weight: 700; }
.page-heading p { margin: .35rem 0 0; color: #64748b; }
.portal-panel { background: #fff; border: 1px solid #dbe3ec; border-radius: 8px; padding: 1.25rem; box-shadow: 0 8px 24px rgba(15, 23, 42, .04); }
.portal-panel.narrow { max-width: 460px; margin: 3rem auto; }
.portal-panel h2 { font-size: 1.35rem; margin-bottom: .75rem; }
.portal-panel label { margin-top: .8rem; margin-bottom: .25rem; font-weight: 600; }
.secondary-link { display: inline-block; margin-top: 1rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar .form-control { max-width: 420px; }
.date-search .form-control { max-width: 180px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem 1rem; }
.form-grid .full-span { grid-column: 1 / -1; }
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: .5rem 1rem; margin: 0; }
.info-grid dt { color: #64748b; font-weight: 700; }
.info-grid dd { margin: 0; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.quick-card { display: flex; flex-direction: column; gap: .4rem; min-height: 120px; padding: 1.2rem; color: #1f2937; text-decoration: none; background: #fff; border: 1px solid #dbe3ec; border-radius: 8px; }
.quick-card:hover { border-color: #1c7ed6; color: #12395f; }
.quick-card strong { font-size: 1.15rem; }
.quick-card.metric strong { font-size: 1.45rem; color: #1c4e80; }
.quick-card span, .empty-state { color: #64748b; }
.quick-card.install-card { border-color: #1c7ed6; background: #f8fbff; }
.quick-card.install-card strong { color: #124f86; }
.inline-form { display: inline-flex; gap: .4rem; }
.line-grid-wrap { border: 1px solid #dbe3ec; border-radius: 8px; margin-bottom: 1rem; }
.line-grid { min-width: 920px; }
.line-grid th { white-space: nowrap; }
.line-grid tfoot th { background: #f8fafc; }
.line-product-name[readonly], .line-product-code[readonly], .line-unit[readonly], .line-total[readonly], .grand-total[readonly] { background: #f8fafc; }
.product-list tbody tr { cursor: pointer; }
.product-list td { vertical-align: middle; }
.voucher-group-row td { background: #eef6ff; border-top: 2px solid #b6d9ff; }
.voucher-summary-row td { background: #fff; }
.print-only { display: none !important; }
.document-action-bar { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.erp-document-heading { display: flex; align-items: flex-end; justify-content: center; position: relative; margin-bottom: 1rem; }
.erp-document-heading h3 { margin: 0; font-size: 2rem; font-weight: 800; letter-spacing: .25rem; color: #111827; }
.erp-document-no { position: absolute; right: 0; bottom: .15rem; color: #475569; font-weight: 700; }
.erp-document-meta { margin-bottom: 1rem; }
.erp-document-meta table { width: 100%; border-collapse: collapse; background: #fff; }
.erp-document-meta th,
.erp-document-meta td { border: 1px solid #1f2937; padding: .45rem .6rem; vertical-align: middle; }
.erp-document-meta th { width: 110px; text-align: center; background: #f8fafc; color: #111827; }
.erp-document-lines { border-collapse: collapse; margin-bottom: 0; }
.erp-document-lines th,
.erp-document-lines td { border: 1px solid #1f2937; }
.erp-document-lines thead th { background: #f8fafc; color: #111827; text-align: center; }
.erp-remarks-box textarea { min-height: 82px; }
.erp-sign-area { min-height: 76px; }
.seal-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border: 2px solid #dc2626;
  border-radius: 50%;
  color: #dc2626;
  font-weight: 700;
  letter-spacing: 0;
}
.seal-stamp img { max-width: 100%; max-height: 100%; object-fit: contain; }
.voucher-print-page { break-inside: avoid; page-break-inside: avoid; }

@media (max-width: 720px) {
  .page-heading, .search-bar { align-items: stretch; flex-direction: column; }
  .search-bar .form-control, .date-search .form-control { max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  header, footer, .toolbar, .search-bar, .btn, .no-print, .modal, .validation-summary-errors, .text-danger { display: none !important; }
  body { background: #fff; margin: 0; font-size: 11px; color: #111827; }
  .portal-panel, .card { border: 0; box-shadow: none !important; padding: 0; }
  .container { max-width: none; width: 100%; }
  .print-document { display: block !important; border: 0 !important; }
  .print-document .card-body { padding: 0 !important; }
  .print-only { display: table-cell !important; }
  .erp-print-sheet { width: 100%; }
  .erp-document-heading { margin-bottom: 8mm; }
  .erp-document-heading h3 { font-size: 24pt; }
  .erp-document-no { font-size: 10pt; }
  .erp-document-meta { display: block; }
  .row.mb-3,
  .d-flex.justify-content-between.align-items-center.mb-2 { display: none !important; }
  .line-grid-wrap { border: 0; overflow: visible !important; }
  .line-grid { min-width: 0; width: 100%; table-layout: fixed; }
  .erp-document-lines th,
  .erp-document-lines td,
  .erp-document-meta th,
  .erp-document-meta td { border-color: #111827 !important; padding: 4px 5px; }
  .erp-document-lines th { font-weight: 700; }
  .erp-document-lines input,
  .erp-remarks-box textarea {
    border: 0 !important;
    background: transparent !important;
    padding: 0 !important;
    min-height: 0;
    color: #111827 !important;
    box-shadow: none !important;
  }
  .erp-remarks-box { margin-top: 8px; }
  .erp-remarks-box label { font-weight: 700; }
  .erp-remarks-box textarea { resize: none; }
  .erp-sign-area { margin-top: 10mm; }
  .seal-stamp { width: 22mm; height: 22mm; font-size: 9pt; }
  body.print-single .voucher-print-page { display: none !important; }
  body.print-single .voucher-print-page.print-target { display: block !important; }
  .voucher-print-page { page-break-after: always; }
  .voucher-print-page:last-child { page-break-after: auto; }
}
