:root {
  --bg: #f4f6f0;
  --surface: #ffffff;
  --surface-alt: #eef3e6;
  --line: #dce4d1;
  --text: #19311d;
  --muted: #627466;
  --accent: #2d8f4e;
  --accent-deep: #205e38;
  --warn: #da7b2e;
  --danger: #ca4b45;
  --shadow: 0 18px 40px rgba(24, 49, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(118, 165, 91, 0.18), transparent 24rem),
    linear-gradient(180deg, #f7f9f5 0%, var(--bg) 100%);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
}

.layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px 16px;
  border-right: 1px solid rgba(25, 49, 29, 0.08);
  background: rgba(23, 42, 27, 0.96);
  color: #f3f8f0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand h1,
.brand p,
.topbar h2,
.hero h3,
.card h3,
.panel-header h3,
.login-card h2 {
  margin: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #8bd05f, #3ea864);
  color: #102114;
  font-weight: 700;
  font-size: 1.2rem;
}

.brand p,
.muted,
.metric-card small,
.eyebrow {
  color: var(--muted);
}

.brand p {
  color: rgba(243, 248, 240, 0.68);
}

.nav {
  display: grid;
  gap: 8px;
}

.mobile-nav {
  display: none;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.nav-item,
.ghost-button,
.primary-button {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
}

.nav-item {
  padding: 12px 14px;
  text-align: left;
  background: transparent;
  color: rgba(243, 248, 240, 0.82);
}

.nav-item:hover,
.nav-item.active {
  background: rgba(139, 208, 95, 0.16);
  color: #ffffff;
}

.mobile-nav .nav-item {
  flex: 0 0 auto;
  background: var(--surface);
  color: var(--accent-deep);
  border: 1px solid var(--line);
}

.mobile-nav .nav-item.active,
.mobile-nav .nav-item:hover {
  background: rgba(45, 143, 78, 0.12);
  color: var(--accent-deep);
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar,
.panel-header,
.card-header,
.hero,
.topbar-actions,
.status-item,
.list-row,
.search-box,
.form-actions,
.inventory-toolbar,
.sales-mode-switch {
  display: flex;
  align-items: center;
}

.topbar,
.panel-header,
.card-header,
.hero,
.status-item,
.list-row {
  justify-content: space-between;
}

.topbar {
  gap: 16px;
  margin-bottom: 20px;
}

.topbar-actions,
.inventory-toolbar,
.sales-mode-switch {
  gap: 12px;
}

.global-search {
  position: relative;
  width: min(360px, 32vw);
}

.global-search input {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
}

.global-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(520px, 80vw);
  max-height: 380px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.global-result {
  width: 100%;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.global-result:hover {
  background: var(--surface-alt);
}

.global-result span {
  color: var(--muted);
  font-size: 0.85rem;
}

.inventory-toolbar,
.sales-mode-switch {
  margin: 14px 0 18px;
}

.dashboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dashboard-head h3 {
  margin: 0;
  font-size: 1.45rem;
}

.dashboard-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border: 1px solid rgba(224, 194, 59, 0.46);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
}

.dashboard-tabs button {
  padding: 10px 28px;
  border-radius: 999px;
  border: 0;
}

.dashboard-board {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.35fr);
  grid-template-areas:
    "stock sales"
    "purchase sales"
    "finance finance";
  align-items: stretch;
  gap: 14px;
}

.board-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(220, 228, 209, 0.74);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.board-section-stock {
  grid-area: stock;
}

.board-section-sales {
  grid-area: sales;
}

.board-section-purchase {
  grid-area: purchase;
}

.board-section-finance {
  grid-area: finance;
}

.board-section-title,
.board-title-line,
.board-title-line > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.board-title-line {
  justify-content: space-between;
}

.board-section-title span,
.board-title-line > div span {
  width: 6px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f36f42, #f2b03f);
}

.board-section-title h3,
.board-title-line h3 {
  margin: 0;
  font-size: 1.08rem;
}

.board-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.board-metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.board-section-finance .board-metric-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.board-section-purchase .board-metric-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.board-metric {
  display: grid;
  gap: 6px;
  min-height: 78px;
  padding: 13px 14px;
  border: 0;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  background: rgba(247, 248, 252, 0.9);
}

.board-metric.warm {
  background: rgba(255, 251, 225, 0.72);
}

.board-metric.danger-soft {
  background: rgba(255, 241, 238, 0.82);
}

.board-metric span {
  color: #1d2c20;
  font-size: 0.9rem;
}

.board-metric strong {
  font-size: 1.45rem;
  line-height: 1;
  color: #07190d;
}

.board-metric.warm strong,
.board-metric.danger-soft strong {
  color: #c8961c;
}

.board-metric.link-like {
  cursor: pointer;
}

.board-metric.link-like strong {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.purchase-order-link {
  padding: 0;
  text-align: left;
  color: var(--accent-deep);
  font-weight: 600;
}

#purchase .detail-table-wrap tbody tr[data-purchase-detail] {
  cursor: pointer;
}

#purchase .detail-table-wrap tbody tr[data-purchase-detail]:hover {
  background: rgba(45, 143, 78, 0.05);
}

.sell-through {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(250, 250, 248, 0.96);
}

.sell-through span {
  color: #1d2c20;
  font-size: 1.05rem;
}

.sell-through strong {
  color: #2671b8;
  font-size: 1.6rem;
}

.sell-through em {
  padding: 6px 12px;
  font-style: normal;
  color: #d18c00;
  background: rgba(255, 241, 164, 0.46);
}

.inventory-filter-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
}

.purchase-filter-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
}

.inventory-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 12px;
}

.purchase-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.profit-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.filter-field,
.page-size-field {
  display: grid;
  gap: 6px;
}

.filter-field {
  position: relative;
}

.filter-field span,
.page-size-field span {
  color: var(--muted);
  font-size: 0.86rem;
}

.filter-field-wide {
  grid-column: span 2;
}

.inventory-filter-actions,
.table-footer,
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inventory-filter-actions {
  justify-content: flex-end;
}

.sales-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.sales-workflow {
  display: grid;
  gap: 18px;
}

.sales-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.sales-info-grid label {
  display: grid;
  gap: 8px;
}

.sales-entry-textarea {
  display: grid;
  gap: 8px;
}

.sales-draft-wrap {
  display: grid;
  gap: 12px;
}

.sales-draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profit-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.profit-summary-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.76);
}

.profit-summary-card strong {
  font-size: 1.25rem;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-line span {
  color: var(--muted);
  white-space: nowrap;
}

.operation-log-list {
  display: grid;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.operation-log-row {
  display: grid;
  grid-template-columns: 150px 120px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.operation-log-row:last-child {
  border-bottom: 0;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.detail-modal.hidden-block {
  display: none;
}

.detail-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 24, 14, 0.38);
}

.detail-modal-panel {
  position: relative;
  z-index: 1;
  max-height: 86vh;
  overflow: auto;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(10, 24, 14, 0.24);
}

.detail-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-modal-header h3 {
  margin: 0;
}

.detail-grid-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-field {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-alt);
}

.server-tag {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(45, 143, 78, 0.1);
  color: var(--accent-deep);
  font-size: 0.92rem;
}

.ghost-button {
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}

.primary-button {
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), #3eb565);
  color: #fff;
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.active-toggle {
  border-color: var(--accent);
  background: rgba(45, 143, 78, 0.1);
  color: var(--accent-deep);
}

.panel {
  display: none;
  min-width: 0;
}

.panel.active {
  display: block;
}

.hero {
  gap: 20px;
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(234, 241, 227, 0.92));
  box-shadow: var(--shadow);
}

.hero h3 {
  font-size: clamp(1.7rem, 2vw, 2.4rem);
  max-width: 14ch;
}

.hero-grid,
.dashboard-grid,
.split-grid,
.detail-grid,
.config-grid,
.form-grid,
.form-grid-4 {
  display: grid;
  gap: 18px;
}

.hero-grid {
  flex: 1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-grid {
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-grid {
  grid-template-columns: 1fr;
  min-width: 0;
}

.config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.metric-card,
.card,
.login-card {
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card strong {
  font-size: 2rem;
  color: var(--accent);
}

.metric-card.warning strong {
  color: var(--warn);
}

.card,
.login-card {
  padding: 20px;
}

.card,
.detail-card {
  min-width: 0;
}

.card-header {
  margin-bottom: 12px;
}

.span-2 {
  grid-column: span 2;
}

.wide {
  grid-column: span 4;
}

.status-list,
.stack-list,
.todo-list,
.check-list,
.order-list {
  display: grid;
  gap: 12px;
}

.config-list {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.66);
}

.config-list-head,
.config-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.config-list-head {
  padding: 10px 12px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.9rem;
}

.config-list-body {
  display: grid;
  max-height: 220px;
  overflow-y: auto;
}

.config-list-row {
  min-height: 44px;
  padding: 8px 10px 8px 12px;
  border-top: 1px solid var(--line);
}

.config-list-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-config {
  margin: 0;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(202, 75, 69, 0.08);
}

.danger-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status-item,
.list-row {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
}

.todo-list,
.check-list,
.order-list {
  margin: 0;
  padding-left: 20px;
}

.todo-list li,
.check-list li,
.order-list li {
  line-height: 1.7;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.inventory-table-card {
  padding: 18px 22px;
}

.inventory-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.detail-table-wrap {
  width: 100%;
  max-width: 100%;
  height: clamp(360px, 58vh, 680px);
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

.sales-draft-table-wrap {
  width: 100%;
  max-width: 100%;
  max-height: min(52vh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
}

.inventory-table-wrap table {
  width: 100%;
  min-width: 1100px;
  table-layout: fixed;
}

.detail-table-wrap table {
  width: max-content;
  min-width: 1180px;
}

#purchase .detail-table-wrap table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
}

#reports .detail-table-wrap table {
  min-width: 2020px;
}

.sales-draft-table-wrap table {
  min-width: 1420px;
}

.inventory-table-wrap thead th,
.detail-table-wrap thead th,
.sales-draft-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.inventory-table-wrap th,
.inventory-table-wrap td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-table-wrap tbody tr:hover {
  background: rgba(45, 143, 78, 0.045);
}

th {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.86rem;
  background: rgba(45, 143, 78, 0.1);
  color: var(--accent-deep);
}

.badge.warning {
  background: rgba(218, 123, 46, 0.14);
  color: #9a5419;
}

.badge.danger {
  background: rgba(202, 75, 69, 0.12);
  color: #962d29;
}

.search-box {
  justify-content: flex-end;
}

.search-box input,
.filter-field input,
.filter-field select,
.page-size-field select,
.sales-info-grid input,
.sales-info-grid select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.inline-actions select {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.table-footer {
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.empty-table-cell {
  padding: 42px 12px;
  text-align: center;
  color: var(--muted);
}

.action-cell {
  min-width: 150px;
}

.draft-sale-amount-input {
  min-width: 120px;
}

.inline-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.row-action-button {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1;
  white-space: nowrap;
}

.compact-button {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.payment-actions {
  min-width: 150px;
}

.payment-actions select {
  min-width: 82px;
  padding: 6px 8px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 33, 20, 0.44);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.overlay.hidden,
.hidden-block {
  display: none !important;
}

.login-card {
  width: min(100%, 460px);
}

.form-grid label {
  display: grid;
  gap: 8px;
  position: relative;
}

.form-grid label span {
  font-size: 0.92rem;
  color: var(--muted);
}

.form-actions {
  gap: 12px;
}

.form-message {
  margin: 0;
  color: var(--muted);
}

.template-import-panel,
.template-delete-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.subsection-header {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.subsection-header h4,
.subsection-header p {
  margin: 0;
}

.template-delete-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.danger-action {
  color: var(--danger);
}

.danger-action:hover {
  border-color: var(--danger);
  background: rgba(202, 75, 69, 0.08);
}

@media (max-width: 1100px) {
  .layout,
  .dashboard-grid,
  .split-grid,
  .detail-grid,
  .config-grid,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
  }

  .hero {
    flex-direction: column;
  }

  .dashboard-head {
    flex-direction: column;
    align-items: stretch;
  }

  .dashboard-board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stock"
      "sales"
      "purchase"
      "finance";
  }

  .hero-grid {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .board-metric-grid,
  .board-metric-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .board-section-purchase .board-metric-grid.compact,
  .board-section-finance .board-metric-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inventory-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purchase-filter-grid {
    grid-template-columns: 1fr;
  }

  .profit-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-2,
  .wide {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .topbar-actions,
  .form-actions,
  .inventory-toolbar,
  .inventory-filter-actions,
  .table-footer,
  .pagination-controls,
  .sales-mode-switch {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .global-search {
    width: 100%;
  }

  .global-search-results {
    left: 0;
    right: auto;
    width: 100%;
  }

  .inventory-filter-grid {
    grid-template-columns: 1fr;
  }

  .purchase-filter-grid {
    grid-template-columns: 1fr;
  }

  .profit-filter-grid {
    grid-template-columns: 1fr;
  }

  .board-metric-grid,
  .board-metric-grid.compact {
    grid-template-columns: 1fr;
  }

  .board-section-purchase .board-metric-grid.compact,
  .board-section-finance .board-metric-grid.compact {
    grid-template-columns: 1fr;
  }

  .dashboard-tabs button {
    padding: 10px 16px;
  }

  .filter-field-wide {
    grid-column: auto;
  }

  .detail-table-wrap {
    height: 58vh;
  }

  .sales-entry-row {
    grid-template-columns: 1fr;
  }

  .sales-info-grid {
    grid-template-columns: 1fr;
  }

  .profit-summary-grid,
  .detail-grid-list {
    grid-template-columns: 1fr;
  }

  .operation-log-row {
    grid-template-columns: 1fr;
  }
}


.login-page-body {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 42, 27, 0.96), rgba(28, 72, 43, 0.92)),
    linear-gradient(180deg, #f7f9f5 0%, var(--bg) 100%);
}

.login-page-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 460px);
  gap: 48px;
  align-items: center;
  width: min(1120px, calc(100vw - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 0;
}

.login-visual {
  color: #f3f8f0;
}

.login-brand-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 42px;
}

.login-brand-row h1,
.login-brand-row p,
.login-panel h2,
.login-subtitle {
  margin: 0;
}

.login-brand-row p {
  color: rgba(243, 248, 240, 0.72);
}

.login-dashboard-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 560px;
}

.preview-stat,
.preview-line {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16);
}

.preview-stat {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 20px;
}

.preview-stat.wide {
  grid-column: 1 / -1;
}

.preview-stat span,
.preview-stat small {
  color: rgba(243, 248, 240, 0.7);
}

.preview-stat strong {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.preview-line {
  height: 16px;
  border-radius: 999px;
}

.preview-line.short {
  width: 68%;
}

.login-panel {
  padding: 32px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(5, 18, 9, 0.24);
}

.login-panel h2 {
  margin-top: 6px;
  font-size: 2rem;
}

.login-subtitle {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.login-form input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfcfa;
  color: var(--text);
}

.login-form input:focus {
  outline: 3px solid rgba(45, 143, 78, 0.16);
  border-color: var(--accent);
}

.login-form .primary-button {
  min-height: 48px;
}

.form-message[data-type="success"] {
  color: var(--accent-deep);
}

.form-message[data-type="error"] {
  color: var(--danger);
}

@media (max-width: 860px) {
  .login-page-shell {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .login-visual {
    display: none;
  }
}

@media (max-width: 520px) {
  .login-page-shell {
    width: min(100% - 24px, 460px);
    padding: 24px 0;
  }

  .login-panel {
    padding: 24px;
  }
}

/* Profit report v3 workbench */
.reports-page-header {
  margin-bottom: 16px;
}

.profit-workbench {
  display: grid;
  gap: 14px;
}

.profit-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.profit-kpi-card {
  position: relative;
  min-height: 112px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profit-kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #c6d3e4;
}

.profit-kpi-card.primary::before {
  background: var(--accent);
}

.profit-kpi-card.success::before {
  background: var(--success);
}

.profit-kpi-card span,
.profit-summary-card > span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.profit-kpi-card strong {
  display: block;
  margin-top: 18px;
  color: var(--text);
  font-size: 1.55rem;
  line-height: 1;
  font-weight: 850;
}

.profit-kpi-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted-soft);
  font-size: 0.8rem;
  font-weight: 750;
}

#reports .profit-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

#reports .profit-summary-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

#reports .summary-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 30px;
  margin-top: 8px;
}

#reports .summary-line strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reports .summary-line span,
#reports .summary-line em {
  color: var(--muted);
  font-size: 0.84rem;
  font-style: normal;
  font-weight: 750;
  white-space: nowrap;
}

#reports .summary-line em {
  color: var(--accent);
}

.profit-filter-panel {
  position: relative;
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.profit-filter-head,
.profit-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.profit-filter-head h3,
.profit-table-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 850;
}

.profit-filter-head p,
.profit-table-head p {
  margin: 4px 0 0;
  font-size: 0.8rem;
}

.profit-filter-head .ghost-button {
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
}

#reports .profit-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(132px, 1fr));
  gap: 8px 10px;
}

#reports .filter-field {
  gap: 4px;
}

#reports .filter-field-wide {
  grid-column: span 2;
}

#reports .filter-field input,
#reports .filter-field select,
#reports .custom-select-trigger {
  min-height: 34px;
  background: var(--surface-soft);
  font-weight: 750;
}

#reports .v3-date-input {
  min-height: 34px;
  padding-right: 34px;
  color: #273448;
  background:
    linear-gradient(45deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    var(--surface-soft);
  cursor: pointer;
}

#reports .v3-date-input:focus {
  border-color: rgba(15, 75, 255, 0.72);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
  outline: none;
}

.profit-table-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profit-table-head {
  padding: 16px 18px 12px;
}

#reports .detail-table-wrap {
  height: clamp(340px, calc(100vh - 488px), 660px);
  border-right: 0;
  border-left: 0;
  border-radius: 0;
}

#reports .detail-table-wrap table {
  min-width: 1840px;
}

#reports .table-footer {
  border-top: 1px solid #eef2f7;
}

#reports .payment-actions .custom-select {
  min-width: 86px;
}

@media (max-width: 1180px) {
  .profit-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #reports .profit-summary-grid {
    grid-template-columns: 1fr;
  }

  #reports .profit-filter-grid {
    grid-template-columns: repeat(3, minmax(132px, 1fr));
  }
}

@media (max-width: 820px) {
  .reports-page-header,
  .profit-filter-head,
  .profit-table-head,
  #reports .table-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .profit-kpi-grid,
  #reports .profit-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #reports .filter-field-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .profit-kpi-grid,
  #reports .profit-filter-grid {
    grid-template-columns: 1fr;
  }

  #reports .summary-line {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  #reports .summary-line em {
    grid-column: 1 / -1;
  }
}

/* V3 premium operations UI */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-soft: #fbfdff;
  --line: #e2e8f0;
  --line-strong: #d7e0ec;
  --text: #111827;
  --muted: #66758a;
  --muted-soft: #8a97a8;
  --accent: #0f4bff;
  --accent-deep: #0b3cc8;
  --accent-soft: #edf4ff;
  --teal: #11a39b;
  --teal-soft: #e6f8f5;
  --warn: #d88a13;
  --warn-soft: #fff4dc;
  --danger: #d64d59;
  --danger-soft: #ffe7eb;
  --success: #16845a;
  --success-soft: #e8f7ef;
  --shadow: 0 14px 34px rgba(21, 32, 51, 0.07);
  --shadow-strong: 0 24px 70px rgba(17, 24, 39, 0.16);
  --radius: 8px;
}

html {
  background: var(--bg);
}

body {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(244, 247, 251, 0.76)),
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

button {
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

input,
select,
textarea {
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 75, 255, 0.12);
  border-color: rgba(15, 75, 255, 0.58) !important;
}

.layout {
  grid-template-columns: 216px minmax(0, 1fr);
  background: transparent;
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  box-shadow: 1px 0 0 rgba(226, 232, 240, 0.52);
}

.brand {
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #eef2f7;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), var(--teal));
  color: #ffffff;
  font-size: 1.05rem;
  box-shadow: 0 12px 24px rgba(15, 75, 255, 0.2);
}

.brand h1 {
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 850;
}

.brand p {
  margin-top: 4px;
  color: var(--muted-soft);
  font-size: 0.82rem;
}

.nav {
  gap: 6px;
}

.nav-item {
  position: relative;
  min-height: 40px;
  padding: 0 14px 0 36px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 700;
}

.nav-item::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  transform: translateY(-50%);
  opacity: 0.82;
}

.nav-item::after {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  width: 3px;
  height: 20px;
  border-radius: 999px;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.active::after {
  background: var(--accent);
}

.main {
  padding: 26px 28px 40px;
}

.topbar {
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.topbar h2,
.panel-header h3,
.dashboard-head h3 {
  color: var(--text);
  font-weight: 850;
}

.topbar h2 {
  font-size: 1.62rem;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.global-search {
  width: min(420px, 31vw);
}

.global-search input {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.global-search-results {
  border-color: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
}

.global-result {
  border-radius: var(--radius);
}

.global-result:hover {
  background: var(--accent-soft);
}

.server-tag {
  min-height: 34px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: #526176;
  font-size: 0.88rem;
  font-weight: 700;
}

.mobile-nav {
  padding-bottom: 4px;
}

.mobile-nav .nav-item {
  padding: 10px 14px 10px 32px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
}

.mobile-nav .nav-item.active,
.mobile-nav .nav-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.panel-header {
  min-height: 58px;
  margin-bottom: 16px;
}

.panel-header h3 {
  font-size: 1.35rem;
}

.dashboard-head {
  margin-bottom: 16px;
}

.dashboard-tabs,
.sales-mode-switch {
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}

.dashboard-tabs button {
  padding: 9px 18px;
  border-radius: var(--radius);
}

.ghost-button,
.primary-button,
.active-toggle {
  min-height: 36px;
  border-radius: var(--radius);
  font-weight: 800;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: #273448;
  text-decoration: none;
}

.ghost-button:hover {
  border-color: #b9c6d8;
  background: var(--surface-alt);
  box-shadow: 0 8px 18px rgba(21, 32, 51, 0.06);
}

.primary-button {
  padding: 10px 15px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 75, 255, 0.18);
}

.primary-button:hover {
  background: var(--accent-deep);
}

.active-toggle {
  border-color: transparent !important;
  background: var(--accent) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(15, 75, 255, 0.16);
}

.text-button {
  color: var(--accent);
  font-weight: 800;
}

.text-button:hover {
  color: var(--accent-deep);
}

.dashboard-board {
  grid-template-columns: minmax(340px, 0.95fr) minmax(520px, 1.35fr);
  gap: 16px;
}

.board-section,
.card,
.metric-card,
.login-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.board-section {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

.board-section::before,
.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  opacity: 0.9;
}

.board-section-title span,
.board-title-line > div span {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  position: relative;
}

.board-section-title span::after,
.board-title-line > div span::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 999px;
  background: var(--accent);
}

.board-section-sales .board-section-title span::after,
.board-section-sales .board-title-line > div span::after {
  background: var(--teal);
}

.board-section-purchase .board-section-title span::after {
  background: var(--warn);
}

.board-section-finance .board-section-title span::after {
  background: var(--success);
}

.board-section-title h3,
.board-title-line h3 {
  font-size: 1.02rem;
  font-weight: 850;
}

.board-metric {
  position: relative;
  min-height: 86px;
  padding: 14px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.board-metric:hover {
  border-color: #d6e1f0;
  background: #ffffff;
}

.board-metric.warm {
  background: var(--warn-soft);
}

.board-metric.danger-soft {
  background: var(--danger-soft);
}

.board-metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.board-metric strong {
  color: var(--text);
  font-size: 1.58rem;
  font-weight: 850;
}

.board-metric.warm strong {
  color: #9a5b00;
}

.board-metric.danger-soft strong {
  color: #a93640;
}

.board-metric.link-like strong {
  text-decoration: none;
}

.sell-through {
  justify-content: space-between;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #d8f0ec;
  border-radius: var(--radius);
  background: var(--teal-soft);
}

.sell-through span {
  color: #04756f;
  font-size: 0.95rem;
  font-weight: 800;
}

.sell-through strong {
  color: #04756f;
  font-size: 1.72rem;
}

.sell-through em {
  border-radius: 999px;
  color: #04756f;
  background: #ffffff;
  font-weight: 800;
}

.inventory-toolbar,
.sales-mode-switch {
  margin: 0 0 16px;
}

.inventory-filter-panel,
.purchase-filter-panel {
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.inventory-filter-grid {
  grid-template-columns: repeat(6, minmax(122px, 1fr));
  gap: 12px;
}

.purchase-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.profit-filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.filter-field,
.page-size-field,
.sales-info-grid label,
.sales-entry-row label,
.sales-entry-textarea,
.login-form label {
  gap: 7px;
}

.filter-field span,
.page-size-field span,
.form-grid label span,
.sales-info-grid label span,
.sales-entry-row label span,
.sales-entry-textarea span,
.login-form label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.search-box input,
.filter-field input,
.filter-field select,
.page-size-field select,
.sales-info-grid input,
.sales-info-grid select,
.sales-entry-row input,
.sales-entry-textarea textarea,
.form-grid input,
.form-grid select,
.form-grid textarea,
.inline-actions select,
.login-form input {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
}

.form-grid textarea,
.sales-entry-textarea textarea {
  min-height: 96px;
  resize: vertical;
}

.inventory-filter-actions {
  justify-content: flex-end;
}

.card,
.login-card {
  padding: 20px;
  border-radius: var(--radius);
}

.inventory-table-card {
  padding: 0;
  overflow: hidden;
}

.card-header {
  min-height: 34px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eef2f7;
}

.card h3 {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
}

.form-card + .form-card,
.detail-grid,
.config-grid,
.dashboard-grid {
  margin-top: 16px;
}

.form-grid,
.form-grid-4,
.hero-grid,
.dashboard-grid,
.split-grid,
.detail-grid,
.config-grid {
  gap: 16px;
}

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

.config-grid {
  align-items: start;
}

.profit-summary-grid {
  gap: 12px;
}

.profit-summary-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.profit-summary-card strong {
  color: var(--text);
  font-size: 1.38rem;
  font-weight: 850;
}

.summary-line span {
  color: var(--muted);
  font-weight: 700;
}

.table-wrap {
  border-radius: var(--radius);
}

.inventory-table-wrap,
.detail-table-wrap,
.sales-draft-table-wrap {
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: #ffffff;
}

.inventory-table-wrap {
  border-radius: 0;
  border-width: 1px 0;
}

.detail-table-wrap {
  height: clamp(360px, 56vh, 660px);
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

.inventory-table-wrap thead th,
.detail-table-wrap thead th,
.sales-draft-table-wrap thead th {
  background: #f8fafc;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid #eef2f7;
}

th {
  color: #728094;
  font-size: 0.78rem;
  font-weight: 850;
}

td {
  color: #344258;
  font-size: 0.9rem;
}

tbody tr {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

.inventory-table-wrap tbody tr:hover,
.detail-table-wrap tbody tr:hover,
.sales-draft-table-wrap tbody tr:hover,
#purchase .detail-table-wrap tbody tr[data-purchase-detail]:hover {
  background: #f7fbff;
}

.table-footer {
  padding: 13px 16px;
  border-top: 0;
  color: var(--muted);
}

.inventory-table-card .table-footer {
  border-top: 1px solid #eef2f7;
}

.pagination-controls {
  flex-wrap: wrap;
}

.page-size-field {
  grid-template-columns: auto 90px;
  align-items: center;
}

.badge {
  padding: 5px 10px;
  border-radius: 7px;
  background: #dbf8f2;
  color: #04756f;
  font-size: 0.82rem;
  font-weight: 850;
}

.badge.warning {
  background: #fff1cf;
  color: #8d5b00;
}

.badge.danger {
  background: var(--danger-soft);
  color: #b83945;
}

.empty-table-cell {
  padding: 46px 14px;
  color: var(--muted);
  background: #ffffff;
}

.row-action-button,
.compact-button {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.82rem;
}

.danger-action {
  color: var(--danger);
}

.danger-action:hover {
  border-color: rgba(214, 77, 89, 0.46);
  background: var(--danger-soft);
}

.sales-entry-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.sales-entry-row label {
  display: grid;
  gap: 7px;
}

.sales-workflow {
  gap: 16px;
}

.sales-info-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.sales-draft-wrap {
  gap: 12px;
}

.sales-draft-head {
  padding: 0 2px;
}

.sales-draft-head strong {
  color: var(--text);
  font-size: 1rem;
}

.config-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.config-list-head {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
}

.config-list-row {
  border-top-color: #eef2f7;
}

.icon-button {
  border-color: var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
}

.icon-button:hover {
  border-color: rgba(214, 77, 89, 0.46);
  color: var(--danger);
  background: var(--danger-soft);
}

.operation-log-list {
  border-color: var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.operation-log-row {
  border-bottom-color: #eef2f7;
}

.status-item,
.list-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.todo-list,
.check-list,
.order-list {
  padding-left: 22px;
}

.todo-list li,
.check-list li,
.order-list li {
  color: #344258;
}

.detail-modal {
  backdrop-filter: blur(6px);
}

.detail-modal-backdrop {
  background: rgba(17, 24, 39, 0.48);
}

.detail-modal-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-strong);
}

.detail-modal-header {
  padding-bottom: 14px;
  border-bottom: 1px solid #eef2f7;
}

.detail-modal-header h3 {
  color: var(--text);
  font-size: 1.18rem;
  font-weight: 850;
}

.detail-modal-body {
  padding-top: 16px;
}

.detail-grid-list {
  gap: 10px;
}

.detail-field {
  padding: 12px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.detail-field span,
.detail-field small {
  color: var(--muted);
  font-weight: 700;
}

.form-actions {
  flex-wrap: wrap;
}

.form-message {
  color: var(--muted);
  font-size: 0.9rem;
}

.template-import-panel,
.template-delete-panel {
  border-top-color: #eef2f7;
}

.subsection-header h4 {
  color: var(--text);
  font-size: 1rem;
}

.subsection-header p,
.muted {
  color: var(--muted);
}

.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 124px;
  padding: 18px;
  overflow: hidden;
}

.metric-card strong {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 850;
}

.metric-card.warning strong {
  color: var(--warn);
}

.inline-actions {
  flex-wrap: wrap;
}

.payment-actions select {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 7px;
}

.login-page-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 18%, rgba(15, 75, 255, 0.22), transparent 28rem),
    radial-gradient(circle at 76% 72%, rgba(17, 163, 155, 0.18), transparent 30rem),
    linear-gradient(135deg, #f8fafc 0%, #eef3f8 100%);
}

.login-page-shell {
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 440px);
  gap: 54px;
}

.login-visual {
  color: var(--text);
}

.login-brand-row {
  margin-bottom: 34px;
}

.login-brand-row h1 {
  color: var(--text);
  font-size: 1.42rem;
  font-weight: 850;
}

.login-brand-row p {
  color: var(--muted);
}

.login-dashboard-preview {
  max-width: 560px;
  gap: 14px;
}

.preview-stat,
.preview-line {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.preview-stat {
  min-height: 126px;
}

.preview-stat span,
.preview-stat small {
  color: var(--muted);
  font-weight: 700;
}

.preview-stat strong {
  color: var(--text);
  font-weight: 850;
}

.preview-line {
  background: linear-gradient(90deg, var(--accent), var(--teal));
  opacity: 0.78;
}

.login-panel {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-strong);
}

.login-panel h2 {
  color: var(--text);
  font-weight: 850;
}

.login-subtitle {
  color: var(--muted);
}

.login-form .primary-button {
  min-height: 46px;
}

.form-message[data-type="success"] {
  color: var(--success);
}

.form-message[data-type="error"] {
  color: var(--danger);
}

#sales .sales-page-header {
  margin-bottom: 16px;
}

#sales .sales-workbench {
  display: grid;
  min-width: 0;
}

#sales .sales-console {
  padding: 0;
  overflow: hidden;
  min-height: 0;
  border: 1px solid #dde6f0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.07);
}

#sales .sales-console-head {
  min-height: auto;
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid #e8eef6;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

#sales .sales-console-head h3 {
  font-size: 1.04rem;
}

#sales .sales-mode-switch {
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 1px solid #d9e5f2;
  border-radius: 8px;
  background: #eef5ff;
}

#sales .sales-mode-switch .ghost-button {
  min-height: 32px;
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #58708c;
  font-size: 0.88rem;
  font-weight: 800;
}

#sales .sales-mode-switch .active-toggle {
  background: #0f6fff;
  color: #ffffff;
  box-shadow: 0 7px 18px rgba(15, 111, 255, 0.22);
}

#sales .sales-workflow {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  height: clamp(680px, calc(100vh - 178px), 920px);
  min-height: 0;
}

#sales .sales-form-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.35fr);
  align-items: start;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid #e8eef6;
  background: #fbfdff;
}

#sales .sales-entry-panel,
#sales .sales-order-panel {
  display: grid;
  gap: 12px;
}

#sales .sales-entry-panel {
  padding: 0;
  border-bottom: 0;
}

#sales .sales-entry-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

#sales .sales-entry-actions {
  display: grid;
  gap: 8px;
}

#sales .sales-entry-row .ghost-button,
#sales .sales-file-import-button,
#sales .sales-draft-head .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  white-space: nowrap;
}

#sales .sales-entry-row .ghost-button,
#sales .sales-file-import-button {
  border-color: #cbd8e8;
  color: #1d4f86;
  font-weight: 800;
}

#sales .sales-file-import-button {
  cursor: pointer;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

#sales .sales-info-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

#sales .sales-field-wide {
  grid-column: 1 / -1;
}

#sales .sales-info-grid input,
#sales .sales-info-grid select,
#sales .sales-info-grid .custom-select-trigger,
#sales .sales-entry-row input,
#sales .sales-entry-textarea textarea {
  min-height: 38px;
  padding: 9px 11px;
  border: 1px solid #d4dfed;
  border-radius: 8px;
  background: #ffffff;
  color: #26384f;
}

#sales .sales-info-grid input:focus,
#sales .sales-info-grid select:focus,
#sales .sales-info-grid .custom-select.is-open .custom-select-trigger,
#sales .sales-entry-row input:focus,
#sales .sales-entry-textarea textarea:focus {
  outline: 0;
  border-color: #0f6fff;
  box-shadow: 0 0 0 3px rgba(15, 111, 255, 0.12);
}

#sales .sales-entry-textarea textarea {
  min-height: 128px;
}

#sales .sales-draft-wrap {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}

#sales .sales-draft-head {
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid #e8eef6;
  background: #ffffff;
}

#sales .sales-draft-title {
  display: grid;
  gap: 6px;
  min-width: 0;
}

#sales .sales-draft-title strong {
  color: #182334;
  font-size: 1rem;
  font-weight: 850;
}

#sales .sales-draft-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#sales .sales-draft-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid #dbe6f2;
  border-radius: 999px;
  background: #f7fbff;
  color: #63748a;
  font-size: 0.78rem;
  font-weight: 800;
}

#sales .sales-draft-meta em {
  color: #243247;
  font-style: normal;
}

#sales .sales-draft-meta span:last-child {
  border-color: #c9e8dd;
  background: #f1fbf7;
  color: #08745f;
}

#sales .sales-draft-meta span:last-child em {
  color: #075f50;
}

#sales .sales-draft-table-wrap {
  height: 100%;
  max-height: none;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  border-width: 0 0 1px;
  border-radius: 0;
}

#sales .sales-draft-table-wrap table {
  min-width: 1320px;
}

#sales .sales-draft-table-wrap thead th {
  background: #f5f8fc;
  color: #667993;
  font-size: 0.77rem;
  letter-spacing: 0;
}

#sales .sales-draft-table-wrap th,
#sales .sales-draft-table-wrap td {
  padding: 11px 10px;
}

#sales .draft-sale-amount-input {
  min-width: 112px;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px solid #d4dfed;
  border-radius: 7px;
}

#sales .sales-draft-table-wrap td:last-child .ghost-button {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 7px;
  color: #b83945;
}

#sales .sales-form-footer {
  min-height: 54px;
  padding: 11px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 0;
  background: #fbfdff;
}

#sales .form-message {
  margin: 0;
}

#sales .sales-draft-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

@media (min-width: 1280px) {
  .main {
    padding-right: 32px;
  }
}

@media (max-width: 1200px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .global-search {
    width: min(100%, 520px);
  }

  .sales-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #sales .sales-workflow {
    grid-template-rows: auto minmax(360px, 1fr);
    height: auto;
    min-height: 0;
  }

  #sales .sales-form-layout {
    grid-template-columns: 1fr;
  }

  #sales .sales-draft-table-wrap {
    height: clamp(320px, 48vh, 560px);
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 20px;
  }

  .mobile-nav {
    display: flex;
  }

  .dashboard-board {
    grid-template-columns: 1fr;
  }

  .inventory-filter-grid,
  .purchase-filter-grid,
  .profit-filter-grid,
  .form-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main {
    padding: 16px;
  }

  .topbar-actions,
  .inventory-toolbar,
  .inventory-filter-actions,
  .table-footer,
  .pagination-controls,
  .sales-mode-switch {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .global-search,
  .global-search input {
    width: 100%;
  }

  .inventory-filter-grid,
  .purchase-filter-grid,
  .profit-filter-grid,
  .form-grid-4,
  .sales-info-grid,
  .profit-summary-grid,
  .detail-grid-list {
    grid-template-columns: 1fr;
  }

  .card,
  .board-section,
  .login-panel {
    padding: 16px;
  }

  .inventory-table-card {
    padding: 0;
  }

  .sales-entry-row {
    grid-template-columns: 1fr;
  }

  .page-size-field {
    grid-template-columns: 1fr;
  }

  #sales .sales-console-head,
  #sales .sales-draft-head {
    align-items: stretch;
    flex-direction: column;
  }

  #sales .sales-info-grid,
  #sales .sales-entry-row {
    grid-template-columns: 1fr;
  }

  #sales .sales-field-wide {
    grid-column: auto;
  }

  #sales .sales-form-layout,
  #sales .sales-draft-head,
  #sales .sales-form-footer {
    padding: 14px;
  }

  #sales .sales-draft-table-wrap {
    height: 360px;
  }

  #sales .sales-form-footer,
  #sales .sales-draft-pagination,
  #sales .sales-draft-pagination .pagination-controls {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  #sales .sales-draft-pagination {
    margin-left: 0;
  }
}

/* Dashboard v3 composition */
@media (min-width: 1180px) {
  .main {
    width: 100%;
  }
}

.dashboard-head-premium {
  align-items: center;
  margin-bottom: 18px;
}

#dashboard .dashboard-head-premium {
  display: none;
}

.topbar > div:first-child,
.dashboard-head-premium > div:first-child,
#current-user,
#template-summary,
#seed-button {
  display: none;
}

.topbar {
  justify-content: flex-end;
}

.dashboard-head-premium {
  justify-content: flex-end;
}

.dashboard-head-premium h3 {
  font-size: 1.52rem;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.dashboard-kpi-card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow);
}

.dashboard-kpi-card::before {
  content: "";
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.dashboard-kpi-card::after {
  content: "";
  position: absolute;
  left: 31px;
  top: 31px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.dashboard-kpi-card:nth-child(2)::before {
  background: var(--teal-soft);
}

.dashboard-kpi-card:nth-child(2)::after {
  background: var(--teal);
}

.dashboard-kpi-card:nth-child(3)::before {
  background: var(--warn-soft);
}

.dashboard-kpi-card:nth-child(3)::after {
  background: var(--warn);
}

.dashboard-kpi-card:nth-child(4)::before {
  background: var(--success-soft);
}

.dashboard-kpi-card:nth-child(4)::after {
  background: var(--success);
}

.dashboard-kpi-card span {
  position: absolute;
  top: 20px;
  left: 60px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.dashboard-kpi-card small {
  position: absolute;
  top: 22px;
  right: 16px;
  color: var(--muted-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.dashboard-kpi-card strong {
  align-self: end;
  margin-top: 42px;
  color: var(--text);
  font-size: 1.88rem;
  font-weight: 850;
  line-height: 1;
}

.dashboard-kpi-card em,
.dashboard-ledger-tabs em,
.dashboard-mini-card em,
.dashboard-risk-card em,
.dashboard-action-card em {
  font-style: normal;
}

.sparkline {
  position: absolute;
  right: 18px;
  bottom: 26px;
  width: 92px;
  height: 32px;
}

.sparkline::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  clip-path: polygon(0 78%, 24% 48%, 48% 62%, 72% 18%, 100% 32%, 100% 42%, 72% 28%, 48% 72%, 24% 58%, 0 88%);
}

.sparkline-blue {
  color: var(--accent);
}

.sparkline-teal {
  color: var(--teal);
}

.sparkline-amber {
  color: var(--warn);
}

.sparkline-green {
  color: var(--success);
}

.dashboard-analytics-grid,
.dashboard-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.dashboard-analytics-card,
.dashboard-insight-card {
  min-width: 0;
  padding: 16px;
}

.dashboard-analytics-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-analytics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-analytics-head h3,
.dashboard-insight-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.03rem;
  font-weight: 850;
}

.dashboard-analytics-head p,
.dashboard-insight-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.dashboard-trend-note {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.dashboard-trend-bars {
  min-height: 172px;
}

.dashboard-ranking-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.dashboard-ranking-item {
  display: grid;
  gap: 6px;
}

.dashboard-ranking-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.dashboard-ranking-item-head strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-ranking-item-head span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-ranking-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2f7;
}

.dashboard-ranking-track i {
  display: block;
  width: var(--value);
  height: 100%;
  background: var(--accent);
}

.dashboard-ranking-item.is-success .dashboard-ranking-track i {
  background: linear-gradient(90deg, var(--teal), var(--success));
}

.dashboard-ranking-item.is-warning .dashboard-ranking-track i {
  background: linear-gradient(90deg, var(--warn), #f59e0b);
}

.dashboard-ranking-item.is-danger .dashboard-ranking-track i {
  background: linear-gradient(90deg, var(--danger), #ef4444);
}

.dashboard-suggestion-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.dashboard-suggestion-item {
  display: grid;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid #eef2f7;
}

.dashboard-suggestion-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.dashboard-suggestion-item strong {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 850;
}

.dashboard-suggestion-item span {
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 800;
}

.dashboard-suggestion-item small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
}

.dashboard-review-headline {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
}


.dashboard-main-column {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.dashboard-filter-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-filter-strip label {
  display: grid;
  gap: 7px;
  min-width: 0;
  position: relative;
}

.dashboard-filter-strip span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.dashboard-filter-strip select,
.dashboard-filter-strip input {
  width: 100%;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  text-align: left;
  font-weight: 650;
}

.dashboard-filter-strip input {
  padding: 8px 12px;
}

.dashboard-filter-strip select:focus,
.dashboard-filter-strip input:focus {
  background: #ffffff;
}

.dashboard-filter-strip .primary-button {
  min-height: 36px;
  align-self: end;
}

.dashboard-ledger-card,
.dashboard-insight-card,
.dashboard-mini-card,
.dashboard-risk-card,
.dashboard-action-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-ledger-card {
  overflow: hidden;
}

.dashboard-ledger-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
}

.dashboard-ledger-head h3,
.dashboard-insight-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
}

.dashboard-ledger-head p {
  margin: 7px 0 0;
  font-size: 0.84rem;
}

.dashboard-ledger-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-ledger-tabs .ghost-button,
.dashboard-ledger-tabs .active-toggle {
  min-height: 30px;
  padding: 6px 12px;
}

.dashboard-ledger-table-wrap {
  border-width: 1px 0;
  border-radius: 0;
}

.dashboard-ledger-table-wrap table {
  min-width: 820px;
  table-layout: fixed;
}

.dashboard-ledger-table-wrap th,
.dashboard-ledger-table-wrap td {
  height: 50px;
  padding: 11px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-ledger-table-wrap tbody tr.is-featured-row {
  background: #f7fbff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.dashboard-ledger-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dashboard-ledger-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-ledger-pagination .ghost-button {
  min-height: 30px;
  padding: 6px 12px;
}

.dashboard-insight-column {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.dashboard-insight-card {
  padding: 16px;
}

.insight-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  margin-top: 16px;
}

.insight-line span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.insight-line strong {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 850;
}

.insight-line i {
  grid-column: 1 / -1;
  display: block;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color) 0 var(--value), #edf2f7 var(--value) 100%);
}

.dashboard-insight-card p {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid #eef2f7;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.dashboard-mini-card {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  min-height: 104px;
  padding: 16px 14px;
  color: var(--text);
  text-align: left;
}

.dashboard-mini-card > span {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--teal-soft);
  position: relative;
}

.dashboard-mini-card > span::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 999px;
  background: var(--teal);
}

.dashboard-mini-card-blue > span {
  background: var(--accent-soft);
}

.dashboard-mini-card-blue > span::after {
  background: var(--accent);
}

.dashboard-mini-card small {
  color: var(--muted);
  font-weight: 800;
}

.dashboard-mini-card strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 850;
  line-height: 1;
}

.dashboard-mini-card p {
  margin: 8px 0 0;
  color: var(--muted-soft);
  font-size: 0.82rem;
  font-weight: 650;
}

.dashboard-risk-card {
  display: grid;
  gap: 12px;
  min-height: 84px;
  padding: 16px;
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a4f00;
  text-align: left;
}

.dashboard-risk-card strong {
  font-size: 1rem;
}

.dashboard-risk-card span {
  font-size: 0.9rem;
  font-weight: 800;
}

.dashboard-action-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 16px;
  align-items: center;
  margin-top: 24px;
  padding: 22px 24px;
}

.dashboard-action-card > span {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 850;
}

.dashboard-action-card strong {
  color: var(--text);
  font-size: 1rem;
}

.dashboard-action-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.dashboard-hidden-metric {
  display: none;
}

.dashboard-comparison-strip,
.inventory-insight-grid,
.profit-insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.comparison-item,
.operations-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.comparison-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.comparison-item strong { font-size: 1rem; }
.comparison-change { font-weight: 850; color: var(--success); }
.comparison-change.is-down { color: var(--danger); }

.operations-panel { padding: 16px; }
.operations-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.operations-panel-head h3,
.operations-panel-head p { margin: 0; }

.task-center-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.task-center-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
}
.task-center-item:hover { border-color: var(--accent); }
.task-center-item strong { font-size: 1.18rem; }
.task-center-item small { color: var(--muted); }
.task-center-item.warning { border-left: 3px solid var(--warn); }
.task-center-item.danger { border-left: 3px solid var(--danger); }

.inventory-insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.profit-insight-grid { grid-template-columns: 2fr 1fr; }
.metric-bar-list { display: grid; gap: 10px; }
.inventory-supplier-summary { margin-bottom: 14px; }
.inventory-supplier-summary .metric-bar-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.metric-bar-row { display: grid; grid-template-columns: minmax(78px, 1fr) auto; gap: 5px 12px; align-items: center; }
.metric-bar-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.metric-bar-row span { color: var(--muted); font-size: .82rem; }
.metric-bar-track { grid-column: 1 / -1; height: 6px; overflow: hidden; border-radius: 3px; background: #edf1f5; }
.metric-bar-track i { display: block; width: var(--value); height: 100%; background: var(--accent); }

.trend-bars { display: flex; align-items: end; gap: 6px; min-height: 150px; overflow-x: auto; padding-top: 18px; }
.trend-bar { display: grid; grid-template-rows: 1fr auto; align-items: end; min-width: 34px; height: 132px; text-align: center; }
.trend-bar i { display: block; min-height: 3px; height: var(--value); background: var(--accent); border-radius: 3px 3px 0 0; }
.trend-bar.is-negative i { background: var(--danger); }
.trend-bar span { padding-top: 6px; color: var(--muted); font-size: .7rem; }

.device-timeline { display: grid; gap: 0; margin-top: 18px; }
.device-timeline-item { position: relative; display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding-bottom: 16px; }
.device-timeline-item::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.device-timeline-item:last-child::before { display: none; }
.device-timeline-dot { width: 15px; height: 15px; margin-top: 2px; border: 3px solid var(--accent-soft); border-radius: 50%; background: var(--accent); z-index: 1; }
.device-timeline-item p { margin: 4px 0 0; color: var(--muted); }
.device-timeline-item time { color: var(--muted); font-size: .78rem; white-space: nowrap; }

.snapshot-list { display: grid; gap: 8px; }
.snapshot-row { display: grid; grid-template-columns: 1fr auto 70px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.snapshot-row:last-child { border-bottom: 0; }
.snapshot-row em { color: var(--success); font-style: normal; font-weight: 850; text-align: right; }
.snapshot-row em.is-down { color: var(--danger); }
.detail-quick-actions { display: flex; justify-content: flex-end; margin: 12px 0; }
.price-history-list { display: grid; gap: 8px; }
.detail-subsection { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.detail-subsection h4 { margin: 0 0 12px; }
.price-history-list > div { display: grid; grid-template-columns: 150px minmax(160px, 1fr) 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.price-history-list time, .price-history-list span { color: var(--muted); }
.custom-report-controls { display: grid; grid-template-columns: repeat(3, minmax(150px, 220px)); gap: 12px; }
.custom-report-controls label { display: grid; gap: 6px; }
.custom-report-fields { display: flex; align-items: center; gap: 12px; min-width: 280px; margin: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.custom-report-fields legend { padding: 0 5px; color: var(--muted); font-size: .78rem; }
.custom-report-fields label { display: flex; align-items: center; gap: 5px; }
.custom-report-result { margin-top: 14px; overflow-x: auto; }
.custom-report-row { display: grid; gap: 12px; min-width: 560px; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.custom-report-head { color: var(--muted); font-size: .8rem; font-weight: 850; background: var(--surface-alt); }
.sales-analysis-panel { display: grid; gap: 12px; }
.sales-analysis-dimension-field { display: grid; gap: 5px; min-width: 180px; }
.sales-analysis-dimension-field span { color: var(--muted); font-size: .78rem; font-weight: 850; }
.sales-analysis-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sales-analysis-result { margin-top: 0; max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.sales-analysis-result .custom-report-head { position: sticky; top: 0; z-index: 1; }
.sales-analysis-row { align-items: center; min-width: 980px; }
.sales-analysis-row span { font-variant-numeric: tabular-nums; }
.sales-analysis-pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sales-performance-panel { display: grid; gap: 12px; }
.sales-performance-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sales-performance-result { margin-top: 0; max-height: 430px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.sales-performance-result .custom-report-head { position: sticky; top: 0; z-index: 1; }
.sales-performance-row { align-items: center; min-width: 1060px; }
.sales-performance-row span { font-variant-numeric: tabular-nums; }
.analysis-workbench { display: grid; gap: 16px; }
.analysis-header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.analysis-insight-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 12px; }
.analysis-source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.analysis-source-card { display: grid; gap: 5px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); }
.analysis-source-card span { color: var(--muted); font-size: .82rem; font-weight: 850; }
.analysis-source-card strong { color: var(--text); font-size: 1.35rem; line-height: 1; }
.analysis-source-card small { overflow-wrap: anywhere; color: var(--muted); font-size: .76rem; }
.analysis-import-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.analysis-import-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: end; }
.analysis-import-form label { display: grid; gap: 6px; min-width: 0; }
.analysis-import-form label span { color: var(--muted); font-size: .82rem; font-weight: 850; }
.analysis-import-form .form-message { grid-column: 1 / -1; margin: 0; min-height: 20px; }
.analysis-file-field { cursor: pointer; }
.analysis-file-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  font-size: .9rem;
  font-weight: 850;
}
.analysis-file-field:hover .analysis-file-button {
  border-color: #b8c7dc;
  background: #ffffff;
}
.analysis-file-name {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analysis-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 220px)); gap: 12px; }
#analysis .filter-field input,
#analysis .filter-field select,
#analysis .custom-select-trigger {
  min-height: 34px;
  background: var(--surface-soft);
  font-weight: 750;
}
#analysis .v3-date-input {
  min-height: 34px;
  padding-right: 34px;
  color: #273448;
  background:
    linear-gradient(45deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    var(--surface-soft);
  cursor: pointer;
}
#analysis .v3-date-input:focus {
  border-color: rgba(15, 75, 255, 0.72);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
  outline: none;
}
.analysis-stats-row { grid-template-columns: minmax(180px, 1.3fr) 80px repeat(4, minmax(90px, 1fr)); align-items: center; }
.analysis-table-card table { min-width: 1680px; }
.notification-center { position: relative; }
.notification-toggle { position: relative; }
.notification-toggle span { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .72rem; }
.notification-toggle span.is-empty { background: var(--muted-soft); color: var(--muted); }
.notification-popover { position: absolute; z-index: 300; top: calc(100% + 8px); right: 0; width: min(430px, 92vw); max-height: 70vh; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-strong); }
.notification-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.notification-head > div { display: grid; gap: 3px; }
.notification-list { display: grid; }
.notification-item { display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; width: 100%; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.notification-item > span { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--warn); }
.notification-item.danger > span { background: var(--danger); }
.notification-item.is-read { opacity: .62; }
.notification-item.is-read > span { background: var(--muted-soft); }
.notification-item div { min-width: 0; }
.notification-item strong, .notification-item p { display: block; margin: 0; }
.notification-item p { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.notification-item time { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.system-maintenance-actions { display: flex; align-items: center; gap: 10px; }
#system-restart-message { margin: 0 0 12px; }
.restore-warning { margin: 0 0 14px; padding: 12px; border: 1px solid #f1c7c4; border-radius: 8px; background: var(--danger-soft); color: var(--danger); line-height: 1.6; }
.backup-restore-list { display: grid; gap: 8px; max-height: 48vh; overflow: auto; }
.backup-restore-option { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; min-height: 58px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); cursor: pointer; }
.backup-restore-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.backup-restore-option span { display: grid; gap: 4px; min-width: 0; }
.backup-restore-option strong { overflow-wrap: anywhere; }
.backup-restore-option small { color: var(--muted); }
.backup-restore-actions { justify-content: flex-end; margin-top: 16px; }
.arrival-date { display: block; white-space: nowrap; }
.arrival-date.is-overdue { color: var(--danger); }
.arrival-note { display: block; margin-top: 3px; color: var(--muted); white-space: nowrap; }

@media (max-width: 1180px) {
  .task-center-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profit-insight-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .dashboard-comparison-strip,
  .dashboard-analytics-grid,
  .dashboard-insight-grid,
  .inventory-insight-grid,
  .sales-analysis-kpi-grid,
  .sales-performance-kpi-grid,
  .analysis-insight-grid,
  .analysis-source-grid,
  .analysis-import-grid,
  .analysis-filter-grid { grid-template-columns: 1fr; }
  .task-center-list { grid-template-columns: 1fr; }
  .price-history-list > div, .custom-report-controls, .analysis-stats-row { grid-template-columns: 1fr; }
  .sales-analysis-pagination { align-items: stretch; }
  .sales-analysis-pagination .pagination-controls { width: 100%; }
  .sales-analysis-pagination .ghost-button { flex: 1; }
  .system-maintenance-actions { width: 100%; flex-direction: column-reverse; align-items: stretch; }
}

@media (max-width: 1280px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-analytics-grid,
  .dashboard-insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-insight-column {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .dashboard-filter-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-filter-strip > .primary-button {
    grid-column: 1 / -1;
  }

  .dashboard-insight-column,
  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-analytics-grid,
  .dashboard-insight-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-action-card {
    grid-template-columns: 44px 1fr;
  }

  .dashboard-action-card .ghost-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .dashboard-filter-strip {
    grid-template-columns: 1fr;
  }

  .dashboard-ledger-head,
  .dashboard-ledger-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-ledger-tabs {
    justify-content: flex-start;
  }
}

/* V3 custom select */
.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.custom-select-trigger {
  position: relative;
  width: 100%;
  min-height: 38px;
  padding: 8px 34px 8px 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
  box-shadow: none;
}

.custom-select-trigger::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #8a97a8;
  border-bottom: 2px solid #8a97a8;
  transform: translateY(-62%) rotate(45deg);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.custom-select-trigger:hover {
  border-color: #b8c7dc;
  background: #ffffff;
}

.custom-select.is-open .custom-select-trigger {
  border-color: rgba(15, 75, 255, 0.72);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
}

.custom-select.is-open .custom-select-trigger::after {
  border-color: var(--accent);
  transform: translateY(-28%) rotate(225deg);
}

.custom-select.is-disabled {
  opacity: 0.58;
}

.custom-select-menu {
  position: fixed;
  z-index: 200;
  display: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-strong);
}

.custom-select.is-open .custom-select-menu {
  display: grid;
  gap: 2px;
}

.custom-select-option {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #273448;
  text-align: left;
  font-weight: 650;
  line-height: 1.25;
}

.custom-select-option:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.custom-select-option.is-selected {
  background: var(--accent);
  color: #ffffff;
  font-weight: 850;
}

.custom-select-option:disabled {
  color: var(--muted-soft);
  cursor: not-allowed;
  opacity: 0.58;
}

#inventory .inventory-filter-panel .custom-select {
  z-index: 30;
}

#inventory .inventory-filter-panel .custom-select.is-open {
  z-index: 120;
}

#inventory .inventory-filter-panel .custom-select-menu {
  position: absolute;
  left: 0 !important;
  top: calc(100% + 6px) !important;
  width: 100% !important;
  max-height: 248px !important;
}

.inline-actions .custom-select,
.payment-actions .custom-select {
  width: auto;
  min-width: 92px;
}

.inline-actions .custom-select-trigger,
.payment-actions .custom-select-trigger,
.page-size-field .custom-select-trigger {
  min-height: 30px;
  padding-top: 5px;
  padding-bottom: 5px;
  font-size: 0.86rem;
}

/* Inventory v3 layout */
#inventory {
  display: none;
}

#inventory.panel.active {
  display: block;
}

.inventory-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.inventory-results-column {
  min-width: 0;
}

.inventory-page-header {
  align-items: center;
  margin-bottom: 16px;
}

.inventory-page-header h3 {
  font-size: 1.52rem;
}

.inventory-page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inventory-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.inventory-summary-card {
  position: relative;
  min-height: 116px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.inventory-summary-card::before {
  content: "";
  display: block;
  width: 32px;
  height: 32px;
  margin-bottom: 22px;
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.inventory-summary-card::after {
  content: "";
  position: absolute;
  left: 31px;
  top: 31px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.inventory-summary-card.warning::before {
  background: var(--warn-soft);
}

.inventory-summary-card.warning::after {
  background: var(--warn);
}

.inventory-summary-card.success::before {
  background: var(--success-soft);
}

.inventory-summary-card.success::after {
  background: var(--success);
}

.inventory-summary-card span {
  position: absolute;
  top: 22px;
  left: 60px;
  color: var(--muted);
  font-weight: 850;
}

.inventory-summary-card strong {
  display: block;
  color: var(--text);
  font-size: 1.85rem;
  font-weight: 850;
  line-height: 1;
}

.inventory-summary-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

#inventory .inventory-filter-panel {
  position: relative;
  z-index: 20;
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: visible;
  padding: 12px 14px;
  margin-bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

#inventory .inventory-filter-panel::-webkit-scrollbar {
  width: 8px;
}

#inventory .inventory-filter-panel::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(138, 151, 168, 0.36);
  background-clip: content-box;
}

.inventory-filter-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.inventory-filter-head h3,
.inventory-table-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
}

.inventory-filter-head p,
.inventory-table-head p {
  margin: 4px 0 0;
  font-size: 0.8rem;
}

#inventory .inventory-filter-grid {
  grid-template-columns: repeat(5, minmax(126px, 1fr));
  gap: 8px 10px;
}

#inventory .filter-field-wide {
  grid-column: span 2;
}

#inventory .filter-field input,
#inventory .filter-field select,
#inventory .custom-select-trigger {
  min-height: 34px;
  background: var(--surface-soft);
  font-weight: 750;
}

#inventory .v3-date-input {
  min-height: 34px;
  padding-right: 34px;
  color: #273448;
  background:
    linear-gradient(45deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    var(--surface-soft);
  cursor: pointer;
}

#inventory .v3-date-input:focus {
  border-color: rgba(15, 75, 255, 0.72);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
  outline: none;
}

#inventory .filter-field {
  gap: 4px;
}

.inventory-date-popover {
  position: absolute;
  z-index: 180;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-strong);
}

.inventory-date-picker-head {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.inventory-date-picker-head strong {
  color: var(--text);
  text-align: center;
  font-size: 0.96rem;
  font-weight: 850;
}

.inventory-date-picker-head button,
.inventory-date-day {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #273448;
  font-weight: 750;
}

.inventory-date-picker-head button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
}

.inventory-date-picker-head button:hover,
.inventory-date-day:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.inventory-date-weekdays,
.inventory-date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.inventory-date-weekdays {
  margin-bottom: 4px;
}

.inventory-date-weekdays span {
  color: var(--muted);
  text-align: center;
  font-size: 0.76rem;
  font-weight: 850;
}

.inventory-date-day {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 32px;
  border-radius: 8px;
  font-size: 0.86rem;
}

.inventory-date-day.is-outside {
  color: var(--muted-soft);
}

.inventory-date-day.is-in-range {
  background: var(--accent-soft);
}

.inventory-date-day.is-today {
  color: var(--accent);
}

.inventory-date-day.is-selected {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 75, 255, 0.22);
}

.inventory-date-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eef2f7;
}

.inventory-date-shortcuts button {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: #52637a;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.inventory-date-shortcuts button:hover {
  border-color: rgba(15, 75, 255, 0.55);
  color: var(--accent);
  background: var(--accent-soft);
}

#inventory .inventory-filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: auto;
}

#inventory .inventory-filter-actions .ghost-button,
#inventory .inventory-filter-actions .primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
}

#inventory .filter-field span {
  font-size: 0.8rem;
}

.inventory-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
}

.inventory-selection-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.inventory-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.inventory-table-actions > span {
  white-space: nowrap;
  font-size: 0.86rem;
  font-weight: 700;
}

#inventory .inventory-table-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#inventory .inventory-table-wrap {
  border-left: 0;
  border-right: 0;
  height: clamp(380px, calc(100vh - 318px), 680px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

#inventory .inventory-table-wrap table {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}

#inventory .inventory-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

#inventory .inventory-table-wrap th:first-child,
#inventory .inventory-table-wrap td:first-child {
  text-align: center;
  width: 40px;
}

#inventory .inventory-select-all,
#inventory [data-outbound-checkbox] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

#inventory .inventory-select-all:disabled,
#inventory [data-outbound-checkbox]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#inventory .inventory-table-wrap th,
#inventory .inventory-table-wrap td {
  height: 46px;
  padding: 9px 8px;
  white-space: nowrap;
}

#inventory .inventory-table-wrap .inline-actions {
  gap: 6px;
}

#inventory .inventory-table-wrap .action-cell {
  width: 240px;
  min-width: 240px;
}

#inventory .inventory-table-wrap .row-action-button {
  min-height: 28px;
  padding: 5px 7px;
}

#inventory .inventory-table-wrap tbody tr:hover {
  background: #f7fbff;
}

#inventory .inventory-table-card .table-footer {
  flex: 0 0 auto;
  padding: 12px 18px;
}

/* Purchase v3 module pages */
#purchase .purchase-module-header {
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.purchase-subnav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 20px rgba(21, 32, 51, 0.05);
}

.purchase-subnav-item {
  min-height: 34px;
  padding: 7px 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.purchase-subnav-item:hover,
.purchase-subnav-item.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 75, 255, 0.18);
}

.purchase-module {
  min-width: 0;
}

.purchase-page {
  display: none;
}

.purchase-page.active {
  display: block;
}

#purchase .card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

#purchase .card-header {
  align-items: flex-start;
  min-height: 0;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

#purchase .card-header .eyebrow,
.purchase-table-head .eyebrow {
  margin: 0 0 4px;
}

.purchase-single-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: start;
}

.purchase-entry-card,
.purchase-import-page-card,
.pending-receive-card {
  padding: 18px;
}

.purchase-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(17, 163, 155, 0.2);
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.purchase-status-pill.pending {
  border-color: rgba(218, 123, 46, 0.24);
  background: rgba(218, 123, 46, 0.12);
  color: #9a5419;
}

.purchase-device-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.purchase-form-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.purchase-section-title {
  color: #52637a;
  font-size: 0.82rem;
  font-weight: 850;
}

.purchase-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.purchase-form-grid label,
.purchase-import-form label {
  display: grid;
  gap: 6px;
}

#purchase .purchase-form-grid label {
  position: relative;
}

.purchase-form-grid label span,
.purchase-import-form label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

#purchase .purchase-form-grid input,
#purchase .purchase-form-grid textarea,
#purchase .purchase-import-form input,
#purchase .pending-receive-form input,
#purchase .purchase-import-form select,
#purchase .purchase-form-grid select,
#purchase .purchase-form-grid .custom-select-trigger,
#purchase .purchase-import-form .custom-select-trigger {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  font-weight: 750;
}

.template-combobox-input {
  width: 100%;
  padding-right: 34px;
  background:
    linear-gradient(45deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    var(--surface-soft);
}

.template-combobox-input:focus {
  border-color: rgba(15, 75, 255, 0.72);
  background:
    linear-gradient(45deg, transparent 44%, var(--accent) 45%, var(--accent) 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, var(--accent) 45%, var(--accent) 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
  outline: none;
}

.template-combobox-menu {
  position: absolute;
  z-index: 520;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 248px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-strong);
}

.template-combobox-menu.open-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.template-combobox-menu.is-floating {
  position: fixed;
  right: auto;
  bottom: auto;
  z-index: 760;
}

.template-combobox-menu.is-open {
  display: grid;
  gap: 2px;
}

.template-combobox-option {
  width: 100%;
  min-height: 34px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #273448;
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}

.template-combobox-option:hover,
.template-combobox-option.is-active,
.template-combobox-option:focus-visible {
  background: var(--accent);
  color: #ffffff;
}

.template-combobox-option:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -3px;
}

.template-combobox-empty {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.template-combobox-empty.is-warning {
  color: #b45309;
}

.purchase-imei-field,
.purchase-note-field {
  grid-column: span 2;
}

#purchase .purchase-form-grid textarea {
  min-height: 82px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.45;
}

.field-hint {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.purchase-form-actions {
  justify-content: flex-start;
  gap: 10px;
  min-height: 38px;
}

.purchase-form-actions .primary-button {
  min-width: 128px;
}

.purchase-side-stack {
  display: grid;
  gap: 10px;
}

.purchase-side-card {
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.purchase-side-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.purchase-side-card strong {
  color: var(--text);
  font-size: 1.06rem;
  font-weight: 900;
}

.purchase-side-card.accent {
  border-color: rgba(15, 75, 255, 0.16);
  background: var(--accent-soft);
}

.purchase-import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.pending-purchase-workbench {
  display: grid;
  grid-template-columns: minmax(500px, 0.95fr) minmax(620px, 1.05fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.pending-purchase-workbench > .card {
  height: 100%;
  margin: 0;
}

.pending-purchase-workbench .card-header {
  min-height: 74px;
}

.pending-import-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  align-items: start;
}

#purchase .purchase-import-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

#purchase .pending-import-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.pending-receive-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pending-receive-form {
  display: grid;
  grid-template-rows: auto auto minmax(252px, 1fr) auto;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.pending-import-form label,
.pending-receive-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.pending-import-form label span,
.pending-receive-form label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.pending-receive-query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.pending-receive-query-row .ghost-button {
  min-height: 40px;
  white-space: nowrap;
}

#purchase .pending-import-form input,
#purchase .pending-import-form select,
#purchase .pending-import-form .custom-select-trigger,
#purchase .pending-receive-form input,
#purchase .pending-receive-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  font-weight: 750;
}

#purchase .pending-receive-form textarea {
  min-height: 64px;
  resize: vertical;
  line-height: 1.45;
}

#purchase .pending-import-form input[type="file"] {
  padding: 6px 10px;
}

#purchase .pending-import-form input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: #273448;
  font-weight: 800;
  cursor: pointer;
}

.pending-receive-summary {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.pending-receive-table-wrap {
  height: 252px;
  min-height: 252px;
  max-height: 252px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overscroll-behavior: contain;
}

.pending-receive-table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.pending-receive-table-wrap th,
.pending-receive-table-wrap td {
  padding: 9px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-receive-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

.pending-receive-select-col {
  width: 42px;
}

.pending-receive-table-wrap th:nth-child(2),
.pending-receive-table-wrap td:nth-child(2) {
  width: 21%;
}

.pending-receive-table-wrap th:nth-child(3),
.pending-receive-table-wrap td:nth-child(3) {
  width: 23%;
}

.pending-receive-table-wrap th:nth-child(4),
.pending-receive-table-wrap td:nth-child(4) {
  width: 26%;
}

.pending-receive-table-wrap th:nth-child(5),
.pending-receive-table-wrap td:nth-child(5) {
  width: 13%;
}

.pending-receive-table-wrap th:nth-child(6),
.pending-receive-table-wrap td:nth-child(6) {
  width: 14%;
}

#pending-purchase-receive-select-all,
[data-pending-receive-checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

#pending-purchase-receive-select-all:disabled,
[data-pending-receive-checkbox]:disabled {
  cursor: not-allowed;
}

.pending-receive-table-wrap .muted-row {
  color: var(--muted);
  background: rgba(248, 250, 252, 0.72);
}

.pending-receive-table-wrap .empty-table-cell {
  height: 170px;
  text-align: center;
  white-space: normal;
}

.purchase-file-field,
.purchase-import-actions,
.pending-import-actions,
.pending-receive-actions {
  grid-column: 1 / -1;
}

.purchase-import-actions,
.pending-import-actions,
.pending-receive-actions {
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 40px;
}

.purchase-import-actions .primary-button {
  min-width: 128px;
}

.pending-import-actions .primary-button {
  min-width: 152px;
}

.pending-receive-actions .primary-button {
  min-width: 124px;
}

.purchase-import-contract {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.purchase-contract-grid {
  display: grid;
  gap: 8px;
}

.purchase-contract-grid span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid #eef2f7;
  border-radius: 7px;
  background: #ffffff;
  color: #344258;
  font-weight: 800;
}

.pending-import-contract {
  align-self: start;
}

.pending-import-contract .purchase-contract-grid span {
  min-height: 36px;
  display: flex;
  align-items: center;
}

#purchase-failed-form {
  display: grid;
  gap: 14px;
}

.purchase-failed-table-wrap {
  max-height: min(58vh, 560px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.purchase-failed-table-wrap table {
  min-width: 1228px;
  table-layout: fixed;
}

.purchase-failed-table-wrap th,
.purchase-failed-table-wrap td {
  padding: 9px 8px;
  vertical-align: top;
}

.purchase-failed-combobox-cell {
  position: relative;
}

.purchase-failed-table-wrap th:nth-child(1),
.purchase-failed-table-wrap td:nth-child(1) {
  width: 44px;
}

.purchase-failed-table-wrap th:nth-child(2),
.purchase-failed-table-wrap td:nth-child(2) {
  width: 130px;
}

.purchase-failed-table-wrap th:nth-child(3),
.purchase-failed-table-wrap td:nth-child(3) {
  width: 140px;
}

.purchase-failed-table-wrap th:nth-child(4),
.purchase-failed-table-wrap td:nth-child(4),
.purchase-failed-table-wrap th:nth-child(5),
.purchase-failed-table-wrap td:nth-child(5),
.purchase-failed-table-wrap th:nth-child(7),
.purchase-failed-table-wrap td:nth-child(7) {
  width: 100px;
}

.purchase-failed-table-wrap th:nth-child(6),
.purchase-failed-table-wrap td:nth-child(6) {
  width: 190px;
}

.purchase-failed-table-wrap th:nth-child(8),
.purchase-failed-table-wrap td:nth-child(8) {
  width: 100px;
}

.purchase-failed-table-wrap th:nth-child(9),
.purchase-failed-table-wrap td:nth-child(9),
.purchase-failed-table-wrap th:nth-child(10),
.purchase-failed-table-wrap td:nth-child(10) {
  width: 130px;
}

.purchase-failed-table-wrap th:nth-child(11),
.purchase-failed-table-wrap td:nth-child(11) {
  width: 64px;
}

.purchase-failed-table-wrap input,
.purchase-failed-table-wrap select,
.purchase-failed-table-wrap .custom-select-trigger {
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-soft);
  color: #273448;
  font-weight: 700;
}

.purchase-failed-table-wrap .template-combobox-input {
  padding-right: 34px;
}

.purchase-failed-table-wrap .template-combobox-menu {
  z-index: 620;
}

.purchase-failed-table-wrap tbody tr:focus-within td {
  background: #f4f7ff;
}

.purchase-failed-reason {
  color: #a93640;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: normal;
}

.purchase-failed-actions {
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.purchase-list-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.pending-purchase-list-card {
  margin-top: 0;
}

.purchase-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #eef2f7;
}

.purchase-table-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 850;
}

.purchase-summary {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.purchase-table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

#purchase .purchase-filter-panel {
  position: relative;
  margin: 0;
  padding: 12px 14px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: rgba(248, 250, 252, 0.72);
  box-shadow: none;
}

#purchase .purchase-filter-grid {
  grid-template-columns: repeat(6, minmax(112px, 1fr));
  gap: 8px 10px;
}

#purchase .filter-field {
  gap: 4px;
}

#purchase .filter-field-wide {
  grid-column: span 2;
}

#purchase .filter-field input,
#purchase .filter-field select,
#purchase .custom-select-trigger {
  min-height: 34px;
  background: var(--surface-soft);
  font-weight: 750;
}

#purchase .v3-date-input {
  min-height: 34px;
  padding-right: 34px;
  color: #273448;
  background:
    linear-gradient(45deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 17px center / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 44%, #8a97a8 45%, #8a97a8 55%, transparent 56%) right 12px center / 8px 8px no-repeat,
    var(--surface-soft);
  cursor: pointer;
}

#purchase .v3-date-input:focus {
  border-color: rgba(15, 75, 255, 0.72);
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(15, 75, 255, 0.12);
  outline: none;
}

#purchase .inventory-filter-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

#purchase .inventory-filter-actions .ghost-button {
  min-height: 34px;
  padding: 7px 12px;
}

#purchase .pending-purchase-filter-grid {
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 0.8fr) minmax(180px, 1fr) minmax(260px, 1.4fr);
  align-items: end;
}

#purchase .pending-purchase-filter-grid .filter-field-wide {
  grid-column: auto;
}

#purchase .detail-table-wrap {
  height: clamp(360px, calc(100vh - 330px), 680px);
  border-width: 0 0 1px;
  border-radius: 0;
}

#purchase .detail-table-wrap table {
  width: 100%;
  min-width: 1120px;
  table-layout: fixed;
}

#purchase .detail-table-wrap th,
#purchase .detail-table-wrap td {
  padding: 11px 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#purchase .detail-table-wrap th:nth-child(1),
#purchase .detail-table-wrap td:nth-child(1) {
  width: 16%;
}

#purchase .detail-table-wrap th:nth-child(2),
#purchase .detail-table-wrap td:nth-child(2) {
  width: 9%;
}

#purchase .detail-table-wrap th:nth-child(3),
#purchase .detail-table-wrap td:nth-child(3) {
  width: 10%;
}

#purchase .detail-table-wrap th:nth-child(4),
#purchase .detail-table-wrap td:nth-child(4) {
  width: 6%;
}

#purchase .detail-table-wrap th:nth-child(5),
#purchase .detail-table-wrap td:nth-child(5) {
  width: 8%;
}

#purchase .detail-table-wrap th:nth-child(6),
#purchase .detail-table-wrap td:nth-child(6) {
  width: 16%;
}

#purchase .detail-table-wrap th:nth-child(7),
#purchase .detail-table-wrap td:nth-child(7) {
  width: 18%;
}

#purchase .detail-table-wrap th:nth-child(8),
#purchase .detail-table-wrap td:nth-child(8) {
  width: 17%;
}

#purchase .detail-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

#purchase .pending-purchase-list-card .detail-table-wrap {
  height: clamp(320px, calc(100vh - 560px), 520px);
  min-height: 320px;
}

#purchase .pending-purchase-list-card .detail-table-wrap table {
  min-width: 1120px;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(1),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(1) {
  width: 15%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(2),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(2) {
  width: 13%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(3),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(3) {
  width: 12%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(4),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(4) {
  width: 6%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(5),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(5) {
  width: 7%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(6),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(6) {
  width: 11%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(7),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(7) {
  width: 11%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(8),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(8) {
  width: 10%;
}

#purchase .pending-purchase-list-card .detail-table-wrap th:nth-child(9),
#purchase .pending-purchase-list-card .detail-table-wrap td:nth-child(9) {
  width: 15%;
}

#purchase .table-footer {
  padding: 10px 14px 14px;
  background: #ffffff;
}

#purchase .payment-actions {
  flex-wrap: nowrap;
}

#purchase .payment-actions .custom-select {
  min-width: 96px;
}

#purchase .inline-actions .ghost-button,
#purchase .payment-actions .ghost-button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 7px;
  white-space: nowrap;
}

#purchase .purchase-order-link {
  font-weight: 850;
}

@media (max-width: 1180px) {
  #purchase .purchase-module-header,
  .purchase-table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .purchase-subnav {
    align-self: flex-start;
  }

  .purchase-single-layout,
  .purchase-import-layout,
  .pending-import-layout,
  .pending-purchase-workbench {
    grid-template-columns: minmax(0, 1fr);
  }

  .purchase-side-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #purchase .purchase-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #purchase .pending-purchase-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .purchase-subnav {
    width: 100%;
    overflow-x: auto;
  }

  .purchase-subnav-item {
    flex: 1 0 auto;
  }

  .purchase-form-grid,
  #purchase .purchase-import-form,
  #purchase .pending-import-form,
  .pending-import-layout,
  .purchase-side-stack,
  #purchase .purchase-filter-grid,
  .pending-purchase-workbench {
    grid-template-columns: 1fr;
  }

  .purchase-imei-field,
  .purchase-note-field,
  .purchase-file-field,
  .purchase-import-actions,
  .pending-import-actions,
  .pending-receive-actions,
  #purchase .filter-field-wide {
    grid-column: auto;
  }

  .purchase-form-actions,
  .purchase-import-actions,
  .pending-import-actions,
  .pending-receive-actions,
  .purchase-failed-actions,
  #purchase .table-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .purchase-form-actions .primary-button,
  .purchase-import-actions .primary-button,
  .pending-import-actions .primary-button,
  .pending-receive-actions .primary-button,
  .purchase-failed-actions .primary-button,
  .purchase-failed-actions .ghost-button,
  .purchase-table-actions .ghost-button {
    width: 100%;
  }

  #purchase .pending-purchase-filter-grid {
    grid-template-columns: 1fr;
  }
}

/* Config v3 module pages */
#config .config-module-header {
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.config-subnav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 20px rgba(21, 32, 51, 0.05);
}

.config-subnav-item {
  min-height: 34px;
  padding: 7px 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.config-subnav-item:hover,
.config-subnav-item.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(15, 75, 255, 0.18);
}

.config-module,
.config-page {
  min-width: 0;
}

.config-page {
  display: none;
}

.config-page.active {
  display: block;
}

#config .card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

#config .card-header {
  align-items: flex-start;
  min-height: 0;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

#config .card-header .eyebrow {
  margin: 0 0 4px;
}

.config-template-card,
.config-basic-card,
.config-log-card {
  padding: 18px;
}

.config-template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 14px;
  align-items: start;
}

.config-template-main,
.config-template-side,
.config-basic-layout {
  display: grid;
  gap: 12px;
}

.config-module-copy {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.config-module-copy strong {
  color: var(--text);
  font-weight: 900;
}

.config-module-copy span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

#config .config-template-form,
#config .config-basic-form {
  gap: 10px;
}

#config .config-template-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#config .config-basic-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

#config .config-template-form label,
#config .config-basic-form label,
#config .config-template-delete-grid label,
#config .template-import-panel label {
  display: grid;
  gap: 6px;
  position: relative;
}

#config .config-template-form label span,
#config .config-basic-form label span,
#config .config-template-delete-grid label span,
#config .template-import-panel label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

#config .config-template-form input,
#config .config-basic-form input,
#config .template-import-panel input,
#config .config-template-delete-grid select,
#config .config-template-delete-grid .custom-select-trigger {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: #273448;
  font-weight: 750;
}

#config .template-import-panel,
#config .template-delete-panel {
  margin: 0;
  padding: 14px;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

#config .subsection-header h4 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 900;
}

#config .config-template-delete-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#config .template-delete-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#config .config-basic-layout {
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1fr);
  align-items: start;
}

#config .config-list {
  margin-top: 0;
  border-radius: var(--radius);
  background: #ffffff;
}

#config .config-list-body {
  max-height: clamp(320px, 54vh, 620px);
}

#config .operation-log-list {
  max-height: clamp(420px, calc(100vh - 230px), 760px);
  overflow: auto;
  border: 1px solid #eef2f7;
  border-radius: var(--radius);
}

#config .operation-log-row {
  grid-template-columns: 170px 120px minmax(0, 1fr);
  padding: 12px 14px;
}

@media (max-width: 1180px) {
  #config .config-module-header {
    align-items: stretch;
    flex-direction: column;
  }

  .config-subnav {
    align-self: flex-start;
    max-width: 100%;
    overflow-x: auto;
  }

  .config-template-layout,
  #config .config-basic-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .config-subnav {
    width: 100%;
  }

  .config-subnav-item {
    flex: 1 0 auto;
  }

  #config .config-template-form,
  #config .config-basic-form,
  #config .config-template-delete-grid {
    grid-template-columns: 1fr;
  }

  #config .config-template-form .wide,
  #config .template-delete-actions {
    grid-column: auto;
  }

  #config .config-basic-form .form-actions,
  #config .template-delete-actions {
    align-items: stretch;
    flex-direction: column;
  }

  #config .config-basic-form .primary-button,
  #config .template-delete-actions .ghost-button {
    width: 100%;
  }

  #config .operation-log-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) {
  .inventory-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #inventory .inventory-filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .inventory-filter-head {
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }

  #inventory .inventory-filter-actions {
    width: auto;
    justify-content: end;
  }

  #inventory .inventory-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #inventory .filter-field-wide {
    grid-column: span 2;
  }
}

@media (max-width: 720px) {
  .inventory-page-header,
  .inventory-filter-head,
  .inventory-table-head {
    align-items: stretch;
    flex-direction: column;
  }

  .inventory-page-actions {
    justify-content: stretch;
  }

  .inventory-page-actions .ghost-button,
  .inventory-page-actions .primary-button {
    width: 100%;
  }

  .inventory-summary-grid,
  #inventory .inventory-filter-grid {
    grid-template-columns: 1fr;
  }

  #inventory .inventory-filter-actions {
    width: 100%;
  }

  #inventory .inventory-filter-actions .ghost-button,
  #inventory .inventory-filter-actions .primary-button {
    width: 100%;
  }

  #inventory .inventory-table-wrap {
    height: clamp(320px, 58vh, 560px);
  }

  .inventory-table-actions {
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
  }

  .inventory-table-actions > span {
    white-space: normal;
  }

  .inventory-table-actions .ghost-button,
  .inventory-table-actions .primary-button {
    width: 100%;
  }

  #inventory .filter-field-wide {
    grid-column: auto;
  }
}

/* Login v3 layout */
.login-page-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 20%, rgba(15, 75, 255, 0.18), transparent 30rem),
    radial-gradient(circle at 76% 72%, rgba(17, 163, 155, 0.16), transparent 32rem),
    linear-gradient(135deg, #f8fafc 0%, #eef3f8 100%);
}

.login-page-shell {
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 440px);
  gap: clamp(40px, 8vw, 112px);
  align-items: center;
  width: min(1040px, calc(100vw - 48px));
  min-height: auto;
  padding: 48px 0;
}

.login-visual {
  display: grid;
  align-content: center;
  color: var(--text);
}

.login-brand-row {
  margin-bottom: 34px;
}

.login-hero-copy {
  max-width: 520px;
  padding: 28px 0;
}

.login-hero-copy h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(2rem, 4.2vw, 3.6rem);
  line-height: 1.08;
  font-weight: 850;
}

.login-hero-copy p:not(.eyebrow) {
  max-width: 34rem;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
  font-weight: 600;
}

.login-panel {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-strong);
}

.login-panel h2 {
  margin-top: 8px;
  font-size: 2rem;
}

.login-form {
  gap: 18px;
  margin-top: 28px;
}

.login-form input {
  min-height: 44px;
  border-radius: var(--radius);
}

.login-form .primary-button {
  min-height: 46px;
}

@media (max-width: 860px) {
  .login-page-shell {
    grid-template-columns: 1fr;
    width: min(100% - 32px, 480px);
    gap: 24px;
  }

  .login-visual {
    display: block;
  }

  .login-hero-copy {
    display: none;
  }
}

@media (max-width: 520px) {
  .login-page-shell {
    width: min(100% - 24px, 460px);
    padding: 24px 0;
  }

  .login-panel {
    padding: 24px;
  }
}

/* Fixed navigation shell: the nav stays put while the workspace scrolls. */
html,
body {
  height: 100%;
}

body {
  overflow: hidden !important;
}

.layout {
  height: 100vh;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.main,
body:has(#reports.panel.active) .main {
  height: 100vh !important;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable;
}

@media (max-width: 1100px) {
  body {
    overflow: hidden !important;
  }

  .layout {
    height: 100vh;
  }

  .main,
  body:has(#reports.panel.active) .main {
    height: 100vh !important;
    overflow-y: auto !important;
  }

  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 80;
    padding: 8px 0;
    background: rgba(244, 247, 251, 0.94);
    backdrop-filter: blur(10px);
  }
}

/* Profit report stable layout: body does not scroll, workspace and table own scrolling. */
body:has(#reports.panel.active) {
  overflow: hidden !important;
}

body:has(#reports.panel.active) .layout {
  height: 100vh;
  overflow: hidden;
}

body:has(#reports.panel.active) .main {
  height: 100vh !important;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding-bottom: 16px !important;
}

#reports.panel.active {
  display: block !important;
  height: auto !important;
  min-height: 0;
}

#reports .profit-workbench {
  display: grid !important;
  min-height: 0;
  overflow: visible !important;
}

#reports .profit-table-card {
  min-height: 0;
}

#reports .detail-table-wrap {
  height: clamp(360px, calc(100vh - 320px), 640px) !important;
  min-height: 320px;
  max-height: 640px;
  overflow: auto;
}

.correction-table-wrap {
  max-height: 460px;
  margin-top: 16px;
  overflow: auto;
}

.correction-table-wrap table {
  min-width: 860px;
}

.correction-table-wrap th:first-child,
.correction-table-wrap td:first-child {
  width: 72px;
  text-align: center;
}

.system-health-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.health-card {
  display: grid;
  gap: 6px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: #f8fafc;
}

.health-card span,
.health-card small {
  color: #64748b;
  font-size: 12px;
}

.health-card strong {
  min-width: 0;
  overflow: hidden;
  color: #0f172a;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .system-health-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

/* Keep global search results above page-level toolbars and filters. */
.global-search {
  z-index: 120;
}

.global-search-results {
  z-index: 130;
}

.detail-modal,
.overlay {
  z-index: 400;
}

/* Single-user workspace: keep each page focused on its primary task. */
#dashboard .dashboard-comparison-strip,
#inventory .inventory-insight-grid,
.optional-analysis {
  display: none;
}

#dashboard {
  max-width: 1440px;
}

#dashboard .dashboard-kpi-grid {
  margin-bottom: 24px;
}

#inventory .inventory-workbench {
  grid-template-columns: minmax(0, 1fr);
}

#inventory .inventory-results-column {
  min-width: 0;
}

/* Operations UI pass: one quiet, dense visual language across every workspace. */
.panel > .panel-header {
  min-height: 64px;
  margin: 0 0 14px;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--line);
}

.panel > .panel-header .eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 750;
}

.panel > .panel-header h3 {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 850;
}

.panel-header-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
}

#inventory .inventory-filter-panel,
#inventory .inventory-table-card,
#purchase .card,
#sales .sales-console,
#reports .operations-panel,
#config .card {
  box-shadow: none;
}

#inventory .inventory-filter-panel,
#purchase .purchase-subnav,
#sales .sales-draft-wrap {
  border-radius: var(--radius);
}

#inventory .inventory-table-wrap tbody td:nth-child(9),
#inventory .inventory-table-wrap tbody td:nth-child(10),
#inventory .inventory-table-wrap tbody td:nth-child(11),
#sales .sales-draft-table-wrap td:nth-child(8),
#sales .sales-draft-table-wrap td:nth-child(9),
#reports .detail-table-wrap td:nth-child(7),
#reports .detail-table-wrap td:nth-child(8),
#reports .detail-table-wrap td:nth-child(9),
#reports .detail-table-wrap td:nth-child(10),
#reports .detail-table-wrap td:nth-child(11),
#reports .detail-table-wrap td:nth-child(12) {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.purchase-side-card:first-child {
  border-color: rgba(15, 75, 255, 0.24);
  background: var(--accent-soft);
}

.purchase-side-card:first-child strong {
  color: var(--accent-deep);
  font-size: 1.34rem;
}

.sales-submit-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 18px rgba(21, 32, 51, 0.05);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.sales-submit-bar .primary-button {
  min-width: 128px;
  min-height: 40px;
}

:where(button, input, select, textarea):focus-visible {
  outline: 3px solid rgba(15, 75, 255, 0.3);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .panel > .panel-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .panel-header-note {
    line-height: 1.5;
  }

  .sales-submit-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .sales-submit-bar .primary-button {
    width: 100%;
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Unified operations system: final page-level overrides. */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-soft: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --muted-soft: #94a3b8;
  --accent: #2563eb;
  --accent-deep: #1d4ed8;
  --accent-soft: #eff6ff;
  --teal: #0f766e;
  --teal-soft: #f0fdfa;
  --success: #047857;
  --success-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-strong: 0 14px 32px rgba(15, 23, 42, 0.14);
  --radius: 8px;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
}

::selection {
  background: #bfdbfe;
  color: #0f172a;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #cbd5e1;
  background-clip: content-box;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.layout {
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  padding: 18px 12px;
  background: #fff;
  box-shadow: none;
}

.brand {
  margin: 0 4px 16px;
  padding: 0 0 16px;
}

.brand-mark {
  box-shadow: none;
}

.nav {
  gap: 3px;
}

.nav-item {
  min-height: 42px;
  border-radius: 6px;
  font-size: 0.92rem;
}

.nav-item:hover {
  background: #f8fafc;
  color: #334155;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-weight: 850;
}

.main {
  padding: 20px 24px 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  min-height: 68px;
  margin: -20px -24px 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(12px);
}

.topbar h2 {
  font-size: 1.35rem;
}

.topbar-actions {
  gap: 8px;
}

.global-search input,
.server-tag,
.notification-toggle,
.topbar-actions > .ghost-button {
  box-shadow: none;
}

.global-search input {
  min-height: 38px;
}

.server-tag {
  min-height: 34px;
  font-size: 0.8rem;
}

button,
.primary-button,
.ghost-button,
.text-button,
.nav-item,
.quick-action,
.inbound-action,
.list-item,
.notification-item {
  touch-action: manipulation;
}

.primary-button {
  box-shadow: none;
}

.primary-button:hover {
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.22);
}

.ghost-button:hover {
  box-shadow: none;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

label:has([required]) > span::after {
  margin-left: 3px;
  color: var(--danger);
  content: "*";
}

.form-message[role="status"],
.form-message {
  min-height: 20px;
}

.dashboard-head,
.panel > .panel-header {
  margin-bottom: 16px;
}

.dashboard-kpi-card,
.inventory-summary-card,
.profit-kpi-card,
.purchase-side-card,
.health-card {
  border-radius: var(--radius);
  box-shadow: none;
}

.dashboard-kpi-card,
.inventory-summary-card {
  border-color: var(--line);
}

.dashboard-kpi-card:hover,
.inventory-summary-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.card,
.operations-panel,
.inventory-filter-panel,
.purchase-filter-panel,
.profit-filter-panel,
.detail-modal-panel {
  border-color: var(--line);
  box-shadow: none;
}

.card-header,
.inventory-table-head,
.purchase-table-head,
.operations-panel-head {
  border-color: var(--line);
}

.inventory-advanced-filters {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.inventory-advanced-filters summary {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.inventory-advanced-filters[open] summary {
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.inventory-advanced-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(126px, 1fr));
  gap: 10px;
  padding: 10px;
}

.table-wrap {
  scrollbar-color: #cbd5e1 transparent;
}

th {
  height: 40px;
  color: #475569;
  font-size: 0.75rem;
}

td {
  color: #334155;
  font-size: 0.86rem;
}

.inventory-table-wrap tbody tr:hover,
.detail-table-wrap tbody tr:hover,
.sales-draft-table-wrap tbody tr:hover,
#purchase .detail-table-wrap tbody tr[data-purchase-detail]:hover {
  background: #f8fafc;
}

.badge,
.status-pill,
.purchase-status-pill,
.server-tag {
  box-shadow: none;
}

.detail-modal {
  padding: 24px;
  place-items: center;
}

.detail-modal-panel {
  width: fit-content;
  min-width: min(560px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  max-height: min(88vh, calc(100dvh - 48px));
  min-height: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-strong);
}

.detail-modal-header {
  position: sticky;
  top: -20px;
  z-index: 2;
  margin: -20px -20px 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.detail-grid-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

#purchase .purchase-subnav,
#config .config-subnav,
.sales-mode-switch {
  box-shadow: none;
}

#purchase .purchase-subnav-item,
#config .config-subnav-item {
  border-radius: 6px;
}

#purchase .purchase-subnav-item.active,
#config .config-subnav-item.active {
  box-shadow: none;
}

#config .config-module-header,
#reports .reports-page-header,
#sales .sales-page-header,
#purchase .purchase-module-header {
  align-items: flex-end;
}

.login-page-body {
  background: var(--bg);
}

.login-page-shell {
  width: min(920px, calc(100vw - 48px));
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 420px);
  gap: clamp(32px, 7vw, 80px);
}

.login-visual {
  align-self: center;
}

.login-panel {
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.login-form input {
  min-height: 44px;
}

@media (max-width: 1180px) {
  .topbar-actions #template-summary {
    display: none;
  }

  .inventory-advanced-filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .layout {
    display: block;
    height: auto;
  }

  .sidebar {
    display: none;
  }

  .main,
  body:has(#reports.panel.active) .main {
    height: 100dvh !important;
    padding: 16px 16px 28px;
  }

  .topbar {
    min-height: 56px;
    margin: -16px -16px 14px;
    padding: 10px 16px;
  }

  .topbar h2 {
    font-size: 1.12rem;
  }

  .topbar .eyebrow,
  #current-user,
  .notification-center {
    display: none;
  }

  .global-search {
    width: min(100%, 360px);
  }

  .global-search input {
    min-height: 40px;
    font-size: 16px;
  }

  .mobile-nav {
    top: 56px;
    z-index: 80;
    gap: 6px;
    margin: 0 -16px 16px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 250, 252, 0.96);
  }

  .mobile-nav .nav-item {
    min-height: 38px;
    padding: 0 12px 0 28px;
    font-size: 0.84rem;
  }

  .detail-modal-panel {
    width: 100vw;
    padding: 18px 16px;
  }

  .detail-modal-header {
    top: -18px;
    margin: -18px -16px 16px;
    padding: 16px;
  }

  .detail-grid-list,
  .inventory-advanced-filter-grid {
    grid-template-columns: 1fr;
  }

  .login-page-shell {
    width: min(100% - 32px, 480px);
  }
}

@media (max-width: 560px) {
  .topbar-actions > .ghost-button:not(#logout-button) {
    display: none;
  }

  .topbar-actions {
    flex: 1;
  }

  .global-search {
    width: 100%;
  }

  .topbar > div:first-child {
    display: none;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions > .global-search {
    flex: 1;
  }

  .login-panel {
    padding: 22px;
  }
}

/* ===== Toast 提示 ===== */
.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  max-width: min(380px, calc(100vw - 48px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #172033;
  color: #fff;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.22);
  animation: toast-in 0.22s ease-out;
  pointer-events: auto;
}

.toast.is-success { background: #0f766e; }
.toast.is-error { background: #b91c1c; }

.toast button {
  margin-left: auto;
  flex: none;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 表头列排序 ===== */
th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th[data-sort]:hover {
  color: var(--accent);
}

th[data-sort]::after {
  content: "";
  display: inline-block;
  width: 0.9em;
  margin-left: 4px;
  opacity: 0.35;
}

th.sorted-asc[data-sort]::after {
  content: "▲";
  opacity: 1;
  color: var(--accent);
}

th.sorted-desc[data-sort]::after {
  content: "▼";
  opacity: 1;
  color: var(--accent);
}

/* ===== 列表错误态 ===== */
td.error-table-cell {
  color: var(--danger);
}

/* ===== Dashboard 空态引导 ===== */
.dashboard-empty-guide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.dashboard-empty-guide p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
