.units-content {
  padding-top: 26px;
}

.units-top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.units-top h1,
.units-top p,
.units-top small {
  margin: 0;
}

.units-top h1 {
  font-size: 30px;
}

.units-top p {
  margin-top: 8px;
  font-weight: 800;
}

.units-top span,
.units-top small {
  color: var(--muted);
}

.units-top small {
  display: block;
  margin-top: 8px;
  font-size: 14px;
}

.unit-actions {
  display: flex;
  gap: 14px;
}

.unit-actions button,
.unit-filter button,
.unit-table td button,
.unit-footer button,
.unit-footer select,
.unit-detail button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-actions button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  height: 44px;
  padding: 0 18px;
}

.unit-actions .primary,
.unit-detail footer .primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--green-bright), var(--green));
}

.unit-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.unit-stats article {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 18px;
  align-items: center;
  min-height: 128px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(23, 44, 39, 0.05);
}

.unit-stats article > span {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 12px;
}

.unit-stats p,
.unit-stats small {
  margin: 0;
}

.unit-stats p {
  color: #4f5e59;
  font-weight: 800;
}

.unit-stats strong {
  display: block;
  margin: 10px 0 12px;
  font-size: 26px;
}

.unit-stats small {
  font-weight: 800;
}

.unit-stats .up {
  color: var(--green);
}

.unit-stats .down {
  color: #e34b5b;
}

/* Filter Bar - Single Row */
.unit-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.unit-filter label {
  flex: 1;
  min-width: 170px;
}

.unit-filter label:first-child {
  flex: 2;
  min-width: 240px;
}

.unit-filter label > span {
  position: relative;
  display: block;
}

.unit-filter input,
.unit-filter select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  outline: 0;
  padding: 0 14px;
  font-family: inherit;
  font-size: 13.5px;
}

.unit-filter input {
  padding: 0 42px 0 14px;
}

.unit-filter label > span i {
  position: absolute;
  right: 12px;
  top: 11px;
  color: var(--muted);
}

.unit-filter button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.unit-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  align-items: start;
}

.unit-table,
.unit-detail {
  padding: 0;
  overflow: hidden;
}

.unit-table h2 {
  height: 62px;
  margin: 0;
  padding: 20px 22px 0;
  font-size: 18px;
}

.table-scroll {
  overflow-x: auto;
}

.unit-table table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
}

.unit-table th {
  background: #fbfcfc;
  text-align: left;
  font-size: 12.5px;
  color: #64748b;
  font-weight: 800;
  white-space: nowrap;
}

.unit-table td {
  padding: 16px 20px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.unit-table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.unit-table tbody tr:hover {
  background: #f8fafc;
}

.unit-table tbody tr.selected-row {
  background: #ecfdf5 !important;
  border-left: 3px solid var(--green);
}

.unit-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  white-space: nowrap;
}

.unit-badge-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* Type Badges */
.type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
  white-space: nowrap;
}

.type-unit {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.type-weight {
  background: #f0fdf4;
  color: #059669;
  border: 1px solid #bbf7d0;
}

.type-volume {
  background: #fdf4ff;
  color: #a855f7;
  border: 1px solid #f0abfc;
}

.type-package {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.active-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  white-space: nowrap;
}

.inactive-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  font-style: normal;
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  white-space: nowrap;
}

.btn-status-toggle {
  cursor: pointer;
  border: none;
}

.unit-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: #fff;
  white-space: nowrap;
}

.unit-footer p {
  margin: 0;
  font-size: 13.5px;
  color: #64748b;
  font-weight: 700;
}

.unit-footer div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination-buttons {
  display: flex;
  gap: 4px;
}

.pagination-buttons button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  border-radius: 6px;
}

.pagination-buttons button.active {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

/* Detail Side Panel */
.unit-detail {
  padding: 22px;
}

.unit-detail header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.unit-detail h2 {
  margin: 0;
  font-size: 18px;
}

.unit-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.unit-hero .unit-badge-icon {
  width: 56px;
  height: 56px;
  font-size: 26px;
  border-radius: 14px;
}

.unit-hero h3 {
  margin: 0 0 4px;
  font-size: 17px;
  color: #0f172a;
}

.unit-hero p {
  margin: 2px 0;
  font-size: 12.5px;
  color: #64748b;
  white-space: nowrap;
}

.unit-info {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.unit-info h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.unit-info dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

.unit-info dt {
  color: #64748b;
  font-weight: 700;
  white-space: nowrap;
}

.unit-info dd {
  margin: 0;
  font-weight: 800;
  color: #1e293b;
  white-space: nowrap;
}

.sample-products {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.sample-products h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
}

.sample-product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 13px;
  white-space: nowrap;
}

.sample-product-item b {
  color: #0f172a;
}

.sample-product-item small {
  color: #94a3b8;
  display: block;
}

.sample-product-item em {
  font-style: normal;
  font-weight: 800;
  color: #0f9f63;
  padding: 2px 8px;
  background: #f0fdf4;
  border-radius: 6px;
  font-size: 11.5px;
}

.unit-detail footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.unit-detail footer button {
  display: inline-flex;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.unit-detail footer .danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

.unit-detail footer .danger:hover {
  background: #dc2626;
  color: #fff;
}

/* ============================================================
   MODAL DIALOG
============================================================ */
.admin-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(4, 15, 12, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.admin-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.admin-modal-card {
  width: 100%;
  max-width: 580px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.admin-modal-backdrop.is-open .admin-modal-card {
  transform: translateY(0);
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.admin-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}

.admin-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
}

.admin-modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.admin-modal-form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.admin-modal-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-modal-form label span {
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
}

.admin-modal-form input,
.admin-modal-form select,
.admin-modal-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 13.5px;
  color: #0f172a;
  outline: none;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.admin-modal-form input:focus,
.admin-modal-form select:focus,
.admin-modal-form textarea:focus {
  border-color: #008a4b;
}

.admin-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

.admin-modal-actions .btn-cancel {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-weight: 700;
  cursor: pointer;
}

.admin-modal-actions .btn-save {
  padding: 10px 24px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #00b368, #008a4b);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 138, 75, 0.3);
}

@media (max-width: 1200px) {
  .unit-main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .unit-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .unit-stats,
  .form-grid-2,
  .unit-filter label,
  .unit-filter label:first-child,
  .unit-detail footer {
    grid-template-columns: 1fr;
    min-width: 100%;
  }
  .unit-top {
    flex-direction: column;
    gap: 16px;
  }
  .unit-actions {
    width: 100%;
    flex-direction: column;
  }
  .unit-footer {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}
