/*
 * GB Report Editor - cleaned desktop stylesheet
 * Refactored from gb-editor (8).css
 * Layout preserved; palette harmonized around a darker original medical blue.
 */

/* =========================================================
+   THEME & BASE
+   ========================================================= */

:root {
  --gb-blue: #075f74;
  --gb-blue-2: #0b7187;
  --gb-blue-light: #ffffff;
  --gb-contrast: #123f4b;
  --gb-focus: #0b7f78;
  --gb-surface: #f3f8f9;
  --gb-line: #afc8ce;
}

html,
body {
  scroll-behavior: auto !important;
}

@keyframes shake {
  0% {transform:translateX(0);}
  25% {transform:translateX(-2px);}
  50% {transform:translateX(2px);}
  75% {transform:translateX(-2px);}
  100% {transform:translateX(0);}
}

@keyframes gbDialogShow {
  from{
  
  transform:translateY(10px) scale(.96);
  
  opacity:0;
  
  }
  
  to{
  
  transform:none;
  
  opacity:1;
  
  }
}

/* =========================================================
+   APP & HEADERS
+   ========================================================= */

.gb-list-header h3 {
  margin: 0;
}

#gb-report-app > h2 {
  text-align: center;
  text-transform: uppercase;
  color: var(--gb-blue);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: 1.2px;
  margin: 0 0 16px;
  position: relative;
  padding-bottom: 10px;
  text-shadow: 0 1px 0 #ffffff;
}

#gb-report-app {
  width: min(96vw, 1600px);
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;
  color: #173b45;
}

#gb-report-app > h2::after {
  content: "";
  display: block;
  width: 180px;
  height: 2px;
  background: linear-gradient(
        90deg,
        transparent,
        var(--gb-blue),
        transparent
    );
  margin: 8px auto 0;
}

#gb-report-app .gb-report-list-title,
#gb-report-app h3 {
  text-transform: uppercase;
  color: var(--gb-blue);
  font-weight: 800;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.gb-list-header {
  display: grid;
  grid-template-columns: 1fr 300px;
  align-items: center;
  padding: 0 4px;
  gap: 12px;
  margin-bottom: 12px;
}

.gb-list-title h3 {
  margin: 0;
  text-transform: uppercase;
  color: var(--gb-blue);
  font-weight: 800;
  letter-spacing: .5px;
}

.gb-list-action {
  width: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* =========================================================
+   FORM CONTROLS
+   ========================================================= */

.gb-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.gb-row label {
  flex: 1;
  min-width: 150px;
}

.gb-datepicker {
  border: 1px solid #c7d5d8;
  border-radius: 4px;
  background: #f4f8f9;
}

.gb-calendar-icon {
  font-size: 22px;
}

.gb-row input,
.gb-row select,
.gb-row textarea {
  width: 100%;
  padding: 8px;
  background: #fbfdfe;
  border: 1px solid var(--gb-line);
  border-radius: 8px;
  color: #153b45;
  box-shadow: inset 0 1px 2px rgba(18,63,75,.06);
  transition: border-color .18s ease,
        background .18s ease,
        box-shadow .18s ease;
}

.gb-row input:focus,
.gb-row select:focus,
.gb-row textarea:focus {
  background: #ffffff;
  border-color: var(--gb-focus);
  box-shadow: 0 0 0 3px rgba(11,127,120,.20),
              0 2px 8px rgba(7,95,116,.10);
  outline: none;
}

textarea.highlight-field {
  background: #fbfdfe;
  border: 1px solid var(--gb-line);
  color: #153b45;
  border-radius: 8px;
  box-shadow: inset 0 1px 2px rgba(18,63,75,.06);
  transition: border-color .18s ease,
        box-shadow .18s ease;
  width: 100%;
  padding: 8px;
  resize: vertical;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.45;
  box-sizing: border-box;
}

textarea.field-kham {
  height: 160px;
}

textarea.field-diagnosis {
  height: 60px;
}

textarea[name="kham_lam_sang"] {
  min-height: 140px;
}

textarea.highlight-field:focus {
  background: #ffffff;
  border-color: var(--gb-focus);
  box-shadow: 0 0 0 3px rgba(11,127,120,.20),
              0 2px 8px rgba(7,95,116,.10);
  outline: none;
}

textarea.gb-auto-resize {
  min-height: 85px !important;
  max-height: 320px;
  overflow-y: hidden;
  resize: vertical;
}

.gb-editor-two-cols textarea {
  width: 100%;
  box-sizing: border-box;
}

.gb-editor-short-two-cols textarea {
  min-height: 70px;
  height: 70px;
}

.gb-upload-btn input {
  display: none;
}

.gb-report-table input {
  width: 100%;
  text-align: center;
}

/* =========================================================
+   PATIENT EDITOR
+   ========================================================= */

.gb-patient {
  border-radius: 5px;
  padding: 8px 8px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

#gb-report-form #gb-patients .gb-patient {
  transition: background 0.2s ease, border-color 0.2s ease,
              box-shadow 0.2s ease;
  background: #edf5f6;
  border: 1px solid #b7cdd2;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(18,63,75,.10);
}

#gb-report-form #gb-patients .gb-patient.open {
  background: #ffffff;
  border-color: #5b9eaa;
  box-shadow: 0 7px 20px rgba(7,95,116,.16);
}

.gb-patient-top {
  display: grid;
  grid-template-columns: auto      
    320px     
    minmax(280px,2fr) 
    200px     
    150px     
    120px;
  gap: 8px;
  align-items: end;
}

.gb-patient input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid var(--gb-line);
  border-radius: 8px;
  color: #153b45;
  box-shadow: inset 0 1px 2px rgba(18,63,75,.06);
  transition: border-color .18s ease,
        box-shadow .18s ease,
        background-color .18s ease;
}

.gb-patient input[type="number"]:focus {
  background: #ffffff;
  border-color: var(--gb-focus);
  box-shadow: 0 0 0 3px rgba(11,127,120,.20);
  outline: none;
}

.gb-patient-top>.gb-remove-patient {
  align-self: end;
}

.gb-patient-top>label {
  min-width: 0;
  flex: none;
}

.gb-patient-top input,
.gb-patient-top select {
  width: 100%;
}

.bn-stt {
  font-size: 14px;
  color: red;
  font-weight: bold;
}

.bn-stt-input {
  width: 100px;
  text-align: center;
  font-weight: bold;
  border: 1px solid #8b9b9f;
  border-radius: 4px;
  margin-left: 4px;
  height: 22px;
  padding: 0 4px;
  font-size: 12px;
}

.gb-patient-card .pc-header {
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: 600;
}

.gb-patient select[name="loai"] {
  border: 2px solid #f59e0b !important;
  font-weight: 700;
}

.gb-patient select {
  background-color: #fbfdfe !important;
  color: #153b45 !important;
  border: 1px solid var(--gb-line);
  border-radius: 8px;
  padding: 8px 10px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-shadow: none;
  outline: none;
}

.gb-patient select:focus {
  background-color: #ffffff !important;
  color: #153b45 !important;
  border-color: var(--gb-focus) !important;
  box-shadow: 0 0 0 3px rgba(11,127,120,.20);
  outline: none;
}

.gb-patient input {
  background-color: #fbfdfe !important;
  color: #153b45 !important;
  border: 1px solid var(--gb-line);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: inset 0 1px 2px rgba(18,63,75,.06);
  outline: none;
  transition: border-color .18s ease,
        box-shadow .18s ease,
        background-color .18s ease;
}

.gb-patient input:focus {
  background-color: #ffffff !important;
  border-color: var(--gb-focus) !important;
  box-shadow: 0 0 0 3px rgba(11,127,120,.20);
  outline: none;
}

.label-bao-cao {
  color: #a62f3b;
  font-weight: 800;
}

.label-ho-ten {
  color: #075f74;
  font-weight: 800;
}

.label-title {
  font-weight: 800;
  color: #294f59;
}

.loai-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.loai-row select {
  flex: 1;
}

.gb-patient.layout-locmau textarea {
  min-height: 50px !important;
  height: 50px !important;
}

.gb-patient.layout-locmau textarea[name="thuoc"] {
  min-height: 180px !important;
  height: 180px !important;
}

.gb-patient.layout-locmau .gb-row {
  margin-bottom: 6px;
}

.gb-patient.layout-locmau .gb-editor-col textarea {
  min-height: 50px !important;
}

.gb-patient.layout-note textarea {
  min-height: 80px !important;
  height: 80px !important;
}

.gb-patient.layout-note textarea[name="kham_lam_sang"] {
  min-height: 220px !important;
  height: 220px !important;
}

/* =========================================================
+   COLLAPSE & SUMMARY
+   ========================================================= */

#gb-report-form #gb-patients .gb-patient-head {
  min-height: 26px;
  padding: 6px 8px;
  border-radius: 4px;
  color: #172f36;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  box-shadow: inset 0 -1px 0 rgba(18,63,75,.08);
}

.gb-patient-body {
  display: none;
  padding-top: 4px;
}

.gb-patient.open .gb-patient-body {
  display: block;
}

/* Báo cáo mới: chỉ hiện nút xoá và ô chọn loại báo cáo. */
.gb-patient.gb-awaiting-report-type.open .gb-patient-body > :not(.gb-patient-top) {
  display: none;
}

.gb-patient.gb-awaiting-report-type .gb-patient-top > label:not(.label-bao-cao) {
  display: none;
}

.gb-report-type-warning {
  display: none;
}

.gb-patient.gb-awaiting-report-type .gb-patient-top {
  background: #fff1a8 !important;
  border: 2px solid #d99b00 !important;
  box-shadow: 0 0 0 3px rgba(224, 170, 0, 0.15);
}

.gb-patient.gb-awaiting-report-type .label-bao-cao {
  color: #b42318 !important;
  font-weight: 800;
}

.gb-patient.gb-awaiting-report-type .gb-report-type-label {
  display: none;
}

.gb-patient.gb-awaiting-report-type .gb-report-type-warning {
  display: block;
  margin-bottom: 5px;
  color: #b00020;
  font-weight: 900;
  letter-spacing: 0.25px;
  text-shadow: 0 1px 0 #ffffff;
}

.gb-patient.gb-awaiting-report-type select[name="loai"] {
  border: 2px solid #c00000 !important;
  background: #fffdf2 !important;
}

.gb-patient.gb-awaiting-report-type select[name="loai"]:focus {
  outline: 3px solid rgba(192, 0, 0, 0.22);
  outline-offset: 2px;
}

.gb-patient:not(.open) .summary-loai {
  color: #624a82;
  font-weight: 800;
  white-space: nowrap;
}

.gb-patient:not(.open) .summary-sep {
  opacity: 0.35;
  margin: 0 6px;
}

.summary-bc {
  color: #172f36;
  font-weight: 800;
  margin-right: 6px;
}

.summary-ten {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gb-patient:not(.open) .summary-ten {
  color: #426c96;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.gb-summary-fields {
  display: grid;
  width: 100%;
  gap: 4px;
  flex: 0 0 100%;
}

.gb-summary-fields label {
  min-width: 0;
  flex: none;
}

.gb-summary-line {
  margin: 6px 0;
}

.gb-patient:not(.open) .gb-summary-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.gb-patient.open .gb-summary-line {
  display: block;
  position: absolute;
  top: 2px;
  right: 8px;
  margin: 0;
}

.gb-patient-head {
  position: relative;
  min-height: 28px;
  background: #f2f5f5;
  padding: 3px 5px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.gb-patient.open .bn-stt {
  display: none;
  color: #172f36;
}

.gb-patient.open .summary-bc,
.gb-patient.open .summary-loai,
.gb-patient.open .summary-ten,
.gb-patient.open .summary-sep {
  display: none;
}

.gb-patient.open .gb-patient-head {
  min-height: 0;
  padding: 0;
  background: transparent;
}

.gb-patient:not(.open) .gb-remove-patient,
.gb-patient:not(.open) .bn-stt {
  color: transparent;
}

.gb-patient:not(.open) .bn-stt input {
  color: #172f36;
}

.gb-save-summary {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.gb-save-summary tr {
  border-bottom: 1px solid #e3eaeb;
}

.gb-save-summary tr:last-child {
  border-bottom: none;
}

.gb-save-summary td {
  padding: 8px 10px;
  vertical-align: middle;
}

.gb-save-summary .label {
  width: 34%;
  font-weight: 600;
  color: #3c5157;
  white-space: nowrap;
}

.gb-save-summary .value {
  width: 16%;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
  color: #176f82;
}

/* =========================================================
+   EDITOR LAYOUTS
+   ========================================================= */

.gb-multi-sep {
  width: 100%;
  height: 40px;
  margin: 30px 0;
  border-radius: 5px;
  text-align: center;
  color: red;
  font-size: 50px;
  font-weight: 700;
  background: linear-gradient(
        to bottom,
        #9f3d46 0%,
        #9f3d46 25%,

        #ffffff 25%,
        #ffffff 50%,

        #287a8c 50%,
        #287a8c 100%
    ) !important;
}

.gb-multi-sep.custom-footer-wrap {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gb-multi-sep .custom-footer-credit {
  position: relative;
  z-index: 2;
  padding: 2px 10px;
  background: rgba(255,255,255,0.85);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
}

.gb-editor-two-cols {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
}

.gb-editor-two-cols > .gb-editor-col {
  flex: 1 1 50%;
  min-width: 0;
}

.gb-editor-short-two-cols {
  display: flex;
  gap: 12px;
}

.gb-editor-short-two-cols .gb-editor-col {
  flex: 1;
}

/* =========================================================
+   ACTIONS & BUTTONS
+   ========================================================= */

.button {
  background: var(--gb-blue);
  color: #ffffff;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-right: 6px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(18,63,75,.18);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

.button:hover {
  opacity: 1;
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(18,63,75,.24);
}

.gb-action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 24px;
  gap: 12px;
}

.gb-action-row .button {
  padding: 10px 18px;
  font-size: 15px;
  border-radius: 6px;
}

.btn-add {
  background: #d9eef1;
  border: 1px solid #4f929e;
  color: #064f60;
}

.btn-save {
  background: #14724f;
  color: #ffffff;
  font-weight: 600;
}

.gb-action-buttons {
  white-space: normal;
}

.gb-action-buttons .button {
  margin-right: 4px;
  margin-top: 2px;
  margin-bottom: 2px;
  padding: 4px 8px;
  font-size: 13px;
  min-height: auto;
  line-height: 1.2;
  border-radius: 6px;
}

.gb-remove-patient {
  background-color: #b4424c;
  color: #ffffff;
  border: none;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background-color 0.2s ease;
}

.gb-remove-patient:hover {
  background-color: #94343d;
}

.gb-remove-patient:active {
  animation: shake 0.2s linear;
}

.gb-delete-report.button {
  background-color: #b4424c;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.gb-delete-report.button:hover {
  background-color: #94343d;
}

.gb-delete-report.button:active {
  transform: scale(0.96);
}

.gb-btn-new {
  font-weight: 600;
  padding: 6px 14px;
  width: 90%;
  margin: 0;
}

#gb-new-report {
  position: relative;
}

#gb-new-report::after {
  content: "NEW ⚡";
  position: absolute;
  top: -8px;
  right: -10px;
  background: #d2b06c;
  color: #594318;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  pointer-events: none;
}

.gb-cls-toolbar button {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 2px;
  background: #ffffff;
  color: #3c5157;
  font-size: 11px;
  line-height: 20px;
  cursor: pointer;
}

.gb-cls-toolbar button:hover {
  background: #276f82;
}

.gb-remove-cls {
  background: #ad414b !important;
}

.gb-remove-cls:hover {
  background: #913640 !important;
}

.gb-dialog-footer button {
  min-width: 90px;
  height: 38px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: .15s;
}

.gb-dialog-footer button:hover {
  transform: translateY(-1px);
}

/* =========================================================
+   TABLES & FILTERS
+   ========================================================= */

.gb-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.gb-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 999px;
  background: #ffffff;
  color: #455d63;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}

.gb-filter-chip:hover {
  background: #f5f5f5;
  border-color: #8b9b9f;
  color: #ff0000;
}

.gb-filter-chip:focus {
  outline: none;
}

.gb-table th,
.gb-table td {
  border: 1px solid #dce8ea;
  padding: 10px;
  text-align: left;
}

.gb-table th {
  background: linear-gradient(90deg,var(--gb-blue-light),#f4f9fa);
  color: var(--gb-contrast);
}

.gb-table tbody tr {
  transition: background .15s ease;
}

.gb-table tbody tr:nth-child(even) {
  background: #f7fafb;
}

.gb-table tbody tr:hover {
  background: #d9ecee !important;
}

.gb-table tbody tr:hover td {
  color: #172f36;
}

.gb-table tbody td {
  border-bottom: 1px solid #d9e5e7;
}

.gb-table th:last-child,
.gb-table td:last-child {
  white-space: nowrap;
  text-align: center;
  width: 420px;
  min-width: 420px;
}

.gb-table td:last-child {
  padding-left: 12px;
}

.col-updated {
  font-size: 12px;
  color: #287a8c;
  white-space: nowrap;
}

.gb-report-table-box {
  margin: 18px 0;
}

#gb-report-tables{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:18px;
  align-items:start;
}
#gb-report-tables .gb-report-table-box{margin:0;min-width:0;}
#gb-report-tables .gb-report-table-wide{grid-column:1 / -1;}
@media(max-width:900px){
  #gb-report-tables{grid-template-columns:1fr;}
  #gb-report-tables .gb-report-table-box{grid-column:1;}
}

.gb-report-table {
  width: 100%;
  border-collapse: collapse;
}

.gb-report-table th {
  background: #0b647c;
  color: #ffffff;
  padding: 8px;
  border: 1px solid #d4dfe1;
}

.gb-report-table td {
  border: 1px solid #d4dfe1;
  padding: 6px;
}

.gb-report-table td:first-child {
  font-weight: 600;
  width: auto;
}

.gb-report-table-actions{margin:10px 0 0;text-align:left;display:flex;align-items:center;gap:8px;}
.gb-custom-row-label-wrap{display:flex;align-items:center;gap:6px;}
.gb-custom-row-label-wrap .gb-row-label-input{flex:1;min-width:0;}
.gb-remove-editor-table-row{
  flex:0 0 auto;
  width:28px;
  height:28px;
  padding:0;
  border:1px solid #c7d0d4;
  border-radius:50%;
  background:#fff;
  color:#a12626;
  cursor:pointer;
}

/* =========================================================
+   IMAGE UPLOAD & GALLERY
+   ========================================================= */

.gb-cls-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.gb-cls-thumb {
  width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  position: relative;
}

.gb-cls-thumb img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border: 1px solid #d4dfe1;
  border-radius: 6px;
  display: block;
}

.gb-cls-toolbar {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 2px 3px;
  border-radius: 6px;
  background: rgba(0,0,0,.65);
  opacity: 0;
  visibility: hidden;
  transition: .15s;
}

.gb-cls-thumb:hover .gb-cls-toolbar {
  opacity: 1;
  visibility: visible;
}

.gb-image-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.gb-image-title {
  font-size: 15px;
  font-weight: 700;
  color: #84333c;
  margin-bottom: 6px;
}

.gb-upload-cls {
  width: 220px !important;
  margin: 0;
}

.gb-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid #d3dee0;
  border-radius: 6px;
  background: #ffffff;
  color: #176b80;
  font-size: 22px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.gb-image-block {
  border: 1px solid #cddadd;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  margin-bottom: 12px;
}

.gb-upload-btn.uploading {
  pointer-events: none;
  opacity: .7;
  color: transparent;
}

.gb-upload-btn.uploading::after {
  content: "⏳";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
  color: #176b80;
  font-size: 18px;
}

/* =========================================================
+   DIALOGS & SAVE SUMMARY
+   ========================================================= */

#gb-dialog {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,.45);
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: .18s;
}

#gb-dialog.show {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.gb-dialog-box {
  width: 650px;
  max-width: 90vw;
  max-height: 80vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 10px;
  padding: 20px;
  border: 1px solid #8cb5be;
  box-shadow: 0 18px 50px rgba(18,63,75,.30);
}

.gb-dialog-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 15px;
}

.gb-dialog-body {
  white-space: pre-line;
  line-height: 1.6;
  margin-bottom: 20px;
}

.gb-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#gb-dialog .gb-dialog-box {
  border-radius: 14px;
  overflow: hidden;
  animation: gbDialogShow .18s ease;
}

.gb-dialog-ok {
  background: #176f82;
  color: #ffffff;
}

.gb-dialog-cancel {
  background: #f2f5f5;
  border: 1px solid #d4dfe1;
  color: #3c5157;
}

#gb-dialog.success .gb-dialog-ok {
  background: #287456;
}

#gb-dialog.warning .gb-dialog-ok {
  background: #a67528;
}

#gb-dialog.danger .gb-dialog-ok {
  background: #9f3d46;
}

#gb-dialog.info .gb-dialog-ok {
  background: #176f82;
}

/* Functional additions only — existing visual design is preserved. */
.gb-table-scroll {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.gb-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.gb-filters label {
  display: grid;
  gap: 4px;
  min-width: 170px;
}

.gb-filters label:has(#gb-filter-search) {
  flex: 1 1 260px;
}

.gb-filters input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  background: #ffffff;
  color: #173b45;
  box-shadow: none;
  appearance: auto;
}

#gb-filter-from,
#gb-filter-to,
#gb-filter-search {
  height: 38px;
  border-radius: 8px;
}

.gb-patient:not(.open) .bn-stt-input {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  cursor: text;
}

.gb-filters .gb-filter-chip {
  min-height: 36px;
}

.gb-sticky-savebar {
  position: sticky;
  bottom: 0;
  z-index: 100;
  padding: 8px 0;
  background: #ffffff;
  flex-wrap: wrap;
}

.gb-save-status {
  flex: 1 1 180px;
  color: #587078;
  font-size: 12px;
  text-align: right;
}

.gb-save-status[data-state="dirty"],
.gb-save-status[data-state="draft-saving"] { color: #8a5a13; }
.gb-save-status[data-state="draft-saved"],
.gb-save-status[data-state="saved"] { color: #176b4d; }
.gb-save-status[data-state="error"] { color: #a12f3c; }

.gb-patient-head:focus-visible,
#gb-report-app button:focus-visible {
  outline: 2px solid var(--gb-focus);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .gb-list-header {
    grid-template-columns: 1fr;
  }

  .gb-list-action,
  .gb-btn-new {
    width: 100%;
  }

  .gb-filters {
    align-items: stretch;
  }

  .gb-filters label,
  .gb-filters label:has(#gb-filter-search) {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .gb-filters .gb-filter-chip {
    flex: 1 1 100%;
  }

  .gb-table {
    min-width: 760px;
  }

  .gb-save-status {
    order: 3;
    flex-basis: 100%;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  #gb-report-app *,
  #gb-dialog * {
    animation-duration: .01ms;
    animation-iteration-count: 1;
    transition-duration: .01ms;
  }
}

/* =========================================================
   REPORT TYPE COLORS
   Mỗi loại báo cáo có một màu riêng; label dùng cùng màu header.
   ========================================================= */
#gb-report-form #gb-patients .gb-patient[data-loai="vao"] {
  --gb-type-color: #356f73;
  --gb-type-soft: #f1f7f7;
}
#gb-report-form #gb-patients .gb-patient[data-loai="cc_trong_gio"] {
  --gb-type-color: #3f7a62;
  --gb-type-soft: #f2f7f4;
}
#gb-report-form #gb-patients .gb-patient[data-loai="cc_ngoai_gio"] {
  --gb-type-color: #4faf8f;
  --gb-type-soft: #e9f8f2;
}
#gb-report-form #gb-patients .gb-patient[data-loai="chuyen_den"] {
  --gb-type-color: #b56538;
  --gb-type-soft: #fff3ec;
}
#gb-report-form #gb-patients .gb-patient[data-loai="chuyen_hstc_cd"],
#gb-report-form #gb-patients .gb-patient[data-loai="chuyen_hstc_cc"] {
  --gb-type-color: #70558e;
  --gb-type-soft: #f6f3f8;
}
#gb-report-form #gb-patients .gb-patient[data-loai="chuyen_khoa"] {
  --gb-type-color: #5e638f;
  --gb-type-soft: #f3f4f8;
}
#gb-report-form #gb-patients .gb-patient[data-loai="vao_va_chuyen_khoa"] {
  --gb-type-color: #4a697f;
  --gb-type-soft: #f2f5f6;
}
#gb-report-form #gb-patients .gb-patient[data-loai="chuyen_vien"] {
  --gb-type-color: #3d7794;
  --gb-type-soft: #f1f6f8;
}
#gb-report-form #gb-patients .gb-patient[data-loai="theo_doi"] {
  --gb-type-color: #8f7135;
  --gb-type-soft: #faf7ef;
}
#gb-report-form #gb-patients .gb-patient[data-loai="xin_ve"] {
  --gb-type-color: #a64b5b;
  --gb-type-soft: #faf2f4;
}
#gb-report-form #gb-patients .gb-patient[data-loai="vao_va_xin_ve"] {
  --gb-type-color: #6e5d67;
  --gb-type-soft: #f6f4f5;
}
#gb-report-form #gb-patients .gb-patient[data-loai="vao_va_chuyen_vien"] {
  --gb-type-color: #3a737f;
  --gb-type-soft: #f1f6f6;
}
#gb-report-form #gb-patients .gb-patient[data-loai="tu_vong"] {
  --gb-type-color: #66747a;
  --gb-type-soft: #f4f6f6;
}
#gb-report-form #gb-patients .gb-patient[data-loai="vao_va_tu_vong"] {
  --gb-type-color: #755e80;
  --gb-type-soft: #f6f3f7;
}
#gb-report-form #gb-patients .gb-patient[data-loai="loc_mau"] {
  --gb-type-color: #315f73;
  --gb-type-soft: #f0f5f7;
}
#gb-report-form #gb-patients .gb-patient[data-loai="loc_mau_cap"] {
  --gb-type-color: #70465f;
  --gb-type-soft: #f7f1f5;
}
#gb-report-form #gb-patients .gb-patient[data-loai="can_thiep"] {
  --gb-type-color: #8c526f;
  --gb-type-soft: #f8f2f5;
}
#gb-report-form #gb-patients .gb-patient[data-loai="can_thiep_hoi_suc"] {
  --gb-type-color: #2f8f83;
  --gb-type-soft: #eaf7f5;
}
#gb-report-form #gb-patients .gb-patient[data-loai="truc_hanh_chinh"] {
  --gb-type-color: #8a6546;
  --gb-type-soft: #f8f4f0;
}
#gb-report-form #gb-patients .gb-patient[data-loai="khac"] {
  --gb-type-color: #3f5e61;
  --gb-type-soft: #f2f6f6;
}
#gb-report-form #gb-patients .gb-patient[data-loai="ca_cdha"] {
  --gb-type-color: #235f8c;
  --gb-type-soft: #eef6fb;
}

.gb-cdha-editor{width:100%;}
.gb-cdha-editor-section{
  margin:16px 0;
  padding:16px;
  border:1px solid #bfd5e4;
  border-radius:12px;
  background:#fff;
}
.gb-cdha-editor-section h5{
  margin:0 0 14px;
  color:#235f8c;
  font-size:16px;
}
.gb-cdha-info-grid{
  display:grid !important;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.gb-cdha-info-grid label{display:flex;flex-direction:column;gap:6px;}
.gb-cdha-editor-section > label{display:block;margin-top:12px;}
.gb-cdha-editor-section textarea{width:100%;min-height:96px;}
.gb-cdha-image-block{margin:10px 0 12px;}
@media(max-width:760px){.gb-cdha-info-grid{grid-template-columns:1fr;}}

#gb-report-form #gb-patients .gb-patient[data-loai]:not([data-loai=""]) {
  background: var(--gb-type-soft, #ffffff);
  border-color: var(--gb-type-color, var(--gb-line));
}

#gb-report-form #gb-patients .gb-patient[data-loai]:not([data-loai=""]) .gb-patient-head {
  background: var(--gb-type-color, var(--gb-blue));
  border-color: var(--gb-type-color, var(--gb-blue));
  color: #ffffff;
}

#gb-report-form #gb-patients .gb-patient[data-loai]:not([data-loai=""]) :is(
  .label-title,
  .label-ho-ten,
  .label-bao-cao,
  .gb-report-type-label,
  .gb-image-title
) {
  color: var(--gb-type-color, var(--gb-blue));
}

#gb-report-form #gb-patients .gb-patient[data-loai]:not([data-loai=""]) .gb-patient-body label {
  color: var(--gb-type-color, var(--gb-blue));
}

#gb-report-form #gb-patients .gb-patient[data-loai]:not([data-loai=""]):not(.open) :is(
  .summary-bc,
  .summary-loai,
  .summary-ten,
  .bn-stt
) {
  color: #ffffff;
}

/* ===== CA TỪ KHOA KHÁC / THÔNG TIN BỔ SUNG ===== */
#gb-report-form .gb-external-patient{border-style:dashed;}
#gb-report-form .gb-external-patient :is(input,select,textarea):disabled{opacity:.82;cursor:not-allowed;background:#f5f6f7;}
#gb-report-form .gb-external-additional{margin-top:14px;padding-top:12px;border-top:1px dashed #cbd5e1;}
#gb-report-form .gb-additional-editor{display:none;margin-top:12px;}
#gb-report-form .gb-external-additional.open .gb-additional-editor{display:block;}
#gb-report-form .gb-external-additional textarea[name="additional_info"]{min-height:110px;width:100%;}
#gb-report-form .gb-external-patient .summary-bc{font-weight:700;}

/* =========================================================
   IMAGE DROP / PASTE ZONE
   Chọn file + kéo thả + dán ảnh từ clipboard (Ctrl+V)
========================================================= */
#gb-report-form .gb-image-block[tabindex="0"]{
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

#gb-report-form .gb-image-drop-hint{
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  margin:2px 0 8px;
  padding:6px 10px;
  border:1px dashed #b9c9ce;
  border-radius:6px;
  background:#f8fbfc;
  color:#5b6f76;
  font-size:13px;
  line-height:1.35;
  text-align:center;
  cursor:copy;
  user-select:none;
}

#gb-report-form .gb-image-block.gb-image-block-active .gb-image-drop-hint{
  border-color:#5d98a7;
  background:#f0f8fa;
  color:#285f6d;
}

#gb-report-form .gb-image-block.gb-drag-over{
  border-color:#29809a;
  box-shadow:0 0 0 3px rgba(41,128,154,.14);
  background:#f3fbfd;
}

#gb-report-form .gb-image-block.gb-drag-over .gb-image-drop-hint{
  border-color:#29809a;
  background:#e9f7fa;
  color:#155f73;
  font-weight:700;
}

#gb-report-form .gb-image-block.gb-drag-over .gb-image-drop-hint::before{
  content:"⬇ ";
}

#gb-report-form .gb-image-block.gb-image-uploading .gb-image-drop-hint{
  opacity:.72;
}

/* Ca khoa khác: ảnh nguồn chỉ đọc, không gợi ý kéo/dán. */
#gb-report-form .gb-external-patient .gb-image-block:not(.gb-additional-image-block) .gb-image-drop-hint{
  display:none;
}

@media (max-width: 700px){
  #gb-report-form .gb-image-drop-hint{
    font-size:12px;
    min-height:32px;
    padding:6px 8px;
  }
}
