/*
 * Bulkovoz UI 1.0.1
 * Autonomous CSS framework for Bulkovoz / MAX web-app interfaces.
 * No external dependencies.
 */

:root {
  color-scheme: light;

  /* Brand */
  --br-primary: var(--bulkovoz-terracotta);
  --br-primary-hover: #A64E30;
  --br-primary-active: #8F432A;
  --br-primary-soft: #f8e3d7;
  --br-primary-contrast: #fffaf5;

  /* Surfaces */
  --br-bg: #fbf5ee;
  --br-bg-strong: #f3e7da;
  --br-surface: #fffaf4;
  --br-surface-raised: #fffdf9;
  --br-surface-muted: #f7eee4;
  --br-border: #eadccd;
  --br-border-strong: #dcc8b4;

  /* Text */
  --br-text: #342a25;
  --br-text-soft: #6f6259;
  --br-text-muted: #94867c;

  /* State */
  --br-success: #78945f;
  --br-success-soft: #e8f0e1;
  --br-warning: #c78135;
  --br-warning-soft: #faecd8;
  --br-danger: #b95649;
  --br-danger-soft: #f7e1dd;
  --br-info: #607c8c;
  --br-info-soft: #e4edf1;

  /* Geometry */
  --br-radius-xs: 8px;
  --br-radius-sm: 12px;
  --br-radius-md: 16px;
  --br-radius-lg: 22px;
  --br-radius-xl: 30px;
  --br-radius-pill: 999px;

  /* Elevation */
  --br-shadow-xs: 0 1px 2px rgba(67, 45, 30, 0.05);
  --br-shadow-sm: 0 4px 14px rgba(67, 45, 30, 0.07);
  --br-shadow-md: 0 10px 30px rgba(67, 45, 30, 0.10);
  --br-shadow-lg: 0 24px 60px rgba(67, 45, 30, 0.14);

  /* Spacing */
  --br-space-1: 4px;
  --br-space-2: 8px;
  --br-space-3: 12px;
  --br-space-4: 16px;
  --br-space-5: 20px;
  --br-space-6: 24px;
  --br-space-7: 32px;
  --br-space-8: 40px;
  --br-space-9: 48px;

  /* Type */
  --br-font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --br-font-brand: Georgia, "Times New Roman", serif;
  --br-font-size-xs: 12px;
  --br-font-size-sm: 13px;
  --br-font-size-md: 15px;
  --br-font-size-lg: 17px;
  --br-font-size-xl: 22px;
  --br-font-size-2xl: 30px;
  --br-line-height: 1.45;

  /* Motion */
  --br-ease: 180ms cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--br-bg);
  color: var(--br-text);
  font-family: var(--br-font-sans);
  font-size: var(--br-font-size-md);
  line-height: var(--br-line-height);
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--br-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

/* Accessibility */
:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--br-primary) 32%, transparent);
  outline-offset: 2px;
}
.br-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Layout */
.br-page { min-height: 100vh; }
.br-container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.br-stack { display: flex; flex-direction: column; gap: var(--br-space-4); }
.br-stack-sm { gap: var(--br-space-2); }
.br-stack-lg { gap: var(--br-space-6); }
.br-row { display: flex; align-items: center; gap: var(--br-space-3); }
.br-row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--br-space-3); }
.br-grid { display: grid; gap: var(--br-space-4); }
.br-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.br-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.br-grow { flex: 1 1 auto; min-width: 0; }
.br-center { display: grid; place-items: center; }

/* Typography */
.br-brand {
  font-family: var(--br-font-brand);
  font-size: clamp(32px, 7vw, 56px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: .03em;
}
.br-h1, .br-h2, .br-h3, .br-h4 { margin: 0; line-height: 1.18; }
.br-h1 { font-size: var(--br-font-size-2xl); font-weight: 760; }
.br-h2 { font-size: var(--br-font-size-xl); font-weight: 730; }
.br-h3 { font-size: var(--br-font-size-lg); font-weight: 700; }
.br-h4 { font-size: var(--br-font-size-md); font-weight: 700; }
.br-text { margin: 0; }
.br-text-sm { font-size: var(--br-font-size-sm); }
.br-caption { color: var(--br-text-muted); font-size: var(--br-font-size-xs); }
.br-muted { color: var(--br-text-muted); }
.br-soft { color: var(--br-text-soft); }
.br-price { font-weight: 760; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Surfaces */
.br-card {
  background: var(--br-surface);
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-lg);
  box-shadow: var(--br-shadow-sm);
  padding: var(--br-space-5);
}
.br-card--flat { box-shadow: none; }
.br-card--raised { background: var(--br-surface-raised); box-shadow: var(--br-shadow-md); }
.br-card--accent {
  color: var(--br-primary-contrast);
  border-color: transparent;
  background: linear-gradient(145deg, #d8653e 0%, var(--br-primary) 58%, #b74b2d 100%);
}
.br-card--accent .br-muted,
.br-card--accent .br-soft { color: rgba(255,250,245,.82); }
.br-divider { border: 0; border-top: 1px solid var(--br-border); margin: 0; }

/* Buttons */
.br-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--br-radius-md);
  min-height: 44px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--br-surface-muted);
  color: var(--br-text);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--br-ease), background var(--br-ease), border-color var(--br-ease), box-shadow var(--br-ease);
  user-select: none;
}
.br-btn:hover { text-decoration: none; transform: translateY(-1px); }
.br-btn:active { transform: translateY(0); }
.br-btn:disabled { opacity: .52; cursor: not-allowed; transform: none; }
.br-btn--primary { background: var(--br-primary); color: var(--br-primary-contrast); box-shadow: var(--br-shadow-xs); }
.br-btn--primary:hover { background: var(--br-primary-hover); }
.br-btn--primary:active { background: var(--br-primary-active); }
.br-btn--secondary { background: transparent; border-color: var(--br-primary); color: var(--br-primary); }
.br-btn--ghost { background: transparent; color: var(--br-primary); }
.br-btn--danger { background: var(--br-danger); color: white; }
.br-btn--block { width: 100%; }
.br-btn--sm { min-height: 36px; padding: 7px 12px; border-radius: var(--br-radius-sm); font-size: var(--br-font-size-sm); }
.br-icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--br-radius-pill);
  background: var(--br-surface-muted);
  color: var(--br-text);
  display: inline-grid;
  place-items: center;
  transition: background var(--br-ease), transform var(--br-ease);
}
.br-icon-btn:hover { background: var(--br-bg-strong); transform: translateY(-1px); }

/* Forms */
.br-field { display: grid; gap: 7px; }
.br-label { color: var(--br-text-soft); font-size: var(--br-font-size-sm); font-weight: 650; }
.br-input,
.br-select,
.br-textarea {
  width: 100%;
  border: 1px solid var(--br-border-strong);
  border-radius: var(--br-radius-md);
  background: var(--br-surface-raised);
  color: var(--br-text);
  min-height: 46px;
  padding: 11px 13px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
  transition: border-color var(--br-ease), box-shadow var(--br-ease), background var(--br-ease);
}
.br-textarea { min-height: 112px; resize: vertical; }
.br-input::placeholder,
.br-textarea::placeholder { color: var(--br-text-muted); }
.br-input:focus,
.br-select:focus,
.br-textarea:focus {
  outline: none;
  border-color: var(--br-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--br-primary) 15%, transparent);
}
.br-help { color: var(--br-text-muted); font-size: var(--br-font-size-xs); }
.br-check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.br-check input { width: 18px; height: 18px; accent-color: var(--br-primary); }

.br-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.br-switch input { position: absolute; opacity: 0; pointer-events: none; }
.br-switch-track {
  width: 46px;
  height: 26px;
  padding: 3px;
  border-radius: var(--br-radius-pill);
  background: var(--br-border-strong);
  transition: background var(--br-ease);
}
.br-switch-thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--br-shadow-xs);
  transition: transform var(--br-ease);
}
.br-switch input:checked + .br-switch-track { background: var(--br-primary); }
.br-switch input:checked + .br-switch-track .br-switch-thumb { transform: translateX(20px); }

/* Badges */
.br-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: var(--br-radius-pill);
  background: var(--br-surface-muted);
  color: var(--br-text-soft);
  font-size: var(--br-font-size-xs);
  font-weight: 720;
  white-space: nowrap;
}
.br-badge--success { background: var(--br-success-soft); color: #5f794c; }
.br-badge--warning { background: var(--br-warning-soft); color: #a96728; }
.br-badge--danger { background: var(--br-danger-soft); color: #99493f; }
.br-badge--info { background: var(--br-info-soft); color: #4c6a79; }
.br-badge--accent { background: var(--br-primary-soft); color: var(--br-primary); }

/* Media */
.br-avatar {
  width: 48px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  background: var(--br-primary-soft);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}
.br-avatar--sm { width: 36px; }
.br-avatar--lg { width: 84px; }
.br-product-image {
  width: 58px;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--br-radius-sm);
  background: var(--br-primary-soft);
}

/* Lists */
.br-list {
  overflow: hidden;
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-lg);
  background: var(--br-surface);
  box-shadow: var(--br-shadow-sm);
}
.br-list-item {
  display: flex;
  align-items: center;
  gap: var(--br-space-3);
  min-height: 70px;
  padding: var(--br-space-4);
  color: inherit;
  text-decoration: none;
}
.br-list-item + .br-list-item { border-top: 1px solid var(--br-border); }
.br-list-item:hover { background: color-mix(in srgb, var(--br-primary-soft) 35%, transparent); text-decoration: none; }
.br-list-chevron { margin-left: auto; color: var(--br-text-muted); font-size: 22px; line-height: 1; }

/* Product row + quantity */
.br-product-row { display: flex; gap: var(--br-space-3); align-items: center; }
.br-qty { display: inline-flex; align-items: center; gap: 10px; }
.br-qty-value { min-width: 20px; text-align: center; font-weight: 760; font-variant-numeric: tabular-nums; }
.br-qty-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--br-primary-soft);
  color: var(--br-primary);
  font-size: 21px;
  line-height: 1;
}
.br-qty-btn--plus { background: var(--br-primary); color: white; }

/* Tabs */
.br-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-md);
  background: var(--br-surface-muted);
}
.br-tab {
  flex: 1 1 0;
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: calc(var(--br-radius-md) - 4px);
  background: transparent;
  color: var(--br-text-soft);
  font-weight: 690;
}
.br-tab[aria-selected="true"] { background: var(--br-primary); color: white; box-shadow: var(--br-shadow-xs); }

/* Order cards */
.br-order-card {
  display: flex;
  align-items: center;
  gap: var(--br-space-3);
  padding: var(--br-space-4);
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-lg);
  background: var(--br-surface);
  box-shadow: var(--br-shadow-xs);
}
.br-order-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--br-primary);
  color: white;
  font-size: 18px;
  flex: 0 0 auto;
}

/* Stepper */
.br-stepper { display: grid; grid-template-columns: repeat(var(--br-steps, 4), 1fr); gap: 0; }
.br-step { position: relative; display: grid; justify-items: center; gap: 7px; text-align: center; color: var(--br-text-muted); font-size: var(--br-font-size-xs); }
.br-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 12px;
  left: calc(50% + 13px);
  right: calc(-50% + 13px);
  height: 2px;
  background: var(--br-border-strong);
}
.br-step-dot {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--br-surface-raised);
  border: 3px solid var(--br-border-strong);
  color: white;
  font-size: 12px;
}
.br-step--done { color: var(--br-success); }
.br-step--done .br-step-dot { background: var(--br-success); border-color: var(--br-success); }
.br-step--done:not(:last-child)::after { background: var(--br-success); }
.br-step--active { color: var(--br-primary); font-weight: 700; }
.br-step--active .br-step-dot { background: var(--br-primary); border-color: var(--br-primary); }

/* Topbar */
.br-topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: var(--br-space-3);
  padding: 10px 16px;
  background: color-mix(in srgb, var(--br-bg) 92%, transparent);
  border-bottom: 1px solid var(--br-border);
  backdrop-filter: blur(16px);
}
.br-topbar-title { flex: 1 1 auto; text-align: center; font-size: var(--br-font-size-lg); font-weight: 760; }
.br-topbar-slot { width: 42px; display: flex; justify-content: center; }

/* Bottom navigation */
.br-bottom-nav {
  display: grid;
  grid-template-columns: repeat(var(--br-nav-items, 4), 1fr);
  gap: 2px;
  min-height: 70px;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--br-border);
  background: color-mix(in srgb, var(--br-surface) 96%, transparent);
  backdrop-filter: blur(16px);
}
.br-nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: var(--br-text-muted);
  font-size: 11px;
  font-weight: 650;
  border-radius: var(--br-radius-sm);
}
.br-nav-icon { font-size: 20px; line-height: 1; }
.br-nav-item--active { color: var(--br-primary); background: color-mix(in srgb, var(--br-primary-soft) 42%, transparent); }

/* Mobile app shell */
.br-phone {
  width: min(100%, 390px);
  min-height: 720px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--br-border-strong);
  border-radius: 34px;
  background: var(--br-bg);
  box-shadow: var(--br-shadow-lg);
}
.br-phone-body { flex: 1 1 auto; padding: 18px 16px 20px; overflow: auto; }
.br-safe-top { height: 16px; }

/* Hero */
.br-hero {
  position: relative;
  overflow: hidden;
  min-height: 178px;
  padding: 22px;
  border-radius: var(--br-radius-xl);
  color: white;
  background: linear-gradient(140deg, #db6b43 0%, var(--br-primary) 48%, #b8492d 100%);
  box-shadow: var(--br-shadow-md);
}
.br-hero::before {
  content: "";
  position: absolute;
  width: 230px;
  height: 230px;
  right: -90px;
  top: -95px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.br-hero-content { position: relative; z-index: 2; width: 58%; }
.br-hero-media { position: absolute; z-index: 1; right: -12px; bottom: -3px; width: 48%; filter: drop-shadow(0 12px 18px rgba(72,34,20,.2)); }

/* Toast */
.br-toast {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-md);
  background: var(--br-surface-raised);
  box-shadow: var(--br-shadow-md);
}
.br-toast-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--br-primary); flex: 0 0 auto; }
.br-toast--success .br-toast-dot { background: var(--br-success); }
.br-toast--warning .br-toast-dot { background: var(--br-warning); }

/* Modal */
.br-modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(38, 29, 24, .44);
  backdrop-filter: blur(4px);
  z-index: 1000;
}
.br-modal-backdrop[hidden] { display: none !important; }
.br-modal {
  width: min(100%, 420px);
  padding: 22px;
  border: 1px solid var(--br-border);
  border-radius: var(--br-radius-xl);
  background: var(--br-surface-raised);
  box-shadow: var(--br-shadow-lg);
}

/* Skeleton */
.br-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--br-radius-sm);
  background: var(--br-bg-strong);
  color: transparent !important;
}
.br-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: br-shimmer 1.4s infinite;
}
@keyframes br-shimmer { to { transform: translateX(100%); } }

/* Utilities */
.br-mt-0 { margin-top: 0 !important; }
.br-mt-2 { margin-top: var(--br-space-2) !important; }
.br-mt-4 { margin-top: var(--br-space-4) !important; }
.br-mt-6 { margin-top: var(--br-space-6) !important; }
.br-mb-0 { margin-bottom: 0 !important; }
.br-mb-2 { margin-bottom: var(--br-space-2) !important; }
.br-mb-4 { margin-bottom: var(--br-space-4) !important; }
.br-p-0 { padding: 0 !important; }
.br-w-full { width: 100% !important; }
.br-text-center { text-align: center !important; }
.br-hidden { display: none !important; }
.br-nowrap { white-space: nowrap !important; }

/* Responsive */
@media (max-width: 760px) {
  .br-container { width: min(100% - 20px, 1180px); }
  .br-grid-2, .br-grid-3 { grid-template-columns: 1fr; }
  .br-card { padding: var(--br-space-4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Browser account → MAX linking */
.profile-max-link { display: grid; gap: 14px; }
.profile-add-contract + .profile-max-link { margin-top: 10px; }
.profile-max-link p { margin: 0; color: var(--muted, #68736f); line-height: 1.45; }
.profile-max-link--linked { border-color: rgba(35,139,94,.28); background: #f4fbf7; }
.max-link-grid { display: grid; grid-template-columns: 210px 1fr; gap: 22px; align-items: center; }
.max-link-qr { display: grid; place-items: center; padding: 10px; border: 1px solid rgba(20,35,30,.12); border-radius: 20px; background: #fff; }
.max-link-qr svg { display: block; width: 100%; height: auto; }
.max-link-actions { display: grid; gap: 10px; align-content: center; }
.max-link-actions .max-link-open { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.max-link-actions small { color: var(--muted, #68736f); line-height: 1.35; }
@media (max-width: 560px) {
  .max-link-grid { grid-template-columns: 1fr; }
  .max-link-qr { width: min(240px, 100%); justify-self: center; }
}
