:root {
  color-scheme: light;
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-subtle: #f7f8f7;
  --surface-strong: #edf1ef;
  --text: #202623;
  --text-secondary: #68716d;
  --text-tertiary: #929a96;
  --line: #dfe4e1;
  --line-strong: #cdd5d1;
  --green: #257255;
  --green-strong: #195f45;
  --green-soft: #e6f1eb;
  --blue: #316fa2;
  --blue-soft: #e8f0f6;
  --amber: #b7791f;
  --amber-soft: #fbf0dc;
  --red: #bd4545;
  --red-soft: #fae9e8;
  --purple: #72569a;
  --sidebar-width: 238px;
  --topbar-height: 74px;
  --radius: 6px;
  --shadow: 0 10px 28px rgba(25, 36, 31, 0.07);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171b19;
  --surface: #202522;
  --surface-subtle: #252b28;
  --surface-strong: #2b322e;
  --text: #eef2ef;
  --text-secondary: #b2bbb6;
  --text-tertiary: #808a85;
  --line: #343c38;
  --line-strong: #48524d;
  --green: #4fa47e;
  --green-strong: #6eb995;
  --green-soft: #233b30;
  --blue: #72a8d2;
  --blue-soft: #233645;
  --amber: #d9a24e;
  --amber-soft: #45371f;
  --red: #df7777;
  --red-soft: #472928;
  --purple: #ad8fd0;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

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

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

.app-loading {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: var(--bg);
  color: var(--text-secondary);
}

.loading-mark,
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: 20px;
  font-weight: 750;
}

.app-loading .loading-mark {
  animation: loadingPulse 1.2s ease-in-out infinite;
}

@keyframes loadingPulse {
  50% { opacity: 0.55; transform: scale(0.96); }
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: width 180ms ease, transform 180ms ease;
}

.brand-row {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-copy strong {
  font-size: 16px;
}

.brand-copy span {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 10px;
}

.icon-button.sidebar-close {
  display: none;
  margin-left: auto;
}

.main-nav {
  flex: 1;
  overflow-y: auto;
  padding: 18px 11px;
}

.nav-item {
  position: relative;
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  padding: 0 13px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-item.is-active {
  background: var(--green-soft);
  color: var(--green-strong);
  font-weight: 650;
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 20px;
  border-radius: 0 2px 2px 0;
  background: var(--green);
}

.nav-item svg {
  flex: 0 0 auto;
}

.nav-item span {
  white-space: nowrap;
}

.nav-count {
  min-width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10px;
}

.nav-divider {
  margin: 20px 13px 8px;
  color: var(--text-tertiary);
  font-size: 10px;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--line);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 9px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.sync-status div {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.sync-status strong {
  font-size: 11px;
}

.sync-status span:last-child {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left 180ms ease;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px, 2.4vw, 34px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar-leading,
.topbar-actions,
.clock,
.user-summary,
.button-row,
.toolbar-controls {
  display: flex;
  align-items: center;
}

.topbar-leading {
  min-width: 0;
  gap: 14px;
}

.breadcrumb {
  margin: 0 0 3px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  gap: 11px;
}

.icon-button {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.clock {
  gap: 9px;
  padding: 0 13px;
  border-right: 1px solid var(--line);
  color: var(--text-secondary);
}

.clock div,
.user-summary > div:nth-child(2) {
  display: flex;
  flex-direction: column;
}

.clock strong {
  font-size: 12px;
}

.clock span,
.user-summary span {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.demo-role {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 10px;
}

.demo-role select {
  height: 32px;
  width: 92px;
}

.user-summary {
  gap: 8px;
  min-width: 150px;
  padding-left: 3px;
}

.user-summary strong {
  font-size: 11px;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.user-menu-trigger {
  width: 30px;
  height: 30px;
  margin-left: auto;
  border: 0;
}

.main-content {
  width: min(100%, 1640px);
  min-height: calc(100vh - var(--topbar-height));
  margin: 0 auto;
  padding: clamp(22px, 2.5vw, 38px);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: viewIn 180ms ease both;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-actions-row {
  min-height: 52px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-actions-row h2,
.panel h3,
.form-section-header h3 {
  margin: 0;
}

.page-actions-row h2 {
  font-size: 22px;
  font-weight: 680;
}

.page-actions-row p,
.panel-header p,
.form-section-header span {
  margin: 7px 0 0;
  color: var(--text-tertiary);
  font-size: 11px;
}

.button-row {
  gap: 9px;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 620;
}

.button.primary {
  background: var(--green);
  color: #fff;
}

.button.primary:hover {
  background: var(--green-strong);
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text-secondary);
}

.button.secondary:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

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

.full-width {
  width: 100%;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-size: 11px;
}

.text-button svg {
  width: 14px;
  height: 14px;
}

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

.panel-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel h3,
.form-section-header h3 {
  font-size: 14px;
  font-weight: 680;
}

.panel-meta,
.document-no {
  color: var(--text-tertiary);
  font-size: 10px;
}

.document-no {
  padding-top: 8px;
  font-variant-numeric: tabular-nums;
}

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

.metric-card {
  position: relative;
  min-height: 126px;
  overflow: hidden;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--metric-color, var(--green));
}

.metric-card .metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 11px;
}

.metric-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--metric-soft, var(--green-soft));
  color: var(--metric-color, var(--green));
}

.metric-icon svg {
  width: 16px;
  height: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 16px;
  font-size: clamp(23px, 2.2vw, 31px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 9px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.dashboard-layout,
.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
  gap: 18px;
  margin-bottom: 18px;
}

.alert-list,
.movement-list {
  min-height: 305px;
}

.alert-item,
.movement-item {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
}

.alert-item {
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 1.2fr) auto;
}

.alert-item:last-child,
.movement-item:last-child {
  border-bottom: 0;
}

.alert-name,
.movement-copy {
  min-width: 0;
}

.alert-name strong,
.movement-copy strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-name span,
.movement-copy span {
  display: block;
  margin-top: 5px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.stock-bar,
.rank-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-strong);
}

.stock-bar i,
.rank-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
}

.stock-amount {
  color: var(--red);
  font-size: 11px;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.movement-item {
  grid-template-columns: 32px minmax(0, 1fr) auto;
}

.movement-symbol {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.movement-symbol.is-in {
  background: var(--green-soft);
  color: var(--green);
}

.movement-symbol.is-out {
  background: var(--amber-soft);
  color: var(--amber);
}

.movement-change {
  font-size: 11px;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.movement-change.positive { color: var(--green); }
.movement-change.negative { color: var(--amber); }

.empty-state {
  min-height: 180px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--text-tertiary);
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
}

.empty-state strong {
  color: var(--text-secondary);
  font-size: 12px;
}

.summary-panel {
  padding-bottom: 18px;
}

.mini-chart,
.report-chart {
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 22px 24px 4px;
}

.chart-day {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  height: 100%;
}

.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.chart-bar {
  width: min(14px, 42%);
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--blue);
}

.chart-bar.purchase {
  background: var(--amber);
}

.chart-day > span {
  margin-top: 8px;
  color: var(--text-tertiary);
  font-size: 8px;
  text-align: center;
}

.table-panel {
  overflow: hidden;
}

.table-toolbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.search-box {
  width: min(100%, 330px);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-tertiary);
}

.search-box.compact {
  width: 240px;
}

.search-box input {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.search-box svg {
  width: 15px;
  height: 15px;
}

.toolbar-controls {
  gap: 8px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

select,
input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-height: 74px;
  padding: 10px;
  resize: vertical;
}

select:hover,
input:hover,
textarea:hover {
  border-color: var(--line-strong);
}

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

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

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

th {
  background: var(--surface-subtle);
  color: var(--text-tertiary);
  font-size: 9px;
  font-weight: 650;
}

td {
  font-size: 11px;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--green-soft) 40%, transparent);
}

.cell-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cell-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--surface-strong);
  color: var(--text-secondary);
}

.cell-title strong,
.cell-title span,
.cell-stack strong,
.cell-stack span {
  display: block;
}

.cell-title strong,
.cell-stack strong {
  font-size: 11px;
}

.cell-title span,
.cell-stack span {
  margin-top: 4px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.status-tag,
.role-tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 9px;
  font-weight: 650;
}

.status-tag.normal { background: var(--green-soft); color: var(--green); }
.status-tag.low { background: var(--red-soft); color: var(--red); }
.role-tag.admin { background: var(--blue-soft); color: var(--blue); }
.role-tag.warehouse { background: var(--green-soft); color: var(--green); }
.role-tag.cashier { background: var(--amber-soft); color: var(--amber); }

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

.stock-cell strong {
  display: block;
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
}

.stock-cell .stock-bar i.normal {
  background: var(--green);
}

.table-footer {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.purchase-layout,
.sales-layout,
.settings-layout {
  display: grid;
  align-items: start;
  gap: 18px;
}

.purchase-layout {
  grid-template-columns: minmax(0, 1fr) 310px;
}

.purchase-main {
  overflow: hidden;
  padding: 0 20px 22px;
}

.form-section-header {
  display: flex;
  justify-content: space-between;
  padding: 20px 0 17px;
  border-bottom: 1px solid var(--line);
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

.purchase-main > .form-grid {
  padding: 18px 0;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 620;
}

.field small,
.field-error {
  min-height: 12px;
  color: var(--text-tertiary);
  font-size: 8px;
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea {
  border-color: var(--red);
}

.field.is-invalid .field-error {
  color: var(--red);
}

.line-table-wrap {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.line-table select,
.line-table input {
  width: 100%;
  min-width: 92px;
}

.line-table td {
  padding: 10px 8px;
}

.line-table th:first-child,
.line-table td:first-child {
  min-width: 180px;
}

.line-subtotal {
  min-width: 74px;
  font-variant-numeric: tabular-nums;
}

.line-remove {
  width: 30px;
  height: 30px;
  border: 0;
  color: var(--text-tertiary);
}

.line-remove:hover {
  color: var(--red);
}

.add-line-button {
  margin: 14px;
}

.order-summary {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
  padding: 20px;
}

.order-summary h3 {
  margin-bottom: 18px;
}

.order-summary dl {
  margin: 0;
}

.order-summary dl div {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.order-summary dt {
  color: var(--text-secondary);
  font-size: 10px;
}

.order-summary dd {
  margin: 0;
  font-size: 11px;
  font-weight: 650;
}

.order-summary .summary-total {
  align-items: end;
  padding: 18px 0;
  border-bottom: 0;
}

.summary-total dd {
  color: var(--green);
  font-size: 24px;
}

.conversion-note {
  display: flex;
  gap: 9px;
  margin: 4px 0 18px;
  padding: 12px;
  background: var(--green-soft);
  border-radius: 5px;
  color: var(--green-strong);
}

.conversion-note svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}

.conversion-note p {
  margin: 0;
  font-size: 9px;
  line-height: 1.6;
}

.sales-layout {
  grid-template-columns: minmax(0, 1fr) 350px;
}

.dish-filters {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
}

.dish-filters button,
.segmented button {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
}

.dish-filters button {
  border-radius: 17px;
}

.dish-filters button.is-active,
.segmented button.is-active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-strong);
  font-weight: 650;
}

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

.dish-card {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.dish-card:hover {
  border-color: var(--green);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.dish-card:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.dish-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 2.45;
  object-fit: cover;
  background: var(--surface-strong);
}

.dish-card-copy {
  padding: 12px;
}

.dish-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dish-card strong {
  font-size: 12px;
}

.dish-card-price {
  color: var(--green);
  font-weight: 700;
}

.dish-card p {
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--text-tertiary);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 18px);
  min-height: 560px;
  overflow: hidden;
  padding-bottom: 18px;
}

.cart-lines {
  max-height: 250px;
  overflow-y: auto;
}

.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.cart-line-title strong,
.cart-line-title span {
  display: block;
}

.cart-line-title strong { font-size: 11px; }
.cart-line-title span { margin-top: 4px; color: var(--text-tertiary); font-size: 9px; }

.stepper {
  display: grid;
  grid-template-columns: 26px 28px 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.stepper button {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.stepper span {
  font-size: 10px;
  text-align: center;
}

.bom-preview {
  margin: 14px 18px;
  padding: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.bom-preview h4 {
  margin: 0 0 10px;
  font-size: 10px;
}

.bom-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  color: var(--text-secondary);
  font-size: 9px;
}

.bom-row.is-short {
  color: var(--red);
  font-weight: 650;
}

.cart-total {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.cart-total span {
  color: var(--text-secondary);
  font-size: 10px;
}

.cart-total strong {
  color: var(--green);
  font-size: 24px;
}

.cart-panel > .button {
  width: calc(100% - 36px);
  margin: 0 18px;
}

.toolbar-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 10px;
}

.toolbar-note svg { width: 15px; height: 15px; color: var(--blue); }

.count-input {
  width: 120px;
}

.variance-positive { color: var(--green); font-weight: 650; }
.variance-negative { color: var(--red); font-weight: 650; }
.variance-zero { color: var(--text-tertiary); }

.segmented {
  display: inline-flex;
}

.segmented button:first-child { border-radius: 5px 0 0 5px; }
.segmented button:last-child { border-radius: 0 5px 5px 0; margin-left: -1px; }

.report-metrics .metric-card {
  min-height: 116px;
}

.report-chart-panel,
.popular-panel {
  min-height: 420px;
}

.report-chart {
  height: 290px;
  gap: 7px;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 18px;
  color: var(--text-tertiary);
  font-size: 9px;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend-sales { background: var(--blue); }
.legend-purchase { background: var(--amber); }

.popular-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
}

.rank-number {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
}

.popular-copy strong,
.popular-copy span {
  display: block;
}

.popular-copy strong { font-size: 11px; }
.popular-copy span { margin-top: 5px; color: var(--text-tertiary); font-size: 9px; }
.popular-qty { font-size: 11px; font-weight: 650; }

.bom-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 420px;
  white-space: normal;
}

.bom-tag {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 3px;
  background: var(--surface-strong);
  color: var(--text-secondary);
  font-size: 9px;
}

.settings-layout {
  grid-template-columns: minmax(300px, 0.76fr) minmax(0, 1.24fr);
}

.settings-panel,
.user-panel {
  overflow: hidden;
}

.inline-setting {
  padding: 20px;
}

.inline-setting .field {
  margin-bottom: 18px;
}

.inline-setting input {
  width: 180px;
}

.modal {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 17, 0.52);
}

.modal-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 0 22px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.modal-dialog.small {
  width: min(430px, 100%);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-header p {
  margin: 6px 0 0;
  color: var(--text-tertiary);
  font-size: 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.login-layer {
  position: fixed;
  z-index: 150;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #edf1ef;
}

.login-panel {
  width: min(410px, 100%);
  padding: 30px;
  background: #fff;
  color: #202623;
  border: 1px solid #dfe4e1;
  border-radius: 7px;
  box-shadow: 0 24px 70px rgba(25, 36, 31, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 36px;
}

.login-brand > div:last-child {
  display: flex;
  flex-direction: column;
}

.login-brand strong { font-size: 15px; }
.login-brand span { margin-top: 3px; color: #87908b; font-size: 9px; }
.login-panel h1 { margin: 0; font-size: 23px; }
.login-panel > div:nth-child(2) p { margin: 8px 0 24px; color: #87908b; font-size: 11px; }
.login-panel .field { margin-bottom: 14px; }
.login-error { min-height: 18px; margin: 0 0 9px; color: #bd4545; font-size: 10px; }
.demo-accounts { display: grid; gap: 5px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e5e9e7; color: #87908b; font-size: 8px; }

.toast-region {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  width: min(360px, calc(100vw - 44px));
  display: grid;
  gap: 9px;
}

.toast {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: 5px;
  box-shadow: var(--shadow);
  animation: toastIn 180ms ease both;
}

.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--amber); }
.toast svg { width: 17px; height: 17px; color: var(--green); }
.toast.error svg { color: var(--red); }
.toast.warning svg { color: var(--amber); }
.toast strong { display: block; font-size: 11px; }
.toast p { margin: 4px 0 0; color: var(--text-secondary); font-size: 9px; line-height: 1.5; }
.toast button { width: 24px; height: 24px; border: 0; background: transparent; color: var(--text-tertiary); cursor: pointer; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

body.sidebar-collapsed {
  --sidebar-width: 76px;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-divider span,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .nav-count {
  display: none;
}

body.sidebar-collapsed .brand-row,
body.sidebar-collapsed .nav-item {
  justify-content: center;
}

body.sidebar-collapsed .nav-item {
  padding: 0;
}

.sidebar-backdrop {
  display: none;
}

.toolbar-input {
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 10px;
}

.cell-title-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cell-title-button:hover strong,
.link-button:hover { color: var(--green); }

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  min-width: 72px;
}

.table-action {
  width: 28px;
  height: 28px;
  border-color: transparent;
}

.table-action:hover {
  border-color: var(--line);
  background: var(--surface-subtle);
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.movement-type {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 9px;
  font-weight: 700;
}

.movement-type.in { background: var(--green-soft); color: var(--green); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: var(--surface-subtle); }

.document-summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 10px;
}

.document-summary strong { color: var(--text); font-size: 15px; }
.compact-action { font-size: 9px; }
.compact-action:disabled { opacity: 0.4; cursor: not-allowed; }

.cart-meta-fields {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.cart-meta-fields .field { gap: 5px; }
.cart-meta-fields .field span { font-size: 9px; }

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
  margin-top: 16px;
}

.analysis-grid > .panel { min-height: 300px; padding: 19px; }
.replenishment-panel { margin-top: 16px; }

.category-value-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(150px, 1.2fr);
  align-items: center;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.category-value-row:last-child { border-bottom: 0; }
.category-value-row > div { min-width: 0; }
.category-value-row strong { display: block; font-size: 11px; }
.category-value-row span { display: block; margin-top: 4px; color: var(--text-tertiary); font-size: 9px; }
.category-value { text-align: right; }
.category-value .rank-bar { margin-top: 8px; }
.compact-table-wrap { overflow-x: auto; }
.compact-table { min-width: 520px; }
.compact-table th, .compact-table td { padding: 10px 8px; }

.field-span-2 { grid-column: 1 / -1; }
.input-with-unit { display: flex; align-items: center; }
.input-with-unit input { border-radius: 6px 0 0 6px; }
.input-with-unit span {
  display: grid;
  place-items: center;
  min-width: 42px;
  align-self: stretch;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 6px 6px 0;
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.modal-dialog.wide { width: min(840px, 100%); }

.detail-drawer {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: none;
}

.detail-drawer.is-open { display: block; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 17, 0.42); }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  width: min(620px, 92vw);
  height: 100%;
  background: var(--surface);
  box-shadow: -18px 0 48px rgba(25, 33, 28, 0.16);
  animation: drawerIn 180ms ease both;
}

@keyframes drawerIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.drawer-header p { margin: 0 0 6px; color: var(--green); font-size: 9px; font-weight: 700; }
.drawer-header h2 { margin: 0; font-size: 19px; }
.drawer-content { flex: 1; overflow-y: auto; padding: 22px 24px 30px; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 9px; min-height: 72px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface); }
.drawer-actions:empty { display: none; }

.drawer-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.drawer-metrics > div { min-width: 0; padding: 13px; background: var(--surface-subtle); }
.drawer-metrics span { display: block; color: var(--text-tertiary); font-size: 8px; }
.drawer-metrics strong { display: block; margin-top: 6px; font-size: 12px; overflow-wrap: anywhere; }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--text-tertiary); font-size: 9px; }
.detail-list dd { margin: 0; color: var(--text); font-size: 10px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.drawer-section { margin-top: 26px; }
.drawer-section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.drawer-section-title h3 { margin: 0; font-size: 13px; }
.drawer-section-title span { color: var(--text-tertiary); font-size: 9px; }
.drawer-line { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.drawer-line div { min-width: 0; }
.drawer-line strong { display: block; font-size: 10px; }
.drawer-line span { display: block; margin-top: 4px; color: var(--text-tertiary); font-size: 8px; }
.drawer-table { min-width: 560px; }
.drawer-table th, .drawer-table td { padding: 10px 8px; }

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

@media (max-width: 760px) {
  .cart-meta-fields { grid-template-columns: 1fr; }
  .document-tabs { width: 100%; overflow-x: auto; }
  .document-summary { justify-content: space-between; }
  .field-span-2 { grid-column: auto; }
  .drawer-panel { width: 100%; }
  .drawer-header, .drawer-content, .drawer-actions { padding-left: 16px; padding-right: 16px; }
  .drawer-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-value-row { grid-template-columns: 1fr; gap: 8px; }
  .category-value { text-align: left; }
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 76px; }

  .brand-copy,
  .nav-item span,
  .nav-divider span,
  .sidebar-footer,
  .nav-count {
    display: none;
  }

  .brand-row,
  .nav-item { justify-content: center; }
  .nav-item { padding: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dish-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock { display: none; }
}

@media (max-width: 930px) {
  .dashboard-layout,
  .report-layout,
  .purchase-layout,
  .sales-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .order-summary,
  .cart-panel {
    position: static;
  }

  .cart-panel { min-height: 0; }
  .settings-layout { gap: 18px; }
  .demo-role span { display: none; }
}

@media (max-width: 760px) {
  :root { --topbar-height: 66px; --sidebar-width: 0px; }

  .sidebar {
    width: min(280px, 86vw);
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .brand-copy,
  .nav-item span,
  .nav-divider span,
  .sidebar-footer,
  .nav-count {
    display: flex;
  }

  .nav-item,
  .brand-row {
    justify-content: flex-start;
  }

  .nav-item { padding: 0 13px; }
  .nav-count { margin-left: auto; }
  .icon-button.sidebar-close { display: grid; }

  body.sidebar-open .sidebar-backdrop {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: block;
    background: rgba(15, 20, 17, 0.42);
  }

  .workspace { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .breadcrumb { display: none; }
  .topbar h1 { font-size: 16px; }
  .topbar-actions { gap: 5px; }
  .user-summary { min-width: 0; }
  .user-summary > div:nth-child(2),
  .user-menu-trigger { display: none; }
  .demo-role { display: none !important; }

  .main-content { padding: 18px 14px 30px; }
  .page-actions-row { align-items: flex-start; margin-bottom: 18px; }
  .page-actions-row h2 { font-size: 19px; }
  .page-actions-row p { max-width: 230px; line-height: 1.5; }
  .button-row .secondary { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { min-height: 112px; padding: 15px; }
  .metric-card strong { font-size: 23px; }

  .table-toolbar { align-items: stretch; flex-direction: column; }
  .search-box,
  .search-box.compact { width: 100%; }
  .toolbar-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-footer span:last-child { display: none; }
  th, td { padding: 12px; }
  .form-grid.two-columns { grid-template-columns: 1fr; }
  .purchase-main { padding-inline: 14px; }
  .line-table-wrap { overflow-x: auto; }
  .line-table { min-width: 720px; }
  .dish-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .dish-card-copy { padding: 10px; }
  .dish-card-row { align-items: flex-start; flex-direction: column; gap: 5px; }
  .mini-chart, .report-chart { padding-inline: 12px; gap: 5px; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-dialog { width: 100%; max-height: 90vh; border-radius: 7px 7px 0 0; }
}

@media (max-width: 430px) {
  .page-actions-row { flex-direction: column; }
  .page-actions-row > .button,
  .page-actions-row .button-row { width: 100%; }
  .page-actions-row .button-row .button { flex: 1; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 104px; }
  .dashboard-layout { gap: 12px; }
  .alert-item { grid-template-columns: minmax(0, 1fr) auto; }
  .alert-item .stock-bar { display: none; }
  .dish-grid { grid-template-columns: 1fr; }
  .dish-card { display: grid; grid-template-columns: 120px minmax(0, 1fr); }
  .dish-card img { height: 100%; aspect-ratio: auto; }
  .table-footer { justify-content: center; }
  .login-panel { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
