/* ============================================================================
   SILICONE STORE ADMIN — CLEAN MINIMALISTIC CALM CSS GRID SYSTEM
   Soft Surfaces + Gentle Elevation + Calm Light Yellow + Fluid Micro-Motion
   ============================================================================ */

:root {
  --font-display: "Outfit", system-ui, -apple-system, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* 60-30-10 Calm Alabaster + Soft Ink + Light Yellow Palette */
  --bg-canvas: #f8f7f3;
  --bg-surface: #ffffff;
  --bg-subtle: #f2f0e8;
  --bg-inset: #faf9f5;
  --border-strong: rgba(34, 30, 20, 0.12);
  --border-muted: rgba(34, 30, 20, 0.07);
  --input-stroke: #6f6752;
  --text-primary: #1d1b15;
  --text-secondary: #5c5646;
  --text-muted: #847d6a;
  --accent: #f3de8a;
  --accent-hover: #eed46f;
  --accent-contrast: #241d06;
  --accent-soft: #fcf6de;
  --accent-text: #7c5c0b;
  --accent-outline: #c7a232;

  /* Semantic Status Colors */
  --status-green: #15803d;
  --status-green-bg: #eefbf3;
  --status-amber: #b45309;
  --status-amber-bg: #fff9eb;
  --status-orange: #c2410c;
  --status-orange-bg: #fff5ee;
  --status-red: #b91c1c;
  --status-red-bg: #fef1f1;

  /* Calm Minimalist Geometry & Motion */
  --radius: 12px;
  --radius-sm: 8px;
  --stroke: 1px;
  --shadow-soft: 0 1px 2px rgba(26, 23, 15, 0.04), 0 4px 12px rgba(26, 23, 15, 0.03);
  --shadow-hover: 0 8px 24px -6px rgba(26, 23, 15, 0.09), 0 2px 6px rgba(26, 23, 15, 0.04);
  --shadow-float: 0 14px 32px -8px rgba(26, 23, 15, 0.14), 0 4px 12px rgba(26, 23, 15, 0.05);
  --shadow-hard: var(--shadow-hover);
  --shadow-hard-sm: var(--shadow-soft);
  --ease-calm: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition: 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg-canvas: #12110e;
  --bg-surface: #1b1914;
  --bg-subtle: #25221b;
  --bg-inset: #161410;
  --border-strong: rgba(245, 240, 224, 0.13);
  --border-muted: rgba(245, 240, 224, 0.07);
  --input-stroke: #b5ad96;
  --text-primary: #faf8f0;
  --text-secondary: #b5ae9a;
  --text-muted: #8a8370;
  --accent: #f0d775;
  --accent-hover: #f5e18f;
  --accent-contrast: #1b1605;
  --accent-soft: #2c2614;
  --accent-text: #f3dc84;
  --accent-outline: #d9bb56;

  --status-green: #4ade80;
  --status-green-bg: rgba(21, 128, 61, 0.18);
  --status-amber: #fbbf24;
  --status-amber-bg: rgba(180, 83, 9, 0.18);
  --status-orange: #fb923c;
  --status-orange-bg: rgba(194, 65, 12, 0.18);
  --status-red: #f87171;
  --status-red-bg: rgba(185, 28, 28, 0.18);

  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.24), 0 4px 12px rgba(0, 0, 0, 0.18);
  --shadow-hover: 0 10px 24px -6px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.24);
  --shadow-float: 0 16px 36px -8px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-hard: var(--shadow-hover);
  --shadow-hard-sm: var(--shadow-soft);
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  transition: background 240ms ease, color 240ms ease;
}

.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;
}

.mono,
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

img {
  display: block;
  max-width: 100%;
}

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

button:focus-visible,
a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent-outline) 65%, transparent);
  outline-offset: 2px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

/* ============================================================================
   CALM MICRO-ANIMATION KEYFRAMES
   ============================================================================ */

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

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
}

@keyframes chartBarGrow {
  from {
    opacity: 0.25;
    transform: scaleY(0.12);
  }
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes calmShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes unseenPulse {
  0%,
  100% {
    box-shadow: var(--shadow-soft), 0 0 0 0 rgba(180, 83, 9, 0.16);
  }
  50% {
    box-shadow: var(--shadow-soft), 0 0 0 4px rgba(180, 83, 9, 0.06);
  }
}

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

/* ============================================================================
   APP SHELL & PUSH SIDEBAR ARCHITECTURE
   ============================================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  overflow-x: clip;
  background: var(--bg-canvas);
}

.app-stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg-canvas);
  transition: transform 260ms var(--ease-calm), box-shadow 260ms var(--ease-calm);
}

.stage-dismiss-layer {
  display: none;
}

.app-shell.is-auth-locked .sidebar,
.app-shell.is-auth-locked .topbar,
.app-shell.is-auth-locked .app-footer,
.app-shell.is-auth-locked .mobile-quick-bar,
.app-shell.is-auth-locked .stage-dismiss-layer {
  display: none !important;
}

.app-shell.is-auth-locked .app-stage {
  transform: none !important;
}

.app-shell.is-auth-locked .main-content {
  flex: 1 0 auto;
  display: grid;
  place-items: center;
  padding: 16px;
}

.app-shell.is-auth-locked .view-root {
  width: 100%;
  max-width: 368px;
}

/* Compact Minimalistic Auth Screen */
.auth-gate-card {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-float);
  display: grid;
  gap: 15px;
  animation: calmFadeUp 340ms var(--ease-calm) both;
}

.auth-gate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.auth-gate-brand {
  display: grid;
  gap: 2px;
}

.auth-gate-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.auth-gate-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-gate-form {
  display: grid;
  gap: 11px;
}

.auth-gate-submit {
  width: 100%;
  min-height: 42px;
}

.auth-gate-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Sidebar (Desktop Push Collapse + Mobile Push Drawer) */
.sidebar {
  flex: 0 0 224px;
  width: 224px;
  display: grid;
  grid-template-rows: 52px 1fr auto;
  background: var(--bg-surface);
  border-right: var(--stroke) solid var(--border-muted);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
  margin-left: 0;
  transition: margin-left 260ms var(--ease-calm), transform 260ms var(--ease-calm);
}

.app-shell.is-sidebar-collapsed .sidebar {
  margin-left: -224px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: var(--stroke) solid var(--border-muted);
}

.brand-wordmark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-decoration: none;
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity var(--transition);
}

.brand-wordmark:hover {
  opacity: 0.78;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  gap: 3px;
  overflow-y: auto;
}

.nav-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 11px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.nav-item:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
  transform: translateX(2px);
}

.nav-item:active {
  transform: scale(0.98);
}

.nav-item.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

.nav-item.is-active:hover {
  transform: none;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  opacity: 0.78;
  transition: transform 220ms var(--ease-spring), opacity var(--transition);
}

.nav-item:hover .nav-icon,
.nav-item.is-active .nav-icon {
  opacity: 1;
  transform: scale(1.08);
}

.nav-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.sidebar-footer {
  border-top: var(--stroke) solid var(--border-muted);
  padding: 12px 14px;
  display: grid;
  gap: 9px;
  background: var(--bg-inset);
}

.auth-summary {
  display: grid;
  gap: 2px;
}

.auth-user-line {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-link {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity var(--transition);
}

.text-link:hover {
  opacity: 0.78;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.theme-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Top Header (Frosted Blur Background) */
.topbar {
  flex: 0 0 auto;
  height: 52px;
  display: grid;
  grid-template-columns: auto minmax(180px, 380px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg-canvas) 74%, transparent) 0%,
    color-mix(in srgb, var(--bg-canvas) 52%, transparent) 100%
  );
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 12px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--bg-canvas) 44%, transparent) 0%,
    transparent 100%
  );
}

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

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-center {
  width: 100%;
}

.search-input {
  width: 100%;
  height: 35px;
  padding: 0 12px;
  background: var(--bg-inset);
  border: var(--stroke) solid color-mix(in srgb, var(--input-stroke) 24%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.search-input:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 38%, transparent);
}

.search-input:focus,
.search-input:focus-visible,
.search-input:active {
  outline: none;
  border-color: color-mix(in srgb, var(--input-stroke) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);
  background: var(--bg-surface);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Content */
.main-content {
  flex: 1 0 auto;
  padding: 18px;
  min-width: 0;
}

.view-root {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-width: 0;
  max-width: 1320px;
  margin: 0 auto;
}

.view-root.is-entering > * {
  animation: calmFadeUp 300ms var(--ease-calm) both;
}

.view-root.is-entering > *:nth-child(2) {
  animation-delay: 35ms;
}

.view-root.is-entering > *:nth-child(3) {
  animation-delay: 70ms;
}

.view-root.is-entering > *:nth-child(4) {
  animation-delay: 105ms;
}

.view-root.is-entering > *:nth-child(5) {
  animation-delay: 140ms;
}

/* Mobile Search Bar (hidden on desktop) */
.mobile-only,
.mobile-only-block {
  display: none;
}

.mobile-quick-bar {
  margin-bottom: 10px;
  display: none;
  gap: 8px;
}

/* Sticky Minimalist Borderless Footer (Frosted Blur + Glow Indicator) */
.app-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 6px 18px;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--bg-canvas) 76%, transparent) 0%,
    color-mix(in srgb, var(--bg-canvas) 54%, transparent) 100%
  );
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: none;
  box-shadow: none;
}

.app-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 12px;
  pointer-events: none;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--bg-canvas) 44%, transparent) 0%,
    transparent 100%
  );
}

.footer-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.footer-brand {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.footer-stats {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), transform 140ms var(--ease-calm);
}

.footer-link i {
  transition: transform 220ms var(--ease-spring), color var(--transition), filter var(--transition);
}

.footer-link:hover:not(.is-active) {
  background: radial-gradient(
    ellipse at 50% 50%,
    color-mix(in srgb, var(--accent) 26%, transparent) 0%,
    transparent 74%
  );
  color: var(--text-primary);
}

.footer-link:hover i {
  transform: translateY(-1px);
}

.footer-link:active {
  transform: scale(0.95);
}

.footer-link.is-active {
  background: radial-gradient(
    ellipse at 50% 50%,
    color-mix(in srgb, var(--accent) 44%, transparent) 0%,
    color-mix(in srgb, var(--accent) 12%, transparent) 55%,
    transparent 78%
  );
  color: var(--text-primary);
  font-weight: 700;
}

.footer-link.is-active i {
  color: var(--accent-text);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--accent-outline) 65%, transparent));
  transform: translateY(-1px) scale(1.08);
}

/* ============================================================================
   FULL-SCREEN SUBPAGES (PRODUCT EDITOR, PATHAO DISPATCH, CAMERA)
   ============================================================================ */

.subpage-shell {
  display: grid;
  gap: 12px;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}

/* Concept-Aligned Clean Light Product Editor */
.pe-shell {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 660px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 0 32px;
}

.pe-section {
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

.pe-section + .pe-section {
  padding-top: 22px;
  border-top: 1px solid var(--border-muted);
}

.pe-sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.pe-sec-title {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.pe-sec-slash {
  color: var(--text-muted);
  margin-right: 4px;
}

.pe-sec-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  color: var(--text-muted);
  white-space: nowrap;
}

.pe-sec-tag-danger {
  color: var(--status-red);
  border-color: color-mix(in srgb, var(--status-red) 35%, transparent);
  cursor: pointer;
}

.pe-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.pe-shell .form-row-pair {
  gap: 10px;
}

/* Outlined Field Box */
.pe-box-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  padding: 6px 13px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.pe-box-field:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 36%, transparent);
}

.pe-box-field:focus-within {
  border-color: color-mix(in srgb, var(--input-stroke) 56%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
}

.pe-box-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.2;
}

.pe-box-input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.pe-box-input::placeholder {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.pe-box-input:focus,
.pe-box-input:focus-visible {
  outline: none;
}

.pe-box-field-combo {
  position: relative;
  padding-right: 46px;
}

.pe-box-field-combo .ccombo-control {
  position: static;
}

.pe-box-field-combo .ccombo-input {
  padding-right: 0;
  text-transform: uppercase;
  font-weight: 700;
}

.pe-box-field-combo .ccombo-toggle {
  position: absolute;
  top: 50%;
  bottom: auto;
  right: 8px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
}

.pe-box-field-combo .ccombo-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

/* Connected Full-Width Stock Stepper */
.pe-stepper {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  min-height: 46px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pe-stepper:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 36%, transparent);
}

.pe-stepper:focus-within {
  border-color: color-mix(in srgb, var(--input-stroke) 56%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
}

.pe-stepper button {
  border: none;
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.pe-stepper button:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.pe-stepper input {
  border: none;
  border-left: 1px solid color-mix(in srgb, var(--input-stroke) 16%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--input-stroke) 16%, transparent);
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
}

.pe-stepper input:focus {
  outline: none;
}

/* AI Description Card */
.pe-ai-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
}

.pe-ai-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pe-ai-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.pe-ai-copy {
  min-width: 0;
}

.pe-ai-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.pe-ai-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pe-ai-btn {
  min-height: 32px;
  padding: 0 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

/* Rich Markdown Card */
.pe-md-card {
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pe-md-card:focus-within {
  border-color: color-mix(in srgb, var(--input-stroke) 56%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
}

.pe-md-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-inset);
}

.pe-md-head-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pe-md-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.pe-md-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.pe-md-head-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pe-md-seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 6px;
  border: 1px solid var(--border-muted);
  background: var(--bg-surface);
}

.pe-md-seg-btn,
.pe-md-expand {
  width: 28px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.pe-md-seg-btn:not(.is-active):hover,
.pe-md-expand:not(.is-active):hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.pe-md-seg-btn.is-active,
.pe-md-expand.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.pe-md-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-muted);
  background: var(--bg-surface);
}

.pe-md-toolbar::-webkit-scrollbar {
  display: none;
}

.pe-md-sep {
  width: 1px;
  height: 15px;
  background: var(--border-muted);
  margin: 0 3px;
  flex-shrink: 0;
}

.pe-md-btn {
  min-width: 25px;
  height: 26px;
  padding: 0 5px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.pe-md-btn:hover {
  background: var(--accent-soft);
  color: var(--text-primary);
}

.pe-md-textarea {
  width: 100%;
  min-height: 132px;
  padding: 11px 13px;
  border: none;
  background: transparent;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-primary);
}

.pe-md-textarea.is-expanded {
  min-height: 240px;
}

.pe-md-textarea:focus {
  outline: none;
}

.pe-md-foot {
  padding: 5px 12px 7px;
  text-align: right;
  font-size: 10.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-muted);
  background: var(--bg-inset);
}

.pe-md-preview {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
}

/* Spec Add Row & Full-Width Action Buttons */
.pe-spec-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: stretch;
}

.pe-square-btn {
  width: 46px;
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.pe-square-btn:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent-outline) 45%, transparent);
  color: var(--text-primary);
}

.pe-full-btn {
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), border-color var(--transition);
}

.pe-full-btn:hover {
  background: var(--bg-subtle);
  border-color: color-mix(in srgb, var(--input-stroke) 36%, transparent);
}

.pe-full-btn-accent {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: color-mix(in srgb, var(--accent-outline) 45%, transparent);
}

.pe-full-btn-accent:hover {
  background: var(--accent-hover);
}

.pe-item-list {
  display: grid;
  gap: 5px;
}

.pe-item-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 11px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 12.5px;
  transition: background var(--transition);
}

.pe-item-row:hover {
  background: var(--bg-subtle);
}

.pe-item-idx {
  font-size: 11px;
  color: var(--text-muted);
}

.pe-item-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Media Card & 4-Tab Bar */
.pe-media-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
}

.pe-media-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  border-radius: 7px;
}

.pe-media-tab {
  min-height: 32px;
  padding: 4px 6px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background var(--transition), color var(--transition);
}

.pe-media-tab:hover:not(.is-active) {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.pe-media-tab.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.pe-media-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: stretch;
}

.pe-media-url-row .pe-box-input {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
}

.pe-media-url-row .pe-box-input:focus {
  border-color: color-mix(in srgb, var(--input-stroke) 56%, transparent);
  background: var(--bg-surface);
}

.pe-media-paste-btn,
.pe-media-apply-btn {
  min-height: 44px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}

.pe-media-paste-btn {
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  background: var(--bg-inset);
  color: var(--text-primary);
}

.pe-media-paste-btn:hover {
  background: var(--bg-subtle);
}

.pe-media-apply-btn {
  border: 1px solid color-mix(in srgb, var(--accent-outline) 45%, transparent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.pe-media-apply-btn:hover {
  background: var(--accent-hover);
}

.pe-img-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Recommended Format Tip & Bottom Actions */
.pe-tip-box {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent-outline) 32%, transparent);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.5;
}

.pe-tip-box i {
  color: var(--accent-text);
  margin-top: 2px;
  flex-shrink: 0;
}

.pe-tip-box strong {
  color: var(--accent-text);
}

.pe-bottom-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-muted);
}

.pe-cancel-btn,
.pe-save-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition), border-color var(--transition), transform 140ms var(--ease-calm);
}

.pe-cancel-btn {
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 22%, transparent);
  color: var(--text-secondary);
}

.pe-cancel-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.pe-save-btn {
  background: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent-outline) 50%, transparent);
  color: var(--accent-contrast);
}

.pe-save-btn:hover {
  background: var(--accent-hover);
}

.pe-save-btn:active,
.pe-cancel-btn:active {
  transform: scale(0.985);
}

.pe-img-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pe-img-btns {
  display: flex;
  gap: 6px;
}

.pe-rbg-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pe-media-action {
  width: 100%;
  min-height: 36px;
  font-size: 12.5px;
}

.subpage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.input-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.url-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
}

.fullscreen-camera {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: #0b0b0c;
  color: #ffffff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  animation: calmFadeUp 220ms var(--ease-calm) both;
}

.fullscreen-camera-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-bottom: var(--stroke) solid var(--border-muted);
}

.fullscreen-camera-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000000;
}

.fullscreen-camera-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.fullscreen-camera-foot {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: var(--bg-surface);
  border-top: var(--stroke) solid var(--border-muted);
}

/* ============================================================================
   BUTTONS, INPUTS & CONTROLS (CALM & TACTILE)
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 13px;
  border: var(--stroke) solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms var(--ease-calm), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
}

.btn i {
  transition: transform 200ms var(--ease-spring);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.btn:hover:not(:disabled) i {
  transform: scale(1.08);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: var(--shadow-soft);
}

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

.btn-primary {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent-outline) 35%, transparent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--accent) 65%, transparent);
}

.btn-accent,
.btn-blue {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent-outline) 45%, transparent);
  color: var(--accent-text);
}

.btn-accent:hover:not(:disabled),
.btn-blue:hover:not(:disabled) {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent-outline) 50%, transparent);
  color: var(--accent-contrast);
}

.btn-danger {
  background: var(--status-red-bg);
  border-color: color-mix(in srgb, var(--status-red) 28%, transparent);
  color: var(--status-red);
}

.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--status-red) 12%, var(--bg-surface));
  border-color: color-mix(in srgb, var(--status-red) 50%, transparent);
}

.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.btn-sm {
  min-height: 29px;
  padding: 4px 10px;
  font-size: 11.5px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 35px;
  height: 35px;
  background: transparent;
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 160ms var(--ease-calm);
}

.icon-btn i {
  transition: transform 200ms var(--ease-spring);
}

.icon-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-btn:active {
  transform: scale(0.93);
}

#topbar-back-btn:hover i {
  transform: translateX(-2px);
}

.btn[hidden],
.icon-btn[hidden] {
  display: none !important;
}

/* ============================================================================
   CALM MINIMALIST SURFACES, GRIDS & CARDS
   ============================================================================ */

.panel {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius);
  padding: 16px 18px;
  min-width: 0;
  max-width: 100%;
  box-shadow: var(--shadow-soft);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-muted);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-meta {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* KPI 4-Column Compact Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: grid;
  gap: 4px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

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

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Analytics Split Grids */
.analytics-split {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.analytics-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

/* Status Breakdown List */
.status-bars {
  display: grid;
  gap: 10px;
}

.status-bar-row {
  display: grid;
  gap: 4px;
}

.status-bar-btn {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 5px 7px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 160ms var(--ease-calm);
}

.status-bar-btn:hover {
  background: var(--bg-inset);
  border-color: var(--border-muted);
  transform: translateX(2px);
}

.status-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
}

.status-track {
  height: 8px;
  background: var(--bg-subtle);
  border: none;
  border-radius: 99px;
  overflow: hidden;
}

.status-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 480ms var(--ease-calm);
}

/* Compact Responsive Insight Panel & Single-Row Tabs */
.insight-panel {
  display: grid;
  gap: 10px;
}

.insight-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  padding: 3px;
  gap: 3px;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.insight-tab {
  min-height: 30px;
  padding: 4px 12px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform 140ms var(--ease-calm);
}

.insight-tab:hover:not(.is-active) {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.insight-tab:active {
  transform: scale(0.97);
}

.insight-tab.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(26, 23, 15, 0.08);
}

.insight-footer-btn {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 140ms var(--ease-calm);
}

.insight-footer-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.insight-footer-btn:active {
  transform: scale(0.985);
}

.insight-list {
  display: grid;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.insight-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  background: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border-muted);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), padding-left var(--transition);
}

.insight-row:last-child {
  border-bottom: none;
}

.insight-row:hover {
  background: var(--bg-inset);
  padding-left: 14px;
}

.insight-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.insight-rank {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  width: 20px;
  flex-shrink: 0;
}

.insight-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.insight-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-sub {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-metrics {
  display: grid;
  justify-items: end;
  gap: 1px;
  flex-shrink: 0;
}

.insight-primary {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.insight-secondary {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Data Tables (Compact) */
.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.data-table th,
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-muted);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-inset);
  border-bottom: var(--stroke) solid var(--border-strong);
  white-space: nowrap;
}

.products-table-panel {
  overflow: hidden;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-inset);
}

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

.pcol-title {
  font-weight: 700;
}

.pcol-mobile-sub {
  display: none;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
}

.pcol-action-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.pcol-btn-icon {
  display: none;
}

.pcol-stock .is-low {
  color: var(--status-red);
  font-weight: 700;
}

/* ============================================================================
   TOOLBARS & SEGMENTED FILTERS
   ============================================================================ */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.products-toolbar-filters {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(170px, 210px);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.products-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

/* Custom Minimal-Brutalist Dropdown */
.cselect {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.cselect-trigger {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 36px;
  padding: 5px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform 140ms var(--ease-calm);
}

.cselect-trigger:hover,
.cselect.is-open .cselect-trigger {
  background: var(--bg-inset);
  border-color: color-mix(in srgb, var(--input-stroke) 60%, transparent);
  box-shadow: var(--shadow-hover);
}

.cselect-trigger:active {
  transform: scale(0.99);
}

.cselect-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cselect-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 240ms var(--ease-spring), color var(--transition);
}

.cselect.is-open .cselect-chevron {
  transform: rotate(180deg);
  color: var(--text-primary);
}

.cselect-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  max-height: 250px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--input-stroke) 30%, transparent) transparent;
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  padding: 6px;
  z-index: 60;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top center;
  transition: opacity 180ms var(--ease-calm), transform 180ms var(--ease-calm), visibility 180ms var(--ease-calm);
}

.cselect-menu::-webkit-scrollbar {
  width: 8px;
}

.cselect-menu::-webkit-scrollbar-track {
  background: transparent;
  margin-block: 6px;
}

.cselect-menu::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--input-stroke) 28%, transparent);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.cselect-menu::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--input-stroke) 48%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
}

.cselect.is-open .cselect-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.cselect-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), padding-left 140ms var(--ease-calm);
}

.cselect-option:hover,
.cselect-option.is-highlighted:not(.is-selected) {
  background: var(--bg-subtle);
  padding-left: 11px;
}

.cselect-option.is-selected {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.cselect-opt-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.cselect-opt-meta {
  font-size: 11px;
  opacity: 0.72;
  flex-shrink: 0;
}

.cselect-check {
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Custom Combobox Dropdown (Type + Select) */
.ccombo {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.ccombo-control {
  position: relative;
  display: flex;
  align-items: center;
}

.input.ccombo-input {
  padding-right: 38px;
  text-transform: uppercase;
}

.ccombo-toggle {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 34px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--transition), color var(--transition);
}

.ccombo-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.ccombo.is-open .ccombo-toggle .cselect-chevron {
  transform: rotate(180deg);
  color: var(--text-primary);
}

.ccombo-menu {
  left: 0;
  right: 0;
  width: 100%;
  max-width: none;
  max-height: 230px;
  z-index: 65;
  -webkit-overflow-scrolling: touch;
}

.ccombo-menu[hidden] {
  display: none !important;
}

.ccombo.is-open .ccombo-menu {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ccombo-option-create {
  border-top: 1px dashed var(--border-muted);
  margin-top: 2px;
  padding-top: 7px;
  color: var(--accent-text);
}

.ccombo-empty {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  padding: 3px;
  gap: 3px;
  overflow: hidden;
  max-width: 100%;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 11px;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform 140ms var(--ease-calm);
}

.seg-btn:hover:not(.is-active) {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.seg-btn:active {
  transform: scale(0.96);
}

.seg-btn.is-active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(26, 23, 15, 0.08);
}

/* ============================================================================
   PRODUCTS GRID & TABLE (COMPACT & CALM)
   ============================================================================ */

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 12px;
  min-width: 0;
}

.product-card {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 132px 1fr auto;
  min-width: 0;
  box-shadow: var(--shadow-soft);
  transition: transform 220ms var(--ease-calm), box-shadow var(--transition), border-color var(--transition);
}

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

.product-thumb {
  position: relative;
  background: var(--bg-inset);
  border-bottom: var(--stroke) solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thumb-fallback {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.product-body {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  align-content: start;
  min-width: 0;
  cursor: pointer;
}

.product-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.meta-line {
  font-size: 10.5px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.card-prices-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  overflow: hidden;
}

.card-metric {
  padding: 4px 7px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
  border-bottom: 1px solid var(--border-muted);
}

.card-metric:nth-child(odd) {
  border-right: 1px solid var(--border-muted);
}

.card-metric:nth-last-child(-n + 2) {
  border-bottom: none;
}

.card-metric-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.card-metric-val {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.card-metric-val.is-accent {
  color: var(--accent-text);
}

.card-metric-val.is-muted {
  color: var(--text-muted);
  font-weight: 500;
}

.card-metric-val.is-low {
  color: var(--status-red);
}

.card-stock-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  overflow: hidden;
}

.card-stock-cell {
  padding: 5px 6px;
  display: grid;
  justify-items: center;
  gap: 1px;
  border-right: 1px solid var(--border-muted);
}

.card-stock-cell:last-child {
  border-right: none;
}

.product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: var(--stroke) solid var(--border-muted);
}

.product-actions button {
  min-height: 36px;
  border: none;
  background: var(--bg-surface);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform 120ms ease;
}

.product-actions button:first-child {
  border-right: var(--stroke) solid var(--border-muted);
}

.product-actions button:hover {
  background: var(--bg-subtle);
}

.product-actions button:active {
  transform: scale(0.97);
}

.product-actions button.danger:hover,
.product-actions button.is-confirming {
  background: var(--status-red-bg);
  color: var(--status-red);
}

/* ============================================================================
   CATEGORIES WORKSPACE (ALIGNED WITH PRODUCT EDITOR CONCEPT UI)
   ============================================================================ */

.cat-shell {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 0 32px;
}

.cat-hero-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.cat-live-thumb {
  position: relative;
  width: 50px;
  min-height: 50px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  overflow: visible;
  transition: border-color var(--transition), background var(--transition);
}

.cat-live-thumb.has-image {
  border-color: color-mix(in srgb, var(--accent-outline) 45%, transparent);
}

.cat-live-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: calc(var(--radius-sm) - 1px);
  padding: 3px;
}

.cat-thumb-clear {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 19px;
  height: 19px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--status-red);
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 140ms var(--ease-spring), background var(--transition);
}

.cat-thumb-clear:hover {
  background: var(--status-red-bg);
  transform: scale(1.08);
}

.cat-rbg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-muted);
}

.cat-rbg-row .segmented {
  width: auto;
}

.cat-rbg-row .seg-btn {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 11px;
}

.cat-full-save {
  width: 100%;
}

.cat-full-save:disabled,
.pe-save-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.cat-action-bar {
  border-top: none;
  padding-top: 0;
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.category-card {
  background: var(--bg-surface);
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  transition: border-color var(--transition), background var(--transition);
}

.category-card:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 36%, transparent);
}

.category-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.category-thumb {
  width: 40px;
  height: 40px;
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  overflow: hidden;
}

.category-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.category-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.category-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-stats {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.category-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  font-size: 11.5px;
}

.icon-btn-danger:hover {
  background: var(--status-red-bg);
  color: var(--status-red);
  border-color: color-mix(in srgb, var(--status-red) 28%, transparent);
}

.subcat-area {
  display: grid;
  gap: 8px;
  padding-top: 9px;
  border-top: 1px solid var(--border-muted);
}

.subcat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.subcat-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.subcat-item:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent-outline) 35%, transparent);
  color: var(--text-primary);
}

.subcat-remove {
  background: none;
  border: none;
  padding: 1px 2px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1;
  transition: color var(--transition);
}

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

.subcat-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: stretch;
}

.subcat-input {
  min-height: 34px;
  height: 34px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-radius: 7px;
  background: var(--bg-inset);
}

.subcat-input:focus {
  border-color: color-mix(in srgb, var(--input-stroke) 56%, transparent);
  background: var(--bg-surface);
}

.subcat-add-btn {
  width: 34px;
  min-height: 34px;
  height: 34px;
  border-radius: 7px;
  font-size: 12px;
}

/* ============================================================================
   ORDERS WORKSPACE (COMPACT & CALM)
   ============================================================================ */

.alert-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  background: var(--status-amber-bg);
  border: var(--stroke) solid color-mix(in srgb, var(--status-amber) 30%, transparent);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 12.5px;
  animation: panelReveal 220ms var(--ease-calm) both;
}

.alert-banner.is-error {
  background: var(--status-red-bg);
  border-color: color-mix(in srgb, var(--status-red) 30%, transparent);
}

.orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.order-card {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: grid;
  gap: 9px;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

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

.order-card.is-unseen {
  border-color: color-mix(in srgb, var(--status-amber) 45%, transparent);
  animation: unseenPulse 2.8s ease-in-out infinite;
}

.order-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-muted);
}

.order-id {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, currentColor 25%, transparent);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status-tag.pending {
  color: var(--status-amber);
  background: var(--status-amber-bg);
}

.status-tag.delivered {
  color: var(--status-green);
  background: var(--status-green-bg);
}

.status-tag.return {
  color: var(--status-orange);
  background: var(--status-orange-bg);
}

.status-tag.cancelled {
  color: var(--status-red);
  background: var(--status-red-bg);
}

.order-items-box {
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
}

.order-item-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.order-totals {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}

.order-status-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid var(--border-muted);
}

.status-action-btn {
  min-height: 30px;
  padding: 3px 5px;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 140ms var(--ease-calm);
}

.status-action-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.status-action-btn:active {
  transform: scale(0.96);
}

.status-action-btn.is-current.pending {
  background: var(--status-amber);
  border-color: transparent;
  color: #ffffff;
}

.status-action-btn.is-current.delivered {
  background: var(--status-green);
  border-color: transparent;
  color: #ffffff;
}

.status-action-btn.is-current.return {
  background: var(--status-orange);
  border-color: transparent;
  color: #ffffff;
}

.status-action-btn.is-current.cancelled {
  background: var(--status-red);
  border-color: transparent;
  color: #ffffff;
}

/* ============================================================================
   FORMS & EDITOR CONTROLS (COMPACT DESKTOP / TOUCH-SAFE MOBILE)
   ============================================================================ */

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

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

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.form-row-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.input,
.select,
.textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 37px;
  padding: 6px 11px;
  background: var(--bg-inset);
  border: var(--stroke) solid color-mix(in srgb, var(--input-stroke) 24%, transparent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 38%, transparent);
}

.input:focus,
.input:focus-visible,
.input:active,
.select:focus,
.select:focus-visible,
.textarea:focus,
.textarea:focus-visible,
.textarea:active {
  outline: none;
  border-color: color-mix(in srgb, var(--input-stroke) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
  background: var(--bg-surface);
}

.textarea {
  min-height: 128px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
}

.stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  border: var(--stroke) solid color-mix(in srgb, var(--input-stroke) 24%, transparent);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-inset);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stepper:hover {
  border-color: color-mix(in srgb, var(--input-stroke) 38%, transparent);
}

.stepper:focus-within {
  border-color: color-mix(in srgb, var(--input-stroke) 58%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
}

.stepper button {
  min-height: 36px;
  border: none;
  background: var(--bg-subtle);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform 120ms ease;
}

.stepper button:hover {
  background: var(--accent-soft);
}

.stepper button:active {
  transform: scale(0.94);
}

.stepper input {
  border: none;
  border-left: var(--stroke) solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  border-right: var(--stroke) solid color-mix(in srgb, var(--input-stroke) 20%, transparent);
  background: transparent;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}

.stepper input:focus,
.stepper input:focus-visible {
  outline: none;
  background: var(--bg-surface);
}

/* Image Preview & 3x3 Grid Overlay */
.preview-stage {
  position: relative;
  height: 170px;
  background: repeating-conic-gradient(var(--bg-subtle) 0% 25%, var(--bg-inset) 0% 50%) 50% / 14px 14px;
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-stage.is-compact {
  height: 124px;
}

.preview-stage img {
  max-width: 100%;
  max-height: 100%;
  transition: transform 80ms linear;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(199, 162, 50, 0.32) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(199, 162, 50, 0.32) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
}

.inline-status {
  padding: 8px 11px;
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-inset);
  animation: panelReveal 200ms var(--ease-calm) both;
}

.inline-status.is-info {
  border-color: color-mix(in srgb, var(--accent-outline) 45%, transparent);
  background: var(--accent-soft);
  color: var(--text-primary);
}

.inline-status.is-success {
  border-color: color-mix(in srgb, var(--status-green) 35%, transparent);
  background: var(--status-green-bg);
  color: var(--status-green);
}

.inline-status.is-error {
  border-color: color-mix(in srgb, var(--status-red) 35%, transparent);
  background: var(--status-red-bg);
  color: var(--status-red);
}

.gallery-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border: 1px solid color-mix(in srgb, var(--input-stroke) 22%, transparent);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.gallery-thumb:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-soft);
  border-color: color-mix(in srgb, var(--input-stroke) 42%, transparent);
}

.gallery-thumb.is-busy img {
  opacity: 0.35;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.gallery-thumb-busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-text);
  font-size: 15px;
  pointer-events: none;
}

.gallery-thumb button {
  position: absolute;
  top: 3px;
  width: 22px;
  height: 22px;
  border: 1px solid var(--border-muted);
  border-radius: 5px;
  background: color-mix(in srgb, var(--bg-surface) 94%, transparent);
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.gallery-del-btn {
  right: 3px;
  color: var(--status-red);
}

.gallery-del-btn:hover:not(:disabled) {
  background: var(--status-red-bg);
  border-color: color-mix(in srgb, var(--status-red) 32%, transparent);
}

.gallery-rbg-btn {
  left: 3px;
  color: var(--accent-text);
  background: color-mix(in srgb, var(--accent-soft) 95%, transparent);
  border-color: color-mix(in srgb, var(--accent-outline) 42%, transparent);
}

.gallery-rbg-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--accent-contrast);
}

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

.pe-add-rbg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--border-muted);
}

.pe-add-rbg-row .segmented {
  width: auto;
}

.pe-add-rbg-row .seg-btn {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 11px;
}

.pe-add-rbg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.spec-list {
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  overflow: hidden;
}

.spec-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-muted);
  font-size: 12.5px;
}

.spec-row:last-child {
  border-bottom: none;
}

.markdown-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.markdown-preview {
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  padding: 10px 12px;
  min-height: 128px;
  font-size: 13px;
}

.markdown-preview h2,
.markdown-preview h3 {
  font-family: var(--font-display);
  margin: 10px 0 4px;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid var(--border-muted);
  padding: 5px 7px;
  font-size: 12px;
}

/* ============================================================================
   TOASTS, CHARTS & SKELETONS
   ============================================================================ */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 58px;
  z-index: 100;
  display: grid;
  gap: 8px;
  max-width: 320px;
  pointer-events: none;
}

.toast {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 10px;
  box-shadow: var(--shadow-float);
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 600;
  pointer-events: auto;
  animation: toastSlideIn 260ms var(--ease-spring) both;
}

.toast.is-leaving {
  animation: toastSlideOut 200ms var(--ease-calm) forwards;
}

.toast.is-error {
  background: var(--status-red);
  color: #ffffff;
}

.chart-box {
  position: relative;
  width: 100%;
  min-height: 154px;
}

.chart-bar-rect {
  transform-box: fill-box;
  transform-origin: center bottom;
  animation: chartBarGrow 420ms var(--ease-calm) both;
  transition: filter 160ms ease, opacity 160ms ease;
}

.chart-bar-group {
  cursor: pointer;
}

.chart-bar-group:hover .chart-bar-rect {
  filter: brightness(0.95) saturate(1.15);
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: var(--stroke) solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-hover);
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  z-index: 10;
  animation: panelReveal 140ms var(--ease-calm) both;
}

.empty-state {
  padding: 30px 16px;
  border: var(--stroke) dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-surface);
  text-align: center;
  display: grid;
  gap: 8px;
  justify-items: center;
  animation: calmFadeUp 260ms var(--ease-calm) both;
}

.skeleton-panel,
.loading-panel {
  display: grid;
  gap: 12px;
}

.skeleton-bar,
.skeleton-box {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-inset) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: calmShimmer 1.6s ease-in-out infinite;
  border: none;
}

.skeleton-bar {
  height: 36px;
  border-radius: var(--radius-sm);
}

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

.skeleton-box {
  height: 88px;
  border-radius: var(--radius);
}

/* ============================================================================
   LEDGER, CUSTOMERS, SUPPLIERS, RESTOCK & SALES LOG
   ============================================================================ */

.ledger-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  min-width: 0;
}

.ledger-card {
  background: var(--bg-surface);
  border: var(--stroke) solid var(--border-muted);
  border-radius: var(--radius);
  padding: 13px 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  align-content: start;
  min-width: 0;
  max-width: 100%;
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

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

.ledger-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.ledger-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ledger-card-btns {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.ledger-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-metric-val.is-paid {
  color: var(--status-green);
}

.ledger-inline-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  min-width: 0;
  background: var(--bg-inset);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  animation: panelReveal 200ms var(--ease-calm) both;
}

.ledger-stmt-list {
  display: grid;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-inset);
  max-height: 220px;
  overflow-y: auto;
  animation: panelReveal 200ms var(--ease-calm) both;
}

.ledger-stmt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-muted);
}

.ledger-stmt-row:last-child {
  border-bottom: none;
}

.ledger-summary-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px;
  min-width: 0;
  background: var(--accent-soft);
  border: var(--stroke) solid color-mix(in srgb, var(--accent-outline) 35%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

.ledger-item-picker {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 78px auto;
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.sale-line-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-muted);
  font-size: 12.5px;
}

.sale-line-row:last-child {
  border-bottom: none;
}

/* ============================================================================
   RESPONSIVE BREAKPOINTS (COMPACT TABLET & MOBILE)
   ============================================================================ */

@media (max-width: 1080px) {
  .kpi-grid,
  .skeleton-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analytics-split,
  .analytics-two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .app-stage {
    width: 100%;
    max-width: 100vw;
  }

  .mobile-only {
    display: inline-flex;
  }

  .mobile-only-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 228px;
    margin-left: 0 !important;
    transform: translateX(-100%);
    z-index: 40;
  }

  .app-shell.is-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.is-sidebar-open .app-stage {
    transform: translateX(228px);
    box-shadow: -12px 0 32px rgba(26, 23, 15, 0.1);
  }

  .app-shell.is-sidebar-open .stage-dismiss-layer:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: transparent;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 10px;
    height: 46px;
  }

  .topbar-center {
    display: none;
  }

  .main-content {
    padding: 10px;
    min-width: 0;
    max-width: 100%;
  }

  .app-footer {
    padding: 6px 8px calc(5px + env(safe-area-inset-bottom, 0px));
    min-height: 52px;
  }

  .footer-meta {
    display: none;
  }

  .footer-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }

  .footer-link {
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    padding: 5px 2px;
    min-height: 42px;
    font-size: 9.5px;
    border: none;
    border-radius: var(--radius);
    overflow: visible;
    text-overflow: ellipsis;
  }

  .footer-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .footer-link i {
    font-size: 13px;
  }

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

  .ledger-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
  }

  .ledger-tabs .seg-btn {
    flex-direction: column;
    gap: 2px;
    padding: 5px 2px;
    font-size: 10px;
    overflow: hidden;
  }

  .ledger-tabs .seg-btn span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

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

  .ledger-item-picker > :first-child {
    grid-column: 1 / -1;
  }

  .ledger-item-picker > button {
    grid-column: 1 / -1;
  }

  .ledger-summary-bar {
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    font-size: 12px;
  }

  .view-root {
    gap: 10px;
  }

  .panel {
    padding: 12px;
  }

  .panel-header {
    padding-bottom: 8px;
    margin-bottom: 10px;
  }

  .btn {
    min-height: 40px;
  }

  .btn-sm {
    min-height: 34px;
  }

  .input,
  .select,
  .textarea,
  .search-input {
    min-height: 40px;
    font-size: 16px;
  }

  input[type="date"].input {
    font-size: 14px;
  }

  .cselect-trigger {
    min-height: 40px;
    font-size: 13.5px;
  }

  .cselect-menu {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
  }

  .cselect-option {
    min-height: 38px;
    font-size: 13.5px;
  }

  .input.ccombo-input {
    padding-right: 44px;
  }

  .ccombo-toggle {
    width: 40px;
  }

  .ccombo-menu {
    max-height: 210px;
  }

  .ccombo-menu .cselect-option {
    min-height: 42px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .products-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

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

  .products-toolbar-filters .cselect-menu {
    width: max-content;
    min-width: 100%;
    max-width: min(260px, calc(100vw - 24px));
  }

  .products-toolbar-filters > :last-child .cselect-menu {
    left: auto;
    right: 0;
  }

  .products-toolbar-right {
    justify-content: space-between;
  }

  /* Compact, Contained Mobile Data & Products Column/Table Views */
  .data-table {
    font-size: 11.5px;
  }

  .data-table th,
  .data-table td {
    padding: 7px 8px;
  }

  .data-table th {
    font-size: 10px;
  }

  .data-table .btn-sm {
    min-height: 28px;
    padding: 3px 8px;
    font-size: 11px;
  }

  /* Compact Products Column View — Fits Mobile Screen Cleanly Without Horizontal Overflow */
  .products-table-panel .table-wrap {
    overflow-x: hidden;
  }

  .products-table {
    table-layout: fixed;
    width: 100%;
  }

  .products-table .pcol-desktop {
    display: none;
  }

  .products-table .pcol-mobile-sub {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .products-table th,
  .products-table td {
    padding: 7px 6px;
  }

  .products-table th:first-child,
  .products-table td:first-child {
    padding-left: 10px;
    white-space: normal;
  }

  .products-table .pcol-title {
    font-size: 12px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  .products-table .pcol-price {
    width: 72px;
    font-size: 11.5px;
  }

  .products-table .pcol-stock {
    width: 44px;
    font-size: 11.5px;
  }

  .products-table .pcol-actions {
    width: 74px;
    padding-left: 4px;
    padding-right: 8px;
  }

  .products-table .pcol-btn-label {
    display: none;
  }

  .products-table .pcol-btn-icon {
    display: inline-block;
  }

  .products-table .pcol-action-group .btn-sm {
    min-height: 28px;
    width: 28px;
    padding: 0;
    font-size: 11px;
  }

  .restock-history-table th:nth-child(3),
  .restock-history-table td:nth-child(3) {
    min-width: 132px;
    max-width: 168px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
  }

  .restock-history-table th:nth-child(4),
  .restock-history-table td:nth-child(4) {
    min-width: 96px;
    max-width: 130px;
    white-space: normal;
    line-height: 1.25;
  }

  .insight-tabs {
    width: 100%;
  }

  .insight-tab {
    padding: 5px 4px;
    font-size: 11px;
  }

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

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

  .form-row-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .pe-shell,
  .cat-shell {
    gap: 22px;
    padding: 4px 0 24px;
  }

  .pe-section {
    gap: 10px;
  }

  .pe-section + .pe-section {
    padding-top: 18px;
  }

  .pe-media-url-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .pe-media-url-row > input {
    grid-column: 1 / -1;
  }

  .pe-img-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

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

  .url-action-row > input {
    grid-column: 1 / -1;
  }

  .segmented-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .segmented-4 .seg-btn {
    padding: 6px 4px;
    text-align: center;
  }

  .kpi-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .kpi-card {
    padding: 10px;
  }

  .kpi-value {
    font-size: 18px;
  }

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

  .category-head {
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .category-thumb {
    width: 38px;
    height: 38px;
  }

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

  .subpage-actions > :only-child {
    grid-column: 1 / -1;
  }

  .toast-stack {
    left: 10px;
    right: 10px;
    bottom: 58px;
    max-width: none;
  }
}

@media (max-width: 380px) {
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .order-status-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .input-action-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .subpage-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}
