.print-dialog {
  width: min(1120px, 95vw); max-height: 94vh; overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-lg);
}
.print-dialog::backdrop { background: var(--overlay); }
.print-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.print-dialog h2 { font-size: 20px; margin: 0; }
.print-dialog p { color: var(--text-muted); overflow-wrap: anywhere; }
.print-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 14px 0; }
.print-tools .field { flex: 1 1 160px; min-width: 0; }
.print-tools input, .print-tools select { width: 100%; }
.print-preview { display: block; width: 100%; height: 65vh; border: 1px solid var(--border); background: var(--surface-subtle); }
.print-preview[hidden], .print-logo-preview[hidden] { display: none; }
.print-logo-preview { max-width: 120px; max-height: 64px; object-fit: contain; }
.print-history { display: flex; flex-wrap: wrap; gap: 8px; }
.print-history h3 { flex-basis: 100%; font-size: 15px; }
.print-dialog details { border: 1px solid var(--border); padding: 12px; border-radius: var(--radius-sm); }
.print-dialog summary { cursor: pointer; }
@media (max-width: 600px) { .print-dialog { padding: 12px; } .print-tools > .btn { flex: 1 1 130px; } }
:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-subtle: #f7f8fa;
  --surface-hover: #eef0f3;
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255, 255, 255, .96);

  --text: #1f2933;
  --text-strong: #1f2933;
  --text-muted: #667085;
  --text-faint: #667085;

  --border: rgba(16, 24, 40, .12);
  --border-strong: #85909f;

  --primary: #2563eb;
  --on-primary: #ffffff;
  --on-danger: #ffffff;
  --overlay: rgba(16, 24, 40, .42);
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, .10);
  --primary-border: #bfdbfe;

  --success: #15803d;
  --success-soft: #ecfdf3;
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, .18);

  --sidebar-width: 264px;
  --sidebar-collapsed: 76px;
  --topbar-height: 66px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 12px;
  --transition: 160ms ease;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111315;
  --surface: #1b1e22;
  --surface-raised: #1b1e22;
  --surface-subtle: #202428;
  --surface-hover: #2a2f35;
  --sidebar-bg: #17191c;
  --topbar-bg: rgba(27, 30, 34, .96);

  --text: #f2f4f7;
  --text-strong: #f2f4f7;
  --text-muted: #a4acb8;
  --text-faint: #a4acb8;

  --border: rgba(255, 255, 255, .14);
  --border-strong: #748190;

  --primary: #60a5fa;
  --on-primary: #111315;
  --on-danger: #111315;
  --overlay: rgba(0, 0, 0, .56);
  --primary-hover: #93c5fd;
  --primary-soft: rgba(96, 165, 250, .14);
  --primary-border: rgba(96, 165, 250, .28);

  --success: #6ee7b7;
  --success-soft: rgba(22, 163, 74, .14);
  --warning: #fcd34d;
  --warning-soft: rgba(217, 119, 6, .14);
  --danger: #fca5a5;
  --danger-soft: rgba(220, 38, 38, .14);
  --info: #93c5fd;
  --info-soft: rgba(2, 132, 199, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .16);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, .24);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .38);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

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

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

[hidden] {
  display: none !important;
}

/* ---------- app shell ---------- */

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

body.sidebar-collapsed .app-shell {
  grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
  gap: 11px;
  color: var(--text-strong);
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 17px;
  font-weight: 800;
  box-shadow: none;
}

.brand-text {
  display: grid;
  min-width: 0;
  line-height: 1.15;
  transition: opacity var(--transition), width var(--transition);
}

.brand-text strong {
  font-size: 17px;
  letter-spacing: .01em;
}

.brand-text small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sidebar-collapse {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
}

.sidebar-collapse span {
  font-size: 22px;
  line-height: 1;
  transition: transform var(--transition);
}

body.sidebar-collapsed .sidebar-collapse span {
  transform: rotate(180deg);
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-item > span:not(.nav-icon),
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-foot .system-state > div,
body.sidebar-collapsed .sidebar-foot .version {
  width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar-head {
  padding-inline: 12px;
}

body.sidebar-collapsed .sidebar-collapse {
  display: none;
}

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 8px;
}

body.sidebar-collapsed .nav-icon {
  margin: 0;
}

.nav-groups {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.nav-group + .nav-group {
  margin-top: 17px;
}

.nav-label {
  padding: 0 10px 6px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .12em;
  white-space: nowrap;
  transition: opacity var(--transition);
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  transition:
    color var(--transition),
    background var(--transition);
}

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

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

.nav-item.active::before {
  position: absolute;
  left: -10px;
  width: 3px;
  height: 23px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
  content: "";
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: currentColor;
  font-size: 15px;
  font-weight: 700;
}

.nav-badge {
  min-width: 21px;
  height: 19px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 12px;
  line-height: 19px;
  text-align: center;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.system-state {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.health-dot {
  display: block;
  flex: 0 0 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text-faint) 15%, transparent);
}

.health-dot.ok {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 16%, transparent);
}

.health-dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
}

.system-state div {
  display: grid;
  min-width: 0;
  transition: opacity var(--transition);
}

.system-state strong {
  font-size: 12px;
}

.system-state small,
.version {
  color: var(--text-muted);
  font-size: 12px;
}

.version {
  margin: 9px 0 0 19px;
  white-space: nowrap;
}

/* ---------- top bar ---------- */

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(160px, .8fr) minmax(280px, 1.3fr) auto;
  align-items: center;
  gap: 20px;
  height: var(--topbar-height);
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar-left {
  min-width: 0;
  gap: 10px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
}

.breadcrumb b {
  color: var(--border-strong);
}

.breadcrumb strong {
  overflow: hidden;
  color: var(--text-strong);
  font-weight: 650;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-center {
  min-width: 0;
}

.global-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  width: min(620px, 100%);
  height: 38px;
  margin: 0 auto;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  transition: border var(--transition), box-shadow var(--transition), background var(--transition);
}

.global-search:focus-within {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.global-search input {
  width: 100%;
  height: 34px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.global-search input::placeholder {
  color: var(--text-faint);
}

.search-icon {
  margin-right: 8px;
  font-size: 18px;
}

.global-search kbd {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-sans);
  box-shadow: var(--shadow-sm);
}

.topbar-actions {
  justify-content: flex-end;
  gap: 8px;
}

.warehouse-context {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.organization-context {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.organization-context > span {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.organization-context select {
  max-width: 155px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.warehouse-context > span {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.warehouse-context select {
  max-width: 155px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  width: 34px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border var(--transition);
}

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

.theme-switcher {
  display: flex;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.theme-switcher button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.theme-switcher button:hover {
  color: var(--text-strong);
}

.theme-switcher button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.user-chip {
  display: flex;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: 3px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

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

.user-copy {
  display: grid;
  max-width: 120px;
  min-width: 0;
  line-height: 1.2;
}

.user-copy strong,
.user-copy small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-copy strong {
  color: var(--text-strong);
  font-size: 12px;
}

.user-copy small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 12px;
}

.mobile-menu {
  display: none;
}

/* ---------- main / views ---------- */

.content {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.view {
  display: none;
  animation: view-enter 150ms ease-out;
}

.view.active {
  display: block;
}

@keyframes view-enter {
  from { opacity: .25; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-head h1 {
  margin: 3px 0 4px;
  color: var(--text-strong);
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: -.025em;
}

.page-head p,
.panel-head p {
  margin: 0;
  color: var(--text-muted);
}

.page-head p {
  font-size: 13px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

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

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill.neutral {
  border-color: var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.status-pill.ok {
  border-color: color-mix(in srgb, var(--success) 24%, transparent);
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.bad {
  border-color: color-mix(in srgb, var(--danger) 24%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- cards / panels ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  position: relative;
  min-width: 0;
  padding: 15px 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card.accent {
  border-top-color: var(--primary);
}

.metric-label {
  position: relative;
  z-index: 1;
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.metric-card strong {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--text-strong);
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  letter-spacing: -.03em;
}

.metric-card small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 12px;
}

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

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

.panel {
  min-width: 0;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 13px;
}

.panel-head h2 {
  margin: 0 0 2px;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 650;
}

.panel-head p {
  font-size: 13px;
}

.panel-meta {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.mini-metrics > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-width: 0;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.mini-metrics span {
  color: var(--text-muted);
  font-size: 13px;
}

.mini-metrics strong {
  color: var(--text-strong);
  font-size: 18px;
}

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

.master-grid .panel {
  overflow: hidden;
}

.empty-panel {
  display: grid;
  justify-items: center;
  min-height: 340px;
  align-content: center;
  text-align: center;
}

.empty-panel h2 {
  margin: 12px 0 5px;
  color: var(--text-strong);
}

.empty-panel p {
  max-width: 560px;
  margin: 0 0 16px;
  color: var(--text-muted);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 26px;
}

/* ---------- dashboard widgets ---------- */

.work-queue {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.work-queue-item {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border var(--transition), background var(--transition);
}

.work-queue-item:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.work-queue-item span {
  color: var(--text-muted);
  font-size: 12px;
}

.work-queue-item strong {
  color: var(--text-strong);
  font-size: 20px;
  line-height: 1;
}

.work-queue-item small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.posture-list {
  display: grid;
  gap: 10px;
}

.posture-row {
  display: grid;
  gap: 5px;
}

.posture-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.posture-head strong {
  color: var(--text-strong);
  font-weight: 650;
}

.posture-track {
  height: 6px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface-hover);
}

.posture-bar {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: var(--primary);
}

.posture-row[data-status="ALLOCATED"] .posture-bar {
  background: var(--primary);
}

.posture-row[data-status="REPLENISHMENT"] .posture-bar {
  background: var(--info);
}

.posture-row[data-status="HOLD"] .posture-bar,
.posture-row[data-status="QC"] .posture-bar {
  background: var(--warning);
}

.posture-row[data-status="DAMAGED"] .posture-bar,
.posture-row[data-status="EXPIRED"] .posture-bar,
.posture-row[data-status="QUARANTINE"] .posture-bar {
  background: var(--danger);
}

.audit-feed {
  display: grid;
}

.audit-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 9px 0;
  border-top: 1px solid var(--border);
}

.audit-item:first-child {
  border-top: 0;
}

.audit-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.audit-copy {
  min-width: 0;
}

.audit-copy strong,
.audit-copy small {
  display: block;
}

.audit-copy strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.audit-copy small,
.audit-time {
  color: var(--text-muted);
  font-size: 12px;
}

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

.quick-action {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.quick-action:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.quick-action > span {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--surface);
  color: var(--primary);
  font-size: 16px;
}

.quick-action b {
  color: var(--text-strong);
  font-size: 13px;
}

.quick-action small {
  color: var(--text-muted);
  font-size: 12px;
}

.empty-state {
  min-height: 80px;
  align-content: center;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

/* ---------- tables ---------- */

.table-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.location-tree {
  padding: 0.75rem 1rem 1rem;
}

.location-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.25rem;
}

.location-tree > ul {
  padding-left: 0;
}

.location-tree li {
  border-left: 1px solid var(--border);
  padding: 0.25rem 0 0.25rem 1rem;
}

.location-tree-node {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.location-tree-code {
  font-family: var(--font-mono);
  font-weight: 650;
}

.location-tree-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.identifier-scan-result {
  min-height: 2.75rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-subtle);
  white-space: pre-wrap;
  word-break: break-word;
}

.identifier-scan-result:empty {
  display: none;
}

.field-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  height: 42px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .045em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  height: 44px;
  max-width: 330px;
  padding: 8px 10px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
  text-overflow: ellipsis;
}

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

tbody tr:hover td {
  background: var(--surface-subtle);
}

tbody tr.filtered-out {
  display: none;
}

td code {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

td .status-cell {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

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

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

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

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

/* ---------- forms ---------- */

.editor {
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.editor summary {
  padding: 11px 14px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.editor summary::-webkit-details-marker {
  display: none;
}

.editor[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 11px;
  padding: 14px;
}

.form-grid > .span-2 {
  grid-column: 1 / -1;
}

.form-grid > .btn {
  align-self: end;
  min-height: 42px;
}

.form-grid.single-column {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.field > span,
.check-field > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .025em;
}

.field input,
.field select,
.compact-select {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border var(--transition), box-shadow var(--transition);
}

.field select[multiple] {
  height: auto;
  min-height: 118px;
  padding-block: 5px;
}

.field input:focus,
.field select:focus,
.compact-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.autocomplete-control {
  position: relative;
  width: 100%;
  min-width: 0;
}

.autocomplete-source {
  display: none !important;
}

.autocomplete-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.autocomplete-option {
  display: block;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.autocomplete-option:hover,
.autocomplete-option.is-active {
  background: var(--primary-soft);
  color: var(--text-strong);
}

.check-field {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 7px;
}

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

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

.compact-editor {
  margin: 0 0 12px;
  background: var(--surface-subtle);
}

.transaction-line-editor {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.transaction-line-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) 105px 105px 105px auto;
  align-items: end;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.transaction-line-row .field input,
.transaction-line-row .field select {
  height: 36px;
}

.transaction-line-remove {
  min-height: 36px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition:
    background var(--transition),
    border var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.btn.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

:root[data-theme="dark"] .btn.primary {
  color: var(--on-primary);
}

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

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

.btn.text {
  padding-inline: 4px;
  background: transparent;
  color: var(--primary);
}

.btn.text:hover {
  color: var(--primary-hover);
}

.btn.wide {
  width: 100%;
}

/* ---------- login ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}

.login-card {
  width: min(430px, 100%);
  padding: 25px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding-bottom: 17px;
  border-bottom: 1px solid var(--border);
}

.login-brand > div {
  display: grid;
}

.login-brand strong {
  color: var(--text-strong);
  font-size: 14px;
}

.login-brand span:not(.brand-mark) {
  color: var(--text-muted);
  font-size: 12px;
}

.login-copy {
  margin: 21px 0 17px;
}

.login-copy h1 {
  margin: 0 0 5px;
  color: var(--text-strong);
  font-size: 21px;
}

.login-copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.login-card .field {
  margin-bottom: 12px;
}

.login-card .field input {
  height: 40px;
}

.login-error {
  min-height: 18px;
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
}

.login-footer {
  margin-top: 16px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 3000;
  max-width: min(430px, calc(100vw - 44px));
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--text-strong);
  color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: toast-in 160ms ease-out;
}

.toast.error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  background: var(--danger);
  color: var(--on-danger);
}

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

/* ---------- responsive ---------- */

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

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

  .work-queue {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar {
    grid-template-columns: minmax(140px, .65fr) minmax(220px, 1fr) auto;
    gap: 12px;
  }

  .warehouse-context > span,
  .organization-context > span,
  .user-copy {
    display: none;
  }
}

@media (max-width: 1040px) {
  .app-shell,
  body.sidebar-collapsed .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    visibility: hidden;
    position: fixed;
    left: 0;
    transform: translateX(-102%);
    width: min(290px, calc(100vw - 48px));
    box-shadow: var(--shadow-lg);
    transition: transform 180ms ease, visibility 180ms;
  }

  body.mobile-nav-open .sidebar {
    visibility: visible;
    transform: none;
  }

  .sidebar-collapse {
    display: none;
  }

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

  .topbar {
    grid-template-columns: auto minmax(180px, 1fr) auto;
    padding-inline: 14px;
  }

  .breadcrumb > span,
  .breadcrumb > b,
  .warehouse-context,
  .organization-context,
  .global-search kbd {
    display: none;
  }

  .content {
    padding-inline: 16px;
  }

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

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

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
    height: 58px;
  }

  .topbar-center {
    display: none;
  }

  .topbar-actions {
    grid-column: 3;
  }

  .theme-switcher button[data-theme-value="system"] {
    display: grid;
  }

  .content {
    padding: 18px 12px 38px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .page-actions {
    justify-content: flex-start;
  }

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

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

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

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

  .user-chip {
    padding-left: 4px;
    border-left: 0;
  }

  .table-wrap {
    scrollbar-width: thin;
  }

  .table-wrap.is-overflowing::after {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 1;
    padding: 3px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    color: var(--text-muted);
    content: "↔";
    font-size: 12px;
    line-height: 1.2;
    pointer-events: none;
  }
}

@media (max-width: 480px) {
  .metric-grid,
  .work-queue,
  .quick-actions,
  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .metric-card {
    padding: 13px;
  }

  .theme-switcher {
    display: flex;
  }

  .topbar-actions {
    gap: 3px;
  }
}

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

/* ---------- UI v2 table tools / saved views ---------- */

.table-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: auto;
}

.table-tools select,
.table-tools input {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.table-tools .tool-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
}

.task-assignment-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  width: 100%;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.task-assignment-tools select {
  min-width: 190px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

.task-selection-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.table-pager-copy {
  color: var(--text-muted);
  font-size: 12px;
}

.table-pager-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.table-pager-actions button {
  min-width: 29px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.table-pager-actions button:hover:not(:disabled) {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}

.table-pager-actions button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.saved-view-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: -6px 0 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.saved-view-bar > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.saved-view-bar select {
  min-width: 170px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12px;
}

/* ---------- row interaction ---------- */

tbody tr.detail-row {
  cursor: pointer;
}

tbody tr.detail-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

tbody tr.detail-row:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--primary);
}

/* ---------- detail drawer ---------- */

.detail-scrim {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--overlay);
  backdrop-filter: blur(1px);
}

.detail-drawer {
  visibility: hidden;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1600;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(660px, calc(100vw - 40px));
  height: 100vh;
  height: 100dvh;
  transform: translateX(102%);
  border-left: 1px solid var(--border);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  transition: transform 190ms ease, visibility 190ms;
}

.detail-drawer.open {
  visibility: visible;
  transform: none;
}

.detail-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.detail-drawer-head h2 {
  margin: 3px 0 3px;
  color: var(--text-strong);
  font-size: 20px;
  letter-spacing: -.02em;
}

.detail-drawer-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.detail-drawer-head #detail-close {
  font-size: 22px;
}

.detail-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.detail-actions:empty {
  display: none;
}

.detail-body {
  overflow-y: auto;
  padding: 18px 20px 28px;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 9px;
  color: var(--text-strong);
  font-size: 12px;
}

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

.detail-kv {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.detail-kv span,
.detail-kv strong {
  display: block;
}

.detail-kv span {
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.detail-kv strong {
  overflow: hidden;
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.detail-json {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.drawer-form {
  display: grid;
  gap: 10px;
}

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

.drawer-form .field input,
.drawer-form .field select {
  height: 34px;
}

.drawer-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
}

.utilization {
  display: grid;
  gap: 11px;
}

.utilization-row {
  display: grid;
  gap: 5px;
}

.utilization-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.utilization-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hover);
}

.utilization-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.capability-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.capability-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--primary-border);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---------- cycle count workspace ---------- */

.count-workspace {
  display: grid;
  gap: 12px;
}

.count-workspace-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-lines {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.count-lines table {
  min-width: 620px;
}

.count-input {
  width: 95px;
  height: 29px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.count-input.dirty {
  border-color: var(--warning);
  box-shadow: 0 0 0 2px var(--warning-soft);
}

.found-stock-editor {
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  background: var(--surface-subtle);
}

.found-stock-editor h4 {
  margin: 0 0 9px;
  color: var(--text-strong);
  font-size: 12px;
}

/* ---------- action buttons ---------- */

.btn.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.btn.danger:hover {
  border-color: var(--danger);
}

.btn.success {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.btn.warning {
  border-color: color-mix(in srgb, var(--warning) 40%, var(--border));
  background: var(--warning-soft);
  color: var(--warning);
}

.btn.small {
  min-height: 29px;
  padding: 5px 8px;
  font-size: 12px;
}

/* ---------- confirmation dialog ---------- */

.confirm-dialog {
  width: min(410px, calc(100vw - 36px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.confirm-dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.confirm-dialog form {
  display: grid;
  justify-items: center;
  padding: 22px;
  text-align: center;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 20px;
  font-weight: 800;
}

.confirm-dialog h3 {
  margin: 12px 0 4px;
  color: var(--text-strong);
}

.confirm-dialog p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 18px;
}

/* ---------- responsive v2 ---------- */

@media (max-width: 760px) {
  .detail-drawer {
    width: 100vw;
  }

  .detail-body {
    display: flex;
    flex-direction: column;
  }

  /* Keep order status and actionable lines ahead of technical metadata on a
     narrow screen. The drawer title/subtitle already retain the identity and
     status, so moving the summary down does not hide the current state. */
  .detail-section.mobile-secondary {
    order: 2;
  }

  .detail-grid,
  .drawer-form-grid {
    grid-template-columns: 1fr;
  }

  .table-tools {
    width: 100%;
    margin-left: 0;
  }

  .saved-view-bar {
    align-items: stretch;
  }

  .saved-view-bar select {
    flex: 1;
  }
}


/* ---------- V0.22 user / RBAC administration ---------- */

.permission-chip-list {
  max-height: 240px;
  overflow: auto;
  align-content: flex-start;
  padding-right: 3px;
}

#user-table td:nth-child(4),
#user-table td:nth-child(5) {
  max-width: 260px;
}

#role-table td:nth-child(2) {
  max-width: 260px;
}

.user-security-note {
  padding: 9px 10px;
  border: 1px solid var(--warning);
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 12px;
}


/* ---------- V0.23 account security / sessions ---------- */

.session-list {
  display: grid;
  gap: 7px;
}

.session-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.session-card-copy {
  display: grid;
  min-width: 0;
}

.session-card-copy strong {
  color: var(--text-strong);
  font-size: 12px;
}

.session-card-copy span,
.session-card-copy small {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.session-card-copy small {
  margin-top: 2px;
}

#password-change-overlay .login-card {
  width: min(470px, 100%);
}

#password-change-overlay .btn + .btn {
  margin-top: 7px;
}

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

  .session-card > .btn {
    grid-column: 1 / -1;
  }
}


/* ---------- V0.24 inbound / outbound operator workspaces ---------- */

.operator-table table {
  min-width: 660px;
}

.operator-record-list,
.operator-line-list {
  display: grid;
  gap: 7px;
}

.operator-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.operator-record:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}

.operator-record-copy,
.operator-line-copy {
  display: grid;
  min-width: 0;
}

.operator-record-copy strong,
.operator-line-copy strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.operator-record-copy small,
.operator-line-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.operator-line-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.receipt-line-editor,
.package-line-editor {
  display: grid;
  gap: 7px;
  max-height: 390px;
  overflow: auto;
  padding: 2px;
}

.receipt-line-edit {
  display: grid;
  grid-template-columns: 22px minmax(150px, 1.4fr) 90px minmax(120px, 1fr)
    minmax(120px, 1fr) minmax(120px, 1fr);
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.package-line-edit {
  display: grid;
  grid-template-columns: 22px minmax(160px, 1fr) 110px;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.receipt-line-edit > input:not([type="checkbox"]),
.receipt-line-edit > select,
.package-line-edit > input:not([type="checkbox"]) {
  min-width: 0;
  height: 31px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.receipt-line-edit input[type="checkbox"],
.package-line-edit input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.receipt-line-item {
  display: grid;
  min-width: 0;
}

.receipt-line-item strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.receipt-line-item small {
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .transaction-line-row {
    grid-template-columns: 1fr 1fr;
  }

  .transaction-line-row .field:first-child {
    grid-column: 1 / -1;
  }

  .operator-line-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .operator-line-card .inline-actions {
    grid-column: 1 / -1;
  }

  .receipt-line-edit {
    grid-template-columns: 22px minmax(0, 1fr) 90px;
  }

  .receipt-line-edit .receipt-line-lot,
  .receipt-line-edit .receipt-line-serial,
  .receipt-line-edit .receipt-line-lpn {
    grid-column: 2 / -1;
  }

  .package-line-edit {
    grid-template-columns: 22px minmax(0, 1fr) 90px;
  }
}


/* ---------- V0.25 sidebar collapse fix ---------- */

/*
 * V0.19 hid .sidebar-collapse after collapsing, which removed the only
 * control capable of expanding the desktop sidebar again.
 */
body.sidebar-collapsed .sidebar-head {
  padding-inline: 4px;
  gap: 4px;
}

body.sidebar-collapsed .brand {
  flex: 0 0 34px;
  justify-content: center;
}

body.sidebar-collapsed .sidebar-collapse {
  display: inline-grid;
  flex: 0 0 28px;
  width: 28px;
  height: 32px;
}

body.sidebar-collapsed .sidebar-collapse span {
  transform: rotate(180deg);
}

body.sidebar-collapsed .brand-mark {
  flex-basis: 34px;
}

@media (max-width: 1040px) {
  body.sidebar-collapsed .sidebar-collapse {
    display: none;
  }
}

/* ---------- V0.25 RMA / reverse logistics ---------- */

.return-create-form {
  padding: 14px;
}

.embedded-head {
  margin: 6px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.returnable-line-editor {
  display: grid;
  gap: 7px;
  min-height: 70px;
}

.returnable-line-row {
  display: grid;
  grid-template-columns: 22px minmax(180px, 1.4fr) minmax(140px, 1fr)
    105px 145px;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.returnable-line-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.returnable-line-copy {
  display: grid;
  min-width: 0;
}

.returnable-line-copy strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.returnable-line-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.returnable-line-row input[type="number"],
.returnable-line-row select {
  min-width: 0;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.rma-progress {
  display: grid;
  gap: 8px;
}

.rma-line-card {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.rma-line-card .progress-track {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hover);
}

.rma-line-card .progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

@media (max-width: 760px) {
  .returnable-line-row {
    grid-template-columns: 22px minmax(0,1fr) 90px;
  }

  .returnable-line-row select {
    grid-column: 2 / -1;
  }
}


/* ---------- V0.27 locale / logout / branding ---------- */

.brand-mark {
  overflow: hidden;
}

.brand-mark .brand-fallback,
.brand-mark .brand-logo {
  width: 100%;
  height: 100%;
}

.brand-mark .brand-fallback {
  display: grid;
  place-items: center;
}

.brand-mark .brand-logo {
  display: block;
  object-fit: contain;
}

.brand-mark .brand-logo[hidden],
.brand-mark .brand-fallback[hidden] {
  display: none !important;
}

.locale-switcher,
.login-locale {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.locale-switcher select,
.login-locale select {
  height: 31px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.login-locale {
  justify-content: space-between;
  margin-top: 10px;
}

.logout-button {
  min-height: 31px;
  white-space: nowrap;
}

.btn.compact {
  padding: 5px 10px;
  font-size: 12px;
}

@media (max-width: 860px) {
  .locale-switcher > span {
    display: none;
  }

  .locale-switcher select {
    max-width: 88px;
  }

  .logout-button {
    padding-inline: 8px;
  }
}

/* ---------- V0.28 web branding + self profile ---------- */

.user-avatar {
  overflow: hidden;
  position: relative;
}

.user-avatar-fallback,
.user-avatar-image {
  width: 100%;
  height: 100%;
}

.user-avatar-fallback {
  display: grid;
  place-items: center;
}

.user-avatar-image {
  display: block;
  object-fit: cover;
}

.user-avatar-image[hidden],
.user-avatar-fallback[hidden] {
  display: none !important;
}

.branding-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, .85fr);
  gap: 14px;
}

.branding-settings-panel,
.branding-logo-panel {
  min-width: 0;
}

.branding-form {
  padding: 14px;
}

.branding-logo-preview-wrap {
  display: grid;
  place-items: center;
  padding: 24px 14px 8px;
}

.branding-logo-preview {
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-subtle);
  color: var(--primary);
  font-size: 48px;
  font-weight: 800;
}

.branding-logo-preview img,
.branding-logo-preview span {
  width: 100%;
  height: 100%;
}

.branding-logo-preview span {
  display: grid;
  place-items: center;
}

.branding-logo-preview img {
  display: block;
  object-fit: contain;
}

.branding-logo-preview img[hidden],
.branding-logo-preview span[hidden] {
  display: none !important;
}

.branding-file {
  margin: 10px 14px 0;
}

.branding-logo-panel > .drawer-actions-row {
  padding: 0 14px 14px;
}

.self-avatar-editor {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-subtle);
}

.self-avatar-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 28px;
  font-weight: 800;
}

.self-avatar-preview img,
.self-avatar-preview span {
  width: 100%;
  height: 100%;
}

.self-avatar-preview span {
  display: grid;
  place-items: center;
}

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

.self-avatar-preview img[hidden],
.self-avatar-preview span[hidden] {
  display: none !important;
}

.self-avatar-controls {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.self-avatar-controls small {
  color: var(--text-muted);
  font-size: 12px;
}

.avatar-file-input {
  max-width: 100%;
}

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

@media (max-width: 560px) {
  .self-avatar-editor {
    grid-template-columns: 1fr;
  }
}

/* Console presentation matched to the live TETRA Core shell. */
:root { --sidebar-collapsed: 68px; --radius: 10px; --topbar-height: 58px; }
body { line-height: 1.62; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.console-icon { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Brand and progressive navigation keep the main sidebar short. */
.sidebar-head { min-height: 122px; padding: 24px 16px 14px; border-bottom: 0; }
.brand { justify-content: center; flex-wrap: nowrap; gap: 12px; }
.brand-text { max-width: calc(100% - 56px); }
.brand-mark { width: 44px; height: 44px; flex-basis: 44px; border-radius: 8px; font-size: 24px; }
.brand-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 27px; font-weight: 650; letter-spacing: .09em; }
.brand-text small { margin-top: 5px; font-size: 12px; letter-spacing: .02em; }
.brand-mark .brand-fallback, .login-brand .brand-mark .brand-fallback { color: var(--on-primary); font-size: inherit; }
.nav-groups { padding: 0 16px 16px; }
.nav-primary { margin-bottom: 12px; }
.nav-group { border-left: 1px solid var(--border); margin-block: 10px; }
.nav-group + .nav-group { margin-top: 10px; }
.nav-group-toggle { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px; color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.nav-group-toggle::-webkit-details-marker { display: none; }
.nav-group-toggle::after { content: ""; width: 7px; height: 7px; flex: 0 0 7px; margin-left: auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.nav-group[open] > .nav-group-toggle::after { transform: rotate(225deg); }
.nav-group-toggle:hover, .nav-item:hover { background: var(--surface-subtle); }
.nav-group.has-current > .nav-group-toggle { background: var(--primary-soft); color: var(--primary); box-shadow: inset 2px 0 var(--primary); }
.nav-item { min-height: 38px; padding: 8px 12px; gap: 8px; color: var(--text); font-size: 14px; font-weight: 500; }
.nav-submenu { padding: 6px 0; }
.nav-submenu .nav-item { color: var(--text-muted); border-radius: 0; font-size: 13px; }
.nav-item.active { color: var(--primary); background: var(--primary-soft); box-shadow: inset 2px 0 var(--primary); font-weight: 600; }
.nav-item.active::before { content: none; }
.nav-icon { width: 18px; height: 18px; flex-basis: 18px; }
.sidebar-foot { padding: 16px 20px; }
.version { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .03em; }
body.sidebar-collapsed .sidebar-head { min-height: 88px; padding: 20px 10px; }
body.sidebar-collapsed .brand { flex: 1; }
body.sidebar-collapsed .brand-mark { width: 36px; height: 36px; flex-basis: 36px; font-size: 21px; }
body.sidebar-collapsed .nav-groups { padding-inline: 10px; }
body.sidebar-collapsed .nav-group-toggle { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .nav-group-name, body.sidebar-collapsed .nav-group-toggle::after, body.sidebar-collapsed .nav-submenu { display: none; }
body.sidebar-collapsed .sidebar-foot { padding: 14px 6px; text-align: center; }
body.sidebar-collapsed .sidebar-foot .version { width: auto; opacity: 1; font-size: 10px; }

/* Compact status strip and outlined tools, matching Core's top bar. */
.topbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; min-height: 58px; height: auto; padding: 8px 16px; box-shadow: var(--shadow-sm); }
.topbar-left { gap: 0; }
.topbar .mobile-menu { display: none; }
.topbar-status-grid { display: grid; grid-template-columns: .85fr 1.25fr 1fr; align-items: stretch; min-width: 0; gap: 6px; }
.topbar-status-grid:has(.organization-context:not([hidden])) { grid-template-columns: .75fr 1.1fr 1.25fr 1fr; }
.topbar-status, .warehouse-context, .organization-context, .user-chip { min-width: 0; min-height: 40px; height: auto; margin: 0; padding: 6px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-hover); }
.topbar-status { gap: 8px; }
.topbar-status > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.status-label, .warehouse-context > span, .organization-context > span { font-size: 11px; font-weight: 650; letter-spacing: .06em; color: var(--text-muted); }
.topbar-status strong { font-size: 12px; font-weight: 600; }
.topbar-status small { display: none; }
.health-dot { flex-basis: 7px; width: 7px; height: 7px; box-shadow: none; }
.health-dot.ok, .health-dot.bad { box-shadow: none; }
.warehouse-context, .organization-context { display: flex; gap: 6px; }
.warehouse-context > span, .organization-context > span { white-space: nowrap; flex-shrink: 0; }
.warehouse-context select, .organization-context select { width: 100%; min-width: 0; max-width: none; font-size: 12px; }
.user-chip { display: flex; gap: 7px; cursor: pointer; }
.user-avatar { width: 25px; height: 25px; flex-basis: 25px; font-size: 11px; }
.user-copy { display: grid; max-width: none; }
.user-copy strong { font-size: 12px; }
.user-copy small { font-size: 11px; margin-top: 2px; }
.topbar-actions { display: flex; flex-wrap: nowrap; gap: 6px; }
.btn { min-height: 36px; padding: 7px 12px; font-size: 13px; font-weight: 600; border-radius: 8px; }
.btn.secondary, .icon-btn { border-color: var(--border-strong); }
.btn.small, .btn.compact { min-height: 32px; font-size: 12px; }
.topbar .btn, .topbar select { min-height: 34px; height: 34px; font-size: 12px; }
.topbar .sidebar-collapse, body.sidebar-collapsed .topbar .sidebar-collapse { display: inline-flex; width: auto; height: 40px; min-width: 62px; flex: none; }
.sidebar-collapse span, body.sidebar-collapsed .sidebar-collapse span { font-size: 13px; transform: none; }
.theme-select, .locale-switcher { display: flex; min-width: 0; }
.theme-select select, .locale-switcher select { width: 86px; padding: 0 7px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 12px; }
.locale-switcher > span { display: none; }
.topbar-refresh { width: 34px; padding: 0; font-size: 18px !important; }
.logout-button { padding-inline: 10px; }

/* Page hierarchy: quiet heading, related-page rail, then filters and content. */
.content { width: min(100%, 1328px); padding: 20px 24px 32px; }
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 16px; padding: 0; margin: 0 0 24px; border: 0; }
.page-head > div { min-width: 0; }
.page-head .eyebrow { display: none; }
.page-head h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.2; font-weight: 400; letter-spacing: -.035em; }
.page-head p { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
.page-actions { flex-wrap: wrap; justify-content: flex-end; }
.page-subnav { grid-column: 2; grid-row: 2; display: flex; justify-content: flex-start; gap: 8px; min-width: 0; max-width: 100%; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.page-tab { flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1.5; text-decoration: none; }
.page-tab:first-child { margin-left: auto; }
.page-tab:hover { background: var(--surface-hover); }
.page-tab[aria-current="page"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.view-search { grid-column: 1; grid-row: 2; display: flex; align-items: center; margin: 0; }
.page-actions #health { display: none; }
.global-search { width: min(420px, 100%); margin: 0; height: 38px; border-radius: 8px; background: var(--surface); border-color: var(--border-strong); }
.global-search input { font-size: 13px; }
.global-search kbd { display: inline; }
.saved-view-bar { margin: 0 0 16px; padding: 0; border: 0; background: transparent; gap: 8px; }
.saved-view-bar select { height: 36px; max-width: 100%; border-color: var(--border-strong); background: var(--surface); }

/* Flat panels and list rows replace decorative nested cards. */
.metric-grid { gap: 12px; margin-bottom: 16px; }
.metric-card { padding: 16px; border-radius: 10px; box-shadow: none; }
.metric-card.accent { border-top-color: var(--border); }
.metric-label { color: var(--text); font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.metric-card strong { font-size: 30px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric-card small { color: var(--text-muted); margin-top: 8px; }
.panel { border-radius: 10px; box-shadow: none; padding: 16px; }
.panel-head { flex-wrap: wrap; margin: -16px -16px 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-head h2 { font-size: 14px; font-weight: 600; }
.panel-head p { font-size: 12px; overflow-wrap: anywhere; }
.panel-meta { font-size: 12px; white-space: normal; }
.dashboard-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }
.dashboard-grid > .panel { margin-bottom: 0; }
.dashboard-grid > .span-2 { grid-column: auto; }
.work-queue { display: grid; grid-template-columns: 1fr; gap: 0; }
.work-queue-item { text-align: left; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.work-queue-item:last-child { border-bottom: 0; }
.work-queue-item span { font-size: 13px; font-weight: 600; color: var(--text); }
.work-queue-item strong { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 22px; font-weight: 600; }
.work-queue-item small { grid-column: 1; font-size: 12px; white-space: normal; }
.quick-actions { grid-template-columns: 1fr; gap: 0; }
.quick-action { padding: 10px 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
.quick-action:last-child { border-bottom: 0; }
.quick-action > span { background: var(--surface-subtle); }
.quick-action b { font-weight: 600; }
.posture-list { min-height: 160px; }
.status-pill, .badge, td .status-cell { border-radius: 6px; }
th { padding: 12px 14px; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
td { padding: 12px 14px; font-size: 13px; }
.table-tools input, .table-tools select { height: 36px; max-width: 100%; }
.table-pager { flex-wrap: wrap; border: 0; background: transparent; padding-inline: 0; }
.table-pager-actions button { min-width: 34px; height: 34px; }
.field input, .field select, .compact-select { font-size: 14px; }
.drawer-form .field input, .drawer-form .field select { height: 42px; }
.detail-kv strong { white-space: normal; overflow-wrap: anywhere; }
.detail-body { overscroll-behavior: contain; }
.detail-drawer-head h2 { font-weight: 500; }
.login-card { width: min(440px, 100%); margin-block: auto; padding: 32px; box-shadow: var(--shadow-md); }
.login-brand { justify-content: center; border-bottom: 0; padding-bottom: 8px; }
.login-copy { text-align: center; }
.login-copy h1 { font-weight: 400; font-size: 28px; }
.login-card .field input { height: 44px; }

@media (min-width: 1041px) and (max-width: 1250px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr); }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .topbar-status-grid { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 1040px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr); padding: 8px 12px; }
  .topbar-left { grid-column: 1; grid-row: 1; }
  .topbar-actions { grid-column: 2; grid-row: 1; justify-content: flex-end; }
  .topbar-status-grid { grid-column: 1 / -1; grid-row: 2; }
  .topbar .sidebar-collapse, body.sidebar-collapsed .topbar .sidebar-collapse { display: none; }
  .topbar .mobile-menu { display: inline-flex; min-height: 38px !important; }
  .warehouse-context > span, .organization-context > span { display: inline; }
  .sidebar-head, body.sidebar-collapsed .sidebar-head { padding: 24px 16px 14px; min-height: 122px; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-item > span:not(.nav-icon),
  body.sidebar-collapsed .sidebar-foot .version { width: auto; opacity: 1; pointer-events: auto; }
  body.sidebar-collapsed .brand { flex: 1; justify-content: center; }
  body.sidebar-collapsed .brand-mark { width: 44px; height: 44px; flex-basis: 44px; font-size: 24px; }
  body.sidebar-collapsed .nav-groups { padding-inline: 16px; }
  body.sidebar-collapsed .nav-item { justify-content: flex-start; padding-inline: 12px; }
  body.sidebar-collapsed .nav-group-toggle { justify-content: flex-start; padding-inline: 12px; }
  body.sidebar-collapsed .nav-group-name, body.sidebar-collapsed .nav-group-toggle::after { display: block; }
  body.sidebar-collapsed details[open] > .nav-submenu { display: block; }
  body.sidebar-collapsed details:not([open]) > .nav-submenu { display: none; }
  body.sidebar-collapsed .sidebar-foot { padding: 16px 20px; text-align: left; }
  body.sidebar-collapsed .sidebar-foot .version { font-size: 12px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { gap: 6px; }
  .topbar-actions { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 5px; }
  .topbar .btn, .topbar select { font-size: 12px; padding-inline: 6px; }
  .theme-select select, .locale-switcher select { width: 100%; min-width: 0; max-width: none; }
  .topbar-refresh { width: 30px; }
  .topbar-status-grid { grid-template-columns: 1fr 1fr; gap: 0; border-block: 1px solid var(--border); }
  .topbar-status, .warehouse-context, .organization-context, .user-chip { border: 0; border-radius: 0; background: transparent; min-height: 36px; }
  .warehouse-context, .organization-context { border-left: 1px solid var(--border); }
  .topbar .user-chip { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-block: 4px; min-height: 30px; }
  .topbar .user-copy { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .user-copy small { margin-top: 0; }
  .user-avatar { width: 22px; height: 22px; flex-basis: 22px; }
  .status-label, .warehouse-context > span, .organization-context > span { font-size: 11px; }
  .content { padding: 20px 12px 32px; }
  .page-head { grid-template-columns: 1fr; gap: 12px; margin-bottom: 20px; }
  .page-head h1 { font-size: 24px; }
  .page-actions { justify-content: flex-start; }
  .page-subnav { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .page-tab { padding-inline: 12px; }
  .page-tab:first-child { margin-left: 0; }
  .view-search { grid-column: 1; grid-row: auto; margin-top: 0; }
  .global-search { width: 100%; height: 40px; }
  .global-search input { font-size: 16px; }
  .global-search kbd { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { padding: 14px; }
  .metric-card strong { font-size: 28px; }
  .metric-card small { overflow-wrap: anywhere; }
  .table-tools { gap: 8px; }
  .table-tools input { min-width: 0; width: 100%; }
  .saved-view-bar { flex-wrap: wrap; }
  .saved-view-bar select { min-width: 0; flex-basis: 150px; }
  .field input, .field select, .compact-select { font-size: 16px; }
  .page-actions .btn, .drawer-actions-row .btn { min-height: 40px; }
  .login-overlay { padding: 16px; }
  .login-card { padding: 24px; }
}
