/**
 * ERP UI — shadcn-inspired tokens & components (no Tailwind).
 * Single source for colors, radius, typography.
 */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --sidebar-width: 17rem;
  --sidebar-width-collapsed: 4.5rem;
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 53.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 53.3%;
  --radius: 0.5rem;
  --radius-sm: calc(var(--radius) - 2px);
  --sidebar: 224 55% 8%;
  --sidebar-foreground: 0 0% 100%;
  --sidebar-muted: 215 25% 72%;
  --sidebar-accent: 221.2 83.2% 53.3%;
  --success-bg: 142.1 76.2% 94.3%;
  --success-fg: 142.1 70.6% 25.3%;
  --success-border: 142.1 45% 82%;
  --warning-bg: 48 96% 89%;
  --warning-fg: 32 95% 30%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
}

a {
  color: inherit;
  text-decoration: none;
}

a.link,
.link {
  color: hsl(var(--primary));
  text-decoration: underline;
  text-underline-offset: 2px;
}

a.link:hover,
.link:hover {
  opacity: 0.9;
}

/* ——— App layout: sidebar + full-width content ——— */
.ui-app {
  display: flex;
  min-height: 100vh;
  width: 100%;
  align-items: stretch;
}

.ui-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, hsl(224 58% 10%) 0%, hsl(var(--sidebar)) 100%);
  color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(0 0% 100% / 0.12);
  box-shadow: 4px 0 24px hsl(224 55% 4% / 0.35);
  transition: width 0.22s ease;
  overflow: hidden;
}

.ui-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  padding: 0.85rem 0.75rem 0.5rem;
  flex-shrink: 0;
}

.ui-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border: 1px solid hsl(0 0% 100% / 0.22);
  border-radius: var(--radius-sm);
  background: hsl(0 0% 100% / 0.1);
  color: hsl(var(--sidebar-foreground));
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.ui-sidebar-toggle:hover {
  background: hsl(0 0% 100% / 0.18);
  border-color: hsl(0 0% 100% / 0.35);
}

.ui-sidebar-toggle:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

@media (min-width: 768px) {
  .ui-sidebar-toggle {
    display: inline-flex;
  }
}

.ui-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.05rem;
  color: hsl(var(--sidebar-foreground));
  transition: background 0.15s;
}

.ui-sidebar-logo:hover {
  background: hsl(0 0% 100% / 0.12);
}

.ui-sidebar-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--sidebar-accent) / 0.35);
  color: hsl(var(--sidebar-foreground));
  font-size: 0.95rem;
  box-shadow: 0 0 0 1px hsl(var(--sidebar-accent) / 0.4);
}

.ui-sidebar-logo-text {
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px hsl(224 55% 4% / 0.4);
}

.ui-sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 1rem;
  overflow-y: auto;
}

.ui-sidebar-group {
  margin-bottom: 0.35rem;
}

.ui-sidebar-group-label {
  margin: 0.65rem 0.35rem 0.35rem;
  padding: 0 0.4rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: hsl(var(--sidebar-muted));
}

.ui-sidebar-group:first-child .ui-sidebar-group-label {
  margin-top: 0.25rem;
}

.ui-sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ui-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--sidebar-foreground) / 0.92);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.ui-sidebar-link-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.15s ease;
}

.ui-sidebar-link:hover {
  background: hsl(0 0% 100% / 0.14);
  color: hsl(var(--sidebar-foreground));
}

.ui-sidebar-link.is-active {
  background: hsl(var(--sidebar-accent) / 0.28);
  color: hsl(var(--sidebar-foreground));
  font-weight: 600;
  box-shadow: inset 3px 0 0 hsl(var(--sidebar-accent));
}

.ui-sidebar-link.is-active .ui-sidebar-link-icon {
  color: hsl(210 100% 85%);
  opacity: 1;
}

.ui-sidebar-link-icon {
  width: 1.25rem;
  text-align: center;
  color: hsl(210 80% 88%);
  opacity: 1;
  flex-shrink: 0;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

/* Sidebar thu gọn (desktop) */
@media (min-width: 768px) {
  html.is-sidebar-collapsed .ui-sidebar {
    width: var(--sidebar-width-collapsed);
  }

  html.is-sidebar-collapsed .ui-sidebar-brand {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.35rem 0.5rem;
  }

  html.is-sidebar-collapsed .ui-sidebar-logo {
    justify-content: center;
    padding: 0.35rem;
    width: 100%;
  }

  html.is-sidebar-collapsed .ui-sidebar-logo-text,
  html.is-sidebar-collapsed .ui-sidebar-group-label,
  html.is-sidebar-collapsed .ui-sidebar-link-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    flex: 0 0 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
  }

  html.is-sidebar-collapsed .ui-sidebar-nav {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  html.is-sidebar-collapsed .ui-sidebar-link {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    gap: 0;
  }
}

.ui-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  background: hsl(var(--muted));
}

.ui-main {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

@media (max-width: 767px) {
  :root {
    --sidebar-width: 100%;
  }

  .ui-app {
    flex-direction: column;
  }

  .ui-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid hsl(0 0% 100% / 0.1);
  }

  .ui-sidebar-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 0.5rem;
  }

  .ui-sidebar-group {
    min-width: 0;
  }
}

/* ——— Workspace top bar (user menu) ——— */
.ui-workspace-header {
  flex-shrink: 0;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky;
  top: 0;
  z-index: 50;
}

.ui-workspace-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.45rem clamp(1rem, 2vw, 1.5rem);
}

.ui-workspace-header-left {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ui-workspace-bar-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  line-height: 1.3;
}

.ui-workspace-header-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ui-user-menu {
  position: relative;
}

.ui-user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: min(100%, 16rem);
  padding: 0.35rem 0.5rem 0.35rem 0.35rem;
  margin: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}

.ui-user-menu-trigger:hover {
  background: hsl(var(--muted));
}

.ui-user-menu-trigger:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.ui-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.ui-user-avatar--img {
  padding: 0;
  overflow: hidden;
  background: hsl(var(--muted));
}

.ui-user-avatar--img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ui-user-menu-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
  flex: 1;
}

.ui-user-menu-name {
  font-size: 0.8125rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-user-menu-role {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ui-user-menu-chevron {
  flex-shrink: 0;
  font-size: 0.65rem;
  opacity: 0.55;
  transition: transform 0.15s ease;
}

.ui-user-menu.is-open .ui-user-menu-chevron {
  transform: rotate(180deg);
}

.ui-user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 11.5rem;
  padding: 0.35rem;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow:
    0 10px 38px -10px rgb(0 0 0 / 0.25),
    0 10px 20px -15px rgb(0 0 0 / 0.15);
  z-index: 60;
}

.ui-user-menu-panel[hidden] {
  display: none !important;
}

.ui-user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: inherit;
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s;
  box-sizing: border-box;
}

.ui-user-menu-item:hover {
  background: hsl(var(--accent));
}

.ui-user-menu-item:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 0;
}

.ui-user-menu-item i {
  width: 1rem;
  flex-shrink: 0;
  text-align: center;
  font-style: normal;
  opacity: 0.85;
}

.ui-user-menu-item--danger {
  color: hsl(var(--destructive));
}

.ui-user-menu-item--danger:hover {
  background: hsl(var(--destructive) / 0.08);
}

@media (max-width: 640px) {
  .ui-user-menu-text {
    display: none;
  }

  .ui-user-menu-trigger {
    max-width: none;
    padding: 0.35rem;
  }
}

/* ——— Page ——— */
.ui-page {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1.5rem clamp(1rem, 2vw, 2rem) 2.5rem;
}

.ui-page-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
  .ui-page-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.ui-page-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

.ui-page-desc {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.ui-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover {
  background: hsl(var(--primary) / 0.92);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border-color: hsl(var(--border));
}

.btn-secondary:hover {
  background: hsl(var(--accent));
}

.btn-outline {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}

.btn-outline:hover {
  background: hsl(var(--accent));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover {
  background: hsl(var(--accent));
}

.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover {
  opacity: 0.92;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: none;
  cursor: pointer;
}

.btn-icon:hover {
  background: hsl(var(--accent));
  color: hsl(var(--foreground));
}

.btn-group {
  display: inline-flex;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.05);
  overflow: hidden;
}

.btn-group .btn {
  border-radius: 0;
  border-right-width: 0;
}

.btn-block {
  width: 100%;
}

/* ——— Card ——— */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-content {
  padding: 1.25rem;
}

/* ——— Form ——— */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring) / 0.35);
}

.textarea {
  min-height: 6rem;
  resize: vertical;
}

.field-hint {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Tooltip cạnh label (thay field-hint dưới input) */
.label--with-tooltip,
.product-form-section-title--with-tooltip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.ui-tooltip-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  line-height: 1;
}

.ui-tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  border: none;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: help;
  border-radius: 50%;
  font-size: 0.875rem;
}

.ui-tooltip-trigger:hover,
.ui-tooltip-trigger:focus-visible {
  color: hsl(var(--primary));
  outline: none;
}

.ui-tooltip {
  position: absolute;
  z-index: 1300;
  left: 50%;
  bottom: calc(100% + 0.4rem);
  transform: translateX(-50%);
  width: max-content;
  max-width: 14.5rem;
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md, 0.375rem);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.14);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.ui-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: hsl(var(--border));
}

.ui-tooltip-wrap:hover .ui-tooltip,
.ui-tooltip-wrap:focus-within .ui-tooltip {
  opacity: 1;
  visibility: visible;
}

.form-error {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  color: hsl(var(--destructive));
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.form-grid {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .form-grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.drawer-form--purchase-order {
  padding: 0.75rem 1rem 1rem;
  max-width: 100%;
}

.purchase-order-form-shell--page {
  max-width: 56rem;
  margin: 0 auto;
}

.drawer-form--purchase-order .purchase-order-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.drawer-form--purchase-order .product-form-section {
  padding: 0.6rem 0.75rem;
}

.drawer-form--purchase-order .product-form-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.6875rem;
}

/* Chi tiết phiếu quỹ (drawer xem) — khoảng cách rõ giữa các section */
/* ——— Thống kê trang index (KPI bar — dùng chung) ——— */
.index-stats,
.cashbook-stats {
  margin-bottom: 1.5rem;
}

.index-stats__grid,
.cashbook-stats__grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 520px) {
  .index-stats__grid,
  .cashbook-stats__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .index-stats__grid--cols-3,
  .cashbook-stats__grid--cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .index-stats__grid--cols-4,
  .cashbook-stats__grid--cols-4,
  .index-stats__grid--cols-5,
  .cashbook-stats__grid--cols-5,
  .index-stats__grid--cols-6,
  .cashbook-stats__grid--cols-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .index-stats__grid--cols-4,
  .cashbook-stats__grid--cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .index-stats__grid--cols-5,
  .cashbook-stats__grid--cols-5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .index-stats__grid--cols-6,
  .cashbook-stats__grid--cols-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.index-stat,
.cashbook-stat {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
  min-height: 5.25rem;
}

.index-stat__icon,
.cashbook-stat__icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  font-size: 1.1rem;
  background: hsl(var(--muted) / 0.35);
  color: hsl(var(--muted-foreground));
}

.index-stat__body,
.cashbook-stat__body {
  min-width: 0;
  flex: 1;
}

.index-stat__label,
.cashbook-stat__label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

.index-stat__value,
.cashbook-stat__value {
  margin: 0.2rem 0 0;
  font-size: clamp(1.0625rem, 1.8vw, 1.35rem);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.index-stat__hint,
.cashbook-stat__hint {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.35;
}

.index-stat--primary,
.index-stat--balance,
.cashbook-stat--balance {
  border-color: hsl(var(--primary) / 0.35);
  background: linear-gradient(135deg, hsl(var(--primary) / 0.06), hsl(var(--card)));
}

.index-stat--primary .index-stat__icon,
.index-stat--balance .index-stat__icon,
.cashbook-stat--balance .cashbook-stat__icon {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.index-stat--primary .index-stat__value,
.index-stat--balance .index-stat__value,
.cashbook-stat--balance .cashbook-stat__value {
  color: hsl(var(--primary));
}

.index-stat--success .index-stat__icon,
.index-stat--income .index-stat__icon,
.cashbook-stat--income .cashbook-stat__icon {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
}

.index-stat--success .index-stat__value,
.index-stat--income .index-stat__value,
.cashbook-stat--income .cashbook-stat__value {
  color: hsl(142 45% 28%);
}

.index-stat--amber .index-stat__icon {
  background: hsl(38 92% 50% / 0.12);
  color: hsl(38 92% 45%);
}

.index-stat--amber .index-stat__value {
  color: hsl(32 85% 32%);
}

.index-stat--cyan .index-stat__icon,
.index-stat--net .index-stat__icon,
.cashbook-stat--net .cashbook-stat__icon {
  background: hsl(188 94% 37% / 0.12);
  color: hsl(188 94% 32%);
}

.index-stat--cyan .index-stat__value,
.index-stat--net .index-stat__value,
.cashbook-stat--net .cashbook-stat__value {
  color: hsl(188 60% 28%);
}

.index-stat--danger .index-stat__icon,
.index-stat--expense .index-stat__icon,
.cashbook-stat--expense .cashbook-stat__icon {
  background: hsl(0 72% 51% / 0.1);
  color: hsl(0 72% 45%);
}

.index-stat--danger .index-stat__value,
.index-stat--expense .index-stat__value,
.cashbook-stat--expense .cashbook-stat__value {
  color: hsl(0 65% 40%);
}

.index-stat--muted .index-stat__icon,
.cashbook-stat--count .cashbook-stat__icon {
  background: hsl(var(--muted) / 0.45);
  color: hsl(var(--muted-foreground));
}

.drawer-form--cashbook-view {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 1.25rem 1.35rem 1.5rem;
  max-width: 100%;
}

.drawer-form--cashbook-view .cashbook-view-section {
  padding: 1.05rem 1.2rem 1.15rem;
  margin: 0;
}

.drawer-form--cashbook-view .product-form-section-title {
  margin: 0 0 0.9rem;
  font-size: 0.75rem;
}

.drawer-form--cashbook-view .cashbook-view-block {
  padding-top: 0.15rem;
}

.drawer-form--cashbook-view .po-form-rows {
  gap: 0.9rem;
}

.drawer-form--cashbook-view .po-form-row {
  gap: 0.65rem 1rem;
}

.drawer-form--cashbook-view .po-form-row .field {
  gap: 0.4rem;
}

.drawer-form--cashbook-view .cashbook-view-alert {
  margin: 0 0 1rem;
}

.drawer-form--cashbook-view .cashbook-view-section--money .po-money-ledger {
  margin-top: 0.25rem;
}

.drawer-form--cashbook-view .po-money-ledger__grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.drawer-form--cashbook-view .po-money-ledger__grid .po-money-ledger__item {
  padding: 1rem 1.15rem;
}

.drawer-form--cashbook-view .cashbook-view-footer {
  margin: 0.25rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / 0.35);
  line-height: 1.5;
}

/* Meta: hàng flex — ô cố định (ngày, trạng thái, mã) không kéo full width */
.po-form-rows {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.po-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.po-form-row .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.po-form-row .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.po-form-row .input,
.po-form-row .select,
.po-form-row .textarea {
  padding: 0.4rem 0.55rem;
  font-size: 0.8125rem;
  max-width: 100%;
}

.po-form-row .field--grow {
  flex: 1 1 14rem;
}

.po-form-row .field--grow .input,
.po-form-row .field--grow .select {
  width: 100%;
}

.po-form-row .field--full {
  flex: 1 1 100%;
  width: 100%;
}

.po-form-row .field--full .input,
.po-form-row .field--full .textarea,
.po-form-row .field--full .select {
  width: 100%;
  max-width: none;
}

/* Ô cố định: không co giãn theo % chiều ngang hàng */
.po-form-row--compact {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.po-form-row--compact .field {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
}

.po-form-row .field--w-date {
  flex: 0 0 auto;
  width: 13.25rem;
  max-width: 100%;
}

.po-form-row .field--w-status {
  flex: 0 0 auto;
  width: 9.75rem;
  max-width: 100%;
}

.po-form-row .field--w-code {
  flex: 0 0 auto;
  width: 10.5rem;
  max-width: 100%;
}

.po-form-row .field--w-invoice {
  flex: 0 0 auto;
  width: 11.5rem;
  max-width: 100%;
}

.po-form-row .field--w-po {
  flex: 1 1 14rem;
  min-width: 12rem;
  max-width: 24rem;
}

.po-form-row .field--w-money {
  flex: 0 0 auto;
  width: 8.75rem;
  max-width: 100%;
}

.po-form-row .field--w-date .input,
.po-form-row .field--w-date .input.input--datetime,
.po-form-row .field--w-status .select,
.po-form-row .field--w-code .input,
.po-form-row .field--w-invoice .input,
.po-form-row .field--w-po .select,
.po-form-row .field--w-money .input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.drawer-form--purchase-order .input.input--datetime,
.drawer-form--purchase-order .input.input--money {
  width: 100%;
  max-width: 100%;
}

.po-form-row--payment {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / 0.2);
}

.po-form-row--payment .field {
  flex: 0 0 auto;
}

.po-form-row .field--note .textarea--compact,
.drawer-form--purchase-order .textarea--compact {
  min-height: 2.5rem;
  resize: vertical;
}

/* Cấu trúc meta cũ (purchase-order-meta-fields) — ô ngày/trạng thái không full width */
.purchase-order-meta-fields {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.purchase-order-meta-row--pair {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
}

.purchase-order-meta-row--pair .field--date,
.purchase-order-meta-row--pair .field.field--date {
  flex: 0 0 auto;
  width: min(13.75rem, 100%);
  max-width: 13.75rem;
}

.purchase-order-meta-row--pair .field--date .input,
.purchase-order-meta-row--pair .field.field--date .input {
  width: 100%;
  max-width: 13.75rem;
  box-sizing: border-box;
}

.purchase-order-meta-row--pair > .field:not(.field--date) {
  flex: 0 0 auto;
  width: min(10.5rem, 100%);
  max-width: 10.5rem;
}

.purchase-order-meta-row--pair > .field:not(.field--date) .select {
  width: 100%;
}

.purchase-order-meta-fields > .field.field--compact {
  flex: 0 0 auto;
  width: min(11.5rem, 100%);
  max-width: 11.5rem;
}

.purchase-order-meta-fields > .field.field--compact .input {
  width: 100%;
}

.po-form-meta > .field-hint {
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: hsl(var(--muted-foreground));
}

.purchase-order-form-top {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.purchase-order-form-section--meta .field-hint {
  margin: 0;
  font-size: 0.6875rem;
}

.drawer-form--purchase-order .purchase-order-form .product-form-grid--supplier {
  grid-template-columns: 1fr;
}

.purchase-order-items__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 10px;
}

.purchase-order-items__footer .field-hint {
  margin: 0;
}

.purchase-order-form-section--items {
  background: linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--muted) / 0.1) 100%);
}

.purchase-order-money-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Hàng nhập: CK phiếu | VAT % | Đã thanh toán */
.purchase-order-payment-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.purchase-order-payment-row .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.purchase-order-payment-row .label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #334155;
}

.purchase-order-payment-row .input {
  width: 100%;
  max-width: none;
  background: #fff;
  border-color: #cbd5e1;
}

/* Bảng tổng hợp số liệu */
.po-money-ledger {
  border: 1px solid #cbd5e1;
  border-radius: calc(var(--radius-sm) + 2px);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.06);
}

.po-money-ledger__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e3a5f;
  background: linear-gradient(90deg, #dbeafe 0%, #e0f2fe 100%);
  border-bottom: 1px solid #93c5fd;
}

.po-money-ledger__header i {
  color: #2563eb;
}

.po-money-ledger__list {
  display: flex;
  flex-direction: column;
}

.po-money-ledger__item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.po-money-ledger__item:last-child {
  border-bottom: none;
}

.po-money-ledger__line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.po-money-ledger__tag {
  font-size: 0.875rem;
  font-weight: 700;
  color: #0f172a;
}

.po-money-ledger__tag--with-tooltip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  max-width: min(100%, 14rem);
}

.po-money-ledger__value {
  font-size: 1.125rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.po-money-ledger__hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

.po-money-ledger__item--goods {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
}

.po-money-ledger__item--goods .po-money-ledger__tag {
  color: #1e40af;
}

.po-money-ledger__item--goods .po-money-ledger__value {
  color: #1d4ed8;
}

.po-money-ledger__item--goods .po-money-ledger__hint {
  color: #3b5998;
}

.po-money-ledger__item--tax {
  background: #ecfeff;
  border-left: 4px solid #0891b2;
}

.po-money-ledger__item--tax .po-money-ledger__tag {
  color: #0e7490;
}

.po-money-ledger__item--tax .po-money-ledger__value {
  color: #0f766e;
}

.po-money-ledger__item--tax .po-money-ledger__hint {
  color: #0f6b7a;
}

.po-money-ledger__item--net {
  background: #f0fdf4;
  border-left: 4px solid #16a34a;
}

.po-money-ledger__item--net .po-money-ledger__tag {
  color: #166534;
}

.po-money-ledger__item--net .po-money-ledger__value,
.po-money-ledger__value--primary {
  font-size: 1.25rem;
  color: #15803d;
}

.po-money-ledger__item--net .po-money-ledger__hint {
  color: #2d6a4f;
}

.po-money-ledger__item--debt {
  background: #fffbeb;
  border-left: 4px solid #d97706;
}

.po-money-ledger__item--debt .po-money-ledger__tag {
  color: #92400e;
}

.po-money-ledger__item--debt .po-money-ledger__value {
  color: #b45309;
}

.po-money-ledger__item--debt .po-money-ledger__hint {
  color: #a16207;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding {
  background: #fef2f2;
  border-left-color: #dc2626;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding .po-money-ledger__tag {
  color: #991b1b;
}

.label--tooltip-emphasis,
.po-money-ledger__tag--emphasis {
  color: #b91c1c;
}

.label--tooltip-emphasis .ui-tooltip-trigger,
.po-money-ledger__tag--emphasis .ui-tooltip-trigger {
  color: #dc2626;
}

.field--payment-emphasis .label,
.field--payment-emphasis .label--tooltip-emphasis {
  color: #b91c1c;
}

.field--payment-emphasis .ui-tooltip-trigger {
  color: #dc2626;
}

.field--payment-emphasis .input--payment-emphasis {
  color: #b91c1c;
  font-weight: 600;
  border-color: hsl(0 55% 72%);
  background: hsl(0 80% 98%);
}

.field--payment-emphasis .input--payment-emphasis:focus {
  color: #991b1b;
  border-color: #dc2626;
  box-shadow: 0 0 0 2px hsl(0 65% 48% / 0.22);
}

.field--payment-emphasis .input--payment-emphasis::placeholder {
  color: hsl(0 45% 55% / 0.75);
}

.field--payment-emphasis .input--payment-emphasis:read-only {
  color: #991b1b;
  background: hsl(0 60% 96%);
}

.po-money-ledger__item--debt .po-money-ledger__tag--emphasis {
  color: #b91c1c;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding .po-money-ledger__tag--emphasis {
  color: #991b1b;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding .po-money-ledger__tag--emphasis .ui-tooltip-trigger {
  color: #dc2626;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding .po-money-ledger__value {
  color: #dc2626;
}

.po-money-ledger__item--debt.po-money-ledger__item--outstanding .po-money-ledger__hint {
  color: #b91c1c;
}

.po-money-ledger__footnote {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #1e40af;
  background: #dbeafe;
  border-top: 1px solid #93c5fd;
}

.po-money-ledger__footnote i {
  margin-top: 0.1rem;
  color: #2563eb;
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .purchase-order-payment-row {
    gap: 0.5rem;
    padding: 0.65rem 0.5rem;
  }

  .purchase-order-payment-row .label {
    font-size: 0.75rem;
  }

  .purchase-order-payment-row .input {
    padding: 0.45rem 0.5rem;
    font-size: 0.8125rem;
  }

  .po-money-ledger__value {
    font-size: 1rem;
  }

  .po-money-ledger__item--net .po-money-ledger__value,
  .po-money-ledger__value--primary {
    font-size: 1.1rem;
  }
}

.drawer-form--purchase-order .purchase-order-form .field--grow .input,
.drawer-form--purchase-order .purchase-order-form .field--grow .select,
.drawer-form--purchase-order .purchase-order-form .field--full .input,
.drawer-form--purchase-order .purchase-order-form .field--full .select,
.drawer-form--purchase-order .purchase-order-form .field--full .textarea,
.drawer-form--purchase-order .purchase-order-form .field--note .textarea {
  width: 100%;
  max-width: none;
}

/* Ô cố định: giữ max-width theo wrapper, không bị rule grow ghi đè */
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-date .input,
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-status .select,
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-code .input,
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-invoice .input,
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-po .select,
.drawer-form--purchase-order .purchase-order-form .po-form-row .field--w-money .input {
  width: 100%;
  max-width: 100%;
}

/* ——— Sale order: bảng chi tiết hàng ——— */
.so-sale-items .table--so-items {
  table-layout: fixed;
  width: 100%;
}

.so-sale-items .table--so-items th,
.so-sale-items .table--so-items td {
  padding: 0.45rem 0.4rem;
  vertical-align: middle;
}

.so-sale-items .col-product {
  width: 40%;
  min-width: 10rem;
}

.so-sale-items .col-stock {
  width: 4.5rem;
  white-space: nowrap;
}

.so-stock-qty {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.so-stock-qty--low {
  color: hsl(var(--destructive));
}

.so-stock-qty--ok {
  color: hsl(142 45% 32%);
}

.so-sale-items .col-unit {
  width: 3.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.so-sale-items .col-qty {
  width: 3.25rem;
}

.so-sale-items .col-price {
  width: 5.5rem;
}

.so-sale-items .col-discount {
  width: 2.75rem;
}

.so-sale-items .col-line-total {
  width: 5.25rem;
  text-align: right;
  white-space: nowrap;
}

.so-sale-items .col-actions {
  width: 2.25rem;
  text-align: center;
  padding-right: 0.25rem;
}

.so-sale-items [data-so-product] {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.so-sale-items .select,
.so-sale-items .input {
  min-width: 0;
  width: 100%;
}

.so-sale-items [data-so-qty],
.so-sale-items [data-so-discount] {
  max-width: none;
  text-align: right;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.so-sale-items [data-so-price] {
  max-width: none;
  text-align: right;
}

.so-sale-items .col-line-total .text-strong {
  font-size: 0.8125rem;
}

/* ——— Phiếu nhập: bảng chi tiết hàng (cùng bố cục phiếu bán) ——— */
.line-items-table .table--line-items {
  table-layout: fixed;
  width: 100%;
}

.line-items-table .table--line-items th,
.line-items-table .table--line-items td {
  padding: 0.45rem 0.4rem;
  vertical-align: middle;
}

.line-items-table .col-product {
  width: 48%;
  min-width: 10rem;
}

.line-items-table .col-unit {
  width: 3.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.line-items-table .col-qty {
  width: 3.25rem;
}

.line-items-table .col-price {
  width: 5.5rem;
}

.line-items-table .col-discount {
  width: 2.75rem;
}

.line-items-table .col-line-total {
  width: 5.25rem;
  text-align: right;
  white-space: nowrap;
}

.line-items-table .col-actions {
  width: 2.25rem;
  text-align: center;
  padding-right: 0.25rem;
}

.line-items-table [data-po-product] {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.line-items-table .select,
.line-items-table .input {
  min-width: 0;
  width: 100%;
}

.line-items-table [data-po-qty],
.line-items-table [data-po-discount],
.line-items-table [data-so-qty],
.line-items-table [data-so-discount] {
  max-width: none;
  text-align: right;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.line-items-table [data-po-cost] {
  max-width: none;
  text-align: right;
}

.line-items-table .col-line-total .text-strong {
  font-size: 0.8125rem;
}

/* ——— Phiếu chuyển kho: bảng chi tiết hàng ——— */
.line-items-table.stock-transfer-items .col-product {
  width: 54%;
  min-width: 12rem;
}

.line-items-table.stock-transfer-items .col-stock {
  width: 4.25rem;
  text-align: right;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  white-space: nowrap;
}

.line-items-table.stock-transfer-items [data-st-product] {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.line-items-table.stock-transfer-items [data-st-qty],
.line-items-table.stock-transfer-items [data-st-cost] {
  text-align: right;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.stock-transfer-items__footer {
  margin-top: 0.75rem;
}

.line-items-table.customer-return-items .customer-return-row--amount-over {
  background: hsl(45 100% 96% / 0.75);
}

.line-items-table.customer-return-items .col-product {
  width: 22%;
  min-width: 9rem;
}

.line-items-table.customer-return-items .col-unit {
  width: 4rem;
}

.line-items-table.customer-return-items .col-qty,
.line-items-table.customer-return-items .col-price,
.line-items-table.customer-return-items .col-line-total {
  width: 5.5rem;
  min-width: 4.5rem;
}

.line-items-table.customer-return-items [data-cr-product] {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.line-items-table.customer-return-items [data-cr-qty],
.line-items-table.customer-return-items [data-cr-price] {
  text-align: right;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.customer-return-items__footer {
  margin-top: 0.75rem;
}

/* ——— Tồn kho (xem) ——— */

.inventory-row--low {
  background: hsl(45 100% 96% / 0.65);
}

.inventory-row--out {
  background: hsl(var(--destructive) / 0.06);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.table-actions__form {
  display: inline-flex;
  margin: 0;
}

/* ——— Tồn kho: tab & lịch sử ——— */
.inventory-module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.inventory-module-tabs__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
}

.inventory-module-tabs__item:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--muted) / 0.35);
}

.inventory-module-tabs__item--active {
  color: hsl(var(--primary));
  background: hsl(var(--card));
  border-color: hsl(var(--border));
}

.inventory-focused-product {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.inventory-focused-product .table-link {
  margin-left: 0.5rem;
  font-size: 0.8125rem;
}


.inv-qty-change--in {
  font-weight: 700;
  color: hsl(142 45% 32%);
}

.inv-qty-change--out {
  font-weight: 700;
  color: hsl(var(--destructive));
}

/* ——— Sale order: hóa đơn chính thức & xác nhận ——— */
[data-sale-order-form] .po-form-row .field--w-status {
  width: 13.75rem;
  min-width: 13.75rem;
}

[data-sale-order-form] .so-invoice-badge {
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
}

.so-invoice-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md, 0.375rem);
  background: hsl(142 76% 94%);
  color: hsl(142 45% 28%);
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid hsl(142 40% 82%);
}

.so-invoice-badge--muted {
  background: hsl(var(--muted) / 0.35);
  color: hsl(var(--muted-foreground));
  border-color: hsl(var(--border));
  font-weight: 500;
}

.so-document-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.so-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.so-confirm-modal.ui-hidden {
  display: none;
}

.so-confirm-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.so-confirm-modal__panel {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(92vh, 800px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-lg, 0.5rem);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
}

.so-confirm-modal__panel--pro .so-confirm-modal__body {
  flex: 1;
  overflow: auto;
  padding: 0 1.25rem 1rem;
}

.so-confirm-modal__hero {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, hsl(var(--primary) / 0.12) 0%, hsl(var(--card)) 55%);
  border-bottom: 1px solid hsl(var(--border));
}

.so-confirm-modal__hero-icon {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md, 0.375rem);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 1.25rem;
}

.so-confirm-modal__title {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.so-confirm-modal__lead {
  margin: 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.45;
}

.so-confirm-modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.15);
}

.so-confirm-modal__actions-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-left: auto;
}

.so-invoice-badge--draft {
  background: hsl(45 90% 94%);
  border-color: hsl(45 70% 75%);
  color: hsl(32 55% 28%);
}

.so-confirm-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.so-confirm-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.so-confirm-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md, 0.375rem);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.so-confirm-card--accent {
  border-color: hsl(142 40% 78%);
  background: hsl(142 76% 96%);
}

.so-confirm-card--wide {
  grid-column: 1 / -1;
}

.so-confirm-card__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: hsl(var(--muted-foreground));
}

.so-confirm-card__label i {
  margin-right: 0.25rem;
  opacity: 0.85;
}

.so-confirm-card__value {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
}

.so-confirm-section__title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.so-confirm-items {
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md, 0.375rem);
  overflow: hidden;
}

.so-confirm-table {
  font-size: 0.75rem;
}

.so-confirm-table thead {
  background: hsl(var(--muted) / 0.35);
}

.so-confirm-table__name {
  max-width: 12rem;
  word-break: break-word;
}

.so-confirm-table__amount {
  font-weight: 700;
  color: hsl(var(--primary));
}

.so-confirm-pay__grid {
  display: grid;
  grid-template-columns: 1fr minmax(9rem, 11rem);
  gap: 1rem;
  align-items: stretch;
}

.so-confirm-pay__lines {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md, 0.375rem);
  background: hsl(var(--muted) / 0.12);
}

.so-confirm-pay__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.8125rem;
}

.so-confirm-pay__row span {
  color: hsl(var(--muted-foreground));
}

.so-confirm-pay__row--warn strong {
  color: hsl(var(--destructive));
}

.so-confirm-pay__hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.75rem;
  border-radius: var(--radius-md, 0.375rem);
  background: linear-gradient(160deg, hsl(var(--primary) / 0.15), hsl(var(--primary) / 0.04));
  border: 1px solid hsl(var(--primary) / 0.25);
}

.so-confirm-pay__hero-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}

.so-confirm-pay__hero-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: hsl(var(--primary));
}

.so-confirm-pay__hero-unit {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.so-confirm-pay__hero-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: center;
}

@media (max-width: 520px) {
  .so-confirm-cards {
    grid-template-columns: 1fr;
  }

  .so-confirm-pay__grid {
    grid-template-columns: 1fr;
  }
}

/* ——— Table ——— */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  text-align: left;
}

.table thead {
  background: hsl(var(--muted));
}

.table th {
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  border-bottom: 1px solid hsl(var(--border));
}

.table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
}

/* Số tiền & số lượng — căn phải */
.table th.text-right,
.table td.text-right,
.table th.num,
.table td.num,
.table th.col-qty,
.table td.col-qty,
.table th.col-price,
.table td.col-price,
.table th.col-discount,
.table td.col-discount,
.table th.col-line-total,
.table td.col-line-total,
.table th.col-stock,
.table td.col-stock {
  text-align: right;
}

.table th.num,
.table td.num {
  white-space: nowrap;
}

.table .col-line-total .text-strong,
.table [data-so-line-total],
.table [data-po-line-total],
.table [data-sr-line-total] {
  display: inline-block;
  width: 100%;
  text-align: right;
}

.so-stock-qty {
  display: inline-block;
  width: 100%;
  text-align: right;
}

.input--money,
.input--qty,
.field--w-money .input,
.purchase-order-payment-row .input {
  text-align: right;
}

.po-money-ledger__value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.so-confirm-table th.text-right,
.so-confirm-table td.text-right {
  text-align: right;
}

.so-confirm-table__amount,
.so-confirm-pay__row strong {
  font-variant-numeric: tabular-nums;
}

.inv-qty-change {
  font-variant-numeric: tabular-nums;
}

.table tbody tr:hover {
  background: hsl(var(--muted) / 0.5);
}

.table-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.text-muted {
  color: hsl(var(--muted-foreground));
}

.text-strong {
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* ——— Badges ——— */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.badge-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-success {
  background: hsl(var(--success-bg));
  color: hsl(var(--success-fg));
  border-color: hsl(var(--success-border));
}

.badge-destructive {
  background: hsl(0 93% 94%);
  color: hsl(0 72% 35%);
  border-color: hsl(0 45% 88%);
}

.badge-status-draft {
  background: hsl(220 16% 92%);
  color: hsl(220 18% 28%);
  border-color: hsl(220 14% 78%);
}

.badge-status-confirmed {
  background: hsl(205 96% 91%);
  color: hsl(205 86% 30%);
  border-color: hsl(205 78% 78%);
}

.badge-status-completed {
  background: hsl(142 76% 90%);
  color: hsl(142 72% 25%);
  border-color: hsl(142 54% 72%);
}

.badge-status-cancelled {
  background: hsl(0 93% 94%);
  color: hsl(0 72% 35%);
  border-color: hsl(0 45% 78%);
}

/* ——— Alerts ——— */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  border: 1px solid hsl(var(--border));
}

.alert-success {
  background: hsl(var(--success-bg));
  color: hsl(var(--success-fg));
  border-color: hsl(var(--success-border));
}

.alert-destructive {
  background: hsl(0 93% 94%);
  color: hsl(0 72% 35%);
  border-color: hsl(0 45% 88%);
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

/* ——— Filters grid ——— */
.filters-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .filters-grid-inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }
}

@media (min-width: 1024px) {
  .filters-grid {
    grid-template-columns: 2fr 1fr;
    align-items: stretch;
  }
}

.filter-field {
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}

.stat-summary {
  padding: 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stat-summary-label {
  margin: 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.stat-summary-value {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 600;
}

/* ——— Dashboard / index KPI (HTML cũ: dash-grid-stats + stat-tile) ——— */
.dash-grid-stats {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 520px) {
  .dash-grid-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .dash-grid-stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
  }
}

.stat-tile {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.04);
  min-height: 5.25rem;
  border-left: none;
  border-color: hsl(var(--primary) / 0.35);
  background: linear-gradient(135deg, hsl(var(--primary) / 0.06), hsl(var(--card)));
}

.stat-tile-top {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-direction: row-reverse;
}

.stat-tile-top > div:first-child {
  display: flex;
  flex-direction: column-reverse;
  flex: 1;
  min-width: 0;
}

.stat-tile-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: hsl(var(--muted-foreground));
  line-height: 1.3;
}

.stat-tile-value {
  margin: 0.2rem 0 0;
  font-size: clamp(1.0625rem, 1.8vw, 1.35rem);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  color: hsl(var(--primary));
}

.stat-tile-icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(var(--radius) - 2px);
  font-size: 1.1rem;
  opacity: 1;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}

.stat-tile--green {
  border-color: hsl(142 76% 36% / 0.35);
  background: linear-gradient(135deg, hsl(142 76% 36% / 0.06), hsl(var(--card)));
}

.stat-tile--green .stat-tile-icon {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
}

.stat-tile--green .stat-tile-value {
  color: hsl(142 45% 28%);
}

.stat-tile--amber {
  border-color: hsl(38 92% 50% / 0.35);
  background: linear-gradient(135deg, hsl(38 92% 50% / 0.06), hsl(var(--card)));
}

.stat-tile--amber .stat-tile-icon {
  background: hsl(38 92% 50% / 0.12);
  color: hsl(38 92% 45%);
}

.stat-tile--amber .stat-tile-value {
  color: hsl(32 85% 32%);
}

.stat-tile--cyan {
  border-color: hsl(188 94% 37% / 0.35);
  background: linear-gradient(135deg, hsl(188 94% 37% / 0.06), hsl(var(--card)));
}

.stat-tile--cyan .stat-tile-icon {
  background: hsl(188 94% 37% / 0.12);
  color: hsl(188 94% 32%);
}

.stat-tile--cyan .stat-tile-value {
  color: hsl(188 60% 28%);
}

.dash-two-col {
  display: grid;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .dash-two-col {
    grid-template-columns: 2fr 1fr;
  }
}

.dash-stack {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.notif-list {
  border-top: 1px solid hsl(var(--border));
}

.notif-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
  transition: background 0.15s;
}

.notif-item:hover {
  background: hsl(var(--muted) / 0.5);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-title {
  font-weight: 500;
  font-size: 0.875rem;
}

.notif-desc {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.notif-icon-warn {
  color: hsl(38 92% 50%);
}

.notif-icon-ok {
  color: hsl(142 76% 36%);
}

.notif-icon-info {
  color: hsl(var(--primary));
}

/* Progress */
.progress-block {
  margin-bottom: 1rem;
}

.progress-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.progress-track {
  height: 1.5rem;
  border-radius: 999px;
  background: hsl(var(--muted));
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: hsl(var(--primary-foreground));
  transition: width 0.3s ease;
}

.progress-bar--primary {
  background: hsl(var(--primary));
}

.progress-bar--green {
  background: hsl(142 76% 36%);
}

.progress-bar--cyan {
  background: hsl(188 94% 37%);
}

.progress-bar--75 {
  width: 75%;
}

.progress-bar--60 {
  width: 60%;
}

.progress-bar--45 {
  width: 45%;
}

.progress-foot {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
}

/* ——— Auth / Login ——— */
.auth-body {
  margin: 0;
  min-height: 100vh;
  background: hsl(var(--background));
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .auth-shell {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
}

.auth-brand {
  display: none;
  position: relative;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem 3rem;
  color: hsl(var(--primary-foreground));
  background: linear-gradient(145deg, hsl(222 47% 11%) 0%, hsl(221 83% 40%) 55%, hsl(221 83% 53%) 100%);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .auth-brand {
    display: flex;
  }
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, hsl(0 0% 100% / 0.08) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, hsl(0 0% 100% / 0.06) 0%, transparent 40%);
  pointer-events: none;
}

.auth-brand-inner {
  position: relative;
  z-index: 1;
}

.auth-brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.auth-brand-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  background: hsl(0 0% 100% / 0.12);
  border: 1px solid hsl(0 0% 100% / 0.15);
  font-size: 1.1rem;
}

.auth-brand-headline {
  margin: 3rem 0 0.75rem;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  max-width: 22rem;
}

.auth-brand-desc {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: hsl(0 0% 100% / 0.82);
  max-width: 26rem;
}

.auth-brand-features {
  position: relative;
  z-index: 1;
  margin: 2.5rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.auth-brand-features li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.8125rem;
  color: hsl(0 0% 100% / 0.88);
}

.auth-brand-features i {
  width: 1.25rem;
  text-align: center;
  opacity: 0.9;
}

.auth-brand-foot {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding-top: 2rem;
  font-size: 0.75rem;
  color: hsl(0 0% 100% / 0.55);
}

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: hsl(var(--muted) / 0.45);
}

.auth-form-wrap {
  width: 100%;
  max-width: 26rem;
}

.auth-form-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow:
    0 1px 2px hsl(0 0% 0% / 0.04),
    0 12px 40px hsl(0 0% 0% / 0.06);
  padding: 2rem 1.75rem;
}

@media (min-width: 640px) {
  .auth-form-card {
    padding: 2.25rem 2rem;
  }
}

.auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
  font-weight: 600;
  font-size: 1rem;
  color: hsl(var(--foreground));
}

@media (min-width: 1024px) {
  .auth-mobile-brand {
    display: none;
  }
}

.auth-mobile-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-size: 0.95rem;
}

.auth-form-title {
  margin: 0 0 0.35rem;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
}

.auth-form-sub {
  margin: 0 0 1.75rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}

.auth-field {
  margin-bottom: 1.15rem;
}

.auth-field .label {
  margin-bottom: 0.4rem;
}

.auth-input-wrap {
  position: relative;
}

.auth-input-wrap .input {
  padding-left: 2.5rem;
  height: 2.625rem;
}

.auth-input-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}

.auth-input-wrap .btn-icon {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
}

.auth-input-wrap .input--password {
  padding-right: 2.5rem;
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.auth-forgot {
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--primary));
  text-decoration: none;
}

.auth-forgot:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-submit {
  width: 100%;
  height: 2.75rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.auth-form-note {
  margin: 1.25rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
  line-height: 1.5;
}

.auth-page-legal {
  margin-top: 1.5rem;
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

.alert-errors-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  list-style: disc;
}

.checkbox-row .label {
  margin: 0;
  font-weight: 400;
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

.checkbox-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: hsl(var(--primary));
}

.alert-dismiss {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.alert-dismiss .btn-icon {
  flex-shrink: 0;
  color: inherit;
}

/* ——— Drawer (staff modal) ——— */
.drawer-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  pointer-events: none;
}

.drawer-root.is-open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: hsl(222 47% 11% / 0.45);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer-root.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 100%;
  max-width: 42rem;
  display: flex;
  flex-direction: column;
  background: hsl(var(--card));
  border-left: 1px solid hsl(var(--border));
  box-shadow: -8px 0 30px hsl(0 0% 0% / 0.12);
  transform: translateX(100%);
  transition: transform 0.3s ease, max-width 0.25s ease;
}

.drawer-root.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-panel.drawer-panel--wide {
  max-width: min(72rem, 98vw);
}

.drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.drawer-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.drawer-body {
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  background: hsl(var(--background));
}

/* Form trong drawer: không lồng thêm khung card (tránh chồng viền) */
.drawer-body [data-ui-drawer-content] > .card,
.drawer-body [data-ui-drawer-content] .card.drawer-form-legacy {
  border: none;
  box-shadow: none;
  background: transparent;
  border-radius: 0;
}

.drawer-body [data-ui-drawer-content] > .card > .card-content,
.drawer-body [data-ui-drawer-content] .card.drawer-form-legacy > .card-content {
  padding: 0;
}

.drawer-form {
  padding: 1rem 1.25rem 1.5rem;
}

/* Loại thu/chi — sửa tên trong drawer */
.drawer-form.drawer-form--cashbook-category,
.drawer-body [data-ui-drawer-content] > .drawer-form.drawer-form--cashbook-category {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
  margin: 0;
  max-width: 100%;
}

.drawer-form.drawer-form--cashbook-category .label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
}

.drawer-form.drawer-form--cashbook-category .input {
  margin: 0;
}

.drawer-form.drawer-form--cashbook-category .form-error {
  margin: 0;
  padding: 0 0 0.25rem;
}

.drawer-form.drawer-form--cashbook-category .cashbook-category-form__actions {
  display: flex;
  justify-content: flex-start;
  margin: 0;
  padding: 0;
}

.drawer-form.drawer-form--cashbook-category .cashbook-category-form__actions .btn {
  width: auto;
  min-width: 0;
}

.drawer-form--cashbook-manual {
  padding: 1.15rem 1.35rem 1.35rem;
  max-width: 100%;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.cb-manual-form__header {
  margin-bottom: 1.1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid hsl(var(--border));
}

.cb-manual-form__type-badge {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.cb-manual-form__lead {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  line-height: 1.5;
}

.drawer-form--cashbook-manual .product-form-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
}

.cb-manual-form__section {
  margin-bottom: 1.15rem;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid hsl(var(--border) / 0.65);
}

.cb-manual-form__section--last {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0.75rem;
}

.cb-manual-form__lookup-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(10rem, 1.4fr) auto;
  gap: 0.65rem 0.75rem;
  align-items: end;
}

@media (max-width: 520px) {
  .cb-manual-form__lookup-row {
    grid-template-columns: 1fr;
  }
}

.cb-manual-form__load-wrap {
  padding-bottom: 0.1rem;
}

.cb-manual-form__hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
}

.cb-manual-doc-summary {
  margin-top: 0.85rem;
  padding: 0;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 3px hsl(220 20% 20% / 0.06);
}

.cb-manual-doc-summary--income {
  border-color: hsl(142 35% 72% / 0.65);
}

.cb-manual-doc-summary--expense {
  border-color: hsl(0 40% 78% / 0.65);
}

.cb-manual-doc-summary__head {
  padding: 0.55rem 0.85rem;
  background: hsl(var(--muted) / 0.35);
  border-bottom: 1px solid hsl(var(--border) / 0.8);
}

.cb-manual-doc-summary__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.cb-manual-doc-summary--income .cb-manual-doc-summary__title {
  color: hsl(142 40% 26%);
}

.cb-manual-doc-summary--expense .cb-manual-doc-summary__title {
  color: hsl(0 50% 30%);
}

.cb-manual-doc-summary__code {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
}

.cb-manual-doc-summary__hero {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  padding: 0.55rem 0.85rem;
  background: hsl(var(--muted) / 0.18);
  border-bottom: 1px solid hsl(var(--border) / 0.75);
}

.cb-manual-doc-summary__hero-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.cb-manual-doc-summary__hero-amount {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2rem;
  margin: 0;
}

.cb-manual-doc-summary__hero-value {
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.cb-manual-doc-summary--income .cb-manual-doc-summary__hero-value,
.cb-manual-doc-summary--income .cb-manual-doc-summary__hero-unit {
  color: hsl(142 48% 32%);
}

.cb-manual-doc-summary--expense .cb-manual-doc-summary__hero-value,
.cb-manual-doc-summary--expense .cb-manual-doc-summary__hero-unit {
  color: hsl(0 65% 42%);
}

.cb-manual-doc-summary__hero-unit {
  font-size: 0.8125rem;
  font-weight: 600;
}

.cb-manual-doc-summary__hero-note {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  line-height: 1.4;
}

.cb-manual-doc-summary__meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0.65rem 0.85rem 0.7rem;
  font-size: 0.8125rem;
  background: hsl(var(--card));
}

.cb-manual-doc-summary__row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 40%) 1fr;
  gap: 0.35rem 0.75rem;
}

.cb-manual-doc-summary__row dt {
  margin: 0;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.cb-manual-doc-summary__row dd {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.cb-manual-doc-summary__row--party dd {
  font-size: 0.875rem;
  color: hsl(217 55% 32%);
}

.cb-manual-doc-summary__row--muted dt,
.cb-manual-doc-summary__row--muted dd {
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}

.cb-manual-doc-summary__warnings {
  margin: 0;
  padding: 0.5rem 0.85rem 0.55rem 1.15rem;
  font-size: 0.75rem;
  color: hsl(38 92% 28%);
  background: hsl(45 90% 96%);
  border-top: 1px solid hsl(42 75% 82% / 0.75);
}

.cb-manual-form__amount--highlight {
  animation: cb-amount-pulse 1.6s ease-out 1;
  border-color: hsl(217 70% 48%) !important;
  box-shadow: 0 0 0 2px hsl(217 70% 48% / 0.2);
}

@keyframes cb-amount-pulse {
  0% {
    box-shadow: 0 0 0 3px hsl(217 70% 48% / 0.35);
  }
  100% {
    box-shadow: 0 0 0 2px hsl(217 70% 48% / 0.12);
  }
}

.cb-manual-form__grid {
  gap: 0.75rem 1rem;
}

.cb-manual-form__grid .label {
  font-size: 0.75rem;
  margin-bottom: 0.2rem;
}

.cb-manual-form__grid .input,
.cb-manual-form__grid .select {
  font-size: 0.8125rem;
  padding: 0.45rem 0.65rem;
}

.cb-manual-form__textarea {
  font-size: 0.8125rem;
  min-height: 3.25rem;
}

.cb-manual-form__actions {
  margin-top: 0.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid hsl(var(--border));
}

.cb-manual-form__debt-title {
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.cb-manual-form__field-stack {
  margin-top: 0.35rem;
}

.cb-manual-form__field-stack .field {
  margin-top: 0.85rem;
}

.cb-manual-form__field-stack .field:first-child {
  margin-top: 0.5rem;
}

.drawer-form--cashbook-manual .cb-manual-form__field-stack .label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
}

.drawer-form--cashbook-manual .cb-manual-form__field-stack .input {
  font-size: 0.8125rem;
}

.cb-manual-form__section--debt .field {
  margin-bottom: 0.65rem;
}

.cb-manual-form__section--debt .field:last-child {
  margin-bottom: 0;
}

.drawer-form--product {
  padding: 1rem 1.35rem 1.5rem;
  max-width: 100%;
}

.product-form-shell--page {
  max-width: 52rem;
  margin: 0 auto;
}

.drawer-loading {
  padding: 3rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.ui-hidden {
  display: none !important;
}

body.overflow-lock {
  overflow: hidden;
}

/* ——— Table link ——— */
.table-link {
  color: hsl(var(--primary));
  font-weight: 500;
}

.table-link:hover {
  text-decoration: underline;
}

.table-link--btn {
  display: inline;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.table-link--btn:hover {
  text-decoration: underline;
}

.table-cell-sub {
  font-size: 0.75rem;
}

/* ——— Empty state ——— */
.empty-cell {
  text-align: center;
  padding: 2rem 1rem !important;
  color: hsl(var(--muted-foreground));
}

/* ——— Product image ——— */
.product-image-field {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.product-image-preview {
  width: 6rem;
  height: 6rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.25);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.25rem;
}

.product-image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem;
  text-align: center;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  line-height: 1.3;
}

.product-image-placeholder i {
  font-size: 1.75rem;
  opacity: 0.65;
}

.product-image-controls {
  flex: 1;
  min-width: 12rem;
}

/* ——— Product form (drawer rộng) ——— */
.drawer-form--product .product-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.product-form-section {
  padding: 0.75rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--card));
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.03);
}

.product-form-section:first-of-type {
  margin-top: 0;
}

.product-form-section--hero {
  padding: 1rem 1.1rem;
  background: linear-gradient(180deg, hsl(var(--card)) 0%, hsl(var(--muted) / 0.12) 100%);
}

.product-form-section--last {
  margin-bottom: 0;
}

.product-form-section-title {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--primary));
  padding-left: 0.55rem;
  border-left: 3px solid hsl(var(--primary));
  line-height: 1.35;
}

.product-form-hero {
  display: grid;
  gap: 1rem 1.25rem;
  align-items: start;
}

@media (min-width: 560px) {
  .product-form-hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }
}

.product-form-hero__fields {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}

.product-form-hero__block {
  min-width: 0;
}

.product-form-hero__block + .product-form-hero__block {
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border) / 0.65);
}

.product-form-media {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.product-form-media__label {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: hsl(var(--foreground));
}

.product-form-media__frame {
  width: 100%;
}

.product-image-preview--hero {
  width: 100%;
  max-width: none;
  aspect-ratio: 1;
  min-height: 10rem;
  margin: 0;
  border-radius: calc(var(--radius) + 2px);
  border: none;
  box-shadow: none;
  background: transparent;
}

.product-image-preview--hero img {
  object-fit: contain;
  padding: 0.5rem;
}

.product-form-media__actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  max-width: none;
  margin: 0;
  width: 100%;
}

.product-form-media__upload {
  width: 100%;
  justify-content: center;
  gap: 0.4rem;
}

.product-form-media__hint {
  margin: 0;
  text-align: center;
  font-size: 0.6875rem;
}

.product-form-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 400;
  cursor: pointer;
}

.product-form-check--remove {
  justify-content: center;
  color: hsl(var(--muted-foreground));
}

.product-form-shell--page .product-image-preview--hero {
  min-height: 12rem;
}

@media (min-width: 768px) {
  .product-form-shell--page .product-image-preview--hero {
    min-height: 14rem;
  }
}

.drawer-panel--wide .product-image-preview--hero {
  min-height: 11rem;
}

.product-form-description {
  min-height: 4.5rem;
}

.label--with-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.ui-field-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: hsl(var(--primary));
  font-size: 0.875rem;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  outline: none;
}

.ui-field-tip:hover,
.ui-field-tip:focus-visible {
  color: hsl(var(--primary) / 0.85);
}

.ui-field-tip__bubble {
  position: absolute;
  z-index: 50;
  bottom: calc(100% + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(17rem, 70vw);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--popover, var(--card)));
  color: hsl(var(--popover-foreground, var(--foreground)));
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 14px hsl(0 0% 0% / 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.ui-field-tip__bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: hsl(var(--border));
}

.ui-field-tip:hover .ui-field-tip__bubble,
.ui-field-tip:focus .ui-field-tip__bubble,
.ui-field-tip:focus-visible .ui-field-tip__bubble {
  opacity: 1;
  visibility: visible;
}

.product-unit-conversions-intro {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0 0.65rem;
  line-height: 1.5;
}

.product-unit-conversions__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.product-unit-conversions__head,
.product-unit-conversions__row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(5.5rem, 7rem) minmax(0, 1fr) minmax(0, 8.5rem) 2.5rem;
  gap: 0.5rem 0.65rem;
  align-items: start;
}

.product-unit-conversions__head {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
  padding-bottom: 0.35rem;
  border-bottom: 1px solid hsl(var(--border));
}

.product-unit-conversions__body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.product-unit-conversions__row {
  padding: 0.35rem 0;
  border-bottom: 1px dashed hsl(var(--border) / 0.6);
}

.product-unit-conversions__row:last-child {
  border-bottom: none;
}

.product-unit-conversions__cell--action {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.15rem;
}

.product-unit-conversions__add {
  margin-top: 0.15rem;
}

/* Tạm ẩn cột mã vạch — dữ liệu vẫn gửi qua input hidden */
.product-unit-conversions--hide-barcode .product-unit-conversions__head-barcode,
.product-unit-conversions--hide-barcode .product-unit-conversions__cell--barcode {
  display: none !important;
}

.product-unit-conversions--hide-barcode .product-unit-conversions__head,
.product-unit-conversions--hide-barcode .product-unit-conversions__row {
  grid-template-columns: minmax(0, 1.2fr) minmax(5.5rem, 7rem) minmax(0, 8.5rem) 2.5rem;
}

@media (max-width: 720px) {
  .product-unit-conversions__head {
    display: none;
  }

  .product-unit-conversions__row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "unit unit"
      "qty price"
      "barcode action";
    gap: 0.45rem;
  }

  .product-unit-conversions__row .product-unit-conversions__cell:nth-child(2) {
    grid-area: unit;
  }

  .product-unit-conversions__row .product-unit-conversions__cell:nth-child(3) {
    grid-area: qty;
  }

  .product-unit-conversions__row .product-unit-conversions__cell:nth-child(4) {
    grid-area: barcode;
  }

  .product-unit-conversions__row .product-unit-conversions__cell:nth-child(5) {
    grid-area: price;
  }

  .product-unit-conversions__row .product-unit-conversions__cell--action {
    grid-area: action;
  }

  .product-unit-conversions--hide-barcode .product-unit-conversions__row {
    grid-template-areas:
      "unit unit"
      "qty price"
      "action action";
  }

  .product-unit-conversions--hide-barcode .product-unit-conversions__row .product-unit-conversions__cell:nth-child(5) {
    grid-area: price;
  }
}

.product-form-grid {
  display: grid;
  gap: 0.65rem 0.85rem;
  align-items: start;
}

/* Mã + tên rộng; danh mục rộng; ĐVT vừa */
/* Hàng 1: mã + tên | Hàng 2: danh mục (rộng) + ĐVT (hẹp) */
.product-form-grid--identity {
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .product-form-grid--identity {
    grid-template-columns: minmax(9rem, 11rem) minmax(0, 2fr) minmax(0, 1fr) minmax(7.5rem, 10.5rem);
    grid-template-rows: auto auto;
  }

  .product-form-grid--identity .field--product-code {
    grid-column: 1;
    grid-row: 1;
  }

  .product-form-grid--identity .field--product-name {
    grid-column: 2 / 5;
    grid-row: 1;
  }

  .product-form-grid--identity .field--product-category {
    grid-column: 2 / 4;
    grid-row: 2;
  }

  .product-form-grid--identity .field--product-unit {
    grid-column: 4;
    grid-row: 2;
    max-width: none;
  }
}

/* NCC rộng — ngày / mã vạch vừa */
.product-form-grid--supplier {
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .product-form-grid--supplier {
    grid-template-columns: minmax(0, 1fr) minmax(10.5rem, 12.5rem) minmax(11rem, 14rem);
  }
}

/* Giá: cột hẹp; trạng thái & tồn vừa */
.product-form-grid--pricing {
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .product-form-grid--pricing {
    grid-template-columns: repeat(3, minmax(0, 10.5rem)) minmax(0, 1fr);
  }
}

@media (min-width: 720px) {
  .product-form-grid--pricing {
    grid-template-columns:
      minmax(0, 10.5rem)
      minmax(0, 10.5rem)
      minmax(0, 10.5rem)
      minmax(11rem, 16rem)
      minmax(0, 9rem)
      minmax(0, 9rem);
  }
}

.product-form-grid--notes {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .product-form-grid--notes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.product-form .field {
  gap: 0.35rem;
  min-width: 0;
}

.product-form .field-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
}

.product-form-pricing-hint {
  margin: 0.5rem 0 0;
}

.product-form .label {
  font-size: 0.8125rem;
}

.product-form .input,
.product-form .select {
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
  min-height: 2.25rem;
}

.product-form .textarea {
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
  min-height: 4.5rem;
  line-height: 1.45;
}

.product-form .input--money,
.product-form .input--qty {
  max-width: 11rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product-form .field--money .input,
.product-form .field--qty .input {
  width: 100%;
}

.product-form .field--date .input {
  max-width: 13rem;
}

.product-form .field--barcode .input {
  min-width: 0;
}

.product-form-actions {
  margin-top: 0.25rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--muted) / 0.2);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.drawer-form .alert {
  margin-bottom: 0.75rem;
}

.table .col-product-media {
  width: 5.5rem;
  padding-right: 0.35rem;
}

.product-thumb-btn {
  display: block;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: calc(var(--radius) + 2px);
  line-height: 0;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.product-thumb-btn:hover {
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.35);
  transform: scale(1.02);
}

.product-thumb-btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.product-thumb {
  width: 4rem;
  height: 4rem;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid hsl(var(--border));
  object-fit: contain;
  background: #fff;
  padding: 0.2rem;
  vertical-align: middle;
  display: block;
}

.product-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  color: hsl(var(--muted-foreground));
  font-size: 1.25rem;
  background: hsl(var(--muted) / 0.3);
  border: 1px dashed hsl(var(--border));
}

.product-name-link {
  font-weight: 500;
}

/* ——— System setup ——— */
.ui-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 1.25rem 0 0.75rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}

.ui-section-title:first-child {
  margin-top: 0;
}

.company-logo-field {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}

.company-logo-preview {
  width: 8rem;
  height: 8rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.35);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0.5rem;
}

.company-logo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.company-logo-placeholder {
  color: hsl(var(--muted-foreground));
  font-size: 2rem;
}

.company-logo-controls {
  flex: 1;
  min-width: 14rem;
}

/* ——— System setup ——— */
.system-setup.ui-page {
  padding-top: 0.75rem;
  padding-bottom: 1.25rem;
}

.system-setup-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.system-setup-alerts .alert {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.system-setup-errors-list {
  margin: 0;
  padding-left: 1.1rem;
}

.system-setup-card .card-content {
  padding: 1rem 1.25rem;
}

.system-setup-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Logo — ngang, preview lớn */
.system-setup-logo-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem 1.5rem;
  padding: 1rem 1.125rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.2);
}

.system-setup-logo-preview-wrap {
  flex-shrink: 0;
}

.system-setup-logo-preview.company-logo-preview {
  width: 10.5rem;
  height: 10.5rem;
  padding: 0.625rem;
}

.system-setup-logo-preview .company-logo-placeholder {
  font-size: 2.75rem;
}

.system-setup-logo-side {
  flex: 1;
  min-width: min(100%, 16rem);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.system-setup-logo-side .system-setup-section-label {
  font-size: 0.875rem;
  text-transform: none;
  letter-spacing: normal;
  color: hsl(var(--foreground));
}

.system-setup-section-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
}

.system-setup-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: hsl(var(--foreground));
  cursor: pointer;
}

.system-setup-meta {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Form — lưới ngang, ít cuộn dọc */
.system-setup-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.system-setup-fields-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  padding-top: 0.5rem;
  margin-top: 0.25rem;
  border-top: 1px solid hsl(var(--border));
}

.system-setup-fields-head:first-child {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.system-setup-prefix-hint {
  margin: 0;
  font-size: 0.75rem;
}

.system-setup-fields-grid {
  gap: 0.5rem 0.875rem;
}

.system-setup-fields-grid--3 {
  grid-template-columns: 1fr;
}

.system-setup-fields-grid--4,
.system-setup-fields-grid--prefix {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .system-setup-fields-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .system-setup-fields-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .system-setup-fields-grid--prefix {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .system-setup-field-span-2 {
    grid-column: span 2;
  }
}

@media (min-width: 1100px) {
  .system-setup-fields-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .system-setup-fields-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .system-setup-fields-grid--prefix {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .system-setup-field-span-2 {
    grid-column: span 2;
  }
}

.system-setup-fields-grid .input-mono {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

.system-setup-footer-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.75rem;
  margin-top: 0.25rem;
  border-top: 1px solid hsl(var(--border));
}

/* ——— Profile ——— */
.profile-page.ui-page {
  padding-top: 0.75rem;
  padding-bottom: 1.25rem;
}

.profile-page-alert {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.profile-page-alert--info {
  background: hsl(var(--muted) / 0.35);
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

.profile-errors-list {
  margin: 0;
  padding-left: 1.1rem;
}

.profile-admin-staff-link {
  margin-left: 0.35rem;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  color: hsl(var(--primary));
  text-decoration: underline;
  cursor: pointer;
}

.profile-card .card-content {
  padding: 1rem 1.25rem;
}

.profile-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.profile-avatar-wrap {
  flex-shrink: 0;
}

.profile-avatar-img,
.profile-avatar-fallback {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}

.profile-avatar-img {
  object-fit: cover;
  display: block;
}

.profile-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  font-size: 1.5rem;
  font-weight: 600;
}

.profile-name {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.profile-username {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
}

.profile-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.profile-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.profile-section-title {
  margin: 0 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: hsl(var(--muted-foreground));
}

.profile-dl--grid {
  display: grid;
  gap: 0.5rem 1rem;
  margin: 0;
}

@media (min-width: 640px) {
  .profile-dl--grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .profile-dl--grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.profile-dl-item {
  margin: 0;
}

.profile-dl-item dt {
  margin: 0 0 0.15rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.profile-dl-item dd {
  margin: 0;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
}

.profile-form-grid {
  gap: 0.5rem 0.875rem;
}

.profile-form-actions {
  margin-top: 0.75rem;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.text-required {
  color: hsl(var(--destructive));
}

.so-index-cashbook-pay {
  min-width: 11rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  vertical-align: top;
}

.so-index-cashbook-pay__block {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.so-index-cashbook-pay__row {
  display: block;
}

.so-index-cashbook-pay__time {
  margin-top: 0.15rem;
  font-size: 0.75rem;
  line-height: 1.3;
  font-weight: 400;
}

.so-index-cashbook-pay__row--debt span:first-child {
  margin-right: 0.25rem;
}
