:root {
    --green-950: #043d2b;
    --green-900: #07563c;
    --green-800: #086747;
    --green-700: #08734f;
    --green-600: #0a865d;
    --green-500: #16a36f;
    --green-100: #dcf6ea;
    --green-50: #eefaf5;
    --page: #f3f6f3;
    --surface: #ffffff;
    --surface-soft: #f7f9f7;
    --surface-strong: #edf2ee;
    --text: #17211b;
    --text-soft: #657169;
    --line: #dfe6e1;
    --danger: #c93f47;
    --danger-soft: #fff0f1;
    --warning: #a66b09;
    --warning-soft: #fff7df;
    --shadow: 0 14px 38px rgba(19, 60, 42, 0.08);
    --shadow-strong: 0 22px 60px rgba(13, 66, 45, 0.14);
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;
    --radius-xl: 34px;
    --sidebar-width: 270px;
    --header-height: 76px;
    color-scheme: light;
}

html[data-theme="dark"] {
    --page: #07110d;
    --surface: #101b16;
    --surface-soft: #14221b;
    --surface-strong: #1b2b23;
    --text: #edf7f0;
    --text-soft: #9fb0a6;
    --line: #2a3a31;
    --green-50: #102b20;
    --green-100: #173f2e;
    --danger-soft: #32191d;
    --warning-soft: #312710;
    --shadow: 0 16px 45px rgba(0, 0, 0, 0.28);
    --shadow-strong: 0 25px 70px rgba(0, 0, 0, 0.42);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--page); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
svg.icon { width: 21px; height: 21px; flex: 0 0 auto; }
svg.icon-xl { width: 42px; height: 42px; }
code { padding: 2px 6px; border-radius: 7px; background: var(--surface-strong); font-size: .86em; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.muted { color: var(--text-soft); }
.grow { flex: 1; }
.text-right { text-align: right; }
.center { justify-content: center; text-align: center; }
.hide-mobile { display: inline-flex; }

.eyebrow { display: inline-flex; align-items: center; gap: 7px; color: var(--green-700); font-size: 11px; line-height: 1; letter-spacing: .13em; font-weight: 800; text-transform: uppercase; }
html[data-theme="dark"] .eyebrow { color: #73d9ad; }
.eyebrow.light { color: rgba(255,255,255,.76); }

.icon-button, .round-arrow, .round-back { width: 42px; height: 42px; padding: 0; border: 1px solid var(--line); border-radius: 8px !important; background: var(--surface); color: var(--text-soft); display: inline-flex; align-items: center; justify-content: center; transition: .18s ease; }
.icon-button:hover, .round-arrow:hover, .round-back:hover { color: var(--green-700); border-color: rgba(10,134,93,.35); background: var(--green-50); transform: translateY(-1px); }
.icon-button.small { width: 34px; height: 34px; border-radius: 8px !important; }
.icon-button.danger { color: var(--danger); }
.icon-button.danger:hover { background: var(--danger-soft); border-color: rgba(201,63,71,.35); }
.round-arrow { border-radius: 8px !important; }
.round-arrow.static { pointer-events: none; background: var(--green-50); color: var(--green-700); border-color: transparent; }
.round-back { border-radius: 8px !important; }

.primary-button, .soft-button, .danger-button, .text-button { min-height: 40px; border-radius: 8px !important; border: 1px solid transparent; padding: 8px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750; font-size: 14px; transition: .18s ease; white-space: nowrap; }
.primary-button { color: #fff; background: var(--green-700); box-shadow: 0 9px 20px rgba(8,115,79,.18); }
.primary-button:hover { background: var(--green-800); transform: translateY(-1px); }
.soft-button { color: var(--text); background: var(--surface); border-color: var(--line); }
.soft-button:hover { color: var(--green-700); background: var(--green-50); border-color: rgba(10,134,93,.32); }
.danger-button { color: var(--danger); background: var(--danger-soft); border-color: rgba(201,63,71,.28); }
.danger-button:hover { background: #ffe3e5; }
html[data-theme="dark"] .danger-button:hover { background: #472129; }
.text-button { padding-left: 8px; padding-right: 8px; color: var(--text-soft); background: transparent; }
.compact { min-height: 34px; padding: 6px 12px; border-radius: 8px !important; font-size: 12px; }
.full { width: 100%; }
.text-link, .mini-link { display: inline-flex; align-items: center; gap: 5px; color: var(--green-700); font-weight: 720; font-size: 13px; border: 0; background: transparent; padding: 0; }
html[data-theme="dark"] .text-link, html[data-theme="dark"] .mini-link { color: #74dcaf; }
.text-link.centered { width: 100%; justify-content: center; margin-top: 20px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack-buttons { display: grid; gap: 10px; margin-top: 22px; }

/* Universal Subtle Square Button Radius (8px) */
button,
.btn-primary-glow,
.btn-subtle,
.btn-qr-download,
.primary-button,
.soft-button,
.danger-button,
.text-button,
.icon-button,
.select-box select,
.search-box {
  border-radius: 8px !important;
}

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 15px; border: 1px solid; display: flex; align-items: center; gap: 11px; font-size: 14px; }
.alert-success { color: #08724e; background: #eafaf3; border-color: #bfead6; }
.alert-error { color: #a52731; background: var(--danger-soft); border-color: #f1c5c8; }
html[data-theme="dark"] .alert-success { color: #8be5bc; background: #0e3022; border-color: #20553e; }
html[data-theme="dark"] .alert-error { color: #ffafb5; border-color: #583039; }
.alert-icon { display: inline-flex; }
.alert-close { margin-left: auto; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: currentColor; opacity: .65; }
.alert-close svg { width: 17px; }

/* Admin shell */
.app-shell { min-height: 100vh; display: flex; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 80; width: var(--sidebar-width); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); transition: width .22s ease, transform .22s ease; }
.sidebar-brand { height: var(--header-height); padding: 14px 16px; display: flex; align-items: center; border-bottom: 1px solid var(--line); gap: 10px; }
.brand-mark { min-width: 0; display: flex; align-items: center; gap: 11px; flex: 1; }
.brand-logo { width: 44px; height: 44px; border-radius: 15px; background: linear-gradient(145deg, var(--green-700), var(--green-500)); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 9px 22px rgba(8,115,79,.22); flex: 0 0 auto; }
.brand-logo.large { width: 54px; height: 54px; border-radius: 18px; }
.brand-logo svg { width: 23px; }
.brand-text { min-width: 0; display: grid; line-height: 1.2; }
.brand-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--green-800); }
html[data-theme="dark"] .brand-text strong { color: #8fe1bd; }
.brand-text small { color: var(--text-soft); font-size: 11px; margin-top: 3px; }
.sidebar-collapse,
.desktop-sidebar-button,
.mobile-menu-button {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
  color: var(--text-soft);
  transition: color 0.2s ease, transform 0.2s ease;
}

.sidebar-collapse:hover,
.desktop-sidebar-button:hover,
.mobile-menu-button:hover {
  color: var(--green-700);
  background: transparent !important;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 18px 13px; }
.nav-item { min-height: 45px; display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-radius: 13px; margin-bottom: 5px; color: var(--text-soft); font-size: 14px; font-weight: 670; transition: .18s ease; border-bottom: 2px solid transparent; }
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active { color: var(--green-700); background: transparent; border-radius: 0; border-bottom: 2px solid var(--green-700); }
html[data-theme="dark"] .nav-item.active { color: #84dfb7; background: transparent; border-bottom: 2px solid #84dfb7; }
.nav-section-label { padding: 18px 13px 8px; color: var(--text-soft); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-account { margin: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; display: flex; align-items: center; gap: 10px; background: var(--surface-soft); }
.account-avatar, .mini-avatar, .user-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(145deg, var(--green-700), #43b383); font-weight: 800; flex: 0 0 auto; }
.account-copy { flex: 1; min-width: 0; display: grid; }
.account-copy strong, .account-copy small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-copy strong { font-size: 13px; }
.account-copy small { color: var(--text-soft); font-size: 11px; }
.account-copy + form .icon-button { width: 33px; height: 33px; }
.workspace { min-width: 0; width: calc(100% - var(--sidebar-width)); margin-left: var(--sidebar-width); transition: width .22s ease, margin-left .22s ease; }
.topbar { position: sticky; top: 0; z-index: 55; height: var(--header-height); padding: 0 28px; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); transition: transform .22s ease, height .22s ease, opacity .22s ease; }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: 10px; }
.desktop-sidebar-button { display: inline-flex; }
.mobile-menu-button { display: none; }
.topbar-title { display: grid; line-height: 1.2; }
.topbar-title span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); }
.topbar-title strong { font-size: 15px; margin-top: 2px; }
.mini-avatar { width: 38px; height: 38px; }

.topbar-public-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 4px;
  transition: color 0.2s ease;
}
.topbar-public-link:hover {
  color: var(--green-700);
}
.topbar-public-link svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}
.topbar-public-link:hover svg {
  transform: translateX(3px);
}

.user-avatar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0;
  cursor: pointer;
  color: var(--text-soft);
  transition: color 0.2s ease;
}
.user-avatar-btn:hover {
  color: var(--green-700);
}
.user-avatar-btn svg {
  width: 15px;
  height: 15px;
  transition: transform 0.2s ease;
}
.user-dropdown-wrap.active .user-avatar-btn svg {
  transform: rotate(180deg);
}

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

.topbar button[data-theme-toggle] {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
  color: var(--text-soft);
  transition: color 0.2s ease, transform 0.2s ease;
}

.topbar button[data-theme-toggle] svg {
  width: 18px;
  height: 18px;
  display: block;
}

.topbar button[data-theme-toggle]:hover {
  color: var(--green-700);
  background: transparent !important;
}

/* Header Notification Bell & Popover Dropdown */
.notif-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.notif-bell-btn {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 32px !important;
  height: 32px !important;
  color: var(--text-soft);
  transition: color 0.2s ease, transform 0.2s ease;
}

.notif-bell-btn:hover {
  color: var(--green-700);
  background: transparent !important;
}

.notif-bell-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.notif-red-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.notif-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 310px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.2s ease;
}

.notif-dropdown-wrap.is-active .notif-dropdown-menu {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
  z-index: 99999 !important;
}

/* Toast Container & Alert Toast Animations */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast-container .alert {
  pointer-events: auto;
  margin: 0;
  width: 340px;
  max-width: 100%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-container .alert.toast-exit {
  transform: translateX(120%);
  opacity: 0;
}

/* Notifikasi Dropdown Customization */
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.notif-dot.bg-success { background-color: #10b981; }
.notif-dot.bg-info { background-color: #3b82f6; }
.notif-dot.bg-warning { background-color: #f59e0b; }
.notif-dot.bg-danger { background-color: #ef4444; }

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  position: relative;
  transition: background 0.15s ease;
}

.notif-item:hover {
  background: var(--surface-soft);
}

.notif-item.unread {
  background: rgba(8, 115, 79, 0.04);
}

html[data-theme="dark"] .notif-item.unread {
  background: rgba(132, 223, 183, 0.04);
}

.notif-item.unread::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background-color: var(--green-700);
  border-radius: 50%;
}

html[data-theme="dark"] .notif-item.unread::before {
  background-color: #84dfb7;
}

.notif-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
  align-self: flex-start;
  margin-left: auto;
}

.notif-item:hover .notif-delete-btn {
  opacity: 0.6;
}

.notif-delete-btn:hover {
  opacity: 1 !important;
  color: #dc2626 !important;
}

.notif-text {
  margin: 0;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
}

.notif-time {
  font-size: 11px;
  color: var(--text-soft);
  display: block;
  margin-top: 4px;
}

/* Reference Image Toolbar Layout: Search Left, Action Controls Right */
.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.6rem !important;
  flex-wrap: wrap;
  width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 320px !important;
  max-width: 100% !important;
  padding: 8px 12px;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box:focus-within {
  border-color: var(--green-700) !important;
  box-shadow: 0 0 0 3px rgba(8, 115, 79, 0.12) !important;
}

.search-box input {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 100% !important;
  font-size: 13px;
  color: var(--text);
}

.filter-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-box,
.select-box select {
  border: none !important;
  background: transparent !important;
  background-color: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft) !important;
  font-family: inherit;
  cursor: pointer;
}

.filter-actions-right input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.18s ease;
}

.select-box select:focus,
.filter-actions-right input[type="date"]:focus {
  border-color: var(--green-700) !important;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px !important;
  max-width: 280px !important;
  padding: 7px 12px;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box:focus-within {
  border-color: var(--green-700) !important;
  box-shadow: 0 0 0 3px rgba(8, 115, 79, 0.12) !important;
}

.search-box input {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: 100% !important;
  font-size: 13px;
  color: var(--text);
}

.select-box select {
  padding: 7px 12px;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.18s ease;
}

.select-box select:focus {
  border-color: var(--green-700) !important;
}

/* Clean Framed Table Container (Single Crisp Border Box) */
.dash-section {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin-bottom: 1.5rem;
  box-shadow: none !important;
}

.dash-table-container {
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  overflow: hidden !important;
  background: var(--surface) !important;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.02);
}

.dash-table th {
  padding: 10px 14px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  color: var(--text-soft) !important;
  background: var(--surface-soft) !important;
  border-bottom: 1px solid var(--line) !important;
}

.dash-table td {
  padding: 12px 14px !important;
  border-bottom: 1px solid var(--line) !important;
  vertical-align: middle !important;
}

.dash-table tbody tr:last-child td {
  border-bottom: none !important;
}

.visibility-dot-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 650;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}
.visibility-dot-text.text-active { color: var(--green-700); }
.visibility-dot-text.text-inactive { color: var(--text-soft); opacity: 0.7; }

.tag-badge {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-family: inherit !important;
  font-weight: 600 !important;
  color: var(--text-soft) !important;
}

.qr-raw-img {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  width: 44px !important;
  height: 44px !important;
}

.btn-page, .btn-page-active {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px !important;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn-page {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
}
.btn-page:hover {
  border-color: var(--green-700);
  color: var(--green-700);
}
.btn-page-active {
  border: none;
  background: var(--green-700);
  color: #ffffff;
}

/* Light Switch / Stop Kontak Lampu Toggle Style */
.archive-switch-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px !important;
  padding: 3px;
  user-select: none;
}

.archive-switch-btn {
  position: relative;
  z-index: 2;
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.22s ease;
  border-radius: 6px !important;
}

.archive-switch-btn.active {
  color: var(--green-700);
}

html[data-theme="dark"] .archive-switch-btn.active {
  color: #8fe1bd;
}

.archive-switch-glider {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  width: calc(50% - 3px);
  background: var(--surface);
  border-radius: 6px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  z-index: 1;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.archive-switch-wrapper[data-active="archived"] .archive-switch-glider {
  transform: translateX(100%);
}

.dash-table th.text-right,
.dash-table th:last-child {
  text-align: left !important;
}

.theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-dark { display: inline-flex; }
html[data-theme="dark"] .theme-icon-light { display: none; }
.show-header-button { position: fixed; right: 20px; top: 14px; z-index: 60; display: none; align-items: center; gap: 7px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px; color: var(--text-soft); background: var(--surface); box-shadow: var(--shadow); font-size: 12px; }
.main-content { max-width: 1540px; margin: 0 auto; padding: 28px 30px 110px; }

body.sidebar-collapsed .sidebar { transform: translateX(-100%); width: 0; opacity: 0; visibility: hidden; overflow: hidden; }
body.sidebar-collapsed .workspace { width: 100%; margin-left: 0; }
body.sidebar-collapsed .desktop-sidebar-button { transform: rotate(180deg); }
body.sidebar-collapsed .dash-wrapper { max-width: 100%; }
body.sidebar-collapsed .main-content { max-width: 100%; }
body.header-hidden .topbar { transform: translateY(-100%); height: 0; opacity: 0; overflow: hidden; border: 0; }
body.header-hidden .show-header-button { display: inline-flex; }
.mobile-overlay, .mobile-bottom-nav { display: none; }

/* General headings and form */
.page-heading, .dashboard-head, .detail-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 24px; }
.page-heading h1, .dashboard-head h1, .detail-page-head h1 { margin: 7px 0 3px; font-size: clamp(28px, 3vw, 42px); line-height: 1.08; letter-spacing: -.035em; }
.page-heading p, .dashboard-head p, .detail-page-head p { margin: 0; }
.breadcrumb-link { display: flex; align-items: center; gap: 5px; color: var(--text-soft); font-size: 12px; margin-bottom: 11px; }
.breadcrumb-link svg { width: 17px; }
.date-chip { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); color: var(--text-soft); font-size: 13px; }
.form-section, .form-panel, .settings-form, .content-card, .record-form-card, .record-list-card, .upload-side-card, .qr-settings-card { padding: 24px; }
.form-section + .form-section { margin-top: 18px; }
.form-section-title, .card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.form-section-title > span { width: 42px; height: 42px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; color: var(--green-700); background: var(--green-50); flex: 0 0 auto; }
.form-section-title > div { flex: 1; }
.form-section-title h2, .card-heading h2 { margin: 0; font-size: 19px; line-height: 1.25; }
.form-section-title p, .card-heading p { margin: 4px 0 0; color: var(--text-soft); font-size: 13px; }
.card-heading > div { min-width: 0; }
.card-heading .eyebrow { margin-bottom: 7px; }
.form-grid { display: grid; gap: 17px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-span { grid-column: 1 / -1; }
.stack-form { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; position: relative; }
.field > span, .select-wrap > span { font-size: 12px; font-weight: 750; color: var(--text); }
.field b { color: var(--danger); }
.field small { color: var(--text-soft); font-size: 11px; }
.field input, .field select, .field textarea, .select-wrap select, .search-input input, .qr-url-box input { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; outline: 0; background: var(--surface-soft); transition: .16s ease; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .select-wrap select:focus, .search-input input:focus { border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(22,163,111,.13); background: var(--surface); }
.input-with-action { display: flex; position: relative; }
.input-with-action input { padding-right: 62px; }
.inside-button { position: absolute; right: 5px; top: 5px; height: 34px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--green-50); color: var(--green-700); font-weight: 800; font-size: 11px; }
.inline-check { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 11px; font-weight: 500; margin-top: 2px; }
.inline-check input { width: 16px; min-height: auto; height: 16px; accent-color: var(--green-700); }
.password-field input { padding-right: 48px; }
.password-toggle { position: absolute; right: 7px; bottom: 7px; width: 34px; height: 32px; border: 0; background: transparent; color: var(--text-soft); display: flex; align-items: center; justify-content: center; }
.toggle-field { display: flex; align-items: flex-start; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.toggle-field input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { width: 43px; height: 24px; border-radius: 999px; background: #aeb8b1; position: relative; flex: 0 0 auto; transition: .2s ease; }
.toggle-ui::after { content: ""; width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; box-shadow: 0 2px 5px rgba(0,0,0,.22); transition: .2s ease; }
.toggle-field input:checked + .toggle-ui { background: var(--green-600); }
.toggle-field input:checked + .toggle-ui::after { transform: translateX(19px); }
.toggle-field > span:last-child { display: grid; }
.toggle-field strong { font-size: 13px; }
.toggle-field small { color: var(--text-soft); font-size: 11px; margin-top: 2px; }
.large-toggle { margin-bottom: 20px; padding: 17px; }
.upload-zone { min-height: 150px; border: 1.5px dashed #a6c8b7; border-radius: 18px; background: var(--green-50); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--green-700); position: relative; cursor: pointer; padding: 18px; text-align: center; }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone strong { font-size: 14px; }
.upload-zone small { color: var(--text-soft); font-size: 11px; }
.compact-zone { min-height: 130px; }
.image-preview-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.image-preview-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.form-info-box, .info-callout, .public-verification-note { margin-top: 16px; padding: 13px; border-radius: 14px; display: flex; gap: 10px; align-items: flex-start; color: var(--text-soft); background: var(--green-50); font-size: 12px; }
.form-info-box svg, .info-callout svg, .public-verification-note svg { color: var(--green-700); flex: 0 0 auto; }
.form-info-box p, .info-callout p, .public-verification-note span { margin: 0; }
.warning-box { padding: 13px 14px; border-radius: 14px; background: var(--warning-soft); color: var(--warning); font-size: 12px; }
.warning-box p { margin: 4px 0 0; }
.note-box { margin-top: 15px; padding: 14px; border-radius: 14px; background: var(--surface-soft); }
.note-box p { margin: 4px 0 0; color: var(--text-soft); font-size: 13px; }

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(340px, .8fr); gap: 20px; }
.farm-weather-card { min-height: 285px; position: relative; overflow: hidden; padding: 30px; border-radius: var(--radius-xl); color: #fff; background: linear-gradient(145deg, #075e40, #0a865d); box-shadow: 0 24px 55px rgba(6,89,61,.23); }
.farm-weather-card::before { content: ""; width: 310px; height: 310px; border-radius: 50%; position: absolute; right: -90px; top: -120px; background: rgba(255,255,255,.08); }
.farm-weather-copy { position: relative; z-index: 2; }
.farm-weather-copy > span { font-size: 13px; color: rgba(255,255,255,.75); }
.farm-weather-copy > strong { display: block; font-size: 68px; line-height: 1; margin: 16px 0 0; letter-spacing: -.06em; }
.farm-weather-copy h2 { margin: 2px 0 4px; font-size: 24px; }
.farm-weather-copy p { margin: 0; color: rgba(255,255,255,.75); font-size: 13px; }
.farm-weather-art { position: absolute; right: 35px; top: 47px; width: 160px; height: 130px; }
.farm-weather-art span { position: absolute; display: flex; align-items: center; justify-content: center; }
.art-sun { right: 10px; top: 0; width: 70px; height: 70px; border-radius: 50%; color: #ffd87d; background: rgba(255,255,255,.13); }
.art-goat { left: 5px; bottom: 0; color: #fff; }
.art-cow { right: 20px; bottom: -5px; color: rgba(255,255,255,.78); }
.farm-weather-bottom { position: absolute; left: 30px; right: 30px; bottom: 24px; padding-top: 17px; display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.78); font-size: 12px; }
.compact-heading { margin-top: 25px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.section-heading h2 { margin: 6px 0 0; font-size: 21px; }
.quick-category-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.quick-category-grid a { min-height: 112px; padding: 15px; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; display: flex; flex-direction: column; align-items: flex-start; transition: .18s ease; }
.quick-category-grid a:hover { border-color: rgba(10,134,93,.35); transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-category-grid a > span { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; color: var(--green-700); background: var(--green-50); border-radius: 12px; margin-bottom: 12px; }
.quick-category-grid strong { font-size: 13px; }
.quick-category-grid small { color: var(--text-soft); font-size: 10px; }
.notes-card { padding: 22px; height: 100%; }
.recent-list { display: grid; gap: 2px; margin-bottom: 17px; }
.recent-item { display: grid; grid-template-columns: 56px minmax(0,1fr) 20px; gap: 11px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recent-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 14px; background: var(--surface-strong); }
.recent-item > div { min-width: 0; display: grid; }
.recent-item strong, .recent-item span, .recent-item small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.recent-item strong { font-size: 13px; }
.recent-item span { color: var(--text-soft); font-size: 11px; }
.recent-item small { color: var(--green-700); font-size: 10px; margin-top: 2px; }
.recent-item > svg { width: 17px; color: var(--text-soft); }
.empty-mini { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--text-soft); padding: 20px; }
.empty-mini.tall { min-height: 300px; }
.empty-mini p { max-width: 280px; font-size: 13px; }
.metrics-grid { margin-top: 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { padding: 18px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); display: flex; align-items: flex-start; gap: 12px; }
.metric-card > span { width: 42px; height: 42px; border-radius: 14px; background: var(--green-50); color: var(--green-700); display: flex; align-items: center; justify-content: center; }
.metric-card > div { display: grid; }
.metric-card small { color: var(--text-soft); font-size: 11px; }
.metric-card strong { font-size: 27px; line-height: 1.1; }
.metric-card p { color: var(--text-soft); font-size: 10px; margin: 4px 0 0; }

/* Tables and animal list */
.filter-card { padding: 15px; margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.filter-form { flex: 1; display: flex; align-items: flex-end; gap: 10px; }
.search-input { min-height: 44px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 13px; padding: 0 12px; background: var(--surface-soft); }
.search-input input { min-height: 40px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.search-input input:focus { box-shadow: none; }
.search-input svg { color: var(--text-soft); }
.select-wrap { min-width: 155px; display: grid; gap: 6px; }
.archive-switch, .section-tabs { display: flex; align-items: center; gap: 5px; padding: 4px; border-radius: 14px; background: var(--surface-soft); }
.archive-switch a, .section-tabs a { min-height: 36px; padding: 8px 12px; border-radius: 10px; display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 12px; font-weight: 750; }
.archive-switch a.active, .section-tabs a.active { background: var(--surface); color: var(--green-700); box-shadow: 0 3px 10px rgba(20,50,35,.08); }
.section-tabs { width: fit-content; margin-bottom: 18px; padding: 5px; }
.section-tabs a { min-height: 42px; padding-inline: 16px; }
.table-card { overflow: hidden; }
.table-summary { padding: 14px 19px; display: flex; justify-content: space-between; color: var(--text-soft); font-size: 12px; border-bottom: 1px solid var(--line); }
.responsive-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 16px; color: var(--text-soft); background: var(--surface-soft); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; text-align: left; white-space: nowrap; }
td { padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--green-50) 50%, transparent); }
.animal-cell { min-width: 170px; display: flex; align-items: center; gap: 11px; }
.animal-cell img { width: 48px; height: 48px; border-radius: 13px; object-fit: cover; background: var(--surface-strong); }
.animal-cell > div, td > span.table-subtext { display: grid; }
.animal-cell span, .table-subtext { color: var(--text-soft); font-size: 11px; margin-top: 2px; }
.status-badge, .visibility-badge, .role-badge, .record-type { width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; gap: 5px; }
.status-badge { margin-top: 5px; }
.status-active, .visibility-badge.on { color: #08724e; background: #e3f7ed; }
.status-sold { color: #986208; background: #fff4d5; }
.status-deceased, .visibility-badge.off { color: #a7343c; background: #ffe9eb; }
html[data-theme="dark"] .status-active, html[data-theme="dark"] .visibility-badge.on { color: #8ce4bc; background: #123b2a; }
html[data-theme="dark"] .status-sold { color: #eec96d; background: #382d12; }
html[data-theme="dark"] .status-deceased, html[data-theme="dark"] .visibility-badge.off { color: #ffadb3; background: #3b1c22; }
.visibility-badge svg { width: 13px; height: 13px; }
.qr-table-cell { display: flex; align-items: center; gap: 9px; }
.qr-table-cell img { width: 56px; height: 56px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.qr-table-cell > div { display: grid; gap: 4px; }
.qr-table-cell small { color: var(--text-soft); font-size: 10px; }
.qr-table-cell .mini-link svg { width: 13px; }
.table-actions, .row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 5px; }
.table-actions form, .row-actions form { display: inline-flex; }
.mobile-animal-list { display: none; }
.empty-state { min-height: 390px; padding: 35px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-icon, .disabled-icon { width: 86px; height: 86px; border-radius: 28px; background: var(--green-50); color: var(--green-700); display: flex; align-items: center; justify-content: center; }
.empty-state h2 { margin: 18px 0 6px; }
.empty-state p { color: var(--text-soft); max-width: 470px; margin: 0 0 20px; }

/* Animal form/detail */
.animal-form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.sticky-card { position: sticky; top: calc(var(--header-height) + 20px); padding: 22px; }
.detail-page-head { align-items: center; justify-content: flex-start; }
.detail-page-head > div:nth-child(2) { flex: 1; }
.detail-page-head h1 { font-size: 31px; }
.detail-head-actions { display: flex; align-items: center; gap: 8px; }
.animal-detail-hero { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(480px, 1.2fr); gap: 18px; }
.animal-visual-card { min-height: 445px; padding: 20px; position: relative; overflow: hidden; }
.visual-topline { display: flex; justify-content: space-between; position: relative; z-index: 3; }
.animal-main-photo { min-height: 320px; display: flex; align-items: center; justify-content: center; position: relative; }
.animal-main-photo img { width: 80%; height: 300px; object-fit: contain; position: relative; z-index: 2; border-radius: 20px; }
.visual-ring { position: absolute; left: 12%; right: 12%; bottom: 22px; height: 36px; border: 2px solid rgba(8,115,79,.42); border-radius: 50%; z-index: 1; }
.visual-ring span { display: block; width: 36px; height: 8px; border-radius: 999px; background: var(--green-700); position: absolute; left: calc(50% - 18px); top: -5px; }
.photo-thumbs { display: flex; justify-content: center; gap: 7px; }
.photo-thumbs img, .thumb-empty { width: 54px; height: 48px; border-radius: 12px; object-fit: cover; border: 2px solid transparent; background: var(--surface-strong); }
.photo-thumbs img.active { border-color: var(--green-600); }
.thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--text-soft); }
.animal-summary-sheet { padding: 27px; display: flex; flex-direction: column; }
.summary-header { display: flex; justify-content: space-between; gap: 20px; }
.summary-header > div:first-child > span { color: var(--green-700); font-size: 12px; font-weight: 800; }
.summary-header h2 { font-size: 28px; margin: 4px 0 2px; }
.summary-header p { color: var(--text-soft); margin: 0; }
.summary-price { text-align: right; }
.summary-price small { display: block; color: var(--text-soft); font-size: 11px; }
.summary-price strong { font-size: 20px; }
.summary-stock-row { margin: 20px 0; padding: 12px 0; border-block: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 12px; color: var(--text-soft); }
.summary-stock-row span { display: flex; align-items: center; gap: 6px; }
.summary-stock-row svg { width: 16px; color: var(--green-700); }
.summary-description h3 { margin: 0 0 5px; font-size: 14px; }
.summary-description p { margin: 0; color: var(--text-soft); font-size: 13px; }
.summary-metrics { margin-top: 22px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.summary-metrics > div { padding: 13px; border-radius: 15px; background: var(--surface-soft); display: grid; }
.summary-metrics > div > span { color: var(--green-700); margin-bottom: 8px; }
.summary-metrics small { color: var(--text-soft); font-size: 10px; }
.summary-metrics strong { font-size: 16px; }
.summary-action-row { margin-top: auto; padding-top: 22px; display: flex; gap: 9px; }
.detail-tabs { margin: 18px 0; padding: 6px; display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 4px; overflow-x: auto; }
.detail-tabs a { min-height: 48px; padding: 9px 10px; border-radius: 13px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--text-soft); font-size: 12px; font-weight: 750; white-space: nowrap; }
.detail-tabs a.active { color: #fff; background: var(--green-700); }
.detail-tabs small { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--surface-strong); color: var(--text-soft); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; }
.detail-tabs a.active small { background: rgba(255,255,255,.18); color: #fff; }
.detail-content-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 20px; margin: 0; }
.info-grid div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.info-grid dt { color: var(--text-soft); font-size: 10px; }
.info-grid dd { margin: 3px 0 0; font-size: 13px; font-weight: 720; }
.parent-cards { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.parent-card { padding: 14px; border: 1px solid var(--line); border-radius: 16px; display: flex; align-items: center; gap: 11px; }
.parent-icon { width: 42px; height: 42px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.parent-icon.female { color: #b44772; background: #fcecf3; }
.parent-icon.male { color: #3972b7; background: #edf4fc; }
html[data-theme="dark"] .parent-icon.female { background: #38212c; }
html[data-theme="dark"] .parent-icon.male { background: #1e2c3e; }
.parent-card > div { display: grid; min-width: 0; }
.parent-card small, .parent-card p { color: var(--text-soft); font-size: 10px; margin: 0; }
.parent-card strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.record-layout { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 18px; align-items: start; }
.record-form-card { position: sticky; top: calc(var(--header-height) + 18px); }
.record-total { padding: 7px 10px; border-radius: 11px; color: var(--green-700); background: var(--green-50); font-size: 11px; }
.timeline-list { display: grid; }
.timeline-item { position: relative; min-height: 86px; display: grid; grid-template-columns: 20px minmax(0,1fr) auto; gap: 11px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.timeline-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--green-600); box-shadow: 0 0 0 5px var(--green-50); margin-top: 5px; }
.timeline-item > div:nth-child(2) { display: grid; align-content: start; }
.timeline-item small { color: var(--text-soft); font-size: 10px; }
.timeline-item strong { font-size: 14px; margin: 2px 0; }
.timeline-item p { color: var(--text-soft); font-size: 11px; margin: 0; }
.record-label-row { display: flex; align-items: center; gap: 7px; }
.record-type { color: var(--green-700); background: var(--green-50); }
.health-timeline .timeline-item strong { font-weight: 600; }
.photos-layout, .qr-detail-layout, .settings-layout { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 18px; align-items: start; }
.photo-gallery { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.gallery-item { position: relative; border-radius: 17px; overflow: hidden; border: 2px solid transparent; background: var(--surface-soft); }
.gallery-item.primary { border-color: var(--green-600); }
.gallery-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.primary-photo-label { position: absolute; left: 8px; top: 8px; padding: 5px 8px; border-radius: 999px; color: #fff; background: rgba(8,115,79,.9); display: flex; gap: 4px; align-items: center; font-size: 9px; font-weight: 800; }
.primary-photo-label svg { width: 12px; }
.gallery-actions { padding: 9px; display: flex; justify-content: space-between; gap: 6px; }
.upload-side-card { position: sticky; top: calc(var(--header-height) + 18px); }
.qr-large-card { padding: 28px; text-align: center; }
.qr-large-frame { width: min(310px, 100%); aspect-ratio: 1; padding: 17px; border-radius: 26px; background: #fff; border: 1px solid var(--line); margin: 0 auto 20px; box-shadow: 0 18px 40px rgba(13,66,45,.09); }
.qr-large-frame img { width: 100%; height: 100%; }
.qr-large-card h2 { font-size: 27px; margin: 8px 0 3px; }
.qr-large-card p { color: var(--text-soft); font-size: 13px; margin: 0 0 19px; }
.qr-url-box { margin-bottom: 18px; }
.qr-url-box > span { display: block; color: var(--text-soft); font-size: 10px; margin-bottom: 6px; }
.qr-url-box > div { display: flex; gap: 7px; }
.qr-url-box input { font-size: 11px; }
.qr-info-list { display: grid; gap: 10px; margin-bottom: 18px; }
.qr-info-list > div { display: flex; align-items: flex-start; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 14px; }
.qr-info-list > div > svg { color: var(--green-700); }
.qr-info-list span { display: grid; }
.qr-info-list strong { font-size: 12px; }
.qr-info-list small { color: var(--text-soft); font-size: 10px; margin-top: 2px; }
.qr-settings-card form + form { margin-top: 9px; }

/* Admin master/users/settings/scan */
.admin-two-column { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 18px; align-items: start; }
.form-panel { position: sticky; top: calc(var(--header-height) + 18px); }
.user-list { display: grid; }
.user-row { display: grid; grid-template-columns: 46px minmax(0,1fr) auto auto; gap: 11px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.user-avatar { width: 44px; height: 44px; }
.user-copy { display: grid; min-width: 0; }
.user-copy strong, .user-copy span, .user-copy small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.user-copy span { color: var(--text-soft); font-size: 11px; }
.user-copy small { color: var(--green-700); font-size: 10px; }
.role-admin { color: #875b00; background: #fff0bd; }
.role-staff { color: #32689e; background: #eaf3fc; }
html[data-theme="dark"] .role-admin { color: #ffd87c; background: #3d3013; }
html[data-theme="dark"] .role-staff { color: #9dcdf9; background: #192d42; }
.settings-preview { padding: 23px; position: sticky; top: calc(var(--header-height) + 18px); }
.settings-preview h2 { margin: 7px 0 18px; }
.mini-phone-preview { max-width: 285px; margin: 0 auto 18px; padding: 13px; border-radius: 28px; background: #edf0ed; color: #142019; box-shadow: inset 0 0 0 1px #d5dbd7; }
.mini-phone-status { padding: 0 5px 9px; display: flex; justify-content: space-between; font-size: 9px; font-weight: 800; }
.mini-phone-green { min-height: 190px; padding: 17px; border-radius: 22px; color: #fff; background: linear-gradient(145deg,#08734f,#0a8c61); display: flex; flex-direction: column; }
.mini-phone-green small { opacity: .7; }
.mini-phone-green strong { font-size: 22px; line-height: 1.15; margin: auto 0 8px; }
.mini-phone-green p { font-size: 9px; opacity: .78; margin: 0; }
.mini-phone-card { margin-top: 9px; padding: 12px; border-radius: 16px; background: #fff; display: flex; align-items: center; gap: 9px; }
.mini-phone-card > span { color: var(--green-700); }
.mini-phone-card > div { display: grid; }
.mini-phone-card strong { font-size: 10px; }
.mini-phone-card small { color: #6c766f; font-size: 8px; }
.scanner-layout { display: grid; grid-template-columns: minmax(0,1.2fr) 360px; gap: 18px; align-items: start; }
.scanner-card, .scanner-side .card { padding: 20px; }
.scanner-side { display: grid; gap: 16px; }
.scanner-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.scanner-live { display: flex; align-items: center; gap: 7px; color: var(--text-soft); font-size: 11px; font-weight: 700; }
.scanner-live i { width: 8px; height: 8px; border-radius: 50%; background: #9aa59e; }
.scanner-live.active i { background: #20bf7d; box-shadow: 0 0 0 5px rgba(32,191,125,.12); }
.scanner-view { min-height: 490px; position: relative; overflow: hidden; border-radius: 22px; background: #07110d; }
.scanner-view video { width: 100%; height: 490px; object-fit: cover; }
.scanner-frame { position: absolute; inset: 12% 17%; pointer-events: none; }
.scanner-frame > span { position: absolute; width: 45px; height: 45px; border-color: #7ff0bf; border-style: solid; }
.scanner-frame > span:nth-child(1) { left: 0; top: 0; border-width: 4px 0 0 4px; border-radius: 10px 0 0 0; }
.scanner-frame > span:nth-child(2) { right: 0; top: 0; border-width: 4px 4px 0 0; border-radius: 0 10px 0 0; }
.scanner-frame > span:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 4px 4px; border-radius: 0 0 0 10px; }
.scanner-frame > span:nth-child(4) { right: 0; bottom: 0; border-width: 0 4px 4px 0; border-radius: 0 0 10px 0; }
.scan-line { position: absolute; left: 5%; right: 5%; top: 15%; height: 2px; background: linear-gradient(90deg,transparent,#7ff0bf,transparent); box-shadow: 0 0 15px #7ff0bf; animation: scanline 2.3s ease-in-out infinite; }
@keyframes scanline { 0%,100% { top: 13%; opacity: .4; } 50% { top: 86%; opacity: 1; } }
.scanner-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #c6d3cb; text-align: center; gap: 5px; background: radial-gradient(circle at center, #153225, #07110d 65%); }
.scanner-placeholder small { opacity: .65; max-width: 280px; }
.scanner-placeholder.hidden { display: none; }
.scanner-actions { display: flex; gap: 9px; margin-top: 12px; }
.scanner-support { color: var(--text-soft); font-size: 11px; margin: 12px 0 0; }
.scan-result { margin-top: 12px; padding: 12px; border-radius: 14px; display: grid; grid-template-columns: 35px minmax(0,1fr) auto; gap: 9px; align-items: center; background: var(--green-50); }
.scan-result > span { color: var(--green-700); }
.scan-result > div { min-width: 0; display: grid; }
.scan-result p { margin: 0; color: var(--text-soft); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Public */
.public-body { min-height: 100vh; background: radial-gradient(circle at 10% 5%, rgba(21,142,97,.13), transparent 28%), radial-gradient(circle at 95% 0%, rgba(7,96,65,.1), transparent 30%), var(--page); }
.public-header { position: sticky; top: 0; z-index: 9999; width: 100%; box-sizing: border-box; padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--green-800); background: var(--green-700); backdrop-filter: blur(12px); }
html[data-theme="dark"] .public-header { background: #064c35; border-bottom: 1px solid #033222; }
.public-brand { display: flex; align-items: center; gap: 10px; }
.public-brand > span:last-child { display: grid; line-height: 1.2; }
.public-brand strong { font-size: 14px; }
.public-brand small { color: var(--text-soft); font-size: 10px; }
.public-header-actions { display: flex; gap: 8px; align-items: center; }
.glass-button { background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(13px); }
.public-main { max-width: 1260px; margin: 0 auto; padding: 35px 28px 80px; }
.public-alert { max-width: 800px; margin-inline: auto; }

/* Hero Section */
.public-hero { min-height: 540px; display: grid; grid-template-columns: minmax(0,1.15fr) minmax(360px,.85fr); gap: 60px; align-items: center; margin-bottom: 60px; }

.public-hero-copy {
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.public-hero-copy h1 { margin: 15px 0; font-size: clamp(38px, 4.8vw, 64px); line-height: 1.08; letter-spacing: -.05em; font-weight: 800; max-width: 740px; }
.public-hero-copy > p { max-width: 620px; color: var(--text-soft); font-size: 16px; line-height: 1.7; }
.public-search { max-width: 580px; margin-top: 24px; }
.public-search > label { display: block; margin-bottom: 8px; font-size: 11.5px; font-weight: 750; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }

.search-control {
  min-height: 54px;
  padding: 6px 6px 6px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-control:focus-within {
  border-color: var(--green-700);
  box-shadow: 0 0 0 4px rgba(8, 115, 79, 0.08);
  transform: translateY(-1px);
}

.search-control > svg { color: var(--text-soft); }
.search-control input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 14px; }
.hero-actions { display: flex; align-items: center; gap: 15px; margin-top: 16px; }

/* Farm Overview Card (SaaS luxury dark theme) */
.farm-overview-card {
  min-height: 380px;
  padding: 30px;
  border-radius: 20px;
  color: #f0f4f2;
  background: #0d1412;
  border: 1px solid #1c2b26;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.16);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
  opacity: 0;
}

.farm-overview-top { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; }
.farm-overview-top > div:first-child { display: grid; }
.farm-overview-top span { color: #84dfb7; font-size: 11px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.05em; }
.farm-overview-top strong { font-size: 68px; line-height: 1; letter-spacing: -.05em; margin: 12px 0 2px; font-weight: 800; }
.farm-overview-top small { color: rgba(255,255,255,.65); font-size: 12px; }

.farm-sun {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(32, 191, 125, 0.08);
  color: #8be5bc;
  border: 1px solid rgba(32, 191, 125, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(32, 191, 125, 0.1); }
  50% { transform: scale(1.04); box-shadow: 0 0 20px 8px rgba(32, 191, 125, 0.04); }
}

.overview-divider { height: 1px; background: rgba(255,255,255,.08); margin: 20px 0 12px; }
.farm-overview-card > p { position: relative; z-index:2; color: rgba(255,255,255,.65); font-size: 12px; line-height: 1.5; margin: 0; }
.overview-mini-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top: 20px; }

.overview-mini-stats > div {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.04);
  display: grid;
  transition: background 0.2s;
}
.overview-mini-stats > div:hover {
  background: rgba(255,255,255,.06);
}

.overview-mini-stats span { color:#84dfb7; margin-bottom: 4px; }
.overview-mini-stats strong { font-size: 18px; font-weight: 700; }
.overview-mini-stats small { color:rgba(255,255,255,.5); font-size:9px; margin-top: 1px; text-transform: uppercase; }

/* Features Grid */
.public-feature-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin:40px 0 60px; }

.feature-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.feature-card:nth-child(1) { animation-delay: 0.1s; }
.feature-card:nth-child(2) { animation-delay: 0.2s; }
.feature-card:nth-child(3) { animation-delay: 0.3s; }
.feature-card:nth-child(4) { animation-delay: 0.4s; }

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.03);
  border-color: var(--green-700);
}

.feature-icon { width:40px; height:40px; border-radius:10px; color:var(--green-700); background:var(--green-50); display:flex; align-items:center; justify-content:center; margin-bottom:16px; }
.feature-card strong { display:block; font-size:13.5px; font-weight: 700; }
.feature-card p { color:var(--text-soft); font-size:11.5px; margin:6px 0 0; line-height:1.55; }

/* Animal Cards Grid */
.public-section { margin-bottom: 60px; }
.public-animal-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }

.public-animal-card {
  display:grid;
  grid-template-columns:68px minmax(0,1fr) 20px;
  align-items:center;
  gap:12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:var(--surface);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.public-animal-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(8, 115, 79, 0.03);
  border-color: var(--green-700);
}

.public-animal-card img { width:68px; height:68px; object-fit:cover; border-radius:10px; background:var(--surface-strong); }
.public-animal-card > div { display:grid; min-width:0; }
.public-animal-card > div span { color:var(--green-700); font-size:9px; font-weight:800; text-transform:uppercase; }
.public-animal-card strong, .public-animal-card small { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.public-animal-card small { color:var(--text-soft); font-size:10px; }
.public-animal-card > svg { color:var(--text-soft); }

/* Contact Card */
.public-contact-card {
  padding: 30px 40px;
  border-radius: 14px;
  color: var(--text-main);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
}

.public-contact-card:hover {
  transform: translateY(-2px);
  border-color: var(--green-700);
}

.public-contact-card .eyebrow { color: var(--green-700); }
.public-contact-card h2 { margin: 8px 0 4px; font-size: 22px; font-weight: 800; }
.public-contact-card p { margin: 0; color: var(--text-soft); font-size: 13px; }
.contact-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--dash-primary-light);
  color: var(--green-700);
  display: flex;
  align-items: center;
  justify-content: center;
}
.public-footer { max-width:1260px; margin:0 auto; padding:22px 28px; border-top:1px solid var(--line); color:var(--text-soft); font-size:11px; display:flex; justify-content:space-between; }
.disabled-public { min-height:500px; max-width:750px; margin:70px auto; padding:50px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.disabled-public h1 { max-width:540px; margin:17px 0 8px; font-size:40px; line-height:1.1; }
.disabled-public p { color:var(--text-soft); max-width:560px; }

/* Public animal detail */
.public-animal-detail { max-width: 850px; margin: 10px auto 60px; }
.public-detail-topbar { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; align-items:center; margin-bottom:10px; }
.public-detail-topbar > div { text-align:center; display:grid; }
.public-detail-topbar span { color:var(--text-soft); font-size:10px; }
.public-detail-topbar strong { font-size:13px; }
.verified-round { width:40px; height:40px; border-radius:50%; display:flex; align-items:center; justify-content:center; color:var(--green-700); background:var(--green-50); }
.public-animal-visual { min-height: auto; margin-bottom: 24px; display: flex; justify-content: center; position: relative; }
.public-animal-visual > img { width: 100%; max-width: 480px; height: 320px; object-fit: cover; border: 1px solid var(--line); padding: 5px; background: #fff; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,0.06); }

.public-slider-wrap {
  width: 100%;
  max-width: 480px;
  height: 320px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  padding: 5px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.public-slider-track {
  width: 100%;
  height: 100%;
  position: relative;
}

.public-slide {
  position: absolute;
  inset: 5px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-in-out, visibility 0.4s;
  z-index: 1;
}

.public-slide.active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}

.public-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 2px;
}

.slider-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.05);
  color: #0f1715;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.slider-nav:hover {
  background: #ffffff;
  transform: translateY(-50%) scale(1.05);
}

.slider-nav.prev { left: 15px; }
.slider-nav.next { right: 15px; }

.slider-dots {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

.slider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.slider-dot.active {
  background: #ffffff;
  transform: scale(1.2);
}

.public-detail-sheet {
  padding: 40px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  /* Stacked paper sheet effect */
  box-shadow: 
    0 1px 3px rgba(0,0,0,0.05),
    0 10px 0 -5px #ffffff,
    0 10px 1px -4px #d1d5db,
    0 20px 0 -10px #ffffff,
    0 20px 1px -9px #d1d5db;
}

[data-theme="dark"] .public-detail-sheet {
  background: #151e1b;
  border-color: #24352e;
  box-shadow: 
    0 1px 3px rgba(0,0,0,0.2),
    0 10px 0 -5px #151e1b,
    0 10px 1px -4px #24352e,
    0 20px 0 -10px #151e1b,
    0 20px 1px -9px #24352e;
}

.detail-sheet-header { display:flex; justify-content:space-between; gap:20px; border-bottom: 2px solid var(--text-main); padding-bottom: 15px; margin-bottom: 20px; }
.detail-sheet-header > div:first-child > span { color:var(--green-700); font-size:10px; font-weight:800; text-transform: uppercase; }
.detail-sheet-header h1 { margin:3px 0 1px; font-size:27px; font-weight: 700; }
.detail-sheet-header p { margin:0; color:var(--text-soft); font-size:12px; }
.public-tag { text-align:right; }
.public-tag span { color:var(--text-soft); font-size:9px; display:block; }
.public-tag strong { font-size:16px; font-family: monospace; }

.public-stat-row { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 16px 0; }
.public-stat-row > div { padding:0; border-radius:0; background:transparent; display:grid; text-align:center; }
.public-stat-row > div:not(:last-child) { border-right: 1px solid var(--line); }
.public-stat-row small { color:var(--text-soft); font-size:9px; margin-top:5px; text-transform: uppercase; letter-spacing: 0.05em; }
.public-stat-row strong { font-size:14px; margin-top: 2px; }

.detail-description h2, .related-photos h2 { font-size:12px; margin:0 0 12px; text-transform: uppercase; letter-spacing: 0.08em; border-bottom: 1px solid var(--text-main); padding-bottom: 4px; color: var(--text-main); }
.detail-list { margin:0 0 20px 0; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:0 30px; }
.detail-list div { padding:8px 0; border-bottom:1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.detail-list dt { color:var(--text-soft); font-size:11px; }
.detail-list dd { margin:0; font-size:12px; font-weight:700; }
.related-photos { margin-top:20px; }
.photo-strip { display:flex; gap:8px; overflow-x:auto; padding-bottom:3px; }
.photo-strip img { width:88px; height:70px; border-radius:4px; border: 1px solid var(--line); object-fit:cover; flex:0 0 auto; }

/* Login */
.guest-body { min-height:100vh; padding:35px; display:flex; align-items:center; justify-content:center; background:radial-gradient(circle at 10% 10%,rgba(17,150,100,.25),transparent 32%),linear-gradient(145deg,#496f60,#2e5346); }
.guest-theme { position:fixed; right:20px; top:20px; z-index:3; }
.login-wrap { width:min(1100px,100%); }
.login-phone-card { min-height:680px; display:grid; grid-template-columns:1.05fr .95fr; overflow:hidden; border-radius:36px; background:var(--surface); box-shadow:0 35px 90px rgba(0,0,0,.25); }
.login-visual { padding:35px; position:relative; overflow:hidden; color:#fff; background:linear-gradient(160deg,#07583c,#07815a); }
.login-visual::after { content:""; width:380px; height:380px; border-radius:50%; position:absolute; right:-160px; top:-120px; background:rgba(255,255,255,.08); }
.login-brand-row { display:flex; align-items:center; gap:12px; position:relative; z-index:2; }
.login-brand-row > span:last-child { display:grid; }
.login-brand-row small { color:rgba(255,255,255,.65); font-size:10px; }
.login-illustration { height:350px; position:relative; }
.animal-bubble { position:absolute; width:105px; height:105px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:rgba(255,255,255,.13); backdrop-filter:blur(8px); }
.animal-bubble.goat { left:12%; top:30%; }
.animal-bubble.cow { right:15%; top:47%; }
.field-lines { position:absolute; left:-10%; right:-10%; bottom:20px; height:110px; border:2px solid rgba(255,255,255,.18); border-radius:50%; transform:rotate(-4deg); }
.field-lines::after { content:""; position:absolute; inset:25px -20px; border:2px solid rgba(255,255,255,.12); border-radius:50%; }
.login-copy { position:relative; z-index:2; max-width:470px; }
.login-copy h1 { margin:11px 0 9px; font-size:40px; line-height:1.06; letter-spacing:-.04em; }
.login-copy p { margin:0; color:rgba(255,255,255,.72); font-size:13px; }
.login-form-panel { padding:65px 60px; display:flex; flex-direction:column; justify-content:center; }
.login-form-panel h2 { margin:9px 0 3px; font-size:33px; letter-spacing:-.035em; }
.login-form-panel > p { margin:0 0 23px; font-size:13px; }
.login-form { margin-top:3px; }
.mobile-brand-small { display:none; }

/* Error */
.error-state { min-height:440px; padding:45px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.error-code { font-size:90px; line-height:1; color:var(--green-700); font-weight:900; letter-spacing:-.08em; }
.error-state h1 { margin:8px 0; }
.error-state p { color:var(--text-soft); max-width:600px; }
.error-details { max-width:100%; max-height:260px; overflow:auto; padding:15px; border-radius:14px; text-align:left; background:var(--surface-soft); color:var(--danger); font-size:10px; }

@media (max-width: 1180px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .notes-card { height:auto; }
    .metrics-grid { grid-template-columns:repeat(2,1fr); }
    .animal-detail-hero { grid-template-columns:1fr 1fr; }
    .animal-form-layout { grid-template-columns:minmax(0,1fr) 310px; }
    .public-hero { gap:30px; }
    .public-feature-grid { grid-template-columns:repeat(2,1fr); }
}

@media (max-width: 930px) {
    :root { --header-height:68px; }
    .sidebar { transform:translateX(-105%); width:280px; box-shadow:var(--shadow-strong); }
    body.mobile-menu-open .sidebar { transform:translateX(0); }
    .workspace, body.sidebar-collapsed .workspace { width:100%; margin-left:0; }
    body.sidebar-collapsed .sidebar { width:280px; }
    body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .nav-section-label, body.sidebar-collapsed .account-copy, body.sidebar-collapsed .sidebar-account form { display:initial; }
    body.sidebar-collapsed .brand-mark { justify-content:flex-start; }
    body.sidebar-collapsed .nav-item { justify-content:flex-start; padding:10px 13px; }
    body.sidebar-collapsed .sidebar-account { justify-content:flex-start; padding:12px; }
    .sidebar-collapse { display:none; }
    .mobile-menu-button { display:none; }
    .desktop-sidebar-button { display:inline-flex; }
    .mobile-overlay { position:fixed; inset:0; z-index:70; background:rgba(3,19,12,.5); backdrop-filter:blur(3px); }
    body.mobile-menu-open .mobile-overlay { display:block; }
    .main-content { padding:22px 20px 105px; }
    .animal-form-layout, .animal-detail-hero, .detail-content-grid, .record-layout, .photos-layout, .qr-detail-layout, .admin-two-column, .settings-layout, .scanner-layout { grid-template-columns:1fr; }
    .sticky-card, .record-form-card, .upload-side-card, .form-panel, .settings-preview { position:static; }
    .animal-detail-hero { max-width:760px; margin-inline:auto; }
    .animal-visual-card { min-height:390px; }
    .detail-tabs { grid-template-columns:repeat(6,150px); }
    .public-hero { grid-template-columns:1fr; padding-top:30px; }
    .farm-overview-card { max-width:600px; width:100%; justify-self:center; }
    .public-hero-copy { text-align:center; }
    .public-hero-copy > p, .public-search { margin-left:auto; margin-right:auto; }
    .hero-actions { justify-content:center; }
    .public-hero-copy .eyebrow { justify-content:center; }
    .login-phone-card { grid-template-columns:1fr; max-width:580px; margin:auto; }
    .login-visual { display:none; }
    .login-form-panel { min-height:650px; padding:50px; }
    .mobile-brand-small { display:flex; align-items:center; gap:10px; margin-bottom:55px; }
}

@media (max-width: 700px) {
    .admin-body { background:var(--surface-soft); }
    .topbar { padding:0 15px; }
    .topbar-title span { display:none; }
    .topbar-title strong { font-size:13px; }
    .topbar-actions .soft-button, .topbar-actions > .icon-button:last-of-type { display:none; }
    .main-content { padding:17px 13px 104px; }
    .mobile-bottom-nav { position:fixed; left:10px; right:10px; bottom:calc(8px + env(safe-area-inset-bottom)); z-index:65; min-height:66px; padding:7px 12px; border:1px solid var(--line); border-radius:22px; background:color-mix(in srgb,var(--surface) 94%,transparent); backdrop-filter:blur(18px); box-shadow:0 12px 35px rgba(0,0,0,.18); display:grid; grid-template-columns:repeat(5,1fr); align-items:end; }
    .mobile-bottom-nav a, .mobile-bottom-nav button { min-width:0; border:0; background:transparent; color:var(--text-soft); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; font-size:9px; padding:4px 1px; }
    .mobile-bottom-nav svg { width:20px; }
    .mobile-bottom-nav a.active, .mobile-bottom-nav button.active { color:var(--green-700); }
    .mobile-scan-action { align-self:start; margin-top:-23px; }
    .mobile-scan-action > span { width:50px; height:50px; border-radius:17px; display:flex; align-items:center; justify-content:center; color:#fff; background:var(--green-700); box-shadow:0 10px 24px rgba(8,115,79,.3); }
    .mobile-scan-action small { margin-top:3px; font-size:9px; }
    .page-heading, .dashboard-head { align-items:flex-start; flex-direction:column; margin-bottom:17px; gap:13px; }
    .page-heading h1, .dashboard-head h1 { font-size:30px; }
    .page-heading > .primary-button, .page-heading > .soft-button { width:100%; }
    .date-chip { display:none; }
    .farm-weather-card { min-height:270px; padding:22px; border-radius:27px; }
    .farm-weather-copy > strong { font-size:58px; }
    .farm-weather-art { right:15px; top:48px; transform:scale(.8); transform-origin:right top; }
    .farm-weather-bottom { left:22px; right:22px; bottom:20px; }
    .quick-category-grid { grid-template-columns:repeat(2,1fr); }
    .quick-category-grid a { min-height:105px; }
    .metrics-grid { grid-template-columns:1fr 1fr; gap:9px; }
    .metric-card { padding:13px; flex-direction:column; gap:8px; }
    .metric-card > span { width:36px; height:36px; }
    .metric-card strong { font-size:23px; }
    .metric-card p { display:none; }
    .filter-card { align-items:stretch; flex-direction:column; padding:12px; }
    .filter-form { display:grid; grid-template-columns:1fr auto; align-items:end; }
    .filter-form .search-input { grid-column:1/-1; }
    .select-wrap { min-width:0; }
    .archive-switch { width:100%; }
    .archive-switch a { flex:1; justify-content:center; }
    .desktop-table-wrap { display:none; }
    .mobile-animal-list { display:grid; gap:12px; }
    .mobile-animal-card { padding:15px; border:1px solid var(--line); border-radius:23px; background:var(--surface); box-shadow:var(--shadow); }
    .mobile-animal-card-head { display:grid; grid-template-columns:58px minmax(0,1fr) 12px; gap:10px; align-items:center; }
    .mobile-animal-card-head img { width:58px; height:58px; object-fit:cover; border-radius:15px; background:var(--surface-strong); }
    .mobile-animal-card-head > div { display:grid; min-width:0; }
    .mobile-animal-card-head span { color:var(--green-700); font-size:8px; text-transform:uppercase; font-weight:800; }
    .mobile-animal-card-head strong, .mobile-animal-card-head small { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
    .mobile-animal-card-head small { color:var(--text-soft); font-size:10px; }
    .status-dot { width:9px; height:9px; border-radius:50%; }
    .status-dot.status-active { background:#14a76f; }
    .status-dot.status-sold { background:#d99a20; }
    .status-dot.status-deceased { background:#d14b54; }
    .mobile-animal-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin:13px 0; }
    .mobile-animal-stats > div { padding:9px; border-radius:12px; background:var(--surface-soft); display:grid; }
    .mobile-animal-stats small { color:var(--text-soft); font-size:8px; }
    .mobile-animal-stats strong { font-size:11px; }
    .mobile-qr-row { display:grid; grid-template-columns:48px minmax(0,1fr) 38px; gap:9px; align-items:center; padding:9px; border-radius:14px; background:var(--green-50); }
    .mobile-qr-row > img { width:48px; height:48px; padding:3px; background:#fff; border-radius:8px; }
    .mobile-qr-row > div { display:grid; }
    .mobile-qr-row strong { font-size:11px; }
    .mobile-qr-row small { color:var(--text-soft); font-size:8px; }
    .mobile-qr-row .icon-button { width:36px; height:36px; }
    .mobile-card-actions { display:flex; gap:7px; margin-top:11px; }
    .form-grid.two { grid-template-columns:1fr; }
    .full-span { grid-column:auto; }
    .animal-form-layout { gap:13px; }
    .form-section, .sticky-card, .form-panel, .settings-form, .content-card, .record-form-card, .record-list-card, .upload-side-card, .qr-settings-card { padding:17px; border-radius:22px; }
    .image-preview-grid { grid-template-columns:repeat(3,1fr); }
    .detail-page-head { display:grid; grid-template-columns:42px minmax(0,1fr) auto; gap:10px; align-items:center; }
    .detail-page-head h1 { font-size:22px; margin:4px 0 0; }
    .detail-page-head p { font-size:10px; }
    .detail-head-actions .soft-button { display:none; }
    .animal-detail-hero { gap:12px; }
    .animal-visual-card { min-height:355px; padding:15px; }
    .animal-main-photo { min-height:270px; }
    .animal-main-photo img { height:250px; }
    .animal-summary-sheet { padding:19px; }
    .summary-header h2 { font-size:23px; }
    .summary-metrics { gap:6px; }
    .summary-metrics > div { padding:10px; }
    .summary-action-row { padding-top:15px; }
    .detail-tabs { margin:12px 0; grid-template-columns:repeat(6,105px); border-radius:18px; }
    .detail-tabs a { min-height:44px; font-size:10px; }
    .detail-tabs a svg { width:17px; }
    .detail-tabs small { display:none; }
    .info-grid, .parent-cards { grid-template-columns:1fr; }
    .record-layout { gap:12px; }
    .timeline-item { grid-template-columns:17px minmax(0,1fr); }
    .timeline-item .row-actions { grid-column:2; justify-content:flex-start; }
    .photo-gallery { grid-template-columns:repeat(2,1fr); gap:8px; }
    .qr-large-card { padding:18px; border-radius:23px; }
    .qr-large-frame { width:min(260px,100%); padding:12px; }
    .user-row { grid-template-columns:42px minmax(0,1fr) auto; }
    .user-row .role-badge { grid-column:2; width:fit-content; }
    .user-row .row-actions { grid-column:3; grid-row:1/3; }
    .scanner-view, .scanner-view video { min-height:380px; height:380px; }
    .scanner-card, .scanner-side .card { padding:14px; border-radius:22px; }
    .public-header { padding:14px; }
    .public-brand small { display:none; }
    .public-brand .brand-logo { width:38px; height:38px; border-radius:13px; }
    .public-header-actions .soft-button { padding-inline:10px; font-size:10px; }
    .public-main { padding:18px 14px 60px; }
    .public-hero { min-height:auto; gap:28px; padding:25px 0 45px; }
    .public-hero-copy h1 { font-size:43px; }
    .public-hero-copy > p { font-size:14px; line-height:1.65; }
    .search-control { flex-wrap:wrap; padding:10px; }
    .search-control > svg { display:none; }
    .search-control input { width:100%; flex-basis:100%; min-height:38px; padding:0 5px; }
    .search-control .primary-button { width:100%; }
    .farm-overview-card { min-height:400px; padding:21px; border-radius:29px; }
    .farm-overview-top strong { font-size:64px; }
    .overview-mini-stats { left:21px; right:21px; bottom:21px; gap:6px; }
    .overview-mini-stats > div { padding:10px; }
    .public-feature-grid { grid-template-columns:1fr 1fr; gap:9px; margin-bottom:55px; }
    .feature-card { padding:15px; }
    .public-animal-grid { grid-template-columns:1fr; }
    .public-contact-card { padding:23px; }
    .contact-icon { display:none; }
    .public-footer { padding:15px 14px; flex-direction:column; gap:4px; text-align:center; }
    .public-animal-detail { margin-top:0; }
    .public-animal-visual { min-height:300px; }
    .public-animal-visual > img { height:275px; width:90%; }
    .public-detail-sheet { padding:19px; border-radius:25px; }
    .detail-list { grid-template-columns:1fr; }
    .guest-body { padding:13px; }
    .login-phone-card { min-height:calc(100vh - 26px); border-radius:28px; }
    .login-form-panel { min-height:auto; padding:36px 23px; justify-content:flex-start; }
    .mobile-brand-small { margin-bottom:60px; }
    .login-form-panel h2 { font-size:30px; }
    .guest-theme { top:23px; right:23px; }
    .disabled-public { margin:25px auto; min-height:520px; padding:28px 20px; border-radius:26px; }
    .disabled-public h1 { font-size:31px; }
    .error-code { font-size:70px; }
}

@media (max-width: 420px) {
    .metrics-grid, .public-feature-grid { grid-template-columns:1fr 1fr; }
    .metric-card { min-height:125px; }
    .farm-weather-art { opacity:.75; }
    .summary-metrics { grid-template-columns:1fr 1fr; }
    .summary-metrics > div:last-child { grid-column:1/-1; }
    .photo-gallery { grid-template-columns:1fr; }
    .public-hero-copy h1 { font-size:37px; }
    .hero-actions { flex-direction:column; }
    .farm-overview-top strong { font-size:57px; }
    .overview-mini-stats small { display:none; }
    .public-stat-row { gap:6px; }
    .public-stat-row > div { padding:10px; }
}

/* Small interaction states */
.text-danger { color: var(--danger) !important; }
.alert { transition: opacity .22s ease, transform .22s ease; }
.alert.alert-fade { opacity: .72; transform: translateY(-2px); }
button:disabled, .primary-button:disabled, .soft-button:disabled { opacity: .58; cursor: not-allowed; }

/* Force tables to scroll horizontally inside their container and prevent page stretching */
.dash-wrapper {
  max-width: 100% !important;
  min-width: 0 !important;
}
.dash-table-container {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}
.dash-table {
  min-width: 900px !important;
  width: 100% !important;
}
@media (max-width: 930px) {
  .workspace, .main-content {
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}

/* Scanner compatibility fallback */
.scanner-view video.hidden,
.scanner-viewport video.hidden { display: none !important; }
.html5-reader { display: none; position: absolute; inset: 0; z-index: 1; background: #000; }
.html5-reader.active { display: block; }
.html5-reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
.html5-reader div,
.html5-reader video,
.html5-reader canvas { border: 0 !important; box-shadow: none !important; }
.scanner-frame,
.scanner-overlay-box,
.scanner-placeholder { z-index: 2; }
.manual-scan-form { display: flex; gap: 10px; margin-top: 14px; }
.manual-scan-form input { flex: 1; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-family: inherit; background: var(--surface); color: var(--text-main); }
.manual-scan-form input:focus { outline: 2px solid color-mix(in srgb, var(--green-700) 30%, transparent); border-color: var(--green-700); }
.scanner-placeholder.hidden { display: none !important; }


/* === Hosting/mobile UI fixes: floating menus, notification, scanner === */
.table-action-menu {
  position: fixed !important;
  z-index: 2147483000 !important;
  display: none;
  min-width: 168px;
  max-width: min(240px, calc(100vw - 24px));
  background: var(--dash-surface, var(--surface)) !important;
  border: 1px solid var(--dash-border, var(--line)) !important;
  border-radius: 12px !important;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.18) !important;
  padding: 0.35rem !important;
  flex-direction: column !important;
  gap: 0.15rem !important;
  overflow: visible !important;
}
.table-action-menu.is-floating-open {
  display: flex !important;
}
.table-action-menu .table-menu-item:hover {
  background: var(--dash-subtle, var(--surface-soft)) !important;
}
.table-action-menu .table-menu-item.danger:hover {
  background: var(--danger-soft, #fef2f2) !important;
}
html[data-theme="dark"] .table-action-menu {
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.48) !important;
}

@media (max-width: 700px) {
  .notif-dropdown-menu {
    position: fixed !important;
    top: calc(var(--header-height, 68px) - 2px) !important;
    right: 12px !important;
    left: auto !important;
    width: min(360px, calc(100vw - 24px)) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: min(72vh, 520px) !important;
    overflow: hidden !important;
    transform: translateY(-8px) !important;
    z-index: 2147482000 !important;
  }
  .notif-dropdown-wrap.is-active .notif-dropdown-menu {
    transform: translateY(0) !important;
  }
  .notif-list {
    max-height: min(56vh, 390px) !important;
  }
  .topbar-actions {
    min-width: 0 !important;
  }
  .dash-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.75rem !important;
  }
  .dash-stat-card {
    min-width: 0 !important;
    padding: 0.95rem !important;
  }
  .dash-stat-card .stat-value,
  .stat-value {
    font-size: clamp(1.2rem, 6vw, 1.55rem) !important;
  }
  .dash-stat-card .stat-label,
  .stat-label {
    font-size: 0.72rem !important;
    line-height: 1.3 !important;
  }
}

.scanner-view.fallback-active .scanner-frame,
.scanner-viewport.fallback-active .scanner-overlay-box {
  display: none !important;
}
.scanner-view.is-running .scanner-placeholder,
.scanner-viewport.is-running .scanner-placeholder {
  display: none !important;
}
.html5-reader,
#html5QrReader {
  border: 0 !important;
  overflow: hidden !important;
}
.html5-reader video,
#html5QrReader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
#html5QrReader__dashboard,
#html5QrReader__dashboard_section,
#html5QrReader__dashboard_section_csr,
#html5QrReader__scan_region img {
  display: none !important;
}
#html5QrReader__scan_region,
#html5QrReader__scan_region video,
#html5QrReader__scan_region canvas {
  border: 0 !important;
  box-shadow: none !important;
}


/* === Public QR scanner hardening: single preview layer, no black fallback overlay === */
.public-scanner-viewport {
  position: relative !important;
  isolation: isolate !important;
  background: #000 !important;
  min-height: 260px !important;
}
.public-scanner-viewport #scannerVideo {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  object-fit: cover !important;
  background: #000 !important;
  z-index: 1 !important;
  transform: translateZ(0);
}
.public-scanner-viewport #scannerVideo.hidden {
  display: block !important;
}
.public-scanner-viewport #html5QrReader,
.public-scanner-viewport .html5-reader {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.public-scanner-viewport .scanner-overlay-box {
  z-index: 3 !important;
}
.public-scanner-viewport .scanner-placeholder {
  z-index: 4 !important;
}
.public-scanner-viewport.is-running .scanner-placeholder {
  display: none !important;
}
@media (max-width: 520px) {
  .public-scanner-viewport {
    min-height: 230px !important;
  }
  .scanner-actions {
    flex-direction: column !important;
  }
  .manual-scan-form {
    flex-direction: column !important;
  }
}


/* === Public scan black-screen fix === */
.public-scanner-viewport.is-running #scannerPlaceholder,
.public-scanner-viewport #scannerPlaceholder.hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}
.public-scanner-viewport #scannerVideo {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 1 !important;
}
.public-scanner-viewport .scanner-overlay-box {
  z-index: 2 !important;
}
