
#app-root { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
#view-auth {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  padding: 24px;
}
.auth-card {
  margin-block: auto;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--sh-3);
}
.auth-logo-img  { display: flex; align-items: baseline; justify-content: center;
                  gap: .45em; font-size: 30px; margin: 0 auto 14px; }
.auth-logo-mark { height: .745em; width: .993em; flex-shrink: 0; }
.auth-logo-word { font-family: "Plus Jakarta Sans", Inter, "Segoe UI", system-ui, sans-serif;
                  font-weight: 800; letter-spacing: .05em; line-height: 1; color: var(--text); }
.tb-brand-img  { font-size: 15.5px; height: .745em; width: .993em; display: block; flex-shrink: 0; }
.sid-logo-mark { min-height: 24px; }
.auth-logo {
  width: 64px;
  height: 64px;
  background: var(--sidebar-bg);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.auth-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.auth-tagline {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 8px;
}
.auth-project {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue2);
  background: rgba(59,130,246,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--r-sm);
  padding: 4px 12px;
  display: inline-block;
  margin-bottom: 28px;
}
.auth-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}
.auth-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur);
  box-sizing: border-box;
}
.auth-input:focus { border-color: var(--blue2); }
.auth-input::placeholder { color: var(--text3); }
.auth-link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 4px;
  background: none;
  border: 0;
  color: var(--text3);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.auth-link:hover { color: var(--text2); }
.auth-link:focus-visible { outline: 2px solid var(--blue2); outline-offset: 2px; border-radius: var(--r-sm); }
@media (prefers-reduced-motion: reduce) { .auth-link { transition: none; } }
.auth-or {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  color: var(--text3);
  font-size: 11px;
}
.auth-or::before, .auth-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 24px;
  width: 100%;
  flex-shrink: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text3);
}
.auth-footer span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.auth-denied {
  display: none;
  margin-top: 16px;
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: var(--r-md);
  padding: 16px;
}
.auth-denied.show { display: block; }
.auth-denied-title { font-size: 13px; font-weight: 700; color: var(--red2); margin-bottom: 4px; }
.auth-denied-body  { font-size: 12px; color: var(--text2); }
.auth-denied-email { font-size: 11px; color: var(--text3); margin-top: 6px; font-family: monospace; }
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}
body.is-admin {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior-y: none;
  display: flex;
  flex-direction: column;
}
body.is-admin #view-dashboard {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.topbar {
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  padding-left: 16px;
  padding-right: 16px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 200;
}
.tb-brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  width: var(--sid-w);
  margin-left: -16px;
}
.tb-brand-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(to bottom, #1976d1, #0d48a2);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  flex-shrink: 0;
}
.tb-brand-name {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.brand-o { color: #ea580c; }
.tb-sep {
  width: 1px;
  height: 18px;
  background: var(--border2);
  flex-shrink: 0;
}
.tb-project {
  font-size: 11px;
  color: var(--text3);
  flex: 1;
  min-width: 0;
}
.tb-project strong { color: var(--text2); font-weight: 500; }
.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text3);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 9px;
  white-space: nowrap;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.online  { background: var(--green2); }
.status-dot.offline { background: var(--red2); }
.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--r-md);
  transition: background var(--dur);
}
.user-pill:hover { background: var(--bg3); }
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.user-name { max-width: 120px; }
.user-role {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  background: rgba(59,130,246,0.12);
  color: var(--blue2);
  flex-shrink: 0;
}
.user-role.role-operator { background: rgba(5,150,105,0.12); color: var(--green2); }
.user-role.role-stock    { background: rgba(217,119,6,0.12);  color: var(--amber2); }
.user-role.role-admin    { background: rgba(124,58,237,0.12); color: var(--purple2); }
.user-role.role-viewer   { background: rgba(14,165,233,0.12); color: var(--blue2); }
.body-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.sidebar {
  width: var(--sid-w);
  background: linear-gradient(to bottom, #1976d1, #0d48a2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.25s var(--ease);
  z-index: 100;
}
.sidebar.collapsed { width: var(--sid-w-col); }
.sid-logo {
  padding: 18px 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  overflow: hidden;
  text-align: center;
}
.sid-logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  white-space: nowrap;
  position: relative;
}
.sid-logo-text {
  display: flex;
  align-items: center;
}
.sid-logo-slashes {
  font-family: 'DM Mono', monospace;
  font-size: 17px;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  letter-spacing: -1px;
}
.sid-logo-wordmark {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-left: 5px;
  letter-spacing: 0.01em;
}
.sid-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.38);
  padding: 4px 6px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
  position: absolute;
  right: 0;
}
.sid-toggle-btn { color: rgba(255,255,255,0.70); }
.sid-toggle-btn:hover { color: #fff; background: rgba(255,255,255,0.12); }
.sid-toggle-open   { display: block; }
.sid-toggle-closed { display: none; }
.sidebar.collapsed .sid-logo-text     { display: none; }
.sidebar.collapsed .sid-logo-mark    { margin-bottom: 0; }
.sidebar.collapsed .sid-toggle-btn   { position: static; }
.sidebar.collapsed .sid-toggle-open  { display: none; }
.sidebar.collapsed .sid-toggle-closed { display: block; }
.sidebar.collapsed .sid-logo         { padding: 14px 10px; }
.sid-prj-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.sid-prj-loc {
  font-size: 10.5px;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.sidebar.collapsed .sid-prj-name,
.sidebar.collapsed .sid-prj-loc { display: none; }
.sid-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.sid-nav::-webkit-scrollbar { width: 4px; }
.sid-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }
.sid-group-lbl {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.78);
  padding: 14px 10px 5px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .sid-group-lbl { opacity: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  font: inherit;
  font-weight: 500;
  text-align: left;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur), color var(--dur);
  color: rgba(255,255,255,0.85);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
.nav-item:hover  { background: rgba(255,255,255,0.12); color: #fff; }
.nav-item:focus-visible {
  outline: 2px solid rgba(255,255,255,0.7);
  outline-offset: -2px;
}
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: #fff;
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color var(--dur);
  color: rgba(255,255,255,0.75);
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-item:hover  .nav-icon { color: #fff; }
.nav-item.active .nav-icon { color: #fff; }
.nav-label { font-size: 13px; }
.sidebar.collapsed .nav-label { display: none; }
.nav-live { position: relative; }
.nav-live.nav-live-on::after {
  content: "";
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  width: 7px; height: 7px;
  background: #34d399;
  border-radius: 50%;
  animation: pulse-live 1.8s infinite;
}
.sidebar.collapsed .nav-live.nav-live-on::after { right: 6px; }
@keyframes pulse-live {
  0%,100% { opacity: 1; transform: translateY(-50%) scale(1); }
  50%      { opacity: 0.4; transform: translateY(-50%) scale(1.35); }
}
@media (prefers-reduced-motion: reduce) {
  .nav-live.nav-live-on::after { animation: none; }
}
.sid-bottom {
  flex-shrink: 0;
  padding: 8px 8px max(8px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255,255,255,0.07);
  position: relative;
}
@media (pointer: coarse) {
  .sid-nav { flex: 0 1 auto; }
}
.sid-account {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.06);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur) var(--ease);
}
.sid-account:hover { background: rgba(255,255,255,0.12); }
.sid-account .user-name { color: #fff; font-size: 12.5px; font-weight: 600; flex: 1; min-width: 0; text-align: left; }
.sid-account-caret { color: rgba(255,255,255,0.6); flex-shrink: 0; transition: transform var(--dur) var(--ease); }
.sid-account[aria-expanded="true"] .sid-account-caret { transform: rotate(180deg); }
.sidebar.collapsed .sid-account { justify-content: center; padding: 8px 4px; }
.sidebar.collapsed .sid-account .user-name,
.sidebar.collapsed .sid-account-caret { display: none; }
.sid-account-menu {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(100% - 2px);
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: 6px;
  z-index: 300;
  animation: samRise 0.14s var(--ease);
}
@keyframes samRise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sidebar.collapsed .sid-account-menu { left: 8px; right: auto; width: 220px; }
.sidebar.collapsed:has(.sid-account-menu:not(.hidden)) { overflow: visible; }
.sam-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 10px;
}
.sam-avatar { width: 34px; height: 34px; font-size: 13px; }
.sam-id-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sam-name  { font-size: 13px; font-weight: 700; color: var(--text); }
.sam-email { font-size: 11px; color: var(--text3); }
.sam-sep { height: 1px; background: var(--border); margin: 4px 0; }
.sam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.sam-item:hover { background: var(--bg3); }
.sam-ico { width: 17px; height: 17px; flex-shrink: 0; color: var(--text2); }
.sam-label { flex: 1; }
.sam-value {
  font-size: 11px; font-weight: 700;
  color: var(--text3);
  background: var(--bg3);
  padding: 2px 8px; border-radius: var(--r-full);
}
.sam-danger { color: var(--red2); }
.sam-danger .sam-ico { color: var(--red2); }
.sam-danger:hover { background: rgba(220,38,38,0.10); }
.sid-reported-by {
  font-size: 10px;
  color: rgba(255,255,255,0.22);
  padding: 6px 10px 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed .sid-reported-by { display: none; }
.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.page-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}
.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-text { min-width: 0; }
.page-header-actions { display: flex; align-items: center; gap: 8px; }
.page-header-actions:empty { display: none; }
.page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
  margin-bottom: 2px;
}
.page-sub {
  font-size: 11px;
  color: var(--text3);
}
.role-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  padding: 32px;
  text-align: center;
}
.role-placeholder-icon {
  font-size: 56px;
  line-height: 1;
}
.role-placeholder-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
.role-placeholder-sub {
  font-size: 13px;
  color: var(--text3);
  max-width: 280px;
}
.mob-header {
  height: var(--top-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 100;
}
.mob-header-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: -0.2px;
}
.mob-header-action {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background var(--dur);
}
.mob-header-action:hover { background: var(--bg3); }
.hb-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  padding: 6px;
  border-radius: var(--r-sm);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--dur);
}
.hb-btn:hover { background: var(--bg3); }
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: var(--top-h);
  left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 250;
}
.sidebar-backdrop.show { display: block; }
@media (max-width: 768px) {
  .page-wrap { padding: 16px; }
  .hb-btn    { display: flex; }
  .tb-brand  { width: auto; margin-left: 0; justify-content: flex-start; }
  .sidebar {
    position: fixed;
    top: var(--top-h);
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    z-index: 300;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed   { width: var(--sid-w); }
  .tb-project { display: none; }
  .tb-sep    { display: none; }
  .user-name { display: none; }
  .status-badge { display: none; }
}
body.is-admin #view-stock {
  height: auto;
  flex: 1;
  min-height: 0;
}
body.is-admin .st-hdr { display: none !important; }
body.is-admin #view-operator { flex: 1; min-height: 0; }
body.is-admin .op-screen     { height: auto; flex: 1; min-height: 0; }
body.is-admin #view-operator .mob-header { display: none !important; }
