:root {
  --primary-color: #0b6b3a;
  --primary-hover: #08502b;
  --primary-light: #e8f5e9;
  --secondary-color: #0284c7;
  --warning-color: #d97706;
  --warning-light: #fef3c7;
  --danger-color: #dc2626;
  --danger-light: #fee2e2;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

/* ================= HEADER ================= */
.app-header {
  background: #ffffff;
  border-bottom: 2px solid var(--primary-color);
  box-shadow: var(--shadow-sm);
  padding: 12px 24px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.brand-text h1 {
  font-size: 19px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.brand-text p {
  font-size: 13px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ================= BUTTONS ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
}

.btn-warning {
  background-color: var(--warning-color);
  color: #ffffff;
}
.btn-warning:hover {
  background-color: #b45309;
}

.btn-danger {
  background-color: var(--danger-color);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #b91c1c;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ================= MAIN CONTAINER ================= */
.main-wrapper {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================= TOOLBAR & SEARCH ================= */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 260px;
  max-width: 420px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--primary-color);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

/* ================= TABLE ================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tr:hover {
  background-color: #f8fafc;
}

.badge-stt {
  display: inline-block;
  padding: 3px 8px;
  font-weight: 700;
  font-size: 13px;
  color: var(--warning-color);
  background: var(--warning-light);
  border-radius: 4px;
}

.badge-active {
  display: inline-block;
  padding: 3px 8px;
  font-weight: 600;
  font-size: 12px;
  color: var(--primary-color);
  background: var(--primary-light);
  border-radius: 4px;
}

/* ================= TABS ================= */
.tab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* ================= MODAL ================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-color);
}

/* ================= PRINT VIEW (A3 DỌC - TIẾT KIỆM GIẤY) ================= */
.print-only {
  display: none;
}

@media print {
  @page {
    size: A3 portrait;
    margin: 12mm 10mm 15mm 10mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt !important;
  }

  /* Ẩn các thành phần không cần in */
  .no-print,
  .app-header,
  .toolbar,
  .btn,
  .tab-nav,
  .modal-overlay,
  footer {
    display: none !important;
  }

  .main-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card-header {
    display: none !important;
  }

  /* Tiêu đề in văn bản chuẩn y tế */
  .print-only {
    display: block !important;
  }

  .print-header-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 12px;
    line-height: 1.35;
  }

  .print-header-left {
    text-align: left;
    font-size: 10pt;
  }

  .print-header-right {
    text-align: center;
    font-size: 10pt;
  }

  .print-title {
    text-align: center;
    margin: 8px 0 4px 0;
  }

  .print-title h2 {
    font-size: 16pt;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .print-subtitle {
    text-align: center;
    font-style: italic;
    font-size: 9.5pt;
    margin-bottom: 12px;
  }

  /* BỐ CỤC ĐA CỘT BẢNG SONG SONG (A3 TIẾT KIỆM GIẤY) */
  .print-columns-wrapper {
    display: flex !important;
    gap: 8mm !important;
    width: 100% !important;
    align-items: flex-start !important;
  }

  .print-col {
    flex: 1 !important;
  }

  .print-sub-table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 9pt !important;
  }

  .print-sub-table th,
  .print-sub-table td {
    border: 1px solid #333 !important;
    padding: 4px 5px !important;
    color: #000 !important;
    line-height: 1.25 !important;
  }

  .print-sub-table th {
    background-color: #f2f2f2 !important;
    font-weight: bold !important;
    text-align: center !important;
  }

  /* Chữ ký cuối trang */
  .print-signatures {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-top: 25px;
    text-align: center;
    font-size: 10pt;
    page-break-inside: avoid;
  }

  .print-sign-box {
    padding: 0 10px;
  }

  .print-sign-space {
    height: 55px;
  }
}
