:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --violet: #7c3aed;
  --violet-soft: #f5f3ff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 5%);
  --shadow-md: 0 10px 30px rgb(15 23 42 / 8%);
  --sidebar-width: 256px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

svg {
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

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

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 15% 15%, rgb(219 234 254 / 60%), transparent 32%),
    radial-gradient(circle at 85% 80%, rgb(224 231 255 / 55%), transparent 30%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 16px rgb(37 99 235 / 22%);
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  transition: border-color 160ms, box-shadow 160ms;
}

.input::placeholder {
  color: var(--muted-light);
}

.input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px #dbeafe;
}

.checkbox-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.checkbox-label input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.text-link {
  color: var(--primary);
  font-weight: 600;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 650;
  transition: background 160ms, border-color 160ms, color 160ms, box-shadow 160ms;
}

.button:focus-visible,
.icon-button:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.button-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: var(--shadow-sm);
}

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

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

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

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.button-block {
  width: 100%;
}

.form-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.demo-hint {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-header {
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.sidebar-brand .brand-mark svg {
  width: 19px;
}

.sidebar-brand-copy {
  min-width: 0;
}

.sidebar-brand-copy .brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 18px 12px;
  overflow-y: auto;
}

.nav-section + .nav-section {
  margin-top: 22px;
}

.nav-section-title {
  margin: 0 10px 8px;
  color: var(--muted-light);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 550;
  text-align: left;
  transition: color 160ms, background 160ms;
}

.nav-link svg {
  width: 18px;
  height: 18px;
}

.nav-link:hover {
  color: var(--text-soft);
  background: var(--surface-soft);
}

.nav-link.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-badge {
  min-width: 20px;
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

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

.user-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  font-size: 13px;
  font-weight: 700;
}

.user-copy {
  min-width: 0;
  flex: 1;
}

.user-name {
  overflow: hidden;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email {
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(12px);
}

.mobile-menu-button {
  display: none;
}

.topbar-spacer {
  flex: 1;
}

.topbar-search {
  position: relative;
  width: min(340px, 36vw);
}

.topbar-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  height: 40px;
  padding: 9px 12px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface-soft);
  font-size: 13px;
  transition: border-color 160ms, box-shadow 160ms, background 160ms;
}

.topbar-search input:focus {
  border-color: #93c5fd;
  background: var(--surface);
  box-shadow: 0 0 0 3px #eff6ff;
}

.icon-button {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  transition: color 160ms, background 160ms, border-color 160ms;
}

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

.icon-button svg {
  width: 18px;
  height: 18px;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ef4444;
}

.popover-wrap {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 50;
  width: 280px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.popover-title {
  padding: 8px 10px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.popover-item {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-soft);
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.popover-item:hover {
  background: var(--surface-soft);
}

.popover-item svg {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  color: var(--muted);
}

.notification-item strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 13px;
}

.notification-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.025em;
}

.page-description {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Cards and metrics */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

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

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius-lg);
}

.metric-card::after {
  position: absolute;
  top: -32px;
  right: -32px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--tint, #eff6ff);
  content: "";
  opacity: 0.8;
}

.metric-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  color: var(--accent, var(--primary));
  background: var(--tint, var(--primary-soft));
}

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

.metric-value {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  font-size: 28px;
  font-weight: 760;
  letter-spacing: -0.035em;
}

.metric-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
}

.trend.up {
  color: var(--success);
}

.trend.down {
  color: var(--danger);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.85fr);
  gap: 20px;
  margin-bottom: 20px;
}

.card {
  min-width: 0;
  border-radius: var(--radius-lg);
}

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

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card-body {
  padding: 20px;
}

.chart {
  width: 100%;
  height: 250px;
  overflow: visible;
}

.chart-grid {
  stroke: #e2e8f0;
  stroke-dasharray: 4 5;
  stroke-width: 1;
}

.chart-area {
  fill: url("#areaGradient");
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-dot {
  fill: #fff;
  stroke: var(--primary);
  stroke-width: 3;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.donut-wrap {
  display: grid;
  place-items: center;
  padding: 24px 20px 14px;
}

.donut {
  position: relative;
  display: grid;
  width: 164px;
  height: 164px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0 48%, #22c55e 48% 74%, #f59e0b 74% 89%, #e2e8f0 89% 100%);
}

.donut::before {
  position: absolute;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
}

.donut-center strong {
  display: block;
  font-size: 25px;
  font-weight: 760;
  letter-spacing: -0.03em;
}

.donut-center span {
  color: var(--muted);
  font-size: 11px;
}

.donut-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 20px 20px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.donut-legend-item i {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--color);
}

.donut-legend-item strong {
  margin-left: auto;
  color: var(--text-soft);
}

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

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fbfdff;
}

.primary-cell {
  color: var(--text);
  font-weight: 650;
}

.cell-with-avatar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}

.cell-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 750;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-info {
  color: var(--primary);
  background: var(--primary-soft);
}

.status-neutral {
  color: var(--muted);
  background: #f1f5f9;
}

.table-action {
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--primary);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.table-action:hover {
  background: var(--primary-soft);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.toolbar-search {
  position: relative;
  width: min(320px, 100%);
}

.toolbar-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
}

.toolbar-search .input {
  min-height: 38px;
  padding-left: 35px;
}

.toolbar-spacer {
  flex: 1;
}

.select {
  min-height: 38px;
  padding: 8px 32px 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--surface);
  font-size: 13px;
}

.select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px #eff6ff;
}

.empty-state {
  padding: 54px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 36px;
  height: 36px;
  margin-bottom: 12px;
  color: var(--muted-light);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.page-buttons {
  display: flex;
  gap: 5px;
}

.page-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
}

.page-button.active {
  border-color: var(--primary);
  color: #fff;
  background: var(--primary);
}

/* Products and reports */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.product-card {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms, box-shadow 160ms;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.product-visual {
  display: grid;
  height: 128px;
  place-items: center;
  color: var(--primary);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 60%), rgb(255 255 255 / 0%)),
    var(--product-bg, #eff6ff);
}

.product-visual svg {
  width: 44px;
  height: 44px;
}

.product-info {
  padding: 17px;
}

.product-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.product-name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.product-sku {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.product-price {
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

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

.bar-chart {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  height: 220px;
  padding: 10px 4px 0;
}

.bar-column {
  display: flex;
  height: 100%;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  gap: 8px;
}

.bar-track {
  display: flex;
  width: 100%;
  max-width: 36px;
  height: 100%;
  align-items: end;
  border-radius: 7px 7px 3px 3px;
  background: #f1f5f9;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, #60a5fa, var(--primary));
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
}

.progress-list {
  display: grid;
  gap: 19px;
}

.progress-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 13px;
}

.progress-item-head strong {
  font-weight: 700;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--fill, var(--primary));
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
  gap: 20px;
}

.settings-form {
  display: grid;
  gap: 18px;
}

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

.form-grid .field-full {
  grid-column: 1 / -1;
}

.textarea {
  min-height: 104px;
  resize: vertical;
}

.settings-note {
  padding: 18px;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  color: #1e40af;
  background: #eff6ff;
  font-size: 13px;
  line-height: 1.65;
}

.settings-note strong {
  display: block;
  margin-bottom: 6px;
  color: #1e3a8a;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}

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

.toggle-copy strong {
  display: block;
  font-size: 13px;
}

.toggle-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  width: 0;
  height: 0;
  opacity: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 160ms;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 25%);
  content: "";
  transition: transform 160ms;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid #bbf7d0;
  border-radius: 11px;
  color: #166534;
  background: #f0fdf4;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 600;
  animation: toast-in 180ms ease-out;
}

.toast svg {
  width: 18px;
  height: 18px;
}

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

.sidebar-backdrop {
  display: none;
}

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

  .dashboard-grid,
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    transform: translateX(-100%);
    width: min(286px, 88vw);
    box-shadow: var(--shadow-md);
    transition: transform 200ms ease;
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: rgb(15 23 42 / 38%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-button {
    display: grid;
  }

  .topbar {
    padding: 12px 16px;
  }

  .topbar-search {
    display: none;
  }

  .content {
    padding: 22px 16px 34px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 20px;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .button {
    flex: 1;
  }

  .metric-grid,
  .product-grid,
  .report-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .form-grid .field-full {
    grid-column: auto;
  }

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

  .toolbar-search {
    width: 100%;
  }

  .toolbar .select {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .login-card {
    padding: 22px 20px;
  }

  .content {
    padding-inline: 13px;
  }

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

  .metric-value {
    font-size: 25px;
  }

  .card-header,
  .card-body,
  .toolbar {
    padding-inline: 16px;
  }

  .page-title {
    font-size: 22px;
  }
}



/* Purchase requisition */
.purchase-sheet-card {
  overflow: hidden;
}

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

.purchase-sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.purchase-sheet-wrap {
  width: 100%;
  overflow-x: auto;
}

.purchase-sheet-table {
  width: 100%;
  min-width: 1540px;
  border-collapse: collapse;
  table-layout: fixed;
}

.purchase-sheet-table th,
.purchase-sheet-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.purchase-sheet-table th:last-child,
.purchase-sheet-table td:last-child {
  border-right: 0;
}

.purchase-sheet-table tbody tr:last-child td {
  border-bottom: 0;
}

.purchase-sheet-table th {
  height: 44px;
  padding: 10px 9px;
  color: var(--text-soft);
  background: #f8fafc;
  font-size: 11px;
  font-weight: 750;
  text-align: left;
  white-space: nowrap;
}

.purchase-sheet-table td {
  height: 50px;
  padding: 6px 7px;
  background: var(--surface);
}

.purchase-sheet-table tbody tr:hover td {
  background: #fbfdff;
}

.purchase-sheet-table th:nth-child(1),
.purchase-sheet-table td:nth-child(1) {
  width: 136px;
}

.purchase-sheet-table th:nth-child(2),
.purchase-sheet-table td:nth-child(2) {
  width: 136px;
}

.purchase-sheet-table th:nth-child(3),
.purchase-sheet-table td:nth-child(3) {
  width: 170px;
}

.purchase-sheet-table th:nth-child(4),
.purchase-sheet-table td:nth-child(4),
.purchase-sheet-table th:nth-child(8),
.purchase-sheet-table td:nth-child(8),
.purchase-sheet-table th:nth-child(10),
.purchase-sheet-table td:nth-child(10) {
  width: 92px;
}

.purchase-sheet-table th:nth-child(5),
.purchase-sheet-table td:nth-child(5) {
  width: 126px;
}

.purchase-sheet-table th:nth-child(6),
.purchase-sheet-table td:nth-child(6) {
  width: 170px;
}

.purchase-sheet-table th:nth-child(7),
.purchase-sheet-table td:nth-child(7),
.purchase-sheet-table th:nth-child(9),
.purchase-sheet-table td:nth-child(9) {
  width: 136px;
}

.purchase-sheet-table th:nth-child(11),
.purchase-sheet-table td:nth-child(11) {
  width: 220px;
}

.purchase-cell-input {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: none;
  color: var(--text-soft);
  background: transparent;
  font-size: 12px;
  transition: border-color 150ms, background 150ms, box-shadow 150ms;
}

.purchase-cell-input::placeholder {
  color: #b6c0cd;
}

.purchase-cell-input:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.purchase-cell-input:focus {
  border-color: #93c5fd;
  background: var(--surface);
  box-shadow: 0 0 0 3px #eff6ff;
}

.purchase-cell-number {
  text-align: right;
}

.purchase-cell-input[type="date"] {
  color-scheme: light;
}

.purchase-image-column {
  padding: 5px !important;
  text-align: center;
}

.purchase-sku-image {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted-light);
  background: var(--surface-soft);
}

.purchase-sku-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.purchase-image-empty {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: #b6c0cd;
}

.purchase-image-missing {
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}

@media (max-width: 820px) {
  .purchase-sheet-header {
    align-items: stretch;
    flex-direction: column;
    padding-inline: 16px;
  }

  .purchase-sheet-actions,
  .purchase-sheet-actions .button {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body {
    background: #fff;
  }

  .app-shell {
    display: block;
  }

  .sidebar,
  .topbar,
  .page-header,
  .purchase-sheet-actions,
  .no-print {
    display: none !important;
  }

  .content {
    max-width: none;
    padding: 0;
  }

  .purchase-sheet-card {
    border: 0;
    box-shadow: none;
  }

  .purchase-sheet-wrap {
    overflow: visible;
  }

  .purchase-sheet-table {
    min-width: 0;
    font-size: 8px;
  }

  .purchase-sheet-table th,
  .purchase-sheet-table td {
    padding: 4px 3px;
  }

  .purchase-cell-input {
    min-height: 26px;
    padding: 3px;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: 8px;
  }

  .purchase-cell-input::placeholder {
    color: transparent;
  }

  .purchase-sku-image {
    border: 0;
    background: transparent;
  }
}


/* SKU image library */
.sku-library-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.62fr) minmax(0, 1.38fr);
  gap: 20px;
  align-items: start;
}

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

.file-input {
  padding: 8px 10px;
}

.file-input::file-selector-button {
  margin-right: 10px;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--primary);
  background: var(--primary-soft);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.sku-upload-preview {
  display: grid;
  min-height: 170px;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 16px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.sku-upload-preview img {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.sku-upload-preview strong {
  color: var(--text-soft);
  font-size: 13px;
}

.sku-upload-preview span {
  color: var(--muted);
  font-size: 11px;
}

.sku-library-table {
  min-width: 680px;
}

.sku-code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
}

.sku-library-thumb {
  width: 50px;
  height: 50px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sku-library-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sku-image-path {
  display: block;
  max-width: 290px;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.sku-delete-action:hover {
  background: var(--danger-soft);
}

@media (max-width: 1050px) {
  .sku-library-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* Roles and permissions */
.demo-hint strong,
.demo-hint span {
  display: block;
}

.demo-hint strong {
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.demo-hint span + span {
  margin-top: 3px;
}

.button:disabled,
.icon-button:disabled,
.purchase-cell-input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.purchase-cell-input:disabled {
  background: #f8fafc;
}

.team-layout {
  display: grid;
  gap: 20px;
}

.team-table {
  min-width: 780px;
}

.team-select {
  min-width: 150px;
}

.current-user-badge {
  margin-left: 6px;
}

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

.permission-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 17px;
}

.permission-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--primary);
  background: var(--primary-soft);
}

.permission-card h3 {
  margin: 1px 0 0;
  font-size: 14px;
  font-weight: 750;
}

.permission-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.permission-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 13px 15px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  color: #92400e;
  background: #fffbeb;
  font-size: 12px;
  line-height: 1.6;
}

.permission-note svg {
  margin-top: 1px;
  flex: 0 0 auto;
}

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

@media (max-width: 640px) {
  .permission-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* Updated purchase columns */
.purchase-sheet-table {
  min-width: 1840px;
}

.purchase-sheet-table th:nth-child(1),
.purchase-sheet-table td:nth-child(1) {
  width: 76px;
}

.purchase-sheet-table th:nth-child(2),
.purchase-sheet-table td:nth-child(2) {
  width: 130px;
}

.purchase-sheet-table th:nth-child(3),
.purchase-sheet-table td:nth-child(3) {
  width: 160px;
}

.purchase-sheet-table th:nth-child(4),
.purchase-sheet-table td:nth-child(4),
.purchase-sheet-table th:nth-child(6),
.purchase-sheet-table td:nth-child(6) {
  width: 220px;
}

.purchase-sheet-table th:nth-child(5),
.purchase-sheet-table td:nth-child(5),
.purchase-sheet-table th:nth-child(10),
.purchase-sheet-table td:nth-child(10),
.purchase-sheet-table th:nth-child(11),
.purchase-sheet-table td:nth-child(11) {
  width: 100px;
}

.purchase-sheet-table th:nth-child(7),
.purchase-sheet-table td:nth-child(7) {
  width: 150px;
}

.purchase-sheet-table th:nth-child(8),
.purchase-sheet-table td:nth-child(8) {
  width: 180px;
}

.purchase-sheet-table th:nth-child(9),
.purchase-sheet-table td:nth-child(9) {
  width: 160px;
}

.purchase-sheet-table th:nth-child(12),
.purchase-sheet-table td:nth-child(12) {
  width: 240px;
}

@media print {
  .purchase-sheet-table,
  .purchase-cell-input {
    font-size: 7px;
  }
}


/* SKU library product fields */
.sku-library-page {
  display: grid;
  gap: 20px;
}

.sku-upload-form-inline {
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1fr) minmax(180px, 0.7fr) auto;
  align-items: end;
}

.sku-upload-preview-inline {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-style: solid;
}

.sku-library-table-wrap {
  border-top: 1px solid var(--line);
}

.sku-library-fields-table {
  min-width: 1840px;
}

.sku-library-fields-table .purchase-cell-input {
  min-width: 0;
}

@media (max-width: 1100px) {
  .sku-upload-form-inline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .sku-upload-form-inline {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Keep the brand subtitle on a single line below the English name. */
.brand-name,
.brand-subtitle {
  display: block;
  width: 100%;
  white-space: nowrap;
}

.sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: visible;
}

.sidebar-brand-copy .brand-name {
  order: 1;
}

.sidebar-brand-copy .brand-subtitle {
  order: 2;
}


/* Image paste hint is shown directly in the upload preview. */


.file-picker-shell {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  gap: 9px;
  padding: 6px 10px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.file-picker-input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-picker-button {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 650;
}

.file-picker-name {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-paste-hint {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .file-picker-shell {
    flex-wrap: wrap;
  }

  .file-picker-name {
    flex-basis: calc(100% - 90px);
  }

  .file-paste-hint {
    flex-basis: 100%;
    padding-left: 58px;
  }
}


/* Consistent typography in SKU image upload controls */
.sku-upload-form .input,
.file-picker-button,
.file-picker-name,
.file-paste-hint,
.sku-upload-preview-inline span {
  font-size: 13px;
}

.file-picker-button {
  font-weight: 650;
}

.file-picker-name,
.file-paste-hint,
.sku-upload-preview-inline span {
  line-height: 1.4;
}


/* SKU image preview */
.sku-image-preview-button {
  padding: 0;
  border: 1px solid var(--line);
  cursor: zoom-in;
}

.sku-image-preview-button img {
  transition: transform 160ms ease;
}

.sku-image-preview-button:hover img {
  transform: scale(1.06);
}

.image-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgb(15 23 42 / 62%);
  backdrop-filter: blur(6px);
}

.image-preview-dialog {
  position: relative;
  display: grid;
  max-width: min(920px, 92vw);
  max-height: 92vh;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgb(15 23 42 / 35%);
}

.image-preview-dialog img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 100px);
  object-fit: contain;
  border-radius: 12px;
  background: var(--surface-soft);
}

.image-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-soft);
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow-sm);
}

.image-preview-caption {
  color: var(--text-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}


/* Simplified purchase request columns */
#purchase-form .purchase-sheet-table {
  min-width: 1200px;
}

#purchase-form .purchase-sheet-table th:nth-child(1),
#purchase-form .purchase-sheet-table td:nth-child(1) {
  width: 76px;
}

#purchase-form .purchase-sheet-table th:nth-child(2),
#purchase-form .purchase-sheet-table td:nth-child(2) {
  width: 140px;
}

#purchase-form .purchase-sheet-table th:nth-child(3),
#purchase-form .purchase-sheet-table td:nth-child(3) {
  width: 260px;
}

#purchase-form .purchase-sheet-table th:nth-child(4),
#purchase-form .purchase-sheet-table td:nth-child(4) {
  width: 120px;
}

#purchase-form .purchase-sheet-table th:nth-child(5),
#purchase-form .purchase-sheet-table td:nth-child(5) {
  width: 320px;
}

#purchase-form .purchase-sheet-table th:nth-child(6),
#purchase-form .purchase-sheet-table td:nth-child(6) {
  width: 284px;
}


/* Purchase quantity column */
#purchase-form .purchase-sheet-table {
  min-width: 1320px;
}

#purchase-form .purchase-sheet-table th:nth-child(4),
#purchase-form .purchase-sheet-table td:nth-child(4) {
  width: 100px;
}

#purchase-form .purchase-sheet-table th:nth-child(5),
#purchase-form .purchase-sheet-table td:nth-child(5) {
  width: 120px;
}

#purchase-form .purchase-sheet-table th:nth-child(6),
#purchase-form .purchase-sheet-table td:nth-child(6) {
  width: 300px;
}

#purchase-form .purchase-sheet-table th:nth-child(7),
#purchase-form .purchase-sheet-table td:nth-child(7) {
  width: 284px;
}


/* Purchase amount column */
#purchase-form .purchase-sheet-table {
  min-width: 1410px;
}

#purchase-form .purchase-sheet-table th:nth-child(6),
#purchase-form .purchase-sheet-table td:nth-child(6) {
  width: 130px;
  text-align: left;
}

#purchase-form .purchase-sheet-table th:nth-child(7),
#purchase-form .purchase-sheet-table td:nth-child(7) {
  width: 300px;
}

#purchase-form .purchase-sheet-table th:nth-child(8),
#purchase-form .purchase-sheet-table td:nth-child(8) {
  width: 284px;
}

.purchase-amount-cell {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}


/* Left-align all purchase request detail content */
#purchase-form .purchase-sheet-table th,
#purchase-form .purchase-sheet-table td,
#purchase-form .purchase-cell-number,
#purchase-form .purchase-amount-cell {
  text-align: left;
}


.purchase-synced-cell {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}


/* Purchase supplier name column */
#purchase-form .purchase-sheet-table {
  min-width: 1640px;
}

#purchase-form .purchase-sheet-table th:nth-child(7),
#purchase-form .purchase-sheet-table td:nth-child(7) {
  width: 200px;
}

#purchase-form .purchase-sheet-table th:nth-child(8),
#purchase-form .purchase-sheet-table td:nth-child(8) {
  width: 300px;
}

#purchase-form .purchase-sheet-table th:nth-child(9),
#purchase-form .purchase-sheet-table td:nth-child(9) {
  width: 284px;
}

/* Supplier name in SKU library */
.sku-library-fields-table {
  min-width: 2000px;
}


/* Purchase request without price and amount */
#purchase-form .purchase-sheet-table {
  min-width: 1380px;
}

#purchase-form .purchase-sheet-table th:nth-child(4),
#purchase-form .purchase-sheet-table td:nth-child(4) {
  width: 100px;
}

#purchase-form .purchase-sheet-table th:nth-child(5),
#purchase-form .purchase-sheet-table td:nth-child(5) {
  width: 200px;
}

#purchase-form .purchase-sheet-table th:nth-child(6),
#purchase-form .purchase-sheet-table td:nth-child(6) {
  width: 320px;
  text-align: left;
}

#purchase-form .purchase-sheet-table th:nth-child(7),
#purchase-form .purchase-sheet-table td:nth-child(7) {
  width: 284px;
}
