@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary-orange: #e67e22;
    --light-peach: #fdf2e9;
    --text-dark: #333333;
    --text-grey: #666666;
    --border-light: #eeeeee;
    }


  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: 'Sarabun', sans-serif;
    font-size: 13px;
    color: #222;
    background: #e8e8e8;
    padding: 0;
    margin: 0;
  }

  .navbar {
    background: var(--primary-orange);
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  .navbar-title {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    margin: 0;
  }

  .navbar-menu {
    display: flex;
    gap: 10px;
  }

  .navbar-menu a,
  .navbar-menu button {
    appearance: none;
    border: 1px solid rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
  }

  .navbar-menu a:hover,
  .navbar-menu button:hover {
    background: rgba(255,255,255,0.25);
  }

  .navbar-menu a.active {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.6);
  }

  .page-content {
    padding: 20px;
  }

  .page-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .toolbar {
    width: 794px;
    max-width: 100%;
    margin: 0 auto 16px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }

  .toolbar button,
  .toolbar .btn-link {
    appearance: none;
    border: 1px solid var(--primary-orange);
    border-radius: 6px;
    padding: 9px 16px;
    font: 600 13px/1 'Sarabun', sans-serif;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
  }

  .toolbar button {
    background: var(--primary-orange);
    color: #fff;
  }

  .toolbar button:hover { background: #d3701c; }

  .toolbar .btn-link {
    background: #fff;
    color: var(--primary-orange);
  }

  .page {
    background: #fff;
    width: 794px;
    min-height: 1123px;
    margin: 0 auto;
    padding: 32px 36px 28px;
    position: relative;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  }

  .top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
  }

  .logo-area { min-width: 90px; max-width: 240px; }
  .logo-area img { max-width: 140px; max-height: 90px; object-fit: contain; }

  /* Text mark used when the seller has no logo image — driven by seller data. */
  .logo-text {
    display: inline-flex;
    align-items: center;
    max-width: 240px;
    padding: 8px 12px;
    border: 1.5px solid var(--primary-orange);
    color: var(--primary-orange);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
  }

  .logo-fallback {
    width: 80px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--primary-orange);
    color: var(--primary-orange);
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.5px;
  }

  .doc-title-area { text-align: right; }

  .page-label {
    font-size: 11px;
    color: #555;
    margin-bottom: 4px;
  }

  .doc-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-orange);
    line-height: 1.1;
  }

  .info-section {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ddd;
  }

  .seller-block, .doc-meta-block { flex: 1; }

  .info-row {
    display: flex;
    gap: 6px;
    margin-bottom: 3px;
    align-items: flex-start;
  }

  .info-label {
    font-weight: 600;
    min-width: 80px;
    color: #333;
    flex-shrink: 0;
  }

  .info-value {
    color: #333;
    flex: 1;
  }

  .tax-id-row { margin-top: 6px; }

  .doc-meta-block { max-width: 280px; }
  .meta-table { width: 100%; border-collapse: collapse; }
  .meta-table td { padding: 2px 4px; vertical-align: top; }

  .meta-table .meta-label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    width: 110px;
  }

  .meta-table .meta-val { color: #333; }

  .meta-table .meta-val.doc-num {
    font-weight: 700;
    color: var(--primary-orange);
  }

  .customer-contact-section {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #ddd;
  }

  .customer-block { flex: 1; }
  .contact-block { max-width: 220px; }

  .contact-title {
    font-weight: 700;
    margin-bottom: 5px;
    color: #333;
  }

  .contact-row {
    display: flex;
    gap: 6px;
    margin-bottom: 3px;
    align-items: center;
    color: #333;
  }

  .contact-icon {
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    color: var(--primary-orange);
  }

  .contact-icon img {
    width: 15px;
    height: 15px;
    object-fit: contain;
    vertical-align: middle;
  }

  .items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
  }

  .items-table thead tr { background: #f5f0e8; }

  .items-table th {
    padding: 7px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 12.5px;
    color: #333;
    border-bottom: 2px solid var(--primary-orange);
  }

  .items-table th.right { text-align: right; }
  .items-table th.center { text-align: center; }

  .items-table td {
    padding: 7px 8px;
    vertical-align: top;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 12.5px;
  }

  .items-table td.right { text-align: right; }
  .items-table td.center { text-align: center; }

  .item-name {
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
  }

  .item-detail {
    font-size: 11.5px;
    color: #555;
    line-height: 1.5;
  }

  .item-detail div { margin-bottom: 1px; }

  .summary-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 10px;
    padding: 14px 0 0;
    border-top: 2px solid var(--primary-orange);
  }

  .summary-left { flex: 1; }

  .summary-left .summary-title {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 13px;
    color: #333;
  }

  .summary-line {
    display: flex;
    gap: 12px;
    margin-bottom: 3px;
    font-size: 12.5px;
  }

  .summary-line .s-label { min-width: 170px; color: #444; }
  .summary-line .s-val { color: #333; font-weight: 500; }

  .summary-right {
    text-align: right;
    min-width: 220px;
  }

  .total-box {
    background: #f5f0e8;
    border: 1.5px solid var(--primary-orange);
    border-radius: 4px;
    padding: 10px 16px;
    margin-bottom: 10px;
  }

  .total-box .total-label {
    font-size: 13px;
    color: #444;
    margin-bottom: 2px;
  }

  .total-box .total-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-orange);
  }

  .deduct-lines {
    font-size: 12px;
    color: #333;
  }

  .deduct-line {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 2px;
  }

  .payment-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #ddd;
  }

  .payment-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #333;
    font-size: 13px;
  }

  .payment-banks {
    display: flex;
    gap: 24px;
  }

  .bank-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px 14px;
  }

  .bank-logo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
  }

  .bank-logo.kbank { background: #138f2d; }
  .bank-logo.scb { background: #4e2d8e; }
  .bank-logo.other { background: #555; }

  .bank-info .bank-name { font-weight: 600; font-size: 12px; color: #333; }
  .bank-info .acc-num { font-size: 12.5px; font-weight: 700; color: #333; }
  .bank-info .acc-name { font-size: 11px; color: #666; }

  .note-footer {
    margin-top: 10px;
    font-size: 11.5px;
    color: #777;
    display: flex;
    align-items: center;
    gap: 5px;
  }

  @media print {
    body { background: #fff; padding: 0; }
    .page { box-shadow: none; margin: 0; }
    .page-wrapper { gap: 0; }
    .toolbar { display: none !important; }
  }
  