/* Giao diện phẳng: menu xanh đậm, thẻ trắng viền mảnh, màu chỉ dùng cho trạng thái.
   Nạp sau cùng trong index.html để ghi đè glass-theme.css và ui-system.css. */
:root {
  --c-canvas: #edf3f1;
  --c-surface: #ffffff;
  --c-subtle: #e3efec;
  --c-line: #d9e4e0;
  --c-ink: #16211f;
  --c-ink-2: #5b6966;
  --c-brand: #087f70;
  --c-brand-bright: #14a08d;
  --c-side: #0b3b36;
  --c-side-line: #1b524b;
  --c-side-text: #bfd8d3;
  --c-side-muted: #7faaa3;
  --c-danger: #b93838;
  --c-danger-soft: #fdecec;
  --c-warning: #9a6200;
  --c-warning-soft: #fff4db;
  --c-accent: #f2a33a;
}

/* 1. Nền và các lớp trang trí --------------------------------------- */
html body {
  background: var(--c-canvas);
  color: var(--c-ink);
}

.ambient-bubbles,
body::before,
body::after,
.app-shell::before,
.app-shell::after,
#workspace::before,
#workspace::after {
  display: none !important;
}

/* 2. Menu bên trái -------------------------------------------------- */
html body #sidebar {
  background: var(--c-side);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  color: var(--c-side-text);
}

#sidebar .brand {
  color: #fff;
}

#sidebar .brand span:not(.brand-mark) {
  color: #fff;
}

#sidebar .brand-mark,
.login-story .brand-mark {
  background: var(--c-brand-bright);
  color: #fff;
  box-shadow: none;
}

#navigation .nav-group {
  margin: 18px 12px 6px;
  text-transform: uppercase;
  color: var(--c-side-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

html body #navigation a {
  min-height: 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--c-side-text);
  font-weight: 400;
  transform: none;
}

#navigation a > span[aria-hidden='true'] {
  display: none;
}

html body #navigation a:hover {
  background: var(--c-side-line);
  color: #fff;
}

html body #navigation a.active {
  background: var(--c-brand-bright);
  color: #fff;
  font-weight: 600;
}

html body #sidebar .profile {
  border: 0;
  border-radius: 10px;
  background: var(--c-side-line);
  box-shadow: none;
  color: #fff;
}

#sidebar .profile small {
  color: var(--c-side-muted);
}

#sidebar .profile .avatar {
  background: var(--c-brand-bright);
  color: #fff;
}

/* 3. Thanh trên và tiêu đề trang ------------------------------------ */
html body .app-shell > header {
  border: 0;
  border-bottom: 1px solid var(--c-line);
  border-radius: 0;
  background: var(--c-surface);
  box-shadow: none;
  backdrop-filter: none;
}

html body .page-heading h1 {
  background: none;
  color: var(--c-ink);
  -webkit-text-fill-color: currentColor;
  font-weight: 600;
}

/* 4. Thẻ, bảng và ô nhập -------------------------------------------- */
html body .panel,
html body .toolbar,
html body .stat,
html body .empty,
html body dialog {
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  box-shadow: none;
  backdrop-filter: none;
}

html body .toolbar {
  padding: 0;
  border: 0;
  background: transparent;
}

html body .panel {
  border-radius: 12px;
}

html body table th {
  background: var(--c-subtle);
  color: var(--c-brand);
  font-weight: 600;
}

html body table td {
  border-color: var(--c-line);
}

html body button,
html body select,
html body input,
html body textarea {
  box-shadow: none;
}

html body button:not(.primary):not(.link):not(.icon-button):not(.profile) {
  border: 1px solid var(--c-line);
  background: var(--c-surface);
}

html body button.primary {
  border: 1px solid var(--c-brand);
  background: var(--c-brand);
  color: #fff;
  box-shadow: none;
}

html body button.primary:hover {
  background: #056657;
  transform: none;
  box-shadow: none;
}

/* 5. Số liệu tổng quan ---------------------------------------------- */
html body .stats .stat {
  border-radius: 12px;
  transform: none;
}

html body .stats .stat:first-child {
  border-color: var(--c-brand);
  background: var(--c-brand);
  color: #fff;
}

html body .stats .stat:first-child small,
html body .stats .stat:first-child strong,
html body .stats .stat:first-child em {
  color: #fff;
}

html body .stats .stat.warn {
  border-color: transparent;
  background: var(--c-warning-soft);
}

html body .stats .stat.warn small,
html body .stats .stat.warn strong,
html body .stats .stat.warn em {
  color: var(--c-warning);
}

/* 6. Danh mục thuốc: thẻ thường phẳng; màu đỏ/vàng trạng thái giữ theo stock-view.css */
html body .medicine-master-card {
  border-width: 1px;
  border-radius: 12px;
  box-shadow: none;
}

html body .medicine-master-card:not(.stock-empty):not(.stock-low) {
  border-color: var(--c-line);
  background: var(--c-surface);
}

/* 6b. Nút, nhãn và dải việc cần xử lý -------------------------------- */
html body button,
html body a.primary,
html body select,
html body input,
html body textarea {
  border-radius: 8px;
  transform: none;
}

html body a.primary {
  border-radius: 8px !important;
  border: 1px solid var(--c-brand);
  background: var(--c-brand);
  color: #fff;
  box-shadow: none;
}

html body .action-strip {
  border: 0;
  border-radius: 12px;
  background: var(--c-warning-soft);
  box-shadow: none;
  backdrop-filter: none;
}

html body .action-strip h2,
html body .action-strip p {
  color: var(--c-warning);
}

html body .stats .stat strong {
  font-weight: 600;
}

html body .panel-header h3,
html body .page-heading h1,
html body .stats .stat small {
  font-weight: 600;
}

html body .timeline-item,
html body .panel .panel,
html body .panel article:not(.medicine-master-card) {
  box-shadow: none;
}

/* 7. Đăng nhập ------------------------------------------------------ */
html body .login-shell {
  background: var(--c-canvas);
}

html body .login-story {
  background: var(--c-side);
  color: #fff;
}

.login-story .brand,
.login-story .brand span:not(.brand-mark),
.login-story h1 {
  background: none;
  color: #fff;
  -webkit-text-fill-color: currentColor;
}

.login-story .eyebrow {
  color: var(--c-accent);
}

.login-story p,
.login-story small {
  color: var(--c-side-text);
}

.login-story .story-badges span {
  border: 0;
  background: var(--c-side-line);
  color: #fff;
}

html body .login-panel {
  background: var(--c-canvas);
}

html body #login-form {
  border: 1px solid var(--c-line);
  border-radius: 16px;
  background: var(--c-surface);
  box-shadow: none;
  backdrop-filter: none;
}

/* 8. Chân trang ----------------------------------------------------- */
html body .app-shell > footer {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--c-ink-2);
}

/* 9. Thẻ nhà kho, đơn hàng và các thẻ con: bỏ bóng, bo góc vừa ------- */
html body #main article:not(.medicine-master-card),
html body #main section:not(.action-strip) {
  box-shadow: none;
  backdrop-filter: none;
}

html body #main article:not(.medicine-master-card) {
  border: 1px solid var(--c-line);
  border-radius: 12px;
}

/* 10. Danh mục dạng bảng và bộ lọc nhanh ---------------------------- */
.catalog-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.catalog-tools .toolbar {
  flex: 1 1 360px;
  margin: 0;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

html body .filter-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 0;
  padding: 6px 12px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-ink-2);
  font-size: 13px;
  font-weight: 500;
}

html body .filter-chips .chip small {
  color: #8a9693;
  font-size: 12px;
}

html body .filter-chips .chip.active {
  border-color: transparent;
  background: #e6f4f1;
  color: var(--c-brand);
  font-weight: 600;
}

html body .filter-chips .chip.active small {
  color: var(--c-brand);
}

.catalog-table .catalog-name .link {
  font-weight: 600;
  text-align: left;
}

.catalog-table .catalog-name small {
  display: block;
  margin-top: 2px;
  color: #8a9693;
  font-size: 12px;
}

html body .row-actions {
  white-space: nowrap;
  text-align: right;
}

html body .row-actions .link + .link {
  margin-left: 14px;
}

html body .row-actions .muted-link {
  color: var(--c-ink-2);
}

html body .delivery-badge {
  padding: 0;
  border: 0;
  background: none;
}

html body .badge {
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font-weight: 500;
}

/* 11. Font ---------------------------------------------------------- */
html body,
html body button,
html body input,
html body select,
html body textarea {
  font-family: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif;
}

html body .catalog-table td,
html body .catalog-table th {
  padding-right: 12px;
}

html body .catalog-table td:nth-child(2) {
  max-width: 230px;
}

html body .catalog-table td:nth-child(3) {
  max-width: 200px;
}

html body .catalog-table .badge,
html body .receipt-table .badge {
  white-space: nowrap;
}

html body .badge {
  white-space: nowrap;
}

html body #navigation a {
  line-height: 1.45;
  margin-bottom: 2px;
}

/* 12. Tiêu đề cột, hành động trong bảng ----------------------------- */
html body table th {
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

html body .table-wrap td:last-child button:not(.primary):not(.link):not(.icon-button):not(.profile) {
  min-height: 0;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--c-brand);
  font-weight: 500;
}

html body .table-wrap td:last-child button.danger:not(.primary):not(.link):not(.icon-button):not(.profile) {
  color: var(--c-danger);
}

html body .table-wrap td:last-child button:hover {
  background: var(--c-subtle);
}

/* 13. Tồn kho: tab dạng segment, đơn vị bên phải -------------------- */
.stock-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

html body .stock-tabs {
  display: inline-flex;
  flex: 0 0 auto;
  width: auto;
  gap: 2px;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: var(--c-subtle);
  box-shadow: none;
}

html body .stock-tabs a {
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  box-shadow: none;
  color: var(--c-ink-2);
  font-weight: 400;
}

html body .stock-tabs a.active {
  background: var(--c-surface);
  color: var(--c-brand);
  font-weight: 600;
}

.unit-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--c-ink-2);
  font-size: 13px;
}

/* 14. Tổng quan: dải việc cần xử lý gọn một dòng -------------------- */
html body .action-strip {
  padding: 12px 16px;
}

html body .action-strip > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}

html body .action-strip h2 {
  margin: 0;
  font-size: 15px;
}

html body .action-strip p {
  margin: 0;
  font-size: 14px;
}

html body .action-strip .badge {
  display: none;
}

html body .action-strip a.primary {
  min-height: 0;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--c-warning);
  font-weight: 600;
}

/* 15. Vị trí lưu trữ: thẻ phẳng, "Chưa phân nhà" màu vàng ------------ */
html body .house-art,
html body .unassigned-symbol {
  display: none;
}

html body .house-card {
  text-align: left;
}

html body .house-card h2 {
  font-size: 16px;
}

html body .house-card.unassigned-house {
  border-color: transparent;
  background: var(--c-warning-soft);
}

html body .house-card.unassigned-house :is(h2, p, a, span, button) {
  color: var(--c-warning);
}

/* 16. Theo dõi đơn hàng --------------------------------------------- */
html body .order-tracking-header {
  background: var(--c-subtle);
}

#main > .filter-chips {
  margin: 12px 0 4px;
}

/* 17. Điện thoại ---------------------------------------------------- */
@media (max-width: 760px) {
  html body #sidebar {
    border-radius: 0;
  }

  .catalog-tools .toolbar {
    flex-basis: 100%;
  }

  .filter-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  html body .filter-chips .chip {
    flex: 0 0 auto;
  }

  .stock-bar {
    align-items: stretch;
  }
}

html body .house-card button.house-open:not(.primary):not(.link):not(.icon-button):not(.profile) {
  background: transparent;
  box-shadow: none;
}

/* Thẻ "Hết hàng" (thứ tư) dùng đỏ nhạt như Figma; "Sắp hết hạn" giữ vàng. */
html body .stats .stat.warn:nth-child(4) {
  background: var(--c-danger-soft);
}

html body .stats .stat.warn:nth-child(4) :is(small, strong, em) {
  color: var(--c-danger);
}

/* 18. Đăng nhập: nền xanh phẳng, bỏ khung kính và bong bóng ---------- */
html body .login-story > div {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

html body .login-story::before,
html body .login-story::after,
html body .login-shell::before,
html body .login-shell::after {
  display: none;
}

html body .login-story h1 {
  font-size: clamp(30px, 3.2vw, 44px);
  font-weight: 600;
  line-height: 1.18;
}

html body .login-story .story-badges span {
  border-radius: 8px;
}

/* 19. Phiếu nhập / xuất: hộp thoại gọn ------------------------------ */
#dialog:has([data-import-cart], [data-export-cart]) {
  width: min(720px, calc(100% - 24px));
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--c-surface);
}

#dialog:has([data-import-cart], [data-export-cart]) .dialog-header {
  margin-bottom: 4px;
}

#dialog:has([data-import-cart], [data-export-cart]) .dialog-header .eyebrow {
  display: none;
}

#dialog:has([data-import-cart], [data-export-cart]) #dialog-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

:is([data-import-cart], [data-export-cart]) .stock-cart-line {
  margin: 10px 0;
  border-color: var(--c-line);
  border-radius: 10px;
  background: var(--c-surface);
}

:is([data-import-cart], [data-export-cart]) .stock-cart-line > summary {
  min-height: 0;
  padding: 10px 12px;
  background: var(--c-subtle);
  border-radius: 10px;
}

:is([data-import-cart], [data-export-cart]) .stock-cart-line[open] > summary {
  border-radius: 10px 10px 0 0;
}

:is([data-import-cart], [data-export-cart]) .stock-cart-line > summary > b {
  color: var(--c-brand);
  font-size: 13px;
  font-weight: 600;
}

:is([data-import-cart], [data-export-cart]) .stock-cart-body {
  padding: 12px;
  border-top: 1px solid var(--c-line);
}

:is([data-import-cart], [data-export-cart]) .form-grid {
  gap: 10px 12px;
}

/* Nhãn cố định phía trên, ô nhập trắng viền mảnh cao 40px */
html body :is([data-import-cart], [data-export-cart]) label.floating-field {
  padding-top: 20px;
  margin: 0;
}

html body :is([data-import-cart], [data-export-cart]) label.floating-field > .floating-caption {
  top: 0;
  left: 0;
  color: var(--c-ink-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  transform: none;
  transition: none;
}

html body :is([data-import-cart], [data-export-cart]) label.floating-field > .floating-surface {
  display: none;
}

html body :is([data-import-cart], [data-export-cart]) label.floating-field > :is(input, select),
html body :is([data-import-cart], [data-export-cart]) label:not(.floating-field) > :is(input, select, textarea) {
  height: 40px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  background: var(--c-surface);
  box-shadow: none;
  font-size: 14px;
  font-weight: 500;
}

html body :is([data-import-cart], [data-export-cart]) label.floating-field > :is(input, select):focus {
  border-color: var(--c-brand);
  outline: 2px solid rgba(8, 127, 112, 0.15);
  outline-offset: 0;
}

html body :is([data-import-cart], [data-export-cart]) button.select-search-toggle:not(.primary) {
  height: 40px;
  min-height: 40px;
  padding: 0 12px;
  align-self: end;
  font-size: 13px;
  font-weight: 500;
}

:is([data-import-cart], [data-export-cart]) p[data-import-manufacturer]:empty {
  display: none;
}

:is([data-import-cart], [data-export-cart]) .label-scan-actions,
:is([data-import-cart], [data-export-cart]) .export-scan-actions {
  display: flex;
  gap: 8px;
  margin: 0;
}

html body :is([data-import-cart], [data-export-cart]) :is(.label-scan-actions, .export-scan-actions, .form-actions) button:not(.primary) {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}

:is([data-import-cart], [data-export-cart]) fieldset.mixed-quantity {
  margin: 0;
  padding: 8px 12px 10px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
}

:is([data-import-cart], [data-export-cart]) fieldset.mixed-quantity > legend {
  padding: 0 4px;
  color: var(--c-ink);
  font-size: 13px;
  font-weight: 600;
}

:is([data-import-cart], [data-export-cart]) .quantity-entry {
  gap: 10px;
}

:is([data-import-cart], [data-export-cart]) #conversion-preview,
:is([data-import-cart], [data-export-cart]) #conversion-rules {
  margin: 6px 0 0;
  font-size: 13px;
}

#dialog:has([data-import-cart], [data-export-cart]) .form-actions:last-child {
  margin-top: 14px;
}

html body [data-export-cart] button[data-export-header-done]:not(.primary) {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
