:root {
  --page: #f3f6f5;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --surface-tint: #edf5f2;
  --ink: #172522;
  --muted: #6f7f7b;
  --subtle: #94a29e;
  --line: #dfe7e4;
  --line-strong: #cddad6;
  --brand-950: #062b27;
  --brand-900: #0a3731;
  --brand-800: #0c493f;
  --brand-700: #0d6556;
  --brand-600: #11806b;
  --brand-500: #159a7f;
  --brand-100: #dff3ed;
  --brand-50: #eff9f6;
  --gold: #bf8d35;
  --gold-soft: #faf2e2;
  --danger: #c64743;
  --danger-soft: #fceceb;
  --warn: #b47819;
  --warn-soft: #fff5df;
  --info: #2b6ba8;
  --info-soft: #eaf3fb;
  --shadow-xs: 0 1px 2px rgba(13, 45, 38, 0.04);
  --shadow-sm: 0 8px 24px rgba(13, 45, 38, 0.07);
  --shadow-lg: 0 28px 70px rgba(4, 32, 27, 0.18);
  --radius-sm: 9px;
  --radius: 14px;
  --radius-lg: 20px;
  --sidebar-width: 264px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: "SF Arabic", "Geeza Pro", "Tajawal", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

button,
summary,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(21, 154, 127, 0.24);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.global-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: #f5f8f7;
  transition: opacity 180ms ease;
}

.global-loader img {
  width: min(240px, 65vw);
  height: 58px;
  object-fit: contain;
}

.global-loader strong {
  color: var(--brand-800);
  font-size: 0.9rem;
}

.loader-ring {
  width: 30px;
  height: 30px;
  border: 3px solid var(--brand-100);
  border-top-color: var(--brand-600);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--brand-600);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.eyebrow.light {
  color: #91d7c6;
}

.danger-text {
  color: var(--danger) !important;
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0.64rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 750;
  font-size: 0.84rem;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: #b7c9c3;
  box-shadow: var(--shadow-xs);
}

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

.btn.primary {
  border-color: var(--brand-600);
  color: #fff;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 7px 18px rgba(13, 101, 86, 0.18);
}

.btn.primary:hover:not(:disabled) {
  border-color: var(--brand-700);
  background: var(--brand-700);
}

.btn.secondary {
  border-color: #bdd9d1;
  color: var(--brand-700);
  background: var(--brand-50);
}

.btn.ghost {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.btn.danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.btn.danger-outline {
  border-color: #e5b5b2;
  color: var(--danger);
  background: var(--danger-soft);
}

.btn.small {
  min-height: 36px;
  padding: 0.42rem 0.74rem;
  font-size: 0.76rem;
}

.btn.wide {
  width: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface);
  font-size: 1.15rem;
}

.icon-btn:hover {
  color: var(--brand-700);
  border-color: #bcd3cc;
}

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

.text-btn {
  padding: 0;
  border: 0;
  color: var(--brand-600);
  background: transparent;
  font-weight: 750;
  font-size: 0.76rem;
}

/* Authentication */
.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(520px, 1.22fr);
  background: var(--surface);
}

.auth-card {
  width: min(100%, 470px);
  align-self: center;
  justify-self: center;
  padding: clamp(28px, 5vw, 54px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-logo {
  width: 180px;
  height: 58px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-brand span {
  color: var(--brand-600);
  font-size: 0.78rem;
  font-weight: 800;
}

.auth-brand h1 {
  margin: 2px 0 0;
  color: var(--brand-950);
  font-size: clamp(1.45rem, 2.4vw, 1.95rem);
}

.auth-intro {
  margin: 22px 0 24px;
  color: var(--muted);
  line-height: 1.8;
}

.auth-form,
.form-stack {
  display: grid;
  gap: 15px;
}

label {
  display: grid;
  gap: 7px;
  color: #43534f;
  font-size: 0.8rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.7rem 0.82rem;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.86rem;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
  color: #a0aca9;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(21, 154, 127, 0.1);
  outline: 0;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-left: 68px;
}

.field-action {
  position: absolute;
  left: 7px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 8px;
  border: 0;
  color: var(--brand-600);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
}

.auth-security {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.security-mark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-700);
  background: var(--brand-100);
  font-weight: 900;
}

.auth-aside {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  color: #fff;
  background:
    radial-gradient(circle at 12% 20%, rgba(59, 190, 158, 0.24), transparent 33%),
    radial-gradient(circle at 90% 85%, rgba(191, 141, 53, 0.18), transparent 36%),
    linear-gradient(145deg, #07352f, #082722 76%);
}

.auth-aside::before,
.auth-aside::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.auth-aside::before { top: -220px; right: -130px; }
.auth-aside::after { bottom: -260px; left: -80px; width: 520px; height: 520px; }

.auth-aside-content {
  width: min(78%, 680px);
  position: relative;
  z-index: 1;
}

.auth-aside h2 {
  margin: 12px 0 34px;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.4;
  letter-spacing: -0.035em;
}

.auth-feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-feature-grid div {
  display: grid;
  gap: 4px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(8px);
}

.auth-feature-grid strong { font-size: 0.9rem; }
.auth-feature-grid span { color: #a9c8c0; font-size: 0.75rem; }

/* Public QR view */
.public-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at 50% 0%, rgba(21, 154, 127, 0.13), transparent 34%),
    var(--page);
}

.public-card {
  width: min(100%, 500px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.public-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.public-brand img { width: 150px; height: 42px; object-fit: contain; }
.public-brand div { display: grid; gap: 2px; }
.public-brand span { color: var(--muted); font-size: 0.72rem; }
.public-brand strong { font-size: 1rem; }

.public-asset-code {
  margin: 24px 0 5px;
  color: var(--brand-600);
  font: 800 1.1rem ui-monospace, monospace;
  direction: ltr;
  text-align: right;
}

.public-asset-name { margin: 0 0 18px; font-size: 1.55rem; }
.public-asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.public-asset-grid div { display: grid; gap: 3px; padding: 12px; border-radius: 12px; background: var(--surface-soft); }
.public-asset-grid span { color: var(--muted); font-size: 0.7rem; }
.public-asset-grid strong { font-size: 0.85rem; }

.public-recovery-card {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px solid #bde3d8;
  border-radius: 16px;
  background: var(--brand-50);
}

.public-recovery-card.is-missing { border-color: #f1b8b8; background: var(--danger-soft); }
.public-recovery-label { color: var(--brand-700); font-size: 0.66rem; font-weight: 850; }
.public-recovery-card.is-missing .public-recovery-label { color: var(--danger); }
.public-recovery-card > strong { font-size: 0.96rem; }
.public-recovery-card p { margin: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.7; }
.public-recovery-card a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 5px;
  border-radius: 11px;
  color: #fff;
  background: var(--brand-600);
  font-size: 0.8rem;
  font-weight: 850;
  text-decoration: none;
}

.public-recovery-card.is-missing a { background: var(--danger); }
.public-recovery-card a:focus-visible { outline: 3px solid rgba(21, 154, 127, 0.25); outline-offset: 2px; }

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

.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  color: #dfeeea;
  background:
    radial-gradient(circle at 100% 0%, rgba(39, 154, 127, 0.18), transparent 28%),
    linear-gradient(180deg, var(--brand-950), #061f1c);
  direction: rtl;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo {
  width: 118px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand > div:nth-child(2) { min-width: 0; display: grid; gap: 1px; }
.sidebar-brand strong { color: #fff; font-size: 1.05rem; }
.sidebar-brand span { color: #8fb1a9; font-size: 0.67rem; white-space: nowrap; }

.main-nav {
  display: grid;
  gap: 5px;
  margin-top: 22px;
}

.nav-item {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 0.65rem 0.72rem;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #a9c0ba;
  background: transparent;
  text-align: right;
  font-size: 0.79rem;
  font-weight: 700;
  transition: color 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.nav-item svg { width: 21px; height: 21px; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.045); }
.nav-item.active { color: #fff; border-color: rgba(101, 219, 188, 0.14); background: rgba(40, 164, 134, 0.16); }
.nav-item.active svg { color: #6fd6bb; }
.nav-count { min-width: 25px; padding: 2px 6px; border-radius: 999px; color: #a9e5d6; background: rgba(88, 207, 174, 0.12); text-align: center; font-size: 0.65rem; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: #5ad4a7; box-shadow: 0 0 0 4px rgba(90, 212, 167, 0.11); }

.sidebar-help {
  display: flex;
  gap: 10px;
  margin-top: auto;
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
}

.help-icon {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #9fe3d2;
  background: rgba(94, 214, 183, 0.1);
  font: 800 0.75rem serif;
}

.sidebar-help div { display: grid; gap: 3px; }
.sidebar-help strong { font-size: 0.71rem; }
.sidebar-help span:last-child { color: #78978f; font-size: 0.62rem; line-height: 1.5; }

.sidebar-user {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 9px;
  padding: 12px 5px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #e8f8f4;
  background: var(--brand-700);
  font-size: 0.8rem;
  font-weight: 800;
}

.sidebar-user > div:nth-child(2) { min-width: 0; display: grid; gap: 1px; }
.sidebar-user strong { overflow: hidden; color: #e9f4f1; font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user span { color: #78988f; font-size: 0.62rem; }
.sidebar-user .icon-btn { width: 34px; height: 34px; border-color: rgba(255, 255, 255, 0.06); color: #8eaaa3; background: transparent; }

.app-main {
  min-width: 0;
  direction: rtl;
}

.topbar {
  min-height: 76px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(18px, 2.5vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.91);
  backdrop-filter: blur(15px);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title > div { display: grid; gap: 1px; }
.topbar-title span { color: var(--muted); font-size: 0.67rem; }
.topbar-title h1 { margin: 0; font-size: 1.14rem; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.68rem;
}

.system-status span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(21, 154, 127, 0.1);
}

.system-status.offline span { background: var(--danger); box-shadow: 0 0 0 4px rgba(198, 71, 67, 0.1); }

.actions-menu {
  position: relative;
}

.actions-menu summary {
  list-style: none;
}

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

.menu-popover {
  width: 220px;
  position: absolute;
  top: calc(100% + 9px);
  left: 0;
  z-index: 100;
  display: grid;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.menu-popover button {
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  color: #43534f;
  background: transparent;
  text-align: right;
  font-size: 0.74rem;
  font-weight: 700;
}

.menu-popover button:hover { color: var(--brand-700); background: var(--brand-50); }
.menu-popover hr { width: 100%; height: 1px; margin: 5px 0; border: 0; background: var(--line); }

.workspace {
  width: min(100%, 1580px);
  margin-inline: auto;
  padding: clamp(18px, 2.5vw, 34px);
}

.view {
  animation: viewIn 180ms ease both;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.view-head h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.view-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

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

.panel-head h3 {
  margin: 0;
  font-size: 0.98rem;
}

/* Dashboard */
.welcome-card {
  min-height: 146px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  overflow: hidden;
  position: relative;
  padding: 26px 28px;
  border-radius: 22px;
  color: #fff;
  background:
    radial-gradient(circle at 15% 30%, rgba(82, 196, 164, 0.2), transparent 29%),
    linear-gradient(110deg, var(--brand-950), var(--brand-800));
  box-shadow: var(--shadow-sm);
}

.welcome-card::after {
  content: "";
  width: 250px;
  height: 250px;
  position: absolute;
  left: -80px;
  bottom: -160px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.welcome-card h2 { margin: 0; font-size: 1.55rem; }
.welcome-card p { margin: 7px 0 0; color: #a8c7bf; font-size: 0.8rem; }
.welcome-actions { display: flex; gap: 9px; position: relative; z-index: 1; }
.welcome-actions .secondary { border-color: rgba(255, 255, 255, 0.14); color: #e9f8f4; background: rgba(255, 255, 255, 0.06); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
  margin: 18px 0;
}

.stat-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
}

.stat-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 1.05rem;
  font-weight: 900;
}

.stat-card.danger .stat-icon { color: var(--danger); background: var(--danger-soft); }
.stat-card.warning .stat-icon { color: var(--warn); background: var(--warn-soft); }
.stat-card.info .stat-icon { color: var(--info); background: var(--info-soft); }
.stat-card.value { border-color: #b8d9d2; background: linear-gradient(145deg, #f4fbf9, #fff); }
.stat-card.value .stat-icon { color: #fff; background: var(--brand-700); font-size: 0.67rem; }
.stat-card.value .stat-copy strong { color: var(--brand-800); font-size: 1.25rem; white-space: nowrap; }
.stat-copy { min-width: 0; display: grid; gap: 1px; }
.stat-copy span { color: var(--muted); font-size: 0.68rem; }
.stat-copy strong { font-size: 1.55rem; line-height: 1.2; }
.stat-copy small { overflow: hidden; color: var(--subtle); font-size: 0.62rem; text-overflow: ellipsis; white-space: nowrap; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 16px;
}

.dashboard-grid > .panel { padding: 20px; }
.activity-panel { grid-column: 1 / -1; }

.inventory-summary {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.progress-ring {
  width: 132px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 50%;
  background: conic-gradient(var(--brand-500) calc(var(--progress) * 1%), var(--brand-100) 0);
}

.progress-ring::after {
  content: "";
  width: 96px;
  aspect-ratio: 1;
  position: absolute;
  border-radius: 50%;
  background: var(--surface);
}

.progress-ring strong { position: relative; z-index: 1; font-size: 1.45rem; }
.progress-ring span { position: absolute; z-index: 1; margin-top: 34px; color: var(--muted); font-size: 0.6rem; }

.inventory-summary-copy { display: grid; gap: 10px; }
.inventory-summary-copy h4 { margin: 0; font-size: 1rem; }
.inventory-summary-copy p { margin: 0; color: var(--muted); font-size: 0.75rem; line-height: 1.65; }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; }
.legend-row span { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.67rem; }
.legend-row i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-500); }
.legend-row .missing i { background: var(--danger); }
.legend-row .unchecked i { background: #d0d9d6; }

.empty-inline {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 10px 0;
}

.empty-inline strong { font-size: 0.9rem; }
.empty-inline p { margin: 0; color: var(--muted); font-size: 0.74rem; }

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

.compact-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.compact-item-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.75rem;
  font-weight: 900;
}

.compact-item-copy { min-width: 0; display: grid; gap: 2px; }
.compact-item-copy strong { overflow: hidden; font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.compact-item-copy span { color: var(--muted); font-size: 0.63rem; }
.compact-item button { padding: 5px; border: 0; color: var(--brand-600); background: transparent; font-size: 0.7rem; font-weight: 750; }

/* Toolbar and tables */
.toolbar {
  display: grid;
  grid-template-columns: minmax(270px, 1.5fr) repeat(3, minmax(130px, 0.62fr)) auto;
  gap: 9px;
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 15px;
}

.search-box {
  position: relative;
}

.search-box svg {
  width: 18px;
  height: 18px;
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
}

.search-box input { padding-right: 40px; }
.toolbar input,
.toolbar select { min-height: 40px; padding-block: 0.55rem; font-size: 0.74rem; }

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
  padding: 10px 13px;
  border: 1px solid #b9dcd3;
  border-radius: 13px;
  background: var(--brand-50);
}

.bulk-actions strong { margin-left: auto; color: var(--brand-800); font-size: 0.75rem; }
.bulk-actions select { width: auto; min-height: 36px; padding-block: 0.35rem; font-size: 0.72rem; background: #fff; }

.table-panel {
  overflow: hidden;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.67rem;
}

.table-meta span:first-child { color: var(--ink); font-weight: 800; }
.table-scroll { overflow: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.data-table th {
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  text-align: right;
  font-size: 0.66rem;
  font-weight: 800;
}

.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid #ebf0ee;
  color: #3f4f4b;
  font-size: 0.73rem;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfcfc; }
.data-table tbody tr.is-selected td { background: var(--brand-50); }
.data-table .check-col { width: 42px; text-align: center; }
.data-table input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand-600); }

.asset-cell {
  min-width: 205px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.asset-symbol {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 0.72rem;
  font-weight: 900;
}

.asset-cell > div { min-width: 0; display: grid; gap: 1px; }
.asset-cell strong { overflow: hidden; color: var(--ink); font-size: 0.76rem; text-overflow: ellipsis; }
.asset-cell span { color: var(--brand-600); font: 750 0.62rem ui-monospace, monospace; direction: ltr; text-align: right; }
.asset-cell small { color: var(--subtle); font: 0.58rem ui-monospace, monospace; direction: ltr; text-align: right; }

.stack-cell { min-width: 140px; display: grid; gap: 2px; }
.stack-cell strong { color: #3e4e4a; font-size: 0.72rem; }
.stack-cell span { color: var(--muted); font-size: 0.63rem; }

.pill {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 800;
}

.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.success { color: #23775f; border-color: #c8e8de; background: #edf9f5; }
.pill.danger { color: var(--danger); border-color: #f2cecc; background: var(--danger-soft); }
.pill.warning { color: var(--warn); border-color: #ead6ae; background: var(--warn-soft); }
.pill.neutral { color: #60716d; border-color: #d8e1de; background: #f3f6f5; }
.pill.info { color: var(--info); border-color: #cbdff0; background: var(--info-soft); }

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.action-btn {
  min-height: 30px;
  padding: 0.34rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #52635e;
  background: #fff;
  font-size: 0.63rem;
  font-weight: 750;
}

.action-btn:hover { color: var(--brand-700); border-color: #bcd7cf; background: var(--brand-50); }
.action-btn.danger-action:hover { color: var(--danger); border-color: #e8b9b6; background: var(--danger-soft); }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 54px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state > span {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 14px;
  color: var(--brand-600);
  background: var(--brand-50);
  font-size: 1.1rem;
}

.empty-state strong { color: var(--ink); font-size: 0.9rem; }
.empty-state p { margin: 0; font-size: 0.72rem; }

/* Custody */
.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.mini-stat div { display: grid; gap: 2px; }
.mini-stat span { color: var(--muted); font-size: 0.67rem; }
.mini-stat strong { font-size: 1.22rem; }
.mini-stat i { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--brand-700); background: var(--brand-50); font-style: normal; font-weight: 900; }
.mini-stat.danger i { color: var(--danger); background: var(--danger-soft); }

.due-overdue { color: var(--danger); font-weight: 800; }

/* Inventory */
.inventory-empty {
  min-height: 410px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.inventory-illustration {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid #bde3d8;
  border-radius: 22px;
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 1.7rem;
  font-weight: 900;
}

.inventory-empty h3 { margin: 0; font-size: 1.15rem; }
.inventory-empty p { max-width: 480px; margin: 8px 0 20px; color: var(--muted); font-size: 0.78rem; line-height: 1.7; }

.inventory-workspace { display: grid; gap: 15px; }
.inventory-session-card { padding: 21px; }
.session-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.session-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.session-top h3 { margin: 8px 0 2px; font-size: 1.15rem; }
.session-top p { margin: 0; color: var(--muted); font-size: 0.7rem; }
.live-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; color: var(--brand-700); background: var(--brand-100); font-size: 0.61rem; font-weight: 800; }
.live-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-500); animation: pulse 1.6s ease infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.inventory-progress { margin-top: 19px; }
.progress-track { height: 10px; overflow: hidden; display: flex; border-radius: 999px; background: #e9efed; }
.progress-track span { height: 100%; }
.progress-track .present { background: var(--brand-500); }
.progress-track .missing { background: var(--danger); }
.progress-track .unchecked { background: #d5ddda; }
.progress-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 9px; }
.progress-meta span { color: var(--muted); font-size: 0.66rem; }
.progress-meta strong { margin-right: 4px; color: var(--ink); }

.inventory-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr); gap: 15px; }
.inventory-grid .panel { padding: 20px; }
.keyboard-hint { padding: 4px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--subtle); background: var(--surface-soft); font: 0.62rem ui-monospace, monospace; }
.scanner-form { display: grid; gap: 12px; }
.scanner-form input { height: 58px; font: 700 1.05rem ui-monospace, monospace; direction: ltr; text-align: right; }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.warehouse-btn { border: 1px solid #c8d5d2; color: #314c46; background: #eef3f2; }
.warehouse-btn:hover { border-color: #9fb6b1; background: #e4edeb; }
.scan-feedback { margin-top: 12px; padding: 11px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); background: var(--surface-soft); font-size: 0.7rem; }
.scan-feedback.success { color: var(--brand-700); border-color: #b9dfd4; background: var(--brand-50); }
.scan-feedback.error { color: var(--danger); border-color: #eac0bd; background: var(--danger-soft); }

/* Activity */
.activity-log-panel { padding: 20px; }
.activity-list,
.activity-timeline { display: grid; }

.activity-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 11px;
  position: relative;
  padding: 10px 0;
}

.activity-timeline .activity-item { padding: 15px 4px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.event-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--brand-700); background: var(--brand-50); font-size: 0.68rem; font-weight: 900; }
.event-icon.custody { color: var(--gold); background: var(--gold-soft); }
.event-icon.inventory { color: var(--info); background: var(--info-soft); }
.event-icon.archive { color: var(--danger); background: var(--danger-soft); }
.event-copy { min-width: 0; display: grid; gap: 3px; }
.event-copy strong { overflow: hidden; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.event-copy span { color: var(--muted); font-size: 0.63rem; }
.activity-item time { color: var(--subtle); font-size: 0.59rem; direction: ltr; }

/* Dialogs */
.app-dialog {
  width: min(94vw, 760px);
  max-height: min(90vh, 920px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.app-dialog::backdrop {
  background: rgba(4, 25, 21, 0.58);
  backdrop-filter: blur(4px);
}

.compact-dialog { width: min(94vw, 560px); }
.detail-dialog { width: min(95vw, 920px); }
.qr-dialog { width: min(94vw, 500px); }

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  padding: 19px 21px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.dialog-head h2 { margin: 0; font-size: 1.16rem; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 0.7rem; }
.dialog-head .icon-btn { width: 36px; height: 36px; flex: 0 0 auto; }
.dialog-body { padding: 20px 21px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid .full { grid-column: 1 / -1; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.identity-banner { margin: 16px 21px 0; padding: 12px 14px; border: 1px solid #beded5; border-radius: 12px; color: var(--brand-800); background: var(--brand-50); font-size: 0.74rem; }
.identity-banner strong { font-family: ui-monospace, monospace; direction: ltr; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 21px 19px;
  border-top: 1px solid var(--line);
}

.form-message {
  margin: 0 21px 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.7rem;
}

.form-message.error { color: #9d3733; border: 1px solid #ecc1bf; background: var(--danger-soft); }

.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 18px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(120deg, var(--brand-950), var(--brand-800));
}

.detail-code { color: #8fe0cc; font: 800 0.82rem ui-monospace, monospace; direction: ltr; text-align: right; }
.detail-hero h3 { margin: 5px 0 2px; font-size: 1.35rem; }
.detail-hero p { margin: 0; color: #a6c8bf; font-size: 0.72rem; }
.detail-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.detail-actions .btn { min-height: 36px; border-color: rgba(255, 255, 255, 0.13); color: #fff; background: rgba(255, 255, 255, 0.07); }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 13px 0 20px; }
.detail-kv { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.detail-kv span { color: var(--muted); font-size: 0.63rem; }
.detail-kv strong { overflow-wrap: anywhere; font-size: 0.75rem; }
.detail-section h4 { margin: 0 0 9px; font-size: 0.86rem; }

.qr-card { display: grid; justify-items: center; text-align: center; }
.qr-card-brand { display: flex; align-items: center; gap: 9px; justify-self: stretch; padding-bottom: 14px; border-bottom: 1px solid var(--line); text-align: right; }
.qr-card-brand img { width: 122px; height: 34px; object-fit: contain; }
.qr-card-brand div { display: grid; gap: 1px; }
.qr-card-brand span { color: var(--muted); font-size: 0.65rem; }
.qr-stage { margin: 20px 0 13px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.qr-stage .qr-code { position: relative; }
.qr-stage img,
.qr-stage canvas { display: block; }
.qr-logo-overlay { width: 19%; height: 19%; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; padding: 2px; border: 3px solid #fff; border-radius: 7px; background: #fff; object-fit: contain; }
.qr-card-code { color: var(--brand-700); font: 850 1.1rem ui-monospace, monospace; direction: ltr; }
.qr-card h3 { margin: 4px 0; font-size: 1rem; }
.qr-card p { margin: 0 0 16px; color: var(--muted); font-size: 0.68rem; }

.confirm-dialog { width: min(92vw, 430px); padding: 25px; text-align: center; }
.confirm-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 15px; color: var(--danger); background: var(--danger-soft); font-size: 1.2rem; font-weight: 900; }
.confirm-dialog h2 { margin: 0; font-size: 1.05rem; }
.confirm-dialog p { margin: 8px 0 18px; color: var(--muted); font-size: 0.75rem; line-height: 1.7; }
.confirm-dialog .dialog-actions { justify-content: center; padding: 0; border: 0; }

/* Toasts */
.toast-region {
  width: min(390px, calc(100vw - 28px));
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 1000;
  display: grid;
  gap: 8px;
}

.toast {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  opacity: 0;
  transition: 180ms ease;
}

.toast.visible { transform: none; opacity: 1; }
.toast-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--brand-700); background: var(--brand-100); font-weight: 900; }
.toast.error .toast-icon { color: var(--danger); background: var(--danger-soft); }
.toast span { font-size: 0.72rem; font-weight: 700; }
.toast button { border: 0; color: var(--subtle); background: transparent; }

.mobile-only { display: none; }
.sidebar-backdrop { display: none; }

/* Print labels */
.print-area { display: none; }

@media (max-width: 1350px) {
  .assets-table th:nth-child(7),
  .assets-table td:nth-child(7) {
    display: none;
  }
}

@media (max-width: 1180px) {
  :root { --sidebar-width: 228px; }
  .toolbar { grid-template-columns: minmax(240px, 1.5fr) repeat(2, minmax(130px, 0.7fr)); }
  .toolbar > :nth-child(4) { grid-column: 2; }
  .toolbar > :nth-child(5) { grid-column: 3; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card.value { grid-column: 1 / -1; }
  .auth-screen { grid-template-columns: minmax(340px, 0.9fr) 1.1fr; }
}

@media (max-width: 900px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-card { min-height: 100vh; display: grid; align-content: center; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    width: min(82vw, 300px);
    position: fixed;
    right: 0;
    transform: translateX(104%);
    transition: transform 180ms ease;
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 70; display: block; background: rgba(4, 25, 21, 0.45); }
  .mobile-only { display: inline-grid; }
  .sidebar-brand .mobile-only { margin-right: auto; border-color: rgba(255, 255, 255, 0.1); color: #fff; background: transparent; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .activity-panel { grid-column: auto; }
  .inventory-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .toolbar > :nth-child(4),
  .toolbar > :nth-child(5) { grid-column: auto; }
}

@media (max-width: 680px) {
  .topbar { min-height: 66px; padding: 10px 12px; }
  .topbar-title h1 { font-size: 0.98rem; }
  .topbar-title span,
  .system-status { display: none; }
  .topbar-actions { gap: 6px; }
  .topbar-actions > .btn { width: 40px; min-height: 40px; overflow: hidden; padding: 0; font-size: 0; }
  .topbar-actions > .btn span { display: block; font-size: 1rem; }
  .workspace { padding: 14px 11px 24px; }
  .view-head { align-items: flex-start; }
  .view-head h2 { font-size: 1.2rem; }
  .view-head p { max-width: 260px; line-height: 1.6; }
  .view-head > .btn { min-height: 38px; padding-inline: 0.75rem; font-size: 0.7rem; }
  .welcome-card { min-height: 185px; align-items: flex-start; flex-direction: column; padding: 22px; }
  .welcome-card h2 { font-size: 1.25rem; }
  .welcome-actions { width: 100%; }
  .welcome-actions .btn { flex: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { grid-template-columns: 36px minmax(0, 1fr); gap: 9px; padding: 13px 11px; border-radius: 14px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 11px; font-size: 0.8rem; }
  .stat-copy strong { font-size: 1.15rem; }
  .stat-copy small { display: none; }
  .dashboard-grid > .panel { padding: 15px; }
  .inventory-summary { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .inventory-summary-copy { justify-items: center; }
  .toolbar { grid-template-columns: 1fr 1fr; padding: 9px; }
  .toolbar select { min-width: 0; }
  .bulk-actions { flex-wrap: wrap; }
  .bulk-actions strong { width: 100%; margin: 0; }
  .bulk-actions select { flex: 1; }
  .table-meta span:last-child { display: none; }
  .data-table thead { display: none; }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .table-scroll { overflow: visible; }
  .data-table tbody { display: grid; gap: 8px; padding: 9px; }
  .data-table tbody tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 11px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
  .data-table td { padding: 0; border: 0; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--subtle); font-size: 0.58rem; }
  .data-table td.check-cell { grid-row: 1; grid-column: 1; }
  .data-table td.asset-data { grid-row: 1 / span 2; grid-column: 2; }
  .data-table td.category-data { display: none; }
  .data-table td.location-data,
  .data-table td.status-data,
  .data-table td.inventory-data { grid-column: span 1; }
  .data-table td.updated-data { display: none; }
  .data-table td.actions-data { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid var(--line); }
  .row-actions { justify-content: stretch; }
  .row-actions .action-btn { flex: 1; }
  .mini-stats { grid-template-columns: 1fr; gap: 8px; }
  .inventory-session-card { padding: 15px; }
  .session-top { align-items: stretch; flex-direction: column; }
  .session-actions .btn { flex: 1; }
  .scan-actions { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-actions { justify-content: flex-start; }
  .dialog-head { padding: 16px; }
  .dialog-body { padding: 16px; }
  .dialog-actions { padding: 12px 16px 16px; }
  .form-message { margin-inline: 16px; }
  .public-asset-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { grid-template-columns: 40px minmax(0, 1fr); }
  .toolbar { grid-template-columns: 1fr; }
  .search-box { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm !important;
    min-width: 210mm !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  body > :not(.print-area) {
    display: none !important;
  }

  .print-area {
    display: block !important;
    width: 210mm;
    margin: 0;
    padding: 0;
  }

  .print-page {
    width: 210mm;
    height: 297mm;
    display: block;
    padding: 5mm;
    overflow: hidden;
    page-break-after: always;
    break-after: page;
  }

  .print-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }

  .print-sheet {
    width: 200mm;
    display: grid;
    direction: ltr;
    align-content: start;
    justify-content: center;
  }

  .print-sheet.label-small { grid-template-columns: repeat(4, 40mm); grid-auto-rows: 30mm; gap: 3mm 5mm; }
  .print-sheet.label-medium { grid-template-columns: repeat(3, 50mm); grid-auto-rows: 30mm; gap: 3mm 5mm; }
  .print-sheet.label-large { grid-template-columns: repeat(3, 60mm); grid-auto-rows: 40mm; gap: 5mm; }

  .print-label {
    position: relative;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 50mm;
    height: 30mm;
    gap: 0.55mm 1.3mm;
    padding: 1.25mm 2.4mm 1mm 1.25mm;
    overflow: hidden;
    box-sizing: border-box;
    border: 0.25mm solid #9db5af;
    border-radius: 2mm;
    color: #092b26;
    background:
      linear-gradient(145deg, rgba(229, 244, 240, 0.72), transparent 18mm),
      #fff;
    direction: ltr;
    break-inside: avoid;
  }

  .print-label::before {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    width: 1.2mm;
    background: #075b50;
  }

  .print-label::after {
    content: "";
    position: absolute;
    top: 0;
    right: 1.2mm;
    width: 7mm;
    height: 0.55mm;
    background: #b8d9d2;
  }

  .label-small .print-label { width: 40mm; height: 30mm; padding: 1.2mm 2mm 1mm 1.2mm; gap: 0.55mm 1.1mm; border-width: 0.25mm; border-radius: 2mm; }
  .label-medium .print-label { width: 50mm; height: 30mm; }
  .label-large .print-label { width: 60mm; height: 40mm; padding: 2mm 2.8mm 1.6mm 2mm; gap: 0.9mm 2mm; border-width: 0.3mm; border-radius: 2.6mm; }

  .label-small .print-label::before { width: 1.1mm; }
  .label-small .print-label::after { right: 1.1mm; width: 6mm; height: 0.5mm; }
  .label-large .print-label::before { width: 1.4mm; }
  .label-large .print-label::after { right: 1.4mm; width: 8mm; height: 0.7mm; }

  .label-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding-bottom: 0.5mm;
    border-bottom: 0.22mm solid #d7e3e0;
    direction: rtl;
  }

  .label-brand { display: flex; align-items: center; min-width: 0; gap: 0.7mm; direction: rtl; }
  .label-brand-mark { width: 4mm; height: 4mm; display: grid; place-items: center; flex: 0 0 auto; border-radius: 1mm; background: #e7f2ef; }
  .label-brand-mark img { width: 3.25mm; height: 3.25mm; object-fit: contain; }
  .label-brand-copy { display: grid; gap: 0.15mm; line-height: 1.05; text-align: right; }
  .label-brand-copy strong { color: #092b26; font-size: 5.4pt; font-weight: 900; }
  .label-brand-copy small { display: none; color: #5e746f; font-size: 4.4pt; font-weight: 650; }
  .label-brand-en { display: none; }
  .label-category { display: none; max-width: 23mm; overflow: hidden; padding: 0.8mm 1.6mm; border: 0.2mm solid #c5dad5; border-radius: 999px; color: #075b50; background: #edf6f4; font-size: 4.7pt; font-weight: 800; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }

  .label-small .label-header { padding-bottom: 0.5mm; }
  .label-small .label-brand { gap: 0.7mm; }
  .label-small .label-brand-mark { width: 4mm; height: 4mm; border-radius: 1mm; }
  .label-small .label-brand-mark img { width: 3.25mm; height: 3.25mm; }
  .label-small .label-brand-copy strong { font-size: 5.4pt; }

  .label-large .label-header { padding-bottom: 1mm; }
  .label-large .label-brand { gap: 1.3mm; }
  .label-large .label-brand-mark { width: 5.5mm; height: 5.5mm; border-radius: 1.5mm; }
  .label-large .label-brand-mark img { width: 4.4mm; height: 4.4mm; }
  .label-large .label-brand-copy strong { font-size: 6.8pt; }
  .label-large .label-brand-subtitle { display: block; font-size: 4.4pt; }
  .label-large .label-brand-en { display: none; }
  .label-large .label-category { display: block; max-width: 23mm; }

  .label-qr-block { align-self: center; display: grid; justify-items: center; gap: 0.35mm; }
  .label-qr-block > span { color: #5c706b; font-size: 3.5pt; font-weight: 750; line-height: 1; }
  .label-qr { position: relative; padding: 0.45mm; border: 0.22mm solid #d2dfdc; border-radius: 1.1mm; background: #fff; }
  .label-qr img:not(.qr-logo-overlay),
  .label-qr canvas { width: 15.5mm !important; height: 15.5mm !important; display: block; image-rendering: crisp-edges; }
  .label-small .label-qr img:not(.qr-logo-overlay),
  .label-small .label-qr canvas { width: 16mm !important; height: 16mm !important; }
  .label-large .label-qr img:not(.qr-logo-overlay),
  .label-large .label-qr canvas { width: 20.5mm !important; height: 20.5mm !important; }
  .label-qr .qr-logo-overlay { width: 15% !important; height: 15% !important; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); padding: 0.35mm; border: 0.65mm solid #fff; border-radius: 0.9mm; background: #fff; object-fit: contain; }
  .label-small .label-qr { padding: 0.55mm; border-radius: 1mm; }
  .label-small .label-qr-block { gap: 0.2mm; }
  .label-small .label-qr-block > span { display: none; }
  .label-small .label-qr .qr-logo-overlay { display: none; }
  .label-large .label-qr { padding: 0.8mm; border-radius: 1.5mm; }
  .label-large .label-qr-block { gap: 0.55mm; }
  .label-large .label-qr-block > span { font-size: 4.3pt; }

  .label-details {
    min-width: 0;
    display: grid;
    align-content: center;
    gap: 0.35mm;
    direction: rtl;
    text-align: right;
  }

  .label-kicker { color: #66807a; font-size: 3.4pt; font-weight: 700; line-height: 1; }
  .label-code { overflow: hidden; color: #006f60; font: 900 7.1pt ui-monospace, "SFMono-Regular", Consolas, monospace; direction: ltr; line-height: 1.05; text-align: right; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0.12pt; }
  .label-name { overflow: hidden; color: #092b26; font-size: 5.4pt; font-weight: 900; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
  .label-info { display: grid; gap: 0.25mm; margin-top: 0.25mm; }
  .label-info-item { min-width: 0; display: block; color: #4f6661; font-size: 3.5pt; line-height: 1.05; }
  .label-info-item em { color: #7a908b; font-style: normal; white-space: nowrap; }
  .label-info-item strong { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

  .label-location-row,
  .label-info-item em { display: none; }

  .label-small .label-details { gap: 0.35mm; }
  .label-small .label-kicker { font-size: 3.3pt; }
  .label-small .label-code { font-size: 7.2pt; letter-spacing: 0.08pt; }
  .label-small .label-name { font-size: 5.2pt; }
  .label-small .label-location-row { display: none; }
  .label-small .label-info { margin-top: 0.2mm; }
  .label-small .label-info-item { font-size: 3.2pt; }

  .label-large .label-details { gap: 0.65mm; }
  .label-large .label-kicker { font-size: 4.5pt; }
  .label-large .label-code { font-size: 9pt; letter-spacing: 0.18pt; }
  .label-large .label-name { font-size: 7.2pt; }
  .label-large .label-info { gap: 0.45mm; margin-top: 0.45mm; }
  .label-large .label-info-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1mm; font-size: 4.5pt; }
  .label-large .label-location-row { display: grid; }
  .label-large .label-info-item em { display: inline; }

  .label-footer {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    padding-top: 0.45mm;
    border-top: 0.22mm solid #d7e3e0;
    color: #617772;
    font-size: 3.2pt;
    font-weight: 750;
    line-height: 1;
    direction: rtl;
  }
  .label-footer span:last-child { display: none; color: #78908a; font-family: ui-monospace, monospace; font-size: 3.8pt; direction: ltr; letter-spacing: 0.25pt; }
  .label-small .label-footer { display: none; }
  .label-large .label-footer { padding-top: 0.8mm; font-size: 4.1pt; }
  .label-large .label-footer span:last-child { display: inline; font-size: 3.8pt; }

  /* High-contrast output tuned for 203 DPI direct-thermal printers. */
  .print-label {
    border-color: #000;
    border-width: 0.4mm;
    color: #000;
    background: #fff;
  }
  .print-label::before { background: #000; }
  .print-label::after { display: none; }
  .label-header { border-bottom: 0.35mm solid #000; }
  .label-brand-mark {
    border: 0.3mm solid #000;
    background: #fff;
  }
  .label-brand-mark img { filter: grayscale(1) contrast(4); }
  .label-brand-copy strong,
  .label-brand-copy small,
  .label-category,
  .label-qr-block > span,
  .label-kicker,
  .label-code,
  .label-name,
  .label-info-item,
  .label-info-item em,
  .label-footer { color: #000; }
  .label-category {
    border: 0.3mm solid #000;
    background: #fff;
  }
  .label-qr {
    border: 0.35mm solid #000;
    border-radius: 0;
    background: #fff;
  }
  .label-qr .qr-logo-overlay { display: none !important; }
  .label-kicker,
  .label-info-item strong,
  .label-info-item em { font-weight: 850; }
  .label-footer { border-top: 0.35mm solid #000; }

  .label-large .print-label {
    padding: 1.8mm 2.8mm 1.4mm 1.8mm;
    border-width: 0.4mm;
  }
  .label-large .label-header { padding-bottom: 0.8mm; }
  .label-large .label-brand-mark { width: 6mm; height: 6mm; border-radius: 1mm; }
  .label-large .label-brand-mark img { width: 4.9mm; height: 4.9mm; }
  .label-large .label-brand-copy strong { font-size: 8pt; }
  .label-large .label-brand-copy small { font-size: 5.2pt; font-weight: 800; }
  .label-large .label-category { padding: 0.75mm 1.4mm; font-size: 5.5pt; }
  .label-large .label-qr { padding: 0.65mm; }
  .label-large .label-qr-block > span { font-size: 5pt; font-weight: 900; }
  .label-large .label-kicker { font-size: 5.2pt; }
  .label-large .label-code { font-size: 10pt; letter-spacing: 0; }
  .label-large .label-name { font-size: 8.2pt; line-height: 1.15; }
  .label-large .label-info { gap: 0.55mm; margin-top: 0.55mm; }
  .label-large .label-info-item { gap: 1mm; font-size: 5.5pt; line-height: 1.1; }
  .label-large .label-footer { padding-top: 0.65mm; font-size: 5pt; font-weight: 900; }
  .label-large .label-footer span:last-child { display: none; }

  html[data-print-mode="roll"],
  html[data-print-mode="roll"] body { min-width: 0 !important; }
  html[data-print-mode="roll"][data-label-size="small"],
  html[data-print-mode="roll"][data-label-size="small"] body,
  .print-area[data-mode="roll"][data-size="small"],
  .print-area[data-mode="roll"][data-size="small"] .print-page,
  .print-area[data-mode="roll"][data-size="small"] .print-sheet { width: 40mm !important; height: 30mm !important; }
  html[data-print-mode="roll"][data-label-size="medium"],
  html[data-print-mode="roll"][data-label-size="medium"] body,
  .print-area[data-mode="roll"][data-size="medium"],
  .print-area[data-mode="roll"][data-size="medium"] .print-page,
  .print-area[data-mode="roll"][data-size="medium"] .print-sheet { width: 50mm !important; height: 30mm !important; }
  html[data-print-mode="roll"][data-label-size="large"],
  html[data-print-mode="roll"][data-label-size="large"] body,
  .print-area[data-mode="roll"][data-size="large"],
  .print-area[data-mode="roll"][data-size="large"] .print-page,
  .print-area[data-mode="roll"][data-size="large"] .print-sheet { width: 60mm !important; height: 40mm !important; }
  .print-area[data-mode="roll"] .print-page { padding: 0; }
  .print-area[data-mode="roll"] .print-sheet { display: block; }
}
