/* ==========================================================================
   Bulurum — mobile-first styles, light/dark themes, no framework.
   ========================================================================== */

:root {
  --bg: #f4f6f9;
  --bg-glow: radial-gradient(1100px 420px at 15% -10%, rgba(37, 99, 235, 0.09), transparent 60%);
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --surface-3: #e3e9f2;
  --text: #111827;
  --muted: #5b6678;
  --muted-2: #7b8798;
  --border: #e0e6ef;
  --border-strong: #cbd5e3;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #e8efff;
  --primary-contrast: #ffffff;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --success: #067647;
  --success-soft: #dcfae6;
  --warning-soft: #fef0c7;
  --focus: rgba(37, 99, 235, 0.4);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 2px 6px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.22);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --header-h: 62px;
  --tabbar-h: 66px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    'Noto Sans', sans-serif;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0b1020;
  --bg-glow: radial-gradient(1100px 420px at 15% -10%, rgba(96, 165, 250, 0.13), transparent 60%);
  --surface: #141b2e;
  --surface-2: #1b2438;
  --surface-3: #243049;
  --text: #e8edf7;
  --muted: #97a3b7;
  --muted-2: #7d8aa0;
  --border: #263149;
  --border-strong: #344260;
  --primary: #6ea2ff;
  --primary-strong: #8ab4ff;
  --primary-soft: #1b2a4d;
  --primary-contrast: #08111f;
  --danger: #ff8a80;
  --danger-soft: #3a1d22;
  --success: #6ce9a6;
  --success-soft: #12301f;
  --warning-soft: #33270e;
  --focus: rgba(110, 162, 255, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1020;
    --bg-glow: radial-gradient(1100px 420px at 15% -10%, rgba(96, 165, 250, 0.13), transparent 60%);
    --surface: #141b2e;
    --surface-2: #1b2438;
    --surface-3: #243049;
    --text: #e8edf7;
    --muted: #97a3b7;
    --muted-2: #7d8aa0;
    --border: #263149;
    --border-strong: #344260;
    --primary: #6ea2ff;
    --primary-strong: #8ab4ff;
    --primary-soft: #1b2a4d;
    --primary-contrast: #08111f;
    --danger: #ff8a80;
    --danger-soft: #3a1d22;
    --success: #6ce9a6;
    --success-soft: #12301f;
    --warning-soft: #33270e;
    --focus: rgba(110, 162, 255, 0.5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-glow);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

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

button {
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-contrast);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------- header -- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--header-h);
  padding: 0 16px max(0px, env(safe-area-inset-top)) 16px;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
}

.app-header.is-scrolled {
  border-bottom-color: var(--border);
}

@media (min-width: 820px) {
  .app-header {
    padding-left: max(16px, calc((100vw - 760px) / 2));
    padding-right: max(16px, calc((100vw - 760px) / 2));
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--primary-contrast);
  background: linear-gradient(150deg, var(--primary), var(--primary-strong));
  box-shadow: var(--shadow-sm);
  flex: none;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-mark circle {
  fill: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 19px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

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

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  flex: none;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.icon-btn .icon {
  width: 22px;
  height: 22px;
}

.icon-moon {
  display: none;
}

:root[data-theme='dark'] .icon-sun,
:root[data-theme='dark'] .icon-moon {
  display: none;
}

:root[data-theme='dark'] .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .icon-sun {
    display: none;
  }
  :root:not([data-theme='light']) .icon-moon {
    display: block;
  }
}

/* --------------------------------------------------------------- offline -- */

.offline-banner {
  position: sticky;
  top: var(--header-h);
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #7a4a00;
  background: #fef0c7;
}

.offline-banner svg {
  width: 16px;
  height: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .offline-banner {
    color: #ffdfa3;
    background: #3a2d10;
  }
}

:root[data-theme='dark'] .offline-banner {
  color: #ffdfa3;
  background: #3a2d10;
}

/* ------------------------------------------------------------------ view -- */

.view {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom));
  animation: view-in 0.2s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .view {
    animation: none;
  }
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 2px 16px;
}

.page-head h1 {
  font-size: 26px;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.page-head p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 26px 2px 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 12px;
}

/* ---------------------------------------------------------------- search -- */

.search-hero {
  margin: 2px 0 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box > svg {
  position: absolute;
  left: 16px;
  width: 22px;
  height: 22px;
  color: var(--muted-2);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 58px;
  padding: 0 48px 0 48px;
  font-size: 17px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::placeholder {
  color: var(--muted-2);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}

.search-clear svg {
  position: static;
  width: 18px;
  height: 18px;
}

.search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
  margin: 10px 4px 6px;
  color: var(--muted);
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  min-height: 40px;
}

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

/* --------------------------------------------------------------- results -- */

.result-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

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

.result:active {
  transform: scale(0.995);
}

.thumb {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb svg {
  width: 26px;
  height: 26px;
  opacity: 0.7;
}

.result-body {
  min-width: 0;
  flex: 1;
}

.result-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.box-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  max-width: 100%;
}

.box-pill .pill-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.qty-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.stock-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted-2);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px 6px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 46px 18px;
  text-align: center;
  color: var(--muted);
}

.empty .empty-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--muted-2);
  margin-bottom: 6px;
}

.empty .empty-icon svg {
  width: 28px;
  height: 28px;
}

.empty strong {
  color: var(--text);
  font-size: 16px;
}

.empty p {
  max-width: 320px;
  font-size: 14px;
}

/* ----------------------------------------------------------------- boxes -- */

.box-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.box-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  box-shadow: var(--shadow-sm);
  min-height: 72px;
}

.box-row:hover {
  border-color: var(--primary);
}

.box-number {
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 48px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.box-main {
  min-width: 0;
  flex: 1;
}

.box-main strong {
  display: block;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.box-main span {
  color: var(--muted);
  font-size: 13px;
}

.chev {
  color: var(--muted-2);
  flex: none;
}

.chev svg {
  width: 20px;
  height: 20px;
}

.box-hero {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--primary), var(--primary-strong));
  color: var(--primary-contrast);
  box-shadow: var(--shadow-md);
}

.box-hero .hero-number {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}

.box-hero h1 {
  font-size: 34px;
  letter-spacing: -0.03em;
  margin-top: 2px;
  word-break: break-word;
}

.box-hero .hero-name {
  font-size: 16px;
  opacity: 0.9;
  margin-top: 4px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-actions .btn {
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border-color: transparent;
}

.hero-actions .btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.hero-actions .btn.danger {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

:root[data-theme='dark'] .box-hero {
  color: #08111f;
}

:root[data-theme='dark'] .hero-actions .btn.danger {
  color: #08111f;
  background: rgba(0, 0, 0, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .box-hero {
    color: #08111f;
  }
  :root:not([data-theme='light']) .hero-actions .btn.danger {
    color: #08111f;
    background: rgba(0, 0, 0, 0.14);
  }
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn.primary {
  background: linear-gradient(150deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: var(--primary-contrast);
  box-shadow: var(--shadow-sm);
}

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

.btn.soft {
  background: var(--surface-2);
  border-color: transparent;
}

.btn.danger {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.btn.small {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13.5px;
  border-radius: 10px;
}

.btn.block {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.field .req {
  color: var(--danger);
  font-size: 11px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--focus);
}

.input.invalid,
.select.invalid {
  border-color: var(--danger);
}

.field-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
}

.field-hint {
  color: var(--muted-2);
  font-size: 12.5px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.form-actions .btn {
  flex: 1;
}

@media (min-width: 620px) {
  .form-actions {
    justify-content: flex-start;
  }
  .form-actions .btn {
    flex: 0 0 auto;
    min-width: 140px;
  }
}

/* ------------------------------------------------------------------ photo -- */

.photo-editor {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.photo-frame {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 16px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted-2);
  flex: none;
}

.photo-frame.has-photo {
  border-style: solid;
}

.photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame .photo-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.photo-frame svg {
  width: 28px;
  height: 28px;
}

.photo-frame .photo-open {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
}

.photo-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.photo-tools .btn {
  justify-content: flex-start;
}

.photo-status {
  color: var(--muted);
  font-size: 12.5px;
}

.photo-status.error {
  color: var(--danger);
}

/* ------------------------------------------------------------------ trash -- */

.trash-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.trash-main {
  flex: 1;
  min-width: 0;
}

.trash-main strong {
  display: block;
  font-size: 15.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.warn {
  background: var(--warning-soft);
  color: #8a6100;
}

:root[data-theme='dark'] .badge.warn {
  color: #ffdfa3;
}

.trash-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.info-box {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.info-box svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}

/* --------------------------------------------------------------- settings -- */

.settings-group {
  margin-top: 22px;
}

.settings-group h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0 4px 8px;
}

.settings-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.setting-row p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  max-width: 44ch;
}

.setting-row strong {
  font-size: 15px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 12px;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  min-height: 40px;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 600;
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------------- qr ---- */

.qr-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px;
  background: #fff;
  color: #111;
  border-radius: 16px;
  text-align: center;
}

.qr-label svg {
  width: min(62vw, 260px);
  height: auto;
}

.qr-label .qr-box-number {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.qr-label .qr-box-name {
  font-size: 15px;
  color: #444;
}

.qr-label .qr-app {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #888;
}

/* ----------------------------------------------------------------- modal -- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 24, 0.55);
  backdrop-filter: blur(2px);
  animation: fade-in 0.16s ease;
}

.modal__card {
  position: relative;
  width: 100%;
  max-height: min(88dvh, 760px);
  overflow: auto;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  animation: sheet-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.modal__card.form-card {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 24px;
  }
  .modal__card {
    max-width: 520px;
    border-radius: 22px;
    animation: pop-in 0.18s ease;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(16%);
    opacity: 0.6;
  }
}

@keyframes pop-in {
  from {
    transform: translateY(10px) scale(0.985);
    opacity: 0;
  }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal__header h2 {
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.modal__header p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 4px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  padding-bottom: 2px;
  background: var(--surface);
  z-index: 1;
}

.modal__actions .btn {
  flex: 1 1 auto;
}

@media (min-width: 480px) {
  .modal__actions {
    justify-content: flex-end;
  }
  .modal__actions .btn {
    flex: 0 0 auto;
    min-width: 110px;
  }
}

.modal-close {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close--floating {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  background: rgba(9, 13, 24, 0.5);
  color: #fff;
  backdrop-filter: blur(6px);
}

.modal__card.photo-modal {
  padding: 8px;
  background: transparent;
  box-shadow: none;
  display: grid;
  place-items: center;
}

.photo-modal .modal__body {
  display: grid;
  place-items: center;
}

.photo-viewer {
  max-width: min(92vw, 720px);
  max-height: 82dvh;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

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

.toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
  width: min(92vw, 460px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #101828;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.18s ease;
  max-width: 100%;
}

.toast.error {
  background: #7a271a;
}

.toast.success {
  background: #054f31;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* --------------------------------------------------------------- tabbar ---- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  min-height: 52px;
  padding: 4px 8px;
  border-radius: 12px;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.tabbar a svg {
  width: 23px;
  height: 23px;
}

.tabbar a[aria-current='page'] {
  color: var(--primary);
}

.tabbar a[aria-current='page'] svg {
  transform: translateY(-1px);
}

@media (min-width: 760px) {
  .tabbar {
    left: 50%;
    right: auto;
    bottom: 18px;
    transform: translateX(-50%);
    width: auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 6px;
    gap: 4px;
    box-shadow: var(--shadow-md);
  }
  .tabbar a {
    min-width: 96px;
    min-height: 50px;
  }
  .fab {
    right: max(24px, calc(50vw - 380px + 24px));
  }
}

/* ------------------------------------------------------------------- fab ---- */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  z-index: 45;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 19px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--primary), var(--primary-strong));
  color: var(--primary-contrast);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.38);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

.fab:hover {
  transform: translateY(-1px);
}

.fab:active {
  transform: scale(0.96);
}

.fab svg {
  width: 27px;
  height: 27px;
}

.fab.is-disabled {
  opacity: 0.45;
  box-shadow: var(--shadow-sm);
}

.fab.is-disabled:hover {
  transform: none;
}

.fab .fab-label {
  display: none;
}

.fab.with-label {
  width: auto;
  padding: 0 20px 0 16px;
  gap: 8px;
  grid-auto-flow: column;
  border-radius: 18px;
}

.fab.with-label .fab-label {
  display: inline;
  font-size: 14px;
  font-weight: 650;
}

/* --------------------------------------------------------------- utilities -- */

body.is-offline .offline-hide {
  display: none !important;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 0;
  color: var(--muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

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

/* ------------------------------------------------------------------ print -- */

@media print {
  @page {
    margin: 10mm;
  }
  body {
    background: #fff !important;
  }
  body > *:not(#modal-root) {
    display: none !important;
  }
  #modal-root {
    display: block !important;
  }
  .modal {
    position: static;
    display: block;
    padding: 0;
  }
  .modal__backdrop,
  .modal__header,
  .modal__actions,
  .no-print {
    display: none !important;
  }
  .modal__card {
    box-shadow: none;
    border: 0;
    padding: 0;
    max-height: none;
    max-width: none;
    background: #fff;
    overflow: visible;
  }
  .qr-label {
    page-break-inside: avoid;
    border-radius: 0;
    padding: 8mm;
    width: 90mm;
    margin: 0 auto;
  }
  .qr-label svg {
    width: 70mm;
  }
}
