﻿:root {
      --bg: #f4f7fb;
      --card: #ffffff;
      --text: #1d2735;
      --muted: #5f6b7a;
      --brand: #0c6b58;
      --brand-2: #0a5849;
      --line: #d8e0ea;
      --head-blue: #8eb0cf;
      --soft-print-blue: #e8f2ff;
      --danger: #c31212;
      --frame: #6b7280;
      --frame-soft: #d1d5db;
    }
    * { box-sizing: border-box; }
    
      padding-top: 68px;
    }
    .topbar {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      width: 100%;
      z-index: 1000;
      background: #ffffff;
      border-bottom: 1px solid var(--line);
    }
    .topbar-inner {
      max-width: none;
      margin: 0 auto;
      padding: 12px clamp(12px, 2vw, 28px);
      display: flex;
      gap: 14px;
      align-items: center;
      flex-wrap: wrap;
    }
    .brand {
      font-weight: 700;
      color: var(--brand);
      margin-right: 10px;
    }
    .nav {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    .nav a {
      text-decoration: none;
      color: var(--text);
      border: 1px solid var(--line);
      padding: 6px 10px;
      border-radius: 8px;
      background: #fff;
      font-size: 14px;
    }
    .nav a:hover { border-color: var(--brand); }
    .nav a[aria-current="page"] {
      background: var(--brand);
      color: #fff;
      border-color: var(--brand);
      pointer-events: none;
      cursor: default;
    }
    main {
      max-width: none;
      margin: 20px auto;
      padding: 20px clamp(12px, 2vw, 28px) 28px;
    }
    .panel {
      background: var(--card);
      border: 1px solid var(--line);
      border-radius: 12px;
      padding: 16px;
    }
    h1 {
      margin: 0 0 8px;
      font-size: 28px;
    }
    p {
      margin: 0;
      color: var(--muted);
    }
    .report-sheet {
      margin-top: 16px;
      border: 1px solid var(--frame);
      background: #fff;
      width: 100%;
      max-width: none;
      margin-left: auto;
      margin-right: auto;
      overflow: hidden;
      border-radius: 8px;
      box-shadow: 0 8px 24px rgba(15, 43, 72, 0.08);
    }
    .sheet-top {
      display: grid;
      grid-template-columns: 320px 1fr;
      border-bottom: 1px solid var(--frame);
      background: #fff;
    }
    .report-header {
      display: grid;
      grid-template-columns: 1fr;
      gap: 0;
      padding: 10px;
      background: #f9fcff;
    }
    .report-brand {
      border-right: 1px solid var(--frame);
      padding: 8px 12px;
      background: #fff;
      display: flex;
      flex-direction: column;
      align-items: stretch;
      justify-content: center;
      gap: 8px;
      min-height: 74px;
    }
    .report-brand-media {
      width: 100%;
      min-height: 56px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .report-logo {
      width: 100%;
      max-width: 100%;
      max-height: 96px;
      height: auto;
      object-fit: contain;
      display: block;
    }
    .report-brand-fallback {
      font-family: "Times New Roman", serif;
      font-size: 24px;
      font-weight: 700;
      color: #114f91;
      letter-spacing: .3px;
      display: none;
    }
    .logo-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      justify-content: flex-end;
      flex-wrap: wrap;
    }
    .logo-size-wrap {
      display: flex;
      align-items: center;
      gap: 6px;
      color: #114f91;
      font-size: 12px;
      font-weight: 600;
    }
    .logo-size-wrap input[type="range"] {
      width: 120px;
      accent-color: #114f91;
    }
    .logo-btn {
      border: 1px solid var(--frame);
      background: #fff;
      color: #114f91;
      border-radius: 6px;
      padding: 6px 10px;
      font-size: 12px;
      cursor: pointer;
      font-weight: 600;
    }
    .logo-btn:hover { background: #eef4fd; }
    .header-field {
      border: 1px solid var(--frame);
      border-radius: 0;
      background: #fff;
      padding: 0;
      display: grid;
      grid-template-columns: 170px 1fr;
      align-items: center;
      min-height: 54px;
      margin-top: -1px;
    }
    .header-label {
      display: block;
      font-size: 22px;
      color: #374151;
      font-weight: 700;
      margin: 0;
      letter-spacing: 0;
      text-align: right;
      padding: 8px 12px 8px 10px;
      font-family: "Times New Roman", serif;
    }
    .header-input {
      width: 100%;
      border: 0;
      outline: 0;
      padding: 8px 12px;
      background: transparent;
      font-family: "Times New Roman", serif;
      font-size: 22px;
      font-weight: 700;
      color: #1f2937;
    }
    .table-wrap {
      overflow-x: auto;
      background: #fff;
    }
    .po-summary {
      display: flex;
      justify-content: flex-end;
      padding: 8px 12px 10px;
      border-top: 1px solid var(--frame-soft);
      background: #fbfdff;
      font-family: "Times New Roman", serif;
      font-size: 20px;
      font-weight: 700;
      color: #1f2c3d;
    }
    .po-summary .amount {
      color: #c31212;
      margin-left: 8px;
    }
    .report-bottom-space {
      height: 80px;
      border-top: 1px dashed #d1d5db;
      background: #fff;
    }
    .report-table {
      width: 100%;
      border-collapse: collapse;
      min-width: 1280px;
      table-layout: auto;
    }
    .report-table th,
    .report-table td {
      border-right: 1px solid var(--frame-soft);
      border-bottom: 1px solid var(--frame-soft);
      padding: 8px 6px;
      font-family: "Times New Roman", serif;
      font-size: 16px;
      vertical-align: middle;
    }
    .report-table th {
      background: #f1f5f9;
      text-align: center;
      font-size: 18px;
      font-weight: 700;
      white-space: normal;
      line-height: 1.15;
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      letter-spacing: 0.3px;
    }
    .report-table td:first-child,
    .report-table th:first-child { border-left: 0; }
    .report-table td:last-child,
    .report-table th:last-child { border-right: 0; }
    .cell-input {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 8px;
      outline: 0;
      background: #fff;
      padding: 8px 10px;
      font: inherit;
      color: inherit;
      resize: none;
      min-height: 36px;
      line-height: 1.3;
    }
    .cell-input:focus {
      border-color: var(--brand);
      box-shadow: 0 0 0 2px rgba(12, 107, 88, 0.12);
    }
    .report-table td:focus-within {
      background: #f8fafc;
    }
    .row-del-btn {
      border: 0;
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 12px;
      cursor: pointer;
      color: #fff;
      background: #b92c2c;
    }
    .row-del-btn:hover { background: #982424; }
    .col-no { width: 64px; text-align: center; }
    .col-name { width: 220px; }
    .col-spec { width: 140px; text-align: center; }
    .col-phone { width: 140px; }
    .col-hospital { width: 190px; }
    .col-location { width: 170px; }
    .col-focus { width: 220px; }
    .col-sample { width: 190px; }
    .col-po { width: 130px; color: var(--danger); font-weight: 700; text-align: center; }
    .col-action { width: 92px; text-align: center; }
    .po-input {
      color: #1d4ed8;
      font-weight: 700;
      text-align: center;
    }
    .entry-form {
      margin-top: 16px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: #fcfeff;
      padding: 12px;
    }
    .row {
      display: grid;
      grid-template-columns: repeat(3, minmax(200px, 1fr));
      gap: 10px;
      margin-bottom: 10px;
    }
    label {
      display: block;
      font-size: 13px;
      margin-bottom: 4px;
      font-weight: 600;
      color: #294455;
    }
    input, textarea {
      width: 100%;
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 8px 10px;
      font-size: 14px;
      background: #fff;
    }
    textarea { min-height: 54px; }
    .actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 6px;
    }
    .actions-top-gap {
      margin-top: 12px;
    }
    .btn {
      border: 0;
      border-radius: 8px;
      padding: 8px 12px;
      font-size: 14px;
      cursor: pointer;
      color: #fff;
      background: var(--brand);
    }
    .btn:hover { background: var(--brand-2); }
    .btn-danger { background: #b92c2c; }
    .btn-danger:hover { background: #982424; }
    .btn-sm {
      border: 0;
      border-radius: 6px;
      padding: 4px 8px;
      font-size: 12px;
      cursor: pointer;
      color: #fff;
      background: var(--brand);
    }
    .btn-sm:hover { background: var(--brand-2); }
    .btn-sm.delete { background: #b92c2c; }
    .btn-sm.delete:hover { background: #982424; }
    .saved-section {
      margin-top: 16px;
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 12px;
      background: #fff;
    }
    .saved-table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 8px;
    }
    .saved-table th,
    .saved-table td {
      border: 1px solid var(--line);
      padding: 8px;
      font-size: 14px;
      text-align: left;
    }
    .saved-table th { background: #f6faf9; }
    .status {
      margin-top: 10px;
      font-size: 14px;
      font-weight: 600;
      color: #1f6d3a;
    }
    .status.error { color: #b92c2c; }
    .suggest-wrap { position: relative; }
    .suggest-box {
      position: absolute;
      left: 0;
      right: 0;
      top: calc(100% + 4px);
      z-index: 20;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 6px 18px rgba(0,0,0,.08);
      max-height: 180px;
      overflow: auto;
      padding: 4px;
    }
    .suggest-item {
      padding: 7px 8px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 14px;
    }
    .suggest-item:hover { background: #eef6f4; }
    @media (max-width: 1000px) {
      .sheet-top { grid-template-columns: 1fr; }
      .report-brand { border-right: 0; border-bottom: 1px solid var(--frame); }
      .report-brand { min-height: 62px; padding: 6px 8px; }
      .report-logo { max-height: 72px; }
      .logo-actions { display: none; }
      .report-header { grid-template-columns: 1fr; }
      .header-field { grid-template-columns: 120px 1fr; min-height: 46px; }
      .header-label { font-size: 18px; padding: 6px 8px; }
      .header-input { font-size: 18px; padding: 6px 8px; }
      .report-table th { font-size: 15px; white-space: normal; }
      .report-table td { font-size: 14px; }
      .row { grid-template-columns: 1fr; }
      .report-bottom-space { height: 48px; }
    }
    @media print {
      @page { size: A4 landscape; margin: 8mm; }
      .topbar, .entry-form, .saved-section, .status, .help { display: none !important; }
      body { background: #fff; }
      .panel { border: 0; padding: 0; }
      h1, p { display: none; }
      .report-sheet { margin-top: 0; }
      .sheet-top { grid-template-columns: 240px 1fr; }
      .report-brand { min-height: 54px; padding: 4px 6px; }
      .report-logo { max-height: 54px; }
      .logo-actions { display: none !important; }
      .report-header { grid-template-columns: 1fr; gap: 0; padding: 0; }
      .header-field { grid-template-columns: 120px 1fr; min-height: 34px; margin-top: -1px; }
      .header-label { font-size: 14px; padding: 4px 6px; }
      .header-input { font-size: 16px; font-family: "Times New Roman", serif; padding: 4px 6px; }
      .report-table th {
        font-size: 16px;
        font-family: "Times New Roman", serif;
        background: var(--soft-print-blue) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
      }
      .report-table td { font-size: 14px; }
      .report-bottom-space { height: 36px; }
    }


/* Stable fixed navigation across pages */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
}
.topbar-inner {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.brand {
  flex-shrink: 0;
}
.nav {
  flex-wrap: nowrap;
  white-space: nowrap;
}
.nav a {
  flex-shrink: 0;
}

/* Navigation hard lock (prevent any bleed behind nav) */
.topbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  z-index: 2147483000 !important;
  background: #ffffff !important;
  border-bottom: 1px solid var(--line) !important;
  isolation: isolate;
}
.topbar-inner {
  position: relative;
  z-index: 1;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.brand { flex-shrink: 0; }
.nav { flex-wrap: nowrap !important; white-space: nowrap; }
.nav a { flex-shrink: 0; }
body { padding-top: 74px !important; }
