:root {
  --bg: #f3f4f6;
  --bg-deep: #e7edf1;
  --surface: rgba(255, 255, 255, 0.68);
  --surface-strong: rgba(255, 255, 255, 0.84);
  --surface-2: rgba(247, 250, 248, 0.76);
  --text: #1f2d29;
  --muted: #61716b;
  --line: rgba(255,255,255,.6);
  --primary: #ff9900;
  --primary-dark: #232f3e;
  --danger: #bc5f68;
  --warning: #b7791f;
  --success: #3d8b71;
  --shadow: 0 18px 45px rgba(31,45,41,.14);
  --shadow-soft: 0 8px 24px rgba(31,45,41,.1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.95), transparent 34%),
    radial-gradient(circle at 85% 15%, rgba(122, 196, 176, .38), transparent 26%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
  color: var(--text);
}
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(10px);
  opacity: .9;
}
body::before {
  width: 340px; height: 340px; left: -80px; bottom: -100px;
  background: rgba(80, 158, 132, .22);
}
body::after {
  width: 420px; height: 420px; right: -120px; top: -120px;
  background: rgba(255,255,255,.48);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px;
  background: linear-gradient(135deg, rgba(35,47,62,.96), rgba(19,25,33,.92));
  backdrop-filter: blur(22px);
  border-bottom: 3px solid #ff9900;
  color: white;
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 44px; height: 44px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #ffb84d, #ff9900);
  color: #111827; font-weight: 900;
  box-shadow: 0 14px 25px rgba(255,153,0,.24), inset 0 1px 1px rgba(255,255,255,.45);
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.topbar .brand p { color: rgba(255,255,255,.72); }
.user-chip { display: flex; gap: 10px; align-items: center; }
.user-chip small { display: block; color: var(--muted); }
.page { padding: 16px; max-width: 1220px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.panel::before {
  content: "";
  position: absolute; inset: 1px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.65), transparent 40%);
}
.panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 56px rgba(31,45,41,.18);
}
.panel h2, .panel h3 { margin-top: 0; letter-spacing: -.03em; }
.stat { display: grid; gap: 6px; min-height: 108px; align-content: center; }
.stat strong { font-size: 32px; letter-spacing: -.04em; }
.muted { color: var(--muted); }
.toolbar { display: grid; gap: 10px; margin-bottom: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(145deg, #ffd36a, #ff9900);
  color: #111827;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(255,153,0,.22), inset 0 1px 1px rgba(255,255,255,.5);
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 28px rgba(255,153,0,.28); filter: saturate(1.05); }
.btn:active { transform: translateY(0); }
.btn.secondary {
  background: rgba(255,255,255,.44);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: 0 10px 20px rgba(31,45,41,.08);
}
.btn.danger { background: linear-gradient(145deg, #cf6d76, #ad4f59); }
.btn.warning { background: linear-gradient(145deg, #d7a355, #b47728); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform:none; }
.input, select, textarea {
  width: 100%;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 18px;
  padding: 12px 14px;
  background: rgba(255,255,255,.55);
  color: var(--text);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.7), 0 8px 18px rgba(31,45,41,.05);
  backdrop-filter: blur(12px);
}
.input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(45,122,103,.5);
  box-shadow: 0 0 0 4px rgba(45,122,103,.12), inset 0 1px 1px rgba(255,255,255,.7);
}
textarea { min-height: 88px; resize: vertical; }
.form-grid { display: grid; gap: 12px; }
.label { display: grid; gap: 6px; font-size: 14px; }
.order-list { display: grid; gap: 14px; }
.order-card {
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 24px;
  padding: 16px;
  background: rgba(255,255,255,.58);
  display: grid; gap: 10px;
  box-shadow: var(--shadow-soft);
  transition: transform .22s ease, box-shadow .22s ease, background .22s ease;
}
.order-card:hover {
  transform: translateY(-4px) rotateX(1deg);
  background: rgba(255,255,255,.62);
  box-shadow: 0 20px 34px rgba(31,45,41,.14);
}
.order-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.order-head h3 { margin: 0 0 4px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255,255,255,.54);
  border: 1px solid rgba(255,255,255,.7);
  font-size: 12px;
}
.badge.success { background: rgba(218, 244, 235, .82); color: var(--success); }
.badge.warning { background: rgba(248, 235, 208, .86); color: var(--warning); }
.badge.danger { background: rgba(249, 222, 226, .86); color: var(--danger); }
.pipeline { display: grid; gap: 10px; }
.pipeline-step {
  display: flex; justify-content: space-between; gap: 10px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 18px; padding: 12px 14px;
  background: rgba(255,255,255,.48);
}
.timeline { display: grid; gap: 12px; }
.timeline-item { border-left: 3px solid rgba(45,122,103,.32); padding-left: 12px; }
.timeline-item strong { display: block; }
.empty { text-align: center; padding: 24px 12px; color: var(--muted); }
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
}
.login-card { max-width: 460px; width: 100%; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.tabs .btn { box-shadow: 0 8px 18px rgba(31,45,41,.08); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.detail-grid { display: grid; gap: 16px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kv div {
  background: rgba(255,255,255,.4);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 18px;
  padding: 12px;
}
.notice {
  border-radius: 18px;
  padding: 13px;
  background: rgba(255,245,219,.72);
  border: 1px solid rgba(235,202,142,.66);
}
.linkish { background: none; border: none; color: var(--primary-dark); padding: 0; }
.desktop-grid { display: grid; gap: 16px; }
.line-items-editor { display:grid; gap:10px; }
.line-item-row {
  display:grid; gap:10px; padding:12px;
  background: rgba(255,255,255,.5);
  border:1px solid rgba(255,255,255,.58);
  border-radius:20px;
}
.line-items-readonly { display:grid; gap:8px; margin-top:10px; }
.line-items-readonly div { display:flex; justify-content:space-between; gap:12px; padding:9px 0; border-bottom:1px solid rgba(255,255,255,.5); }
.line-wrap{display:grid!important;gap:8px;border-bottom:1px solid rgba(255,255,255,.5);padding:10px 0}
.qty-row{display:flex;justify-content:space-between;gap:12px}
.batch-box,.batch-create,.dispatch-row{
  background:rgba(255,255,255,.52);
  border:1px solid rgba(255,255,255,.58);
  border-radius:20px;
  padding:14px;
  display:grid;
  gap:8px;
}
.photo-list{display:grid;gap:6px}.photo-list div{display:flex;gap:8px;justify-content:space-between}.line-item-row{margin-bottom:10px}
@media (min-width: 760px) {
  .page { padding: 24px; }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1.3fr repeat(3, .8fr); align-items: end; }
  .desktop-grid { grid-template-columns: 1.25fr .75fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .form-grid.two { grid-template-columns: repeat(2, 1fr); }
  .line-item-row { grid-template-columns: 1.2fr .7fr .7fr auto; align-items:end; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.login-scene {
  position: relative;
  perspective: 1200px;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .8;
  animation: drift 12s ease-in-out infinite;
}
.orb-one {
  width: 280px; height: 280px;
  top: 8%; left: 10%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.95), rgba(93,177,152,.28));
}
.orb-two {
  width: 360px; height: 360px;
  right: 8%; bottom: 8%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.8), rgba(45,122,103,.22));
  animation-delay: -5s;
}
.login-3d {
  transform-style: preserve-3d;
  animation: cardFloat 7s ease-in-out infinite;
}
.login-3d::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,.45), transparent 40%, rgba(45,122,103,.08));
  transform: translateZ(18px);
  pointer-events: none;
}
.dashboard-cards { perspective: 1200px; }
.float-card {
  transform-style: preserve-3d;
  animation: floatTile 6s ease-in-out infinite;
  animation-delay: calc(var(--i) * .35s);
}
.float-card:hover {
  transform: translateY(-8px) rotateX(7deg) rotateY(-5deg);
}
@keyframes drift {
  0%,100% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(0,-18px,0) scale(1.04); }
}
@keyframes cardFloat {
  0%,100% { transform: rotateX(0deg) rotateY(0deg) translateY(0); }
  50% { transform: rotateX(2deg) rotateY(-3deg) translateY(-10px); }
}
@keyframes floatTile {
  0%,100% { transform: translateY(0) rotateX(0deg); }
  50% { transform: translateY(-7px) rotateX(3deg); }
}

.view-shell {
  animation: viewEnter .42s cubic-bezier(.2,.8,.2,1);
}
.glow-stat {
  position: relative;
}
.glow-stat::after {
  content: "";
  position: absolute;
  inset: auto 14px 10px 14px;
  height: 34px;
  background: radial-gradient(circle, rgba(45,122,103,.2), transparent 70%);
  filter: blur(10px);
  opacity: .85;
}
.count-up {
  text-shadow: 0 0 24px rgba(45,122,103,.2);
}
.theme-toggle { min-width: 96px; }
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(10px) scale(.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
:root[data-theme="dark"] {
  --bg: #0d1715;
  --bg-deep: #13221e;
  --surface: rgba(20, 31, 28, .7);
  --surface-strong: rgba(24, 37, 33, .82);
  --surface-2: rgba(31, 47, 42, .72);
  --text: #edf5f1;
  --muted: #aabbb4;
  --line: rgba(255,255,255,.12);
  --primary: #5bc3a7;
  --primary-dark: #8be0ca;
  --shadow: 0 18px 45px rgba(0,0,0,.32);
  --shadow-soft: 0 10px 24px rgba(0,0,0,.24);
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(98, 179, 157, .16), transparent 30%),
    radial-gradient(circle at 85% 15%, rgba(91,195,167,.18), transparent 24%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
}
:root[data-theme="dark"] body::before { background: rgba(91,195,167,.16); }
:root[data-theme="dark"] body::after { background: rgba(255,255,255,.05); }
:root[data-theme="dark"] .topbar { background: rgba(12,20,18,.48); }
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] .input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .order-card,
:root[data-theme="dark"] .pipeline-step,
:root[data-theme="dark"] .kv div,
:root[data-theme="dark"] .line-item-row,
:root[data-theme="dark"] .batch-box,
:root[data-theme="dark"] .batch-create,
:root[data-theme="dark"] .dispatch-row {
  background: rgba(255,255,255,.06);
}
:root[data-theme="dark"] .badge { background: rgba(255,255,255,.08); }
:root[data-theme="dark"] .notice { background: rgba(195,139,57,.16); border-color: rgba(195,139,57,.28); }
:root[data-theme="dark"] .glow-stat::after { background: radial-gradient(circle, rgba(91,195,167,.28), transparent 70%); }
.review-row{display:grid;gap:8px;padding:12px 0;border-bottom:1px solid rgba(255,255,255,.5)}
@media (min-width:760px){.line-item-row{grid-template-columns:1.1fr .6fr .6fr .7fr auto}}

.dept-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.dept-pill {
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 20px;
  padding: 12px 14px;
  background: rgba(255,255,255,.48);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.dept-pill.active {
  background: linear-gradient(145deg, #232f3e, #131921);
  color: #fff;
  box-shadow: 0 18px 34px rgba(35,47,62,.22);
  border-bottom: 3px solid #ff9900;
}
.dept-count {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 6px;
  margin-left:5px;
  border-radius:999px;
  background:rgba(255,255,255,.9);
  color:var(--primary-dark);
  font-size:11px;
  font-weight:900;
}
.dept-pill:hover { transform: translateY(-2px); }
.active-dept {
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:9px 12px;
  background:rgba(255,255,255,.52);
  border:1px solid rgba(255,255,255,.68);
  font-weight:700;
}
.view-shell { margin-top: 16px; }
.hero-panel {
  display: grid;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 22px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.82), rgba(255,255,255,.44)),
    radial-gradient(circle at 90% 12%, rgba(91,195,167,.26), transparent 28%);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: var(--shadow);
}
.hero-panel h2 {
  margin: 4px 0 6px;
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1.02;
  letter-spacing: -.05em;
}
.hero-panel p { margin: 0; color: var(--muted); max-width: 680px; }
.hero-actions { display:flex; gap:10px; flex-wrap:wrap; }
.eyebrow {
  display:inline-flex;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-dark);
}
.wide { width: 100%; justify-content:center; }
.summary-line { color: var(--muted); }
.mini-metrics {
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:13px;
}
.req { color: #d64155; font-weight: 900; }
.date-pretty input { min-height: 48px; }
.product-title { margin-top: 16px; }
.notes-field { margin-top: 12px; }
.compact { margin: 0; }
.compact h4 { margin: 0; }
.wide-field { grid-column: 1 / -1; }
.action-card {
  margin-top: 16px;
  padding: 16px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.66);
  background: rgba(255,255,255,.46);
}
.switch-label {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 11px;
  border-radius:999px;
  background:rgba(255,255,255,.58);
  border:1px solid rgba(255,255,255,.7);
  color:var(--primary-dark);
  font-weight:700;
}
.switch-label input { width: 20px; height: 20px; accent-color: var(--primary); }
.batch-fields {
  display:grid;
  gap:10px;
  grid-template-columns: 1fr;
}
.batch-box.soft { background: rgba(237, 249, 243, .66); }
.warning-box { background: rgba(255, 246, 225, .74); }
.line-items-readonly div.line-wrap,
.line-items-readonly div.line-main,
.line-items-readonly div.photo-card,
.line-items-readonly div.file-list {
  border-bottom: 0;
}
.line-main {
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:0!important;
}
.photo-list {
  display:grid;
  gap:10px;
  margin-top:10px;
}
.photo-card {
  display:grid!important;
  grid-template-columns: 92px 1fr;
  align-items:center;
  gap:12px!important;
  padding:10px!important;
  border-radius:18px;
  background:rgba(255,255,255,.58);
  border:1px solid rgba(255,255,255,.7);
}
.photo-card img {
  width: 92px;
  height: 72px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}
.file-tile {
  width:92px;
  height:72px;
  display:grid!important;
  place-items:center;
  border-radius:14px;
  background:rgba(45,122,103,.12);
  color:var(--primary-dark);
  font-weight:800;
}
.photo-actions {
  display:flex!important;
  justify-content:flex-start!important;
  gap:8px!important;
  margin-top:8px;
  padding:0!important;
}
.btn.success { background: linear-gradient(145deg, #47a887, #2d7a67); }
.file-list {
  display:flex!important;
  justify-content:flex-start!important;
  flex-wrap:wrap;
  gap:8px;
  padding:8px 0 0!important;
}
.subpanel {
  margin-top: 14px;
  padding: 14px;
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}
.packing-request {
  grid-column: 1 / -1;
  border-radius:22px;
  padding:14px;
  background:rgba(255,255,255,.48);
  border:1px solid rgba(255,255,255,.66);
}
.dispatch-row { margin-bottom: 10px; }
.admin-tools { margin-top: 16px; }
.undo {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.compact-list {
  margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.pipeline-step small {
  display:block;
  color:var(--muted);
  margin-top:4px;
}

@media (min-width: 760px) {
  .dept-switch { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .hero-panel { grid-template-columns: 1fr auto; }
  .batch-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dispatch-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .topbar { align-items:flex-start; gap:12px; flex-direction:column; }
  .user-chip { width:100%; justify-content:space-between; }
  .kv { grid-template-columns: 1fr; }
  .photo-card { grid-template-columns: 1fr; }
  .photo-card img, .file-tile { width:100%; height:160px; }
}

:root[data-theme="dark"] .dept-pill,
:root[data-theme="dark"] .active-dept,
:root[data-theme="dark"] .hero-panel,
:root[data-theme="dark"] .action-card,
:root[data-theme="dark"] .switch-label,
:root[data-theme="dark"] .packing-request,
:root[data-theme="dark"] .photo-card {
  background: rgba(255,255,255,.07);
}

/* Compact, zoomed-out operational layout */
.topbar { padding: 10px 14px; }
.logo { width: 38px; height: 38px; border-radius: 13px; }
.brand h1 { font-size: 16px; }
.page { padding: 12px; max-width: 1380px; }
.dept-switch { gap: 8px; margin-bottom: 10px; }
.dept-pill { padding: 9px 11px; border-radius: 16px; }
.tabs { margin-bottom: 8px; }
.btn { padding: 8px 12px; }
.panel { border-radius: 20px; padding: 12px; }
.panel:hover { transform: translateY(-2px); }
.hero-panel { padding: 14px 16px; border-radius: 22px; margin-bottom: 10px; }
.hero-panel h2 { font-size: clamp(20px, 2.5vw, 30px); }
.hero-panel p { font-size: 13px; }
.dashboard-cards { gap: 10px; }
.stat { min-height: 76px; }
.stat strong { font-size: 24px; }
.order-card { border-radius: 18px; padding: 11px; gap: 7px; }
.order-card.pending-highlight {
  border-color: rgba(45,122,103,.55);
  box-shadow: 0 0 0 3px rgba(45,122,103,.08), 0 18px 34px rgba(31,45,41,.14);
}
.order-card.overdue-card {
  border-color: rgba(188,95,104,.55);
  box-shadow: 0 0 0 3px rgba(188,95,104,.1), 0 18px 34px rgba(31,45,41,.14);
}
.badge.next-action {
  background: rgba(255, 224, 178, .95);
  color: #8a4b00;
  font-weight: 800;
}
.form-grid { gap: 8px; }
.label { gap: 4px; font-size: 13px; }
.input, select, textarea { border-radius: 13px; padding: 9px 11px; }
textarea { min-height: 62px; }
.kv { gap: 7px; }
.kv div { border-radius: 14px; padding: 8px 10px; }
.pipeline { gap: 7px; }
.pipeline-step { border-radius: 14px; padding: 8px 10px; }
.detail-grid { gap: 10px; }
.action-card { margin-top: 10px; padding: 12px; border-radius: 18px; }
.batch-box,.batch-create,.dispatch-row { border-radius: 16px; padding: 10px; gap: 7px; }
.line-wrap { padding: 7px 0!important; }
.notice { border-radius: 14px; padding: 9px 10px; }
.timeline { gap: 8px; }
.timeline-item { font-size: 13px; }
.stage-rail {
  display:flex;
  gap:7px;
  flex-wrap:wrap;
}
.stage-chip {
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:7px 10px;
  background:rgba(255,255,255,.55);
  border:1px solid rgba(255,255,255,.7);
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}
.stage-chip.done {
  background:rgba(218,244,235,.86);
  color:var(--success);
}
.stage-chip.active {
  background:linear-gradient(145deg,#3d987f,#246653);
  color:#fff;
}
.production-upload-panel {
  display:grid;
  gap:8px;
  width:100%;
}
.upload-card {
  display:grid;
  gap:10px;
  width:100%;
  padding:10px;
  border-radius:16px;
  background:rgba(255,255,255,.58);
  border:1px solid rgba(255,255,255,.72);
}
.upload-progress {
  display:grid;
  gap:5px;
  margin-top:8px;
}
.progress-meta {
  display:flex;
  justify-content:space-between;
  gap:10px;
  color:var(--muted);
  font-size:12px;
}
.progress-track {
  height:10px;
  overflow:hidden;
  border-radius:999px;
  background:rgba(45,122,103,.12);
  border:1px solid rgba(255,255,255,.68);
}
.progress-track span {
  display:block;
  height:100%;
  min-width:18px;
  border-radius:inherit;
  background:linear-gradient(90deg,#ff9900,#ffd36a);
  transition:width .2s ease;
}

/* CRED-inspired dark premium redesign */
:root {
  --bg: #050506;
  --bg-deep: #111114;
  --surface: #151519;
  --surface-strong: #1d1d23;
  --surface-2: #101014;
  --text: #f5f5f2;
  --muted: #9b9ba5;
  --line: rgba(255,255,255,.09);
  --primary: #d4af37;
  --primary-dark: #f3e7bd;
  --shadow: 0 20px 60px rgba(0,0,0,.45);
  --shadow-soft: 0 12px 28px rgba(0,0,0,.32);
}
body {
  background:
    radial-gradient(circle at 18% -10%, rgba(212,175,55,.16), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(110,86,207,.15), transparent 24%),
    linear-gradient(135deg, #050506, #121216 55%, #070708);
}
.panel,.order-card,.pipeline-step,.kv div,.line-item-row,.batch-box,.batch-create,.dispatch-row,.action-card,.hero-panel,.photo-card,.upload-card,.packing-request {
  background: linear-gradient(145deg, rgba(32,32,38,.96), rgba(14,14,18,.98));
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: none;
}
.panel::before { display:none; }
.topbar {
  background: rgba(5,5,6,.96);
  border-bottom: 1px solid rgba(212,175,55,.45);
}
.logo,.btn {
  background: linear-gradient(135deg, #f7df8a, #b98b21);
  color: #050506;
}
.btn.secondary {
  background: #232329;
  color: var(--text);
  border-color: rgba(255,255,255,.12);
}
.dept-pill {
  background: #121216;
  border-color: rgba(255,255,255,.1);
  color: var(--text);
}
.dept-pill.active {
  background: linear-gradient(135deg, #2b2b32, #111114);
  border-color: rgba(212,175,55,.65);
  border-bottom-color: #d4af37;
}
.input, select, textarea {
  background: #0f0f13;
  border-color: rgba(255,255,255,.12);
  color: var(--text);
  backdrop-filter: none;
}
.order-list { gap: 8px; }
.order-card {
  grid-template-columns: 1.1fr 1.7fr auto;
  align-items: center;
}
.order-card .summary-line,.order-card .badges,.order-card .mini-metrics { margin:0; }
.target-card,.master-list {
  display:grid;
  gap:8px;
  padding:10px;
  border-radius:16px;
  background:#101014;
  border:1px solid rgba(255,255,255,.08);
}
.target-track {
  height:10px;
  background:#08080a;
  border-radius:999px;
  overflow:hidden;
}
.target-track span {
  display:block;
  height:100%;
  background:linear-gradient(90deg,#7c5cff,#d4af37);
}
.target-meta {
  display:flex;
  justify-content:space-between;
  color:var(--muted);
  font-size:12px;
}
.compact-order .line-item-row { grid-template-columns: 1.3fr .55fr .6fr .7fr auto; }
.staff-card { display:block; }
@media (max-width:900px){
  .order-card { grid-template-columns: 1fr; }
  .compact-order .line-item-row { grid-template-columns: 1fr; }
}
.photo-section-below {
  display:grid;
  gap:8px;
  margin-top:8px;
  padding-top:8px;
  border-top:1px solid rgba(255,255,255,.66);
}
.large-photos .photo-card {
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items:start;
}
.large-photos .photo-card img,
.large-photos .file-tile {
  width:100%;
  height:190px;
}
.approval-card {
  display:grid;
  gap:8px;
  padding:8px;
  border-radius:18px;
  background:rgba(255,255,255,.38);
  border:1px solid rgba(255,255,255,.6);
}
.photo-actions .btn,
.photo-actions a.btn {
  text-decoration:none;
  font-size:12px;
  padding:7px 10px;
}

@media (min-width: 1020px) {
  .detail-grid { grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); }
  .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .desktop-grid { grid-template-columns: 1.35fr .65fr; }
}

@media (max-width: 760px) {
  .large-photos .photo-card { grid-template-columns: 1fr; }
  .large-photos .photo-card img,
  .large-photos .file-tile { height: 180px; }
}

/* Final Light/Dark theme authority
   Light is bright, clean and operational.
   Dark preserves the premium CRED-style interface. */
:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --bg-deep: #eef4f8;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-2: #f4f8fb;
  --text: #15202b;
  --muted: #64748b;
  --line: rgba(15, 23, 42, .1);
  --primary: #0f8f9c;
  --primary-dark: #065f68;
  --accent: #d4a72c;
  --danger: #c2414b;
  --warning: #b7791f;
  --success: #16845f;
  --shadow: 0 20px 55px rgba(15, 23, 42, .1);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, .08);
  --field-bg: #ffffff;
  --soft-blue: #eaf8fb;
  --soft-gold: #fff7df;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #050506;
  --bg-deep: #111114;
  --surface: #151519;
  --surface-strong: #1d1d23;
  --surface-2: #101014;
  --text: #f5f5f2;
  --muted: #9b9ba5;
  --line: rgba(255,255,255,.09);
  --primary: #d4af37;
  --primary-dark: #f3e7bd;
  --accent: #7c5cff;
  --danger: #ff7b86;
  --warning: #f4be63;
  --success: #64d6a5;
  --shadow: 0 20px 60px rgba(0,0,0,.45);
  --shadow-soft: 0 12px 28px rgba(0,0,0,.32);
  --field-bg: #0f0f13;
  --soft-blue: rgba(124, 92, 255, .12);
  --soft-gold: rgba(212,175,55,.12);
}

body {
  background:
    radial-gradient(circle at 14% -10%, rgba(15, 143, 156, .16), transparent 30%),
    radial-gradient(circle at 86% 8%, rgba(212, 167, 44, .16), transparent 27%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
  color: var(--text);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 18% -10%, rgba(212,175,55,.16), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(110,86,207,.15), transparent 24%),
    linear-gradient(135deg, #050506, #121216 55%, #070708);
}

body::before {
  background: rgba(15, 143, 156, .12);
}

body::after {
  background: rgba(212, 167, 44, .1);
}

:root[data-theme="dark"] body::before {
  background: rgba(212,175,55,.12);
}

:root[data-theme="dark"] body::after {
  background: rgba(124,92,255,.1);
}

.topbar {
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid rgba(15,143,156,.22);
  color: var(--text);
  box-shadow: 0 12px 36px rgba(15, 23, 42, .08);
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .topbar {
  background: rgba(5,5,6,.96);
  border-bottom: 1px solid rgba(212,175,55,.45);
  color: var(--text);
  box-shadow: none;
}

.brand h1 { color: var(--text); }
.brand p,
.topbar .brand p { color: var(--muted); }

.logo {
  background: linear-gradient(135deg, #0f8f9c, #15bfd0);
  color: #fff;
  box-shadow: 0 14px 24px rgba(15,143,156,.22);
}

:root[data-theme="dark"] .logo {
  background: linear-gradient(135deg, #f7df8a, #b98b21);
  color: #050506;
  box-shadow: 0 14px 25px rgba(212,175,55,.22), inset 0 1px 1px rgba(255,255,255,.3);
}

.active-dept {
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.panel,
.order-card,
.pipeline-step,
.kv div,
.line-item-row,
.batch-box,
.batch-create,
.dispatch-row,
.action-card,
.hero-panel,
.photo-card,
.upload-card,
.packing-request,
.approval-card,
.target-card,
.master-list,
.staff-card,
.file-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow-soft);
  backdrop-filter: none;
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .order-card,
:root[data-theme="dark"] .pipeline-step,
:root[data-theme="dark"] .kv div,
:root[data-theme="dark"] .line-item-row,
:root[data-theme="dark"] .batch-box,
:root[data-theme="dark"] .batch-create,
:root[data-theme="dark"] .dispatch-row,
:root[data-theme="dark"] .action-card,
:root[data-theme="dark"] .hero-panel,
:root[data-theme="dark"] .photo-card,
:root[data-theme="dark"] .upload-card,
:root[data-theme="dark"] .packing-request,
:root[data-theme="dark"] .approval-card,
:root[data-theme="dark"] .target-card,
:root[data-theme="dark"] .master-list,
:root[data-theme="dark"] .staff-card,
:root[data-theme="dark"] .file-tile {
  background: linear-gradient(145deg, rgba(32,32,38,.96), rgba(14,14,18,.98));
  border-color: rgba(255,255,255,.08);
  box-shadow: var(--shadow-soft);
}

.panel::before { display:none; }

.hero-panel {
  background:
    linear-gradient(135deg, rgba(255,255,255,.97), rgba(235,248,251,.96)),
    radial-gradient(circle at 90% 20%, rgba(212,167,44,.16), transparent 26%);
}

:root[data-theme="dark"] .hero-panel {
  background: linear-gradient(145deg, rgba(32,32,38,.96), rgba(14,14,18,.98));
}

.btn,
.logo {
  border: 0;
}

.btn {
  background: linear-gradient(135deg, #0f8f9c, #11b7c7);
  color: #fff;
  box-shadow: 0 12px 22px rgba(15,143,156,.2);
}

.btn:hover {
  box-shadow: 0 16px 30px rgba(15,143,156,.24);
}

.btn.secondary {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
}

.btn.warning {
  background: linear-gradient(135deg, #d4a72c, #f3c650);
  color: #1f1600;
}

.btn.danger {
  background: linear-gradient(135deg, #e65f6b, #bd3542);
  color: #fff;
}

.btn.success {
  background: linear-gradient(135deg, #18a77a, #0d7f5e);
  color: #fff;
}

:root[data-theme="dark"] .btn,
:root[data-theme="dark"] .logo {
  background: linear-gradient(135deg, #f7df8a, #b98b21);
  color: #050506;
}

:root[data-theme="dark"] .btn.secondary {
  background: #232329;
  color: var(--text);
  border-color: rgba(255,255,255,.12);
}

:root[data-theme="dark"] .btn.warning {
  background: linear-gradient(135deg, #d4af37, #a97818);
  color: #070708;
}

:root[data-theme="dark"] .btn.danger {
  background: linear-gradient(135deg, #ff7b86, #a83643);
  color: #fff;
}

:root[data-theme="dark"] .btn.success {
  background: linear-gradient(135deg, #64d6a5, #16845f);
  color: #07100d;
}

.dept-pill {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(15, 23, 42, .05);
}

.dept-pill.active {
  background: linear-gradient(135deg, #e8fbfd, #ffffff);
  border-color: rgba(15,143,156,.42);
  border-bottom-color: var(--primary);
  box-shadow: 0 14px 28px rgba(15,143,156,.14);
}

:root[data-theme="dark"] .dept-pill {
  background: #121216;
  border-color: rgba(255,255,255,.1);
  color: var(--text);
  box-shadow: none;
}

:root[data-theme="dark"] .dept-pill.active {
  background: linear-gradient(135deg, #2b2b32, #111114);
  border-color: rgba(212,175,55,.65);
  border-bottom-color: #d4af37;
}

.dept-count {
  background: var(--primary);
  color: #fff;
}

:root[data-theme="dark"] .dept-count {
  background: #d4af37;
  color: #050506;
}

.input,
select,
textarea {
  background: var(--field-bg);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}

.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(15,143,156,.55);
  box-shadow: 0 0 0 4px rgba(15,143,156,.12);
}

:root[data-theme="dark"] .input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #0f0f13;
  border-color: rgba(255,255,255,.12);
  color: var(--text);
  box-shadow: none;
}

:root[data-theme="dark"] .input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  border-color: rgba(212,175,55,.55);
  box-shadow: 0 0 0 4px rgba(212,175,55,.12);
}

.badge {
  background: #edf7f9;
  color: var(--primary-dark);
  border: 1px solid rgba(15,143,156,.12);
}

.badge.success {
  background: #e8f8f1;
  color: var(--success);
  border-color: rgba(22,132,95,.14);
}

.badge.warning {
  background: #fff7df;
  color: var(--warning);
  border-color: rgba(183,121,31,.16);
}

.badge.danger {
  background: #fff0f2;
  color: var(--danger);
  border-color: rgba(194,65,75,.14);
}

.badge.next-action {
  background: linear-gradient(135deg, #0f8f9c, #13bfce);
  color: #fff;
  border-color: transparent;
}

:root[data-theme="dark"] .badge {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-color: rgba(255,255,255,.08);
}

:root[data-theme="dark"] .badge.success {
  background: rgba(100,214,165,.12);
  color: var(--success);
}

:root[data-theme="dark"] .badge.warning {
  background: rgba(244,190,99,.13);
  color: var(--warning);
}

:root[data-theme="dark"] .badge.danger {
  background: rgba(255,123,134,.13);
  color: var(--danger);
}

:root[data-theme="dark"] .badge.next-action {
  background: linear-gradient(135deg, #7c5cff, #d4af37);
  color: #fff;
}

.notice {
  background: var(--soft-gold);
  border: 1px solid rgba(212,167,44,.24);
  color: #7a5200;
}

:root[data-theme="dark"] .notice {
  background: rgba(195,139,57,.16);
  border-color: rgba(195,139,57,.28);
  color: var(--text);
}

.timeline-item {
  border-left-color: rgba(15,143,156,.35);
}

:root[data-theme="dark"] .timeline-item {
  border-left-color: rgba(212,175,55,.35);
}

.stage-chip {
  background: #f1f6f8;
  border-color: var(--line);
  color: var(--muted);
}

.stage-chip.done {
  background: #e8f8f1;
  color: var(--success);
}

.stage-chip.active {
  background: linear-gradient(135deg, #0f8f9c, #13bfce);
  color: #fff;
}

:root[data-theme="dark"] .stage-chip {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.1);
}

:root[data-theme="dark"] .stage-chip.done {
  background: rgba(100,214,165,.12);
  color: var(--success);
}

:root[data-theme="dark"] .stage-chip.active {
  background: linear-gradient(135deg, #7c5cff, #d4af37);
  color: #fff;
}

.progress-track,
.target-track {
  background: #e6eef2;
  border-color: rgba(15,23,42,.06);
}

.progress-track span,
.target-track span {
  background: linear-gradient(90deg, #0f8f9c, #d4a72c);
}

:root[data-theme="dark"] .progress-track,
:root[data-theme="dark"] .target-track {
  background: #08080a;
  border-color: rgba(255,255,255,.08);
}

:root[data-theme="dark"] .progress-track span,
:root[data-theme="dark"] .target-track span {
  background: linear-gradient(90deg,#7c5cff,#d4af37);
}

.pending-card {
  border-color: rgba(15,143,156,.35);
  box-shadow: 0 16px 34px rgba(15,143,156,.12);
}

:root[data-theme="dark"] .pending-card {
  border-color: rgba(212,175,55,.42);
  box-shadow: 0 18px 44px rgba(212,175,55,.08);
}

a {
  color: var(--primary-dark);
}

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

/* Compact department login */
.compact-login {
  align-items: center;
  background:
    radial-gradient(circle at 22% 12%, rgba(15,143,156,.18), transparent 28%),
    radial-gradient(circle at 78% 10%, rgba(212,167,44,.16), transparent 24%);
}

.compact-login .login-card {
  max-width: 410px;
  padding: 18px;
  border-radius: 24px;
}

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

.login-brand h1 {
  margin: 2px 0 2px;
  font-size: 22px;
  letter-spacing: -.04em;
}

.login-brand p {
  margin: 0;
  font-size: 13px;
}

.login-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.login-error {
  margin: 0;
  color: var(--danger);
  background: #fff0f2;
  border-color: rgba(194,65,75,.2);
}

.compact-btn {
  padding-inline: 10px;
}

.dept-switch.locked {
  grid-template-columns: minmax(180px, 320px);
}

.dept-pill:disabled {
  cursor: default;
  opacity: 1;
}

.dept-pill:disabled:hover {
  transform: none;
}

.login-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.login-admin-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.compact-switch {
  justify-content: flex-start;
  gap: 8px;
}

:root[data-theme="dark"] .compact-login {
  background:
    radial-gradient(circle at 18% -10%, rgba(212,175,55,.16), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(110,86,207,.15), transparent 24%);
}

:root[data-theme="dark"] .login-error {
  background: rgba(255,123,134,.13);
  border-color: rgba(255,123,134,.22);
  color: var(--danger);
}

:root[data-theme="dark"] .login-admin-card {
  background: #101014;
  border-color: rgba(255,255,255,.08);
}

@media (max-width: 560px) {
  .compact-login .login-card { max-width: 100%; padding: 14px; }
  .login-footer { align-items: stretch; flex-direction: column; }
  .login-footer .btn { width: 100%; }
}

/* Final green Light Mode accents */
:root {
  --primary: #42b883;
  --primary-dark: #167453;
  --accent: #a8e6c1;
  --soft-blue: #edfdf5;
}

body {
  background:
    radial-gradient(circle at 14% -10%, rgba(66, 184, 131, .18), transparent 30%),
    radial-gradient(circle at 86% 8%, rgba(212, 167, 44, .14), transparent 27%),
    linear-gradient(135deg, var(--bg), var(--bg-deep));
}

.logo,
.btn,
.stage-chip.active,
.badge.next-action {
  background: linear-gradient(135deg, #42b883, #8be5ae);
}

.btn:hover {
  box-shadow: 0 16px 30px rgba(66,184,131,.24);
}

.dept-pill.active {
  background: linear-gradient(135deg, #edfdf5, #ffffff);
  border-color: rgba(66,184,131,.42);
  border-bottom-color: #42b883;
  box-shadow: 0 14px 28px rgba(66,184,131,.14);
}

.input:focus,
select:focus,
textarea:focus {
  border-color: rgba(66,184,131,.55);
  box-shadow: 0 0 0 4px rgba(66,184,131,.12);
}

.badge {
  background: #edfdf5;
  color: #167453;
  border-color: rgba(66,184,131,.14);
}

.timeline-item {
  border-left-color: rgba(66,184,131,.35);
}

.pending-card,
.order-card.pending-highlight {
  border-color: rgba(66,184,131,.4);
  box-shadow: 0 16px 34px rgba(66,184,131,.12);
}

.timeline-drawer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  overflow: hidden;
}

.timeline-drawer summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 850;
  color: var(--text);
}

.timeline-drawer .timeline {
  padding: 0 14px 14px;
}

.single-detail {
  grid-template-columns: 1fr !important;
}

.qty-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.qty-summary {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

:root[data-theme="dark"] {
  --primary: #d4af37;
  --primary-dark: #f3e7bd;
  --accent: #7c5cff;
}

:root[data-theme="dark"] .logo,
:root[data-theme="dark"] .btn {
  background: linear-gradient(135deg, #f7df8a, #b98b21);
  color: #050506;
}

:root[data-theme="dark"] .btn.secondary {
  background: #232329;
  color: var(--text);
  border-color: rgba(255,255,255,.12);
}

:root[data-theme="dark"] .btn.warning {
  background: linear-gradient(135deg, #d4af37, #a97818);
  color: #070708;
}

:root[data-theme="dark"] .btn.danger {
  background: linear-gradient(135deg, #ff7b86, #a83643);
  color: #fff;
}

:root[data-theme="dark"] .btn.success {
  background: linear-gradient(135deg, #64d6a5, #16845f);
  color: #07100d;
}

:root[data-theme="dark"] .stage-chip.active,
:root[data-theme="dark"] .badge.next-action {
  background: linear-gradient(135deg, #7c5cff, #d4af37);
}

/* Modern SaaS responsive shell */
.app-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.side-nav {
  position: sticky;
  top: 86px;
}
.side-nav .dept-switch {
  display: grid;
  grid-template-columns: 1fr;
}
.main-workspace {
  min-width: 0;
}
.module-tabs {
  position: sticky;
  top: 78px;
  z-index: 8;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.hero-panel,
.panel,
.order-card {
  border-radius: 22px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,.72);
}
.photo-modal {
  width: min(980px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 14px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.photo-modal img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  border-radius: 18px;
  background: #000;
}
.notification-card p {
  margin: 4px 0 8px;
}
.material-po-line {
  grid-template-columns: .9fr 1.2fr .55fr .55fr 1fr auto;
}
.po-update {
  margin-top: 8px;
}
@media (max-width: 860px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding-bottom: 76px;
  }
  .side-nav {
    position: static;
  }
  .side-nav .dept-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .module-tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .module-tabs .btn {
    white-space: nowrap;
  }
  .material-po-line {
    grid-template-columns: 1fr;
  }
}

:root[data-theme="dark"] .module-tabs,
:root[data-theme="dark"] .photo-modal {
  background: #101014;
  border-color: rgba(255,255,255,.08);
}

/* Apple Clean upgrade overrides - v6 */
:root {
  --bg: #f7fbf8;
  --surface: #ffffff;
  --surface-2: #f1f8f3;
  --ink: #17231c;
  --muted: #66756d;
  --line: rgba(29, 73, 48, .12);
  --primary: #39b66f;
  --primary-2: #157f4b;
  --accent: #d6ad4b;
  --danger: #d94b5c;
  --warning: #f1a33b;
  --shadow: 0 22px 60px rgba(27, 80, 50, .12);
  --shadow-soft: 0 10px 30px rgba(27, 80, 50, .08);
}
body {
  background:
    radial-gradient(circle at 12% 0%, rgba(87, 199, 133, .18), transparent 30%),
    linear-gradient(180deg, #fbfefc 0%, #f4faf6 55%, #eef7f1 100%);
  color: var(--ink);
}
.topbar {
  background: rgba(255,255,255,.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.logo {
  background: linear-gradient(135deg, #39b66f, #88d99d);
  color: #fff;
  box-shadow: 0 12px 30px rgba(57,182,111,.24);
}
.panel,
.order-card,
.hero-panel,
.photo-modal,
.login-card,
.module-tabs {
  background: rgba(255,255,255,.96);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.sales-hero.apple-hero {
  background:
    linear-gradient(135deg, rgba(57,182,111,.16), rgba(255,255,255,.96) 42%),
    radial-gradient(circle at 90% 10%, rgba(214,173,75,.22), transparent 28%);
}
.btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 10px 22px rgba(21,127,75,.18);
}
.btn.secondary,
.linkish {
  background: #fff;
  color: var(--primary-2);
  border: 1px solid rgba(21,127,75,.18);
  box-shadow: none;
}
.btn.warning { background: linear-gradient(135deg, #f6bc5e, #d88a1f); color:#1d1604; }
.btn.danger { background: linear-gradient(135deg, #ff6f7f, #cf3349); color:#fff; }
.btn.success { background: linear-gradient(135deg, #4ed486, #15965a); color:#fff; }
.input,
input,
select,
textarea {
  background: #fbfdfb;
  color: var(--ink);
  border: 1px solid rgba(29,73,48,.16);
  border-radius: 14px;
}
.input:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(57,182,111,.24);
  border-color: rgba(57,182,111,.62);
}
.badge.next-action,
.stage-chip.active,
.dept-pill.active {
  background: linear-gradient(135deg, #39b66f, #7fdc98);
  color: #fff;
}
.badge.success,
.success-note { background: rgba(57,182,111,.14); color: #157f4b; }
.badge.warning { background: rgba(241,163,59,.16); color: #89540b; }
.badge.danger { background: rgba(217,75,92,.13); color: #b12f42; }
.pending-highlight {
  border-color: rgba(57,182,111,.48) !important;
  box-shadow: 0 14px 44px rgba(57,182,111,.14) !important;
}
.order-card:hover,
.panel:hover {
  transform: translateY(-1px);
  transition: transform .18s ease, box-shadow .18s ease;
}
.staff-list { display:grid; gap:10px; }
.staff-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  overflow: hidden;
}
.staff-row summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 13px 15px;
}
.staff-row summary::-webkit-details-marker { display: none; }
.staff-summary { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.staff-edit { padding: 0 15px 15px; }
.task-edit-bar { margin: 12px 0; }
.follow-card .actions,
.dispatch-desk .actions { margin-top: 8px; }
.photo-modal { z-index: 999; }
.modal-backdrop { z-index: 998; }
:root[data-theme="dark"] {
  --bg: #090a0d;
  --surface: #121318;
  --surface-2: #191b22;
  --ink: #f4f4ee;
  --muted: #aaa89e;
  --line: rgba(255,255,255,.09);
  --primary: #d4af37;
  --primary-2: #7c5cff;
}
:root[data-theme="dark"] body {
  background: radial-gradient(circle at 20% -10%, rgba(124,92,255,.24), transparent 30%), #090a0d;
}
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .order-card,
:root[data-theme="dark"] .hero-panel,
:root[data-theme="dark"] .module-tabs,
:root[data-theme="dark"] .login-card,
:root[data-theme="dark"] .staff-row {
  background: #121318;
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] .linkish {
  background: #181a21;
  color: #f1d57a;
  border-color: rgba(212,175,55,.22);
}
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 10px; }
  .brand p { display:none; }
  .user-chip { width:100%; justify-content:space-between; }
  .hero-panel { padding: 16px; }
  .panel { padding: 14px; }
  .order-card { padding: 12px; }
  .staff-row summary { align-items:flex-start; flex-direction:column; }
}

/* Apple Macintosh compact UI refresh - v7 */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0,0,0,.10);
  --primary: #007aff;
  --primary-2: #0a84ff;
  --accent: #34c759;
  --danger: #ff3b30;
  --warning: #ff9f0a;
  --shadow: 0 18px 45px rgba(0,0,0,.10);
  --shadow-soft: 0 8px 24px rgba(0,0,0,.07);
}
body {
  background: linear-gradient(180deg,#fbfbfd 0%,#f5f5f7 55%,#ededf2 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}
.topbar {
  min-height: 66px;
  padding: 10px 18px;
  background: rgba(251,251,253,.86);
  backdrop-filter: blur(24px) saturate(1.3);
  border-bottom: 1px solid rgba(0,0,0,.08);
}
.logo { background: linear-gradient(135deg,#007aff,#5ac8fa); box-shadow: 0 12px 30px rgba(0,122,255,.20); }
.brand h1 { font-size: 18px; letter-spacing:-.03em; }
.brand p { font-size: 12px; }
.app-layout { grid-template-columns: 260px minmax(0,1fr); gap: 12px; }
.side-nav { top: 76px; }
.side-nav .dept-switch { gap: 8px; }
.dept-pill {
  min-height: 44px;
  justify-content: flex-start;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(0,0,0,.08);
  color: var(--ink);
}
.dept-pill.active { background:#007aff; color:#fff; box-shadow: 0 12px 26px rgba(0,122,255,.20); }
.left-summary {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-size: 13px;
}
.left-summary strong { color: var(--ink); font-size: 14px; }
.module-tabs {
  top: 76px;
  padding: 6px;
  gap: 6px;
  border-radius: 18px;
  background: rgba(251,251,253,.92);
  overflow-x: auto;
}
.module-tabs .btn { min-height: 36px; padding: 8px 12px; border-radius: 13px; font-size: 13px; white-space: nowrap; }
.panel,
.order-card,
.hero-panel,
.photo-modal,
.login-card,
.staff-row {
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(0,0,0,.08);
  box-shadow: var(--shadow-soft);
}
.panel { padding: 14px; }
.hero-panel { padding: 16px 18px; min-height: auto; }
.hero-panel h2 { font-size: clamp(20px,2.1vw,28px); }
.btn {
  min-height: 38px;
  border-radius: 13px;
  padding: 8px 14px;
  background: #007aff;
  color: white;
  box-shadow: 0 8px 20px rgba(0,122,255,.18);
  font-weight: 700;
}
.btn.secondary,
.linkish { background: #f2f2f7; color: #1d1d1f; border: 1px solid rgba(0,0,0,.08); box-shadow:none; }
.btn.success { background:#34c759; color:#fff; }
.btn.warning { background:#ff9f0a; color:#201400; }
.btn.danger { background:#ff3b30; color:#fff; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.actions,
.photo-actions,
.po-actions { display:flex; flex-wrap:wrap; gap:8px; align-items:center; overflow:visible; }
.order-list.compact-list,
.order-list { gap: 10px; }
.order-card { padding: 12px; gap: 7px; }
.order-head h3 { font-size: 15px; }
.summary-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.badges,.qty-row,.mini-metrics { gap:6px; flex-wrap:wrap; }
.badge { border-radius:999px; padding:5px 9px; font-size:12px; }
.badge.next-action,.stage-chip.active { background:#007aff; color:#fff; }
.badge.success,.ready-chip { background:rgba(52,199,89,.12); color:#1f7a39; border:1px solid rgba(52,199,89,.18); }
.badge.warning { background:rgba(255,159,10,.13); color:#8a5300; }
.badge.danger { background:rgba(255,59,48,.12); color:#bf241b; }
.desktop-grid { gap: 12px; }
.line-wrap {
  display:grid!important;
  gap:8px;
  padding:10px 0!important;
  border-bottom:1px solid rgba(0,0,0,.07)!important;
}
.line-main { display:grid; grid-template-columns:minmax(170px,1fr) auto; gap:10px; align-items:center; }
.batch-box { overflow:hidden; }
.photo-list.large-photos { grid-template-columns: repeat(auto-fit,minmax(250px,1fr)); gap:10px; }
.large-photos .photo-card,
.photo-card {
  grid-template-columns: 180px minmax(0,1fr);
  align-items:center;
  gap:12px;
  padding:10px;
  overflow:hidden;
}
.large-photos .photo-card img,
.photo-card img { width: 180px; height: 150px; object-fit: cover; border-radius: 14px; }
.photo-actions .btn,
.photo-actions a.btn { min-width: 0; padding: 7px 10px; font-size: 12px; }
.compact-action { padding:10px; border-radius:16px; background:#f8f8fb; border:1px solid var(--line); }
.ready-chip { margin-top:8px; padding:8px 10px; border-radius:12px; font-size:13px; }
.dispatch-edit { margin-top:8px; padding:8px; border-radius:14px; background:#f8f8fb; border:1px solid var(--line); }
.dispatch-edit summary { cursor:pointer; font-weight:700; color:#007aff; }
.dispatch-edit-row { margin-top:8px; }
.material-po-line { grid-template-columns: .9fr 1.2fr .55fr .55fr 1fr auto; }
.inline-label { min-width: 170px; }
.compact-input { max-width: 260px; }
.material-po-card .line-wrap { padding:6px 0!important; }
.sales-hero.apple-hero { background: linear-gradient(135deg,#ffffff 0%,#eef6ff 100%); }
.target-card { padding:10px; border-radius:15px; background:#f8f8fb; border:1px solid var(--line); }
:root[data-theme="dark"] {
  --bg:#101014; --surface:#1c1c1e; --surface-2:#2c2c2e; --ink:#f5f5f7; --muted:#a1a1a6; --line:rgba(255,255,255,.12); --primary:#0a84ff; --primary-2:#64d2ff;
}
:root[data-theme="dark"] body { background:#101014; }
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .module-tabs,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .order-card,
:root[data-theme="dark"] .hero-panel,
:root[data-theme="dark"] .staff-row,
:root[data-theme="dark"] .left-summary { background:rgba(28,28,30,.92); border-color:var(--line); color:var(--ink); }
:root[data-theme="dark"] .btn.secondary,
:root[data-theme="dark"] .linkish,
:root[data-theme="dark"] .compact-action,
:root[data-theme="dark"] .dispatch-edit,
:root[data-theme="dark"] .target-card { background:#2c2c2e; color:#f5f5f7; border-color:var(--line); }
@media (max-width: 980px) { .app-layout { grid-template-columns: 1fr; } .left-summary { display:none; } }
@media (max-width: 760px) {
  .module-tabs { bottom:8px; left:8px; right:8px; top:auto; }
  .large-photos .photo-card,.photo-card { grid-template-columns:1fr; }
  .large-photos .photo-card img,.photo-card img { width:100%; height:180px; }
  .line-main { grid-template-columns:1fr; }
  .material-po-line { grid-template-columns:1fr; }
}

/* iOS compact application shell - v8 */
:root {
  --bg:#f5f5f7;
  --surface:#ffffff;
  --surface-2:#f2f2f7;
  --ink:#1d1d1f;
  --muted:#6e6e73;
  --line:rgba(0,0,0,.09);
  --primary:#007aff;
  --primary-2:#5ac8fa;
  --accent:#5856d6;
  --danger:#ff3b30;
  --warning:#ff9f0a;
  --shadow:0 16px 38px rgba(0,0,0,.10);
  --shadow-soft:0 8px 22px rgba(0,0,0,.06);
}
html,body{height:100%;}
body{background:#f5f5f7;color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","SF Pro Display","Segoe UI",sans-serif;overflow:hidden;}
.topbar{height:58px;min-height:58px;padding:8px 16px;background:rgba(245,245,247,.82);backdrop-filter:blur(24px) saturate(1.35);border-bottom:1px solid var(--line);}
.brand h1{font-size:17px}.brand p{display:none}.logo{width:40px;height:40px;border-radius:13px;background:linear-gradient(135deg,#007aff,#5ac8fa);font-size:15px;}
.user-chip{gap:7px}.active-dept{font-size:13px;padding:8px 11px;border-radius:999px;background:rgba(255,255,255,.76);border:1px solid var(--line)}
.page{height:calc(100vh - 58px);overflow:hidden;padding:10px;}
.app-layout{grid-template-columns:278px minmax(0,1fr);gap:10px;height:100%;align-items:stretch;}
.side-nav{position:relative;top:auto;height:100%;display:flex;flex-direction:column;gap:10px;overflow:hidden;}
.side-nav .dept-switch{display:grid;grid-template-columns:1fr;gap:7px;}
.dept-pill{height:38px;min-height:38px;padding:7px 11px;border-radius:12px;display:flex;align-items:center;gap:9px;font-size:13px;background:rgba(255,255,255,.78);border:1px solid var(--line);box-shadow:none;}
.dept-pill.active{background:#007aff;color:#fff;box-shadow:0 10px 22px rgba(0,122,255,.20)}.dept-count{margin-left:auto;background:rgba(255,255,255,.28);border-radius:999px;padding:2px 7px;font-size:11px;}
.side-modules{display:grid;gap:6px;padding:9px;border-radius:18px;background:rgba(255,255,255,.72);border:1px solid var(--line);box-shadow:var(--shadow-soft)}
.side-module{height:34px;text-align:left;border:0;border-radius:11px;padding:0 10px;font-weight:700;color:var(--muted);background:transparent;cursor:pointer;}
.side-module.active,.side-module:hover{background:#007aff;color:#fff;}
.left-summary,.product-history,.sidebar-timeline{padding:10px;border-radius:18px;background:rgba(255,255,255,.78);border:1px solid var(--line);box-shadow:var(--shadow-soft);font-size:12px;}
.left-summary{display:grid;gap:5px}.left-summary strong,.product-history h3,.sidebar-timeline strong{font-size:13px;color:var(--ink)}
.sidebar-timeline{overflow:auto;min-height:120px;max-height:28vh}.side-timeline-item{display:grid;gap:2px;padding:7px 0;border-bottom:1px solid var(--line)}.side-timeline-item span{font-weight:800;font-size:11px}.side-timeline-item small,.side-timeline-item em{font-size:10.5px;color:var(--muted);font-style:normal;line-height:1.25}
.product-history{overflow:auto;max-height:25vh}.history-pill{width:100%;border:0;background:#f2f2f7;border-radius:12px;margin-top:6px;padding:7px 8px;display:grid;text-align:left;gap:2px;cursor:pointer}.history-pill strong{font-size:12px}.history-pill span{font-size:11px;color:var(--muted)}
.main-workspace{height:100%;min-width:0;overflow:hidden}.view-shell{height:100%;overflow:auto;padding-right:4px;}
.module-tabs{display:none!important;}
.hero-panel,.panel{border-radius:22px;background:rgba(255,255,255,.86);border:1px solid var(--line);box-shadow:var(--shadow-soft);padding:13px;margin-bottom:10px}.hero-panel{min-height:auto;grid-template-columns:1fr auto}.hero-panel h2{font-size:22px}.hero-panel p{font-size:12px;max-width:560px}
.dashboard-cards{grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.panel.stat{min-height:86px}.panel.stat strong{font-size:clamp(22px,2.1vw,32px)}
.desktop-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(360px,.68fr);gap:10px}.desktop-grid>.panel{min-height:0}.pipeline-panel{overflow:hidden}.pipeline-list{display:grid;gap:7px;max-height:45vh;overflow:auto;padding-right:3px}
.pipeline-row{display:grid;grid-template-columns:110px minmax(120px,1fr) auto 58px;gap:8px;align-items:center;padding:9px;border-radius:16px;background:#f8f8fb;border:1px solid var(--line)}.pipeline-id{display:grid}.pipeline-id strong{font-size:13px}.pipeline-id span,.pipeline-product{font-size:12px;color:var(--muted)}.pipeline-product{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pipeline-chips{display:flex;gap:5px;flex-wrap:wrap;justify-content:flex-end}.pending-chip{background:rgba(255,149,0,.14)!important;color:#8a5300!important}.tiny-btn{min-height:30px!important;padding:5px 10px!important;font-size:12px!important;border-radius:10px!important}.has-pending{border-color:rgba(255,149,0,.25)}
.order-card.compact-order-card{padding:10px;border-radius:16px;gap:6px;overflow:hidden}.order-head h3{font-size:14px}.text-clip,.summary-line{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.compact-badges .badge{max-width:100%;}.mini-metrics{display:flex;gap:5px;flex-wrap:wrap}.mini-metrics span{font-size:12px;background:#f2f2f7;border-radius:999px;padding:5px 8px}.pending-metric{background:rgba(255,149,0,.14)!important;color:#8a5300}.card-footer{display:flex;align-items:center;justify-content:space-between;gap:8px}.btn.wide{width:auto!important;}
.btn{min-height:34px;padding:7px 12px;border-radius:11px;background:#007aff;color:white;box-shadow:none;font-size:13px}.btn.secondary,.linkish{background:#f2f2f7;color:#1d1d1f;border:1px solid rgba(0,0,0,.08)}.btn.success{background:#34c759}.btn.warning{background:#ff9f0a;color:#1d1300}.btn.danger{background:#ff3b30;color:#fff}.actions,.photo-actions,.po-actions{display:flex;flex-wrap:wrap;gap:7px;align-items:center;overflow:visible}.task-edit-bar .btn{min-height:28px;padding:4px 9px;font-size:12px}
input,select,textarea,.input,.ios-select{min-height:34px;border-radius:11px;border:1px solid rgba(0,0,0,.10);background:#f8f8fb;color:var(--ink);padding:7px 10px;font-size:13px}select,.ios-select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#8e8e93 50%),linear-gradient(135deg,#8e8e93 50%,transparent 50%);background-position:calc(100% - 15px) 14px,calc(100% - 10px) 14px;background-size:5px 5px;background-repeat:no-repeat;padding-right:28px}
.line-wrap.pending-line{background:rgba(255,149,0,.06);border-radius:14px;padding:9px!important;border:1px solid rgba(255,149,0,.18)!important}.qty-chips .badge.warning{font-weight:900}.detail-grid.single-detail{height:100%}.timeline-drawer{display:none}.kv{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.pipeline.qty-summary{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}.line-main{grid-template-columns:minmax(160px,1fr) auto;}
.compact-action{padding:9px}.pack-fields{margin-top:8px}.ready-update{border-color:rgba(52,199,89,.22)}.upload-card{padding:9px;border-radius:14px}.upload-card .btn.danger{min-height:28px;padding:4px 9px;font-size:12px;border-radius:9px}.progress-track{height:6px}
.dispatch-desk .dispatch-row{display:grid;grid-template-columns:1fr repeat(3,minmax(120px,150px)) 110px;gap:8px;align-items:end;padding:9px}.dispatch-desk .dispatch-row h4{margin:0;font-size:13px}.dispatch-uploads{grid-column:1/-1;background:#f8f8fb;border:1px solid var(--line);border-radius:12px;padding:8px}.dispatch-uploads summary{cursor:pointer;font-weight:800;color:#007aff}.dispatch-edit-row{grid-template-columns:repeat(4,1fr) auto!important;}
.approval-inbox .photo-list.large-photos{display:grid;grid-template-columns:1fr;gap:8px}.approval-card{border:1px solid var(--line);border-radius:16px;background:#f8f8fb;padding:8px}.approval-card .photo-card{grid-template-columns:150px minmax(0,1fr);background:transparent;border:0;box-shadow:none}.approval-card .photo-card img{width:150px;height:110px}.approval-card .photo-actions{justify-content:flex-start}.approval-card>.btn{margin-top:6px}
.badge{font-size:11px;padding:4px 8px}.badge.next-action,.stage-chip.active{background:#007aff;color:#fff}.badge.warning{background:rgba(255,159,10,.13);color:#8a5300}.badge.success{background:rgba(52,199,89,.14);color:#1f7a39}.badge.danger{background:rgba(255,59,48,.12);color:#bf241b}
@media(max-width:1100px){body{overflow:auto}.page{height:auto;overflow:visible}.app-layout{grid-template-columns:1fr}.side-nav{height:auto}.left-summary,.product-history,.sidebar-timeline{display:none}.main-workspace,.view-shell{height:auto;overflow:visible}.desktop-grid{grid-template-columns:1fr}.dashboard-cards{grid-template-columns:repeat(2,1fr)}.dispatch-desk .dispatch-row{grid-template-columns:1fr 1fr}.pipeline-row{grid-template-columns:1fr}.pipeline-chips{justify-content:flex-start}}
:root[data-theme="dark"]{--bg:#050509;--surface:#111116;--surface-2:#1c1c24;--ink:#f5f5f7;--muted:#a6a6b0;--line:rgba(255,255,255,.10);--primary:#8b5cf6;--primary-2:#a78bfa;--accent:#7c3aed;}
:root[data-theme="dark"] body{background:radial-gradient(circle at 80% 0%,rgba(139,92,246,.22),transparent 34%),#050509;color:var(--ink)}
:root[data-theme="dark"] .topbar{background:rgba(5,5,9,.82);border-color:var(--line)}:root[data-theme="dark"] .logo{background:linear-gradient(135deg,#8b5cf6,#c084fc)}
:root[data-theme="dark"] .panel,:root[data-theme="dark"] .hero-panel,:root[data-theme="dark"] .order-card,:root[data-theme="dark"] .side-modules,:root[data-theme="dark"] .left-summary,:root[data-theme="dark"] .product-history,:root[data-theme="dark"] .sidebar-timeline,:root[data-theme="dark"] .approval-card{background:rgba(17,17,22,.88);border-color:var(--line);color:var(--ink)}
:root[data-theme="dark"] .dept-pill,:root[data-theme="dark"] .btn.secondary,:root[data-theme="dark"] .linkish,:root[data-theme="dark"] input,:root[data-theme="dark"] select,:root[data-theme="dark"] textarea,:root[data-theme="dark"] .input,:root[data-theme="dark"] .history-pill,:root[data-theme="dark"] .pipeline-row,:root[data-theme="dark"] .mini-metrics span,:root[data-theme="dark"] .compact-action,:root[data-theme="dark"] .dispatch-uploads{background:#1c1c24;color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .btn,:root[data-theme="dark"] .dept-pill.active,:root[data-theme="dark"] .side-module.active,:root[data-theme="dark"] .side-module:hover,:root[data-theme="dark"] .badge.next-action,:root[data-theme="dark"] .stage-chip.active{background:#8b5cf6;color:#fff;box-shadow:0 0 24px rgba(139,92,246,.22)}
:root[data-theme="dark"] .active-dept{background:#1c1c24;color:var(--ink);border-color:var(--line)}
:root[data-theme="dark"] .sales-hero.apple-hero{background:linear-gradient(135deg,rgba(139,92,246,.18),rgba(17,17,22,.92))}

/* Scroll and upload reliability fixes - v9 */
body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
.page {
  height: calc(100vh - 58px);
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
.main-workspace,
.view-shell {
  min-height: 0;
}
.view-shell {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: calc(100vh - 78px);
  padding-bottom: 28px;
}
.side-nav {
  max-height: calc(100vh - 78px);
  overflow-y: auto !important;
}
.upload-card {
  align-items: center;
}
.upload-card .btn.danger {
  align-self: center;
  min-width: 54px;
}
.upload-progress [data-upload-bar] {
  transition: width .18s ease;
}
@media(max-width:1100px){
  .page,
  .view-shell,
  .side-nav {
    max-height: none;
    height: auto;
    overflow-y: visible !important;
  }
}

/* Hard scroll repair - v10 */
html,
body {
  height: auto !important;
  min-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
body {
  position: static !important;
}
.page,
.app-layout,
.main-workspace,
.view-shell {
  height: auto !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: visible !important;
}
.page {
  padding-bottom: 48px !important;
}
.side-nav {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  position: sticky !important;
  top: 68px !important;
  align-self: start !important;
}
.sidebar-timeline,
.product-history,
.pipeline-list {
  overflow-y: auto !important;
}
@media (max-width:1100px) {
  .side-nav {
    position: static !important;
  }
}

/* Dispatch slip and auto-ready quantity polish - v11 */
.dispatch-desk .dispatch-row {
  grid-template-columns: minmax(160px,1.1fr) repeat(5,minmax(120px,150px)) 110px;
}
.dispatch-desk .label small {
  display:block;
  margin-top:4px;
  font-size:10.5px;
  color:var(--muted);
  line-height:1.2;
}
.dispatch-edit-row {
  grid-template-columns: repeat(3,minmax(120px,1fr)) !important;
}
.dispatch-edit-row .btn {
  align-self:end;
}
@media(max-width:1300px){
  .dispatch-desk .dispatch-row { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media(max-width:760px){
  .dispatch-desk .dispatch-row,
  .dispatch-edit-row { grid-template-columns:1fr !important; }
}
@media print {
  body > *:not(.print-slip-root) { display:none !important; }
}

/* Dispatch slip access + alignment polish - v12 */
.back-pill {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:34px;
  padding:7px 13px !important;
  border-radius:999px !important;
  background:#f2f2f7 !important;
  color:#1d1d1f !important;
  border:1px solid rgba(0,0,0,.08) !important;
  font-weight:800;
  text-decoration:none;
}
.back-pill:hover {
  background:#e8e8ed !important;
  transform:translateX(-1px);
}
.section-title {
  align-items:center;
  gap:12px;
  margin-bottom:12px;
}
.panel,
.action-card,
.order-card,
.line-wrap,
.dispatch-row,
.batch-box,
.compact-action {
  box-sizing:border-box;
}
.detail-grid .panel {
  display:grid;
  gap:12px;
}
.line-items-readonly {
  display:grid;
  gap:10px;
}
.line-wrap {
  margin:0;
  padding:12px !important;
  border-radius:16px;
  background:rgba(255,255,255,.58);
  border:1px solid rgba(0,0,0,.07) !important;
}
.latest-slip-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:9px 10px;
  border-radius:14px;
  background:rgba(0,122,255,.07);
  border:1px solid rgba(0,122,255,.14);
  margin-top:8px;
}
.latest-slip-row div {
  display:grid;
  gap:2px;
  min-width:0;
}
.latest-slip-row strong {
  font-size:13px;
  color:var(--ink);
}
.latest-slip-row span {
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.dispatch-desk {
  gap:12px !important;
}
.dispatch-desk .dispatch-row {
  border-radius:16px;
  background:#f8f8fb;
  border:1px solid var(--line);
  padding:12px;
  align-items:end;
}
.dispatch-desk .dispatch-row h4 {
  align-self:center;
  line-height:1.25;
}
.dispatch-desk .btn[data-dispatch-line] {
  align-self:end;
  min-width:104px;
}
.dispatch-uploads {
  margin-top:2px;
}
.dispatch-edit {
  margin-top:10px;
}
.dispatch-edit summary {
  padding:3px 0;
}
.actions {
  margin-top:4px;
}
.btn.tiny-btn {
  white-space:nowrap;
}
:root[data-theme="dark"] .back-pill {
  background:#1c1c24 !important;
  color:#f5f5f7 !important;
  border-color:rgba(255,255,255,.12) !important;
}
:root[data-theme="dark"] .back-pill:hover {
  background:#2a2a35 !important;
}
:root[data-theme="dark"] .line-wrap,
:root[data-theme="dark"] .dispatch-desk .dispatch-row {
  background:rgba(28,28,36,.78);
  border-color:rgba(255,255,255,.10) !important;
}
:root[data-theme="dark"] .latest-slip-row {
  background:rgba(139,92,246,.16);
  border-color:rgba(139,92,246,.28);
}
@media(max-width:760px){
  .latest-slip-row {
    align-items:flex-start;
    flex-direction:column;
  }
  .latest-slip-row .btn {
    width:100%;
  }
}

/* Item Master + production cleanup polish - v13 */
.item-master {
  display:grid;
  gap:12px;
}
.item-master-toolbar {
  display:grid;
  grid-template-columns:minmax(220px,1fr) 180px;
  gap:10px;
  align-items:center;
}
.item-master-form {
  padding:12px;
  border-radius:18px;
  background:linear-gradient(180deg,#ffffff,#f7f7fa);
  border:1px solid rgba(0,0,0,.07);
}
.item-master-list {
  display:grid;
  gap:8px;
  max-height:520px;
  overflow:auto;
  padding-right:4px;
}
.compact-master .item-master-list {
  max-height:340px;
}
.item-row {
  border:1px solid rgba(0,0,0,.08);
  border-radius:16px;
  background:#fff;
  padding:10px 12px;
  box-shadow:0 8px 24px rgba(15,23,42,.05);
}
.item-row[open] {
  box-shadow:0 14px 32px rgba(15,23,42,.08);
}
.item-row summary,
.item-row.readonly {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  cursor:pointer;
  list-style:none;
}
.item-row summary::-webkit-details-marker { display:none; }
.item-row strong { color:var(--ink); }
.item-row span:not(.badge) {
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-top:2px;
}
.item-row.inactive {
  opacity:.68;
  background:#f6f6f8;
}
.item-edit-grid {
  margin-top:12px;
  padding-top:12px;
  border-top:1px solid rgba(0,0,0,.07);
}
.item-reference {
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:8px;
}
.side-module[data-view="items"]::before { content:"📦 "; }
:root[data-theme="dark"] .item-master-form,
:root[data-theme="dark"] .item-row {
  background:#171720;
  border-color:rgba(255,255,255,.10);
  box-shadow:0 12px 30px rgba(0,0,0,.28);
}
:root[data-theme="dark"] .item-row.inactive {
  background:#111118;
}
:root[data-theme="dark"] .item-edit-grid {
  border-top-color:rgba(255,255,255,.10);
}
@media(max-width:760px){
  .item-master-toolbar { grid-template-columns:1fr; }
  .item-row summary,
  .item-row.readonly { align-items:flex-start; flex-direction:column; }
}

/* Proper mobile app alignment upgrade - v14 */
.mobile-dept-picker { display:none; }

@media (max-width: 900px) {
  html, body {
    width:100%;
    min-width:0;
    overflow-x:hidden !important;
    overflow-y:auto !important;
    -webkit-text-size-adjust:100%;
  }
  body {
    background:#f5f5f7 !important;
  }
  #app,
  .app-shell,
  .saas-shell {
    min-width:0;
    width:100%;
    overflow-x:hidden;
  }
  .topbar {
    position:sticky !important;
    top:0;
    z-index:80;
    height:auto !important;
    min-height:58px !important;
    padding:8px 10px !important;
    display:grid !important;
    grid-template-columns:1fr auto;
    gap:8px !important;
    align-items:center !important;
    border-radius:0 !important;
    background:rgba(248,248,250,.94) !important;
    backdrop-filter:blur(18px) saturate(1.25);
  }
  .brand {
    min-width:0;
    gap:8px !important;
  }
  .brand .logo {
    width:38px !important;
    height:38px !important;
    min-width:38px !important;
    border-radius:13px !important;
    font-size:15px !important;
  }
  .brand h1 {
    font-size:16px !important;
    line-height:1.1 !important;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:46vw;
  }
  .brand p { display:none !important; }
  .user-chip {
    display:flex !important;
    align-items:center;
    justify-content:flex-end;
    gap:6px !important;
    min-width:0;
    flex-wrap:nowrap !important;
  }
  .user-chip .theme-toggle {
    display:none !important;
  }
  .user-chip .active-dept {
    max-width:34vw;
    min-width:0;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    padding:8px 10px !important;
    border-radius:999px !important;
    font-size:12px !important;
  }
  .user-chip .compact-btn,
  .user-chip .btn {
    min-height:36px !important;
    height:36px !important;
    padding:0 10px !important;
    border-radius:999px !important;
    font-size:12px !important;
  }
  .mobile-dept-picker {
    display:flex;
    align-items:center;
    gap:5px;
    font-size:11px;
    color:var(--muted);
  }
  .mobile-dept-picker select {
    height:34px;
    max-width:118px;
    padding:0 28px 0 10px;
    border-radius:999px;
    border:1px solid var(--line);
    background:#fff;
    color:var(--ink);
    font-weight:800;
  }
  .page,
  .app-layout {
    display:block !important;
    width:100% !important;
    max-width:none !important;
    height:auto !important;
    min-height:calc(100vh - 58px) !important;
    overflow:visible !important;
    padding:10px 10px 86px !important;
  }
  .side-nav {
    position:static !important;
    height:auto !important;
    width:auto !important;
    padding:0 !important;
    margin:0 !important;
    overflow:visible !important;
    background:transparent !important;
    border:0 !important;
    box-shadow:none !important;
  }
  .side-nav .dept-switch,
  .left-summary,
  .product-history,
  .sidebar-timeline {
    display:none !important;
  }
  .side-modules {
    position:fixed !important;
    left:10px;
    right:10px;
    bottom:10px;
    z-index:90;
    display:grid !important;
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:6px !important;
    padding:7px !important;
    border-radius:24px !important;
    border:1px solid rgba(0,0,0,.08) !important;
    background:rgba(255,255,255,.92) !important;
    backdrop-filter:blur(22px) saturate(1.25);
    box-shadow:0 18px 42px rgba(15,23,42,.16) !important;
    overflow:hidden !important;
  }
  .side-module {
    min-width:0 !important;
    height:52px !important;
    padding:4px 3px !important;
    border-radius:17px !important;
    display:flex !important;
    align-items:center;
    justify-content:center;
    text-align:center;
    font-size:10px !important;
    line-height:1.1 !important;
    font-weight:850 !important;
    white-space:normal !important;
    overflow:hidden;
  }
  .side-module:nth-child(n+6) { display:none !important; }
  .side-module.active {
    background:#007aff !important;
    color:#fff !important;
    box-shadow:0 8px 18px rgba(0,122,255,.28) !important;
  }
  .main-workspace,
  .view-shell {
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    padding:0 !important;
    width:100% !important;
  }
  .hero-panel,
  .panel,
  .action-card,
  .order-card,
  .line-wrap,
  .batch-box,
  .batch-create,
  .dispatch-row,
  .upload-card,
  .approval-card,
  .item-row {
    width:100% !important;
    max-width:100% !important;
    box-sizing:border-box !important;
    border-radius:20px !important;
  }
  .hero-panel {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:12px !important;
    padding:14px !important;
    margin-bottom:10px !important;
  }
  .hero-panel h2,
  .sales-hero h2 {
    font-size:22px !important;
    line-height:1.08 !important;
  }
  .hero-panel p,
  .sales-hero p {
    font-size:13px !important;
    line-height:1.35 !important;
  }
  .hero-actions,
  .actions {
    display:flex !important;
    flex-wrap:wrap !important;
    gap:8px !important;
  }
  .hero-actions .btn,
  .actions .btn,
  .btn.wide {
    flex:1 1 auto;
  }
  .dashboard-cards,
  .grid.cards.dashboard-cards {
    display:grid !important;
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    gap:9px !important;
  }
  .panel.stat {
    min-height:92px !important;
    padding:12px !important;
  }
  .panel.stat strong {
    font-size:24px !important;
    line-height:1.05 !important;
    word-break:break-word;
  }
  .desktop-grid {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:10px !important;
  }
  .order-list,
  .compact-list,
  .pipeline-list,
  .line-items-readonly {
    display:grid !important;
    gap:9px !important;
    max-height:none !important;
    overflow:visible !important;
    padding-right:0 !important;
  }
  .order-card.compact-order-card,
  .order-card,
  .pipeline-row {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:8px !important;
    padding:12px !important;
  }
  .order-head,
  .section-title,
  .line-main,
  .card-footer,
  .latest-slip-row,
  .item-row summary,
  .item-row.readonly {
    display:flex !important;
    align-items:flex-start !important;
    justify-content:space-between !important;
    gap:10px !important;
    flex-wrap:wrap !important;
  }
  .summary-line,
  .pipeline-product,
  .text-clip {
    white-space:normal !important;
    overflow:visible !important;
    text-overflow:clip !important;
    max-width:100% !important;
    font-size:13px !important;
    line-height:1.32 !important;
  }
  .badges,
  .compact-badges,
  .pipeline-chips,
  .qty-row,
  .qty-chips,
  .mini-metrics {
    display:flex !important;
    flex-wrap:wrap !important;
    gap:6px !important;
  }
  .badge {
    max-width:100%;
    white-space:normal !important;
    text-align:left;
  }
  .btn,
  button,
  .linkish,
  input,
  select,
  textarea {
    font-size:14px !important;
  }
  .btn,
  button.btn,
  .back-pill {
    min-height:42px !important;
    padding:10px 14px !important;
    border-radius:14px !important;
  }
  .tiny-btn {
    min-height:38px !important;
    padding:8px 12px !important;
  }
  .form-grid,
  .form-grid.two,
  .compact-order .line-item-row,
  .line-item-row,
  .batch-fields,
  .staff-edit,
  .item-edit-grid,
  .item-master-toolbar,
  .dispatch-edit-row {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:9px !important;
  }
  .label,
  .wide-field {
    grid-column:auto !important;
    width:100% !important;
    min-width:0 !important;
  }
  .input,
  input,
  select,
  textarea {
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    box-sizing:border-box !important;
  }
  input,
  select,
  .input {
    min-height:44px !important;
  }
  textarea { min-height:86px !important; }
  .kv,
  .qty-summary,
  .pipeline {
    display:grid !important;
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
    gap:8px !important;
  }
  .kv div,
  .pipeline-step {
    padding:10px !important;
    min-width:0 !important;
  }
  .detail-grid,
  .single-detail {
    display:block !important;
  }
  .detail-grid .panel,
  .compact-order {
    display:grid !important;
    gap:10px !important;
    padding:12px !important;
  }
  .timeline-drawer {
    border:1px solid var(--line);
    border-radius:16px;
    padding:10px;
    background:rgba(255,255,255,.62);
  }
  .timeline-drawer summary {
    min-height:38px;
    display:flex;
    align-items:center;
    font-weight:900;
    cursor:pointer;
  }
  .dispatch-desk,
  .dispatch-desk .dispatch-row {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:9px !important;
    align-items:stretch !important;
  }
  .dispatch-desk .dispatch-row h4 {
    font-size:15px !important;
    padding:8px 10px;
    border-radius:13px;
    background:rgba(0,122,255,.08);
  }
  .dispatch-desk .btn[data-dispatch-line] {
    width:100% !important;
  }
  .dispatch-uploads {
    grid-column:auto !important;
  }
  .latest-slip-row {
    align-items:stretch !important;
  }
  .latest-slip-row .btn {
    width:100% !important;
  }
  .photo-list,
  .large-photos,
  .approval-inbox .photo-list {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:10px !important;
  }
  .photo-card,
  .approval-card {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:10px !important;
    overflow:hidden !important;
  }
  .photo-thumb,
  .photo-card img,
  .approval-card img {
    max-width:100% !important;
    width:100% !important;
    height:auto !important;
    object-fit:contain !important;
  }
  .upload-card {
    display:grid !important;
    grid-template-columns:1fr !important;
    gap:9px !important;
  }
  .item-master-list {
    max-height:none !important;
    overflow:visible !important;
  }
  .staff-row summary,
  .review-row,
  .target-card,
  .material-po-card,
  .material-edit-card {
    overflow:hidden;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns:1fr !important;
    align-items:stretch !important;
  }
  .user-chip {
    justify-content:space-between !important;
    width:100%;
  }
  .user-chip .active-dept {
    flex:1 1 auto;
    max-width:none;
  }
  .mobile-dept-picker {
    order:5;
    flex:1 1 100%;
  }
  .mobile-dept-picker select {
    max-width:none;
    flex:1;
  }
  .page,
  .app-layout {
    padding:8px 8px 84px !important;
  }
  .side-modules {
    left:8px;
    right:8px;
    bottom:8px;
    border-radius:22px !important;
    gap:5px !important;
  }
  .side-module {
    height:50px !important;
    font-size:9.5px !important;
  }
  .hero-panel,
  .panel,
  .compact-order {
    padding:11px !important;
    border-radius:18px !important;
  }
  .dashboard-cards,
  .grid.cards.dashboard-cards,
  .kv,
  .qty-summary,
  .pipeline {
    grid-template-columns:1fr 1fr !important;
    gap:7px !important;
  }
  .panel.stat {
    min-height:84px !important;
    padding:10px !important;
  }
  .panel.stat strong {
    font-size:21px !important;
  }
  .hero-panel h2,
  .sales-hero h2 {
    font-size:20px !important;
  }
  .order-head h3,
  .section-title h2,
  .section-title h3 {
    font-size:18px !important;
  }
  .line-wrap,
  .order-card,
  .dispatch-row,
  .batch-box,
  .batch-create,
  .action-card {
    padding:10px !important;
  }
  .btn,
  button.btn,
  .back-pill {
    min-height:42px !important;
    width:auto;
  }
  .actions .btn {
    flex:1 1 100%;
  }
  .order-head .badge,
  .section-title .badge {
    font-size:11px !important;
  }
  .login.compact-login {
    min-height:100svh;
    padding:12px !important;
  }
  .compact-login .login-card {
    width:100% !important;
    padding:16px !important;
    border-radius:22px !important;
  }
}

:root[data-theme="dark"] .side-modules {
  background:rgba(16,16,22,.92) !important;
  border-color:rgba(255,255,255,.10) !important;
}
:root[data-theme="dark"] .mobile-dept-picker select {
  background:#171720;
  color:#f5f5f7;
  border-color:rgba(255,255,255,.12);
}
@media (max-width: 900px) {
  :root[data-theme="dark"] body { background:#050509 !important; }
  :root[data-theme="dark"] .topbar { background:rgba(5,5,9,.94) !important; }
  :root[data-theme="dark"] .timeline-drawer { background:rgba(17,17,22,.78); }
}

/* Mobile nav/action refinement - v15 */
@media (max-width:900px){
  .panel.stat .linkish,
  .float-card .linkish {
    width:100%;
    min-height:36px;
    margin-top:8px;
    border:1px solid rgba(0,122,255,.12) !important;
    background:rgba(0,122,255,.08) !important;
    color:#007aff !important;
    border-radius:12px !important;
    font-weight:900 !important;
  }
  .side-module[data-view="notifications"]::before { content:"🔔"; display:block; font-size:15px; margin-bottom:2px; }
  .side-module[data-view="dashboard"]::before { content:"⌂"; display:block; font-size:16px; margin-bottom:2px; }
  .side-module[data-view="orders"]::before { content:"◫"; display:block; font-size:16px; margin-bottom:2px; }
  .side-module[data-view="items"]::before { content:"📦"; display:block; font-size:14px; margin-bottom:2px; }
  .side-module[data-view="crm"]::before,
  .side-module[data-view="admin"]::before { content:"⋯"; display:block; font-size:18px; margin-bottom:0; }
}

/* Native mobile app polish - v16 */
@media (max-width:900px){
  :root {
    --mobile-bg:#f2f3f7;
    --mobile-card:#ffffff;
    --mobile-soft:#f8f9fc;
    --mobile-blue:#007aff;
  }
  body {
    background:var(--mobile-bg) !important;
    font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif !important;
  }
  .app-shell::before {
    content:"";
    position:fixed;
    inset:0;
    pointer-events:none;
    background:
      radial-gradient(circle at 20% 0%, rgba(0,122,255,.10), transparent 28%),
      radial-gradient(circle at 90% 15%, rgba(52,199,89,.08), transparent 24%);
    z-index:-1;
  }
  .topbar {
    box-shadow:0 10px 28px rgba(15,23,42,.08) !important;
  }
  .brand h1 {
    letter-spacing:-.03em;
    font-weight:950 !important;
  }
  .user-chip {
    padding:0 !important;
  }
  .user-chip .compact-btn[data-view="notifications"] {
    width:40px !important;
    min-width:40px !important;
    padding:0 !important;
    font-size:0 !important;
    position:relative;
  }
  .user-chip .compact-btn[data-view="notifications"]::before {
    content:"🔔";
    font-size:16px;
  }
  .user-chip .active-dept {
    background:#fff !important;
    border:1px solid rgba(0,0,0,.06) !important;
    box-shadow:0 8px 22px rgba(15,23,42,.08) !important;
    color:#1d1d1f !important;
  }
  .user-chip .compact-btn[data-logout] {
    font-size:0 !important;
    width:40px !important;
    min-width:40px !important;
    padding:0 !important;
  }
  .user-chip .compact-btn[data-logout]::before {
    content:"⎋";
    font-size:17px;
    font-weight:900;
  }
  .mobile-dept-picker {
    background:rgba(255,255,255,.72);
    border:1px solid rgba(0,0,0,.06);
    border-radius:999px;
    padding:4px 4px 4px 10px;
  }
  .mobile-dept-picker select {
    box-shadow:none !important;
    background:#fff !important;
  }
  .view-shell > .hero-panel:first-child,
  .view-shell > .sales-hero:first-child {
    margin-top:2px !important;
    background:linear-gradient(145deg,#ffffff 0%,#f7fbff 100%) !important;
    border:1px solid rgba(0,122,255,.08) !important;
    box-shadow:0 14px 34px rgba(15,23,42,.08) !important;
  }
  .eyebrow {
    font-size:11px !important;
    letter-spacing:.13em !important;
  }
  .hero-panel h2,
  .sales-hero h2 {
    letter-spacing:-.045em;
  }
  .hero-panel .btn,
  .sales-hero .btn,
  .action-card > .btn,
  .dispatch-row > .btn {
    border-radius:16px !important;
    min-height:46px !important;
    font-weight:950 !important;
  }
  .panel,
  .order-card,
  .line-wrap,
  .dispatch-row,
  .action-card,
  .batch-box,
  .batch-create,
  .upload-card,
  .item-row {
    background:rgba(255,255,255,.92) !important;
    border:1px solid rgba(0,0,0,.055) !important;
    box-shadow:0 10px 26px rgba(15,23,42,.065) !important;
  }
  .panel.stat {
    display:grid !important;
    align-content:space-between !important;
    background:linear-gradient(180deg,#fff,#fafbff) !important;
  }
  .panel.stat .muted {
    font-size:12px !important;
    font-weight:800 !important;
  }
  .panel.stat strong {
    letter-spacing:-.04em !important;
  }
  .order-card.compact-order-card,
  .pipeline-row {
    border-radius:19px !important;
    position:relative;
  }
  .order-card.compact-order-card::before,
  .pipeline-row::before {
    content:"";
    position:absolute;
    left:0;
    top:14px;
    bottom:14px;
    width:4px;
    border-radius:0 999px 999px 0;
    background:var(--mobile-blue);
    opacity:.8;
  }
  .order-head h3,
  .pipeline-id strong {
    font-size:16px !important;
    letter-spacing:-.02em;
  }
  .badge {
    border-radius:999px !important;
    padding:6px 9px !important;
    font-size:11px !important;
    font-weight:850 !important;
  }
  .qty-chips .badge,
  .mini-metrics span {
    background:#f2f6ff !important;
    color:#1d1d1f !important;
    border:1px solid rgba(0,122,255,.08) !important;
  }
  .pending-line,
  .line-wrap.pending-line {
    background:linear-gradient(180deg,#fff,#fffaf2) !important;
    border-color:rgba(255,149,0,.20) !important;
  }
  .form-grid.action-card,
  .action-card {
    background:#fff !important;
  }
  .label {
    color:#5f6368 !important;
    font-size:12px !important;
    font-weight:850 !important;
  }
  input,
  select,
  textarea,
  .input {
    background:#f7f8fb !important;
    border:1px solid rgba(0,0,0,.08) !important;
    border-radius:14px !important;
    box-shadow:inset 0 1px 0 rgba(255,255,255,.75) !important;
  }
  input:focus,
  select:focus,
  textarea:focus,
  .input:focus {
    outline:none !important;
    border-color:rgba(0,122,255,.55) !important;
    box-shadow:0 0 0 4px rgba(0,122,255,.12) !important;
  }
  .side-modules {
    height:72px !important;
    padding:8px !important;
    align-items:center;
  }
  .side-module {
    height:56px !important;
    border-radius:19px !important;
    flex-direction:column !important;
    gap:2px !important;
    color:#6b7280 !important;
    background:transparent !important;
  }
  .side-module.active {
    color:#fff !important;
    background:linear-gradient(180deg,#1688ff,#007aff) !important;
  }
  .side-module::before {
    line-height:1 !important;
  }
  .timeline-drawer,
  details.dispatch-edit,
  .dispatch-uploads {
    background:#f8f9fc !important;
    border-color:rgba(0,0,0,.06) !important;
  }
  .empty {
    min-height:110px;
    display:grid;
    place-items:center;
    color:#7b7f87 !important;
    text-align:center;
  }
}

@media (max-width:640px){
  .topbar {
    padding:9px 10px 8px !important;
  }
  .brand {
    justify-content:flex-start;
  }
  .brand h1 {
    max-width:calc(100vw - 76px) !important;
    font-size:17px !important;
  }
  .user-chip {
    display:grid !important;
    grid-template-columns:40px minmax(0,1fr) 40px !important;
    gap:7px !important;
  }
  .user-chip .active-dept {
    max-width:none !important;
    text-align:center;
  }
  .mobile-dept-picker {
    grid-column:1/-1;
  }
  .mobile-dept-picker select {
    height:36px !important;
  }
  .hero-actions .btn {
    min-width:0 !important;
  }
  .section-title {
    margin-bottom:8px !important;
  }
  .section-title h2,
  .section-title h3,
  .panel h2,
  .panel h3 {
    letter-spacing:-.035em;
  }
  .dashboard-cards .panel.stat:nth-child(n+5) {
    grid-column:span 2;
  }
  .kv div small,
  .pipeline-step span {
    font-size:11px !important;
  }
  .kv div strong,
  .pipeline-step strong {
    font-size:15px !important;
  }
  .side-module:nth-child(4) {
    font-size:8.8px !important;
  }
  .side-module:nth-child(5) {
    font-size:8.8px !important;
  }
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .order-card,
:root[data-theme="dark"] .line-wrap,
:root[data-theme="dark"] .dispatch-row,
:root[data-theme="dark"] .action-card,
:root[data-theme="dark"] .batch-box,
:root[data-theme="dark"] .batch-create,
:root[data-theme="dark"] .upload-card,
:root[data-theme="dark"] .item-row {
  background:rgba(18,18,25,.94) !important;
  border-color:rgba(255,255,255,.09) !important;
}
@media(max-width:900px){
  :root[data-theme="dark"] .view-shell > .hero-panel:first-child,
  :root[data-theme="dark"] .view-shell > .sales-hero:first-child {
    background:linear-gradient(145deg,#15151d,#101018) !important;
    border-color:rgba(139,92,246,.20) !important;
  }
  :root[data-theme="dark"] input,
  :root[data-theme="dark"] select,
  :root[data-theme="dark"] textarea,
  :root[data-theme="dark"] .input {
    background:#101018 !important;
    border-color:rgba(255,255,255,.11) !important;
  }
  :root[data-theme="dark"] .user-chip .active-dept,
  :root[data-theme="dark"] .mobile-dept-picker,
  :root[data-theme="dark"] .mobile-dept-picker select {
    background:#15151d !important;
    color:#f5f5f7 !important;
    border-color:rgba(255,255,255,.10) !important;
  }
}
