/* === BEGIN INLINED DESIGN TOKENS === */
/* ============================================================================
   Open Design System v1.0 — Molds & Cooks OMS
   Пастельная палитра, Inter Variable, soft elevation.
   Источник: docs/OMS_DESIGN_RESEARCH_2025_2026.md
   ============================================================================ */

/* Inter Variable font — ранее подгружался с https://rsms.me/inter/inter.css,
 * но CDN-шрифт блокируется нашим Content-Security-Policy (style-src 'self' 'unsafe-inline').
 * Используем системный sans-serif стек — внешний вид практически неотличим,
 * а загрузка страницы ускоряется (нет внешнего DNS-запроса).
 */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* === LIGHT THEME (default) === */
:root,
[data-theme="light"] {
  /* === NEUTRAL GREYS (8-10 оттенков) === */
  --grey-50:  #FAFAF9;
  --grey-100: #F5F5F4;
  --grey-200: #E7E5E4;
  --grey-300: #D6D3D1;
  --grey-400: #A8A29E;
  --grey-500: #78716C;
  --grey-600: #57534E;
  --grey-700: #44403C;
  --grey-800: #292524;
  --grey-900: #1C1917;

  /* === SURFACES (мягче текущего #f0ebe3) === */
  --bg:           #FAF8F4;
  --surface:      #FFFFFF;
  --surface-2:    #F5F3EE;
  --surface-3:    #EFEDE7;

  /* === PRIMARY (Sage Green — замена тёмно-зелёному) === */
  --primary-50:  #F2F6F3;
  --primary-100: #E0EBE3;
  --primary-200: #C1D7C8;
  --primary-300: #9CBEA7;
  --primary-400: #7B9E89;
  --primary-500: #5C8170;
  --primary-600: #466453;
  --primary-700: #354C40;
  --primary-800: #283830;
  --primary-900: #1C2620;

  /* === SEMANTIC COLORS (пастельные) === */
  --success:     #86A98A;
  --success-bg:  #E8F0E9;
  --warning:     #D4A574;
  --warning-bg:  #F7EFE3;
  --danger:      #C77B7B;
  --danger-bg:   #F2E2E2;
  --info:        #8AA5C2;
  --info-bg:     #E6EDF5;

  /* === ACCENT (фичи) === */
  --accent-lavender:  #B5A8C9;
  --accent-rose:      #D4A8AB;
  --accent-cream:     #EFE3D0;

  /* === SHADOWS (4-уровневая система) === */
  --shadow-xs: 0 1px 2px rgba(28, 25, 23, 0.04);
  --shadow-sm: 0 2px 4px rgba(28, 25, 23, 0.04), 0 1px 2px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.06), 0 1px 3px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 12px 24px rgba(28, 25, 23, 0.08), 0 4px 8px rgba(28, 25, 23, 0.04);
  --shadow-xl: 0 24px 48px rgba(28, 25, 23, 0.10);
  --shadow: var(--shadow-sm);

  /* === RADII (soft, modern) === */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --radius: var(--radius-md);

  /* === SPACING SCALE (4px base) === */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* === TYPE SCALE (Major Third 1.250) === */
  --text-xs:   0.75rem;     /* 12px */
  --text-sm:   0.875rem;    /* 14px */
  --text-base: 0.9375rem;   /* 15px */
  --text-md:   1rem;        /* 16px */
  --text-lg:   1.125rem;    /* 18px */
  --text-xl:   1.25rem;     /* 20px */
  --text-2xl:  1.5rem;      /* 24px */
  --text-3xl:  1.875rem;    /* 30px */
  --text-4xl:  2.25rem;     /* 36px */
  --text-5xl:  3rem;        /* 48px */

  /* === FONT FAMILIES ===
     System stack only — Inter Variable is not self-hosted and CSP blocks the
     old CDN. Preferring a missing family caused Times/serif fallback on some phones. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono",
               "Courier New", ui-monospace, monospace;

  /* === FONT WEIGHTS === */
  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* === LINE HEIGHTS === */
  --leading-tight:   1.2;
  --leading-snug:    1.35;
  --leading-normal:  1.5;
  --leading-relaxed: 1.65;

  /* === LETTER SPACING === */
  --tracking-tight:   -0.02em;
  --tracking-normal:  0;
  --tracking-wide:    0.02em;
  --tracking-widest:  0.08em;

  /* === MOTION TOKENS === */
  --duration-instant: 80ms;
  --duration-fast:    150ms;
  --duration-base:    220ms;
  --duration-slow:    350ms;
  --ease-out-quart:   cubic-bezier(0.25, 1, 0.5, 1);
  --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out:         cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:      cubic-bezier(0.65, 0, 0.35, 1);

  /* === LEGACY ALIASES (для обратной совместимости со старыми CSS) === */
  --accent:        var(--primary-400);
  --accent-soft:   var(--primary-100);
  --text:          var(--grey-900);
  --muted:         var(--grey-500);
  --border:        var(--grey-200);
  --warn:          var(--warning);
  --touch-min:     44px;
  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --safe-left:     env(safe-area-inset-left, 0px);
  --safe-right:    env(safe-area-inset-right, 0px);
  --bottom-nav-h:  56px;
}

/* === DARK THEME (auto по системе или через data-theme) === */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --grey-50:  #18181B;
    --grey-100: #27272A;
    --grey-200: #3F3F46;
    --grey-300: #52525B;
    --grey-400: #71717A;
    --grey-500: #A1A1AA;
    --grey-600: #D4D4D8;
    --grey-700: #E4E4E7;
    --grey-800: #F4F4F5;
    --grey-900: #FAFAFA;

    --bg:           #0E0E0C;
    --surface:      #18181B;
    --surface-2:    #1F1F23;
    --surface-3:    #27272A;

    --primary-50:  #14201A;
    --primary-100: #1C2E26;
    --primary-200: #2A4438;
    --primary-300: #9CBEA7;
    --primary-400: #9CBEA7;
    --primary-500: #7B9E89;
    --primary-600: #5C8170;

    --success-bg:  #1A2A1C;
    --warning-bg:  #2A2418;
    --danger-bg:   #2A1A1A;
    --info-bg:     #1A222A;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.20);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.40), 0 4px 8px rgba(0, 0, 0, 0.25);
    --shadow: var(--shadow-sm);

    --text: var(--grey-900);
    --muted: var(--grey-500);
    --border: var(--grey-200);
    --accent: var(--primary-400);
    --accent-soft: var(--primary-100);
  }
}

[data-theme="dark"] {
  color-scheme: dark;
  --grey-50:  #18181B;
  --grey-100: #27272A;
  --grey-200: #3F3F46;
  --grey-300: #52525B;
  --grey-400: #71717A;
  --grey-500: #A1A1AA;
  --grey-600: #D4D4D8;
  --grey-700: #E4E4E7;
  --grey-800: #F4F4F5;
  --grey-900: #FAFAFA;

  --bg:           #0E0E0C;
  --surface:      #18181B;
  --surface-2:    #1F1F23;
  --surface-3:    #27272A;

  --primary-50:  #14201A;
  --primary-100: #1C2E26;
  --primary-200: #2A4438;
  --primary-300: #9CBEA7;
  --primary-400: #9CBEA7;
  --primary-500: #7B9E89;
  --primary-600: #5C8170;

  --success-bg:  #1A2A1C;
  --warning-bg:  #2A2418;
  --danger-bg:   #2A1A1A;
  --info-bg:     #1A222A;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.40), 0 4px 8px rgba(0, 0, 0, 0.25);
  --shadow: var(--shadow-sm);

  --text: var(--grey-900);
  --muted: var(--grey-500);
  --border: var(--grey-200);
  --accent: var(--primary-400);
  --accent-soft: var(--primary-100);
}

/* === MOTION UTILITIES === */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.animate-fade-in { animation: fade-in var(--duration-base) var(--ease-out-quart) both; }
.live-dot { animation: pulse-dot 2s var(--ease-in-out) infinite; }
.skeleton {
  background: linear-gradient(
    90deg,
    var(--grey-100) 0%,
    var(--grey-200) 50%,
    var(--grey-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
/* === END INLINED DESIGN TOKENS === */

/* ============================================================================
   Open Design System — пастельная палитра, soft elevation, Inter Variable
   Design tokens are inlined at the top by scripts/build_admin_bundle.py
   (from _design-tokens.css). Do NOT use @import — it breaks under SW/PWA cache.
   Здесь — обратно-совместимые алиасы + переопределения для admin-specific.
   ============================================================================ */

/* === LEGACY ALIASES (для обратной совместимости со старыми стилями) ===
   Цвета берутся из inlined tokens (light + prefers-color-scheme: dark).
   Здесь только layout/safe-area — НЕ перебиваем --bg/--surface светлыми hex. */
:root {
  --radius: var(--radius-md);
  --shadow: var(--shadow-sm);
  --touch-min: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --bottom-nav-h: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-weight: var(--weight-normal);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.embed .app-header,
body.embed .sidebar-note { display: none; }

body.embed .bottom-nav,
body.embed .side-menu,
body.embed .side-menu-overlay { display: none !important; }

body.embed { padding-bottom: 0; }

body.embed .layout { grid-template-columns: 1fr; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-theme-toggle {
  min-width: var(--touch-min);
  padding-left: 10px;
  padding-right: 10px;
}

.header-theme-toggle .theme-toggle-icon {
  font-size: 1.05rem;
  line-height: 1;
  display: inline-block;
}

.org-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.org-switcher-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.org-switcher select {
  min-width: 170px;
  max-width: 260px;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

[hidden] {
  display: none !important;
}

.btn-login-prominent {
  background: var(--accent, #1a6b5c);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(26, 107, 92, 0.35);
  min-height: var(--touch-min, 44px);
}

.btn-login-prominent:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-logout:not([hidden]),
#btnLogout:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  min-height: var(--touch-min, 44px);
  padding: 8px 14px;
}

.side-menu-auth-btn {
  width: 100%;
  justify-content: center;
  margin-bottom: 8px;
}

.side-menu-auth-btn:not([hidden]) {
  display: inline-flex;
}

.btn-login-prominent:hover {
  filter: brightness(1.08);
}

.auth-banner {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--info-bg);
  border-bottom: 1px solid var(--grey-200);
  color: var(--grey-700);
  font-size: var(--text-sm);
}

.auth-banner[hidden] {
  display: none !important;
}

.auth-banner:not([hidden]) {
  display: flex;
}

.auth-banner-text {
  flex: 1;
  min-width: 200px;
  font-weight: 500;
}

#btnLoginBanner {
  flex-shrink: 0;
  font-weight: 700;
  min-height: var(--touch-min, 44px);
  padding: 10px 20px;
}

.queue-badge {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-badge--warn {
  color: #b45309;
  background: #fef3c7;
}

.org-list .org-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 72px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}

.sidebar-section {
  margin: 14px 12px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  margin-bottom: 4px;
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--accent-soft);
}

.sidebar-note {
  margin-top: 20px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.content {
  padding: 20px 24px 40px;
}

.panel { display: none; }
.panel.active { display: block; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-card strong {
  display: block;
  font-size: 1.6rem;
  margin-top: 4px;
}

.stat-card span { color: var(--muted); font-size: 0.82rem; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar input[type="search"],
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.btn-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.linkish {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
button.linkish:hover {
  color: var(--accent);
}

.archive-lead {
  margin: 0;
  flex: 1;
  color: var(--muted);
  font-size: 0.88rem;
}

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

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card .table-scroll table {
  min-width: 640px;
}

input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 12px;
}

input, select, textarea {
  background: var(--surface);
  color: var(--text);
  color-scheme: light dark;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.9;
}

/* Autofill must not force black text on dark surfaces */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 99999s ease-out;
}

button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

button.secondary {
  background: var(--surface);
  color: var(--text);
}

button.ghost {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.th-sort {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.th-sort:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.th-sort.active {
  color: var(--accent);
  font-weight: 700;
}

tr:hover td { background: #faf7f2; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.pipeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
  align-items: stretch;
  min-height: calc(100vh - 200px);
}

.pipeline-col {
  min-width: 288px;
  flex: 0 0 288px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 480px;
}

.pipeline-col h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
  line-height: 1.3;
}

.pipeline-count {
  font-weight: 400;
  opacity: 0.7;
}

.pipeline-dropzone {
  flex: 1;
  min-height: 400px;
  border-radius: 8px;
  padding: 6px 4px;
  transition: background 0.15s, outline 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-modal-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tab {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
}

.auth-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.accounts-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.accounts-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.accounts-activity {
  margin-top: 16px;
}

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

.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.pending-card {
  max-width: 560px;
  padding: 24px;
}

.danger-text {
  color: #b91c1c;
}

body.workstation-only .sidebar-note,
body.workstation-only #btnExportArchive,
body.workstation-only #btnSeedDemo {
  display: none !important;
}

body.workstation-only .sidebar--workstation-only {
  min-width: 11rem;
}

body.workstation-only .sidebar--workstation-only .nav-btn[hidden] {
  display: none !important;
}

body.workstation-only .layout {
  grid-template-columns: minmax(10rem, 12rem) 1fr;
}

@media (max-width: 900px) {
  body.workstation-only .sidebar--workstation-only {
    display: none;
  }

  body.workstation-only .layout {
    grid-template-columns: 1fr;
  }
}

.workstation-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.workstation-header .panel-lead {
  flex: 1 1 100%;
  margin: 0;
}

.workstation-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: stretch;
  min-height: calc(100vh - 220px);
}

.workstation-col {
  min-width: 280px;
  flex: 0 0 280px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.workstation-col h3 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.workstation-dropzone {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  border-radius: 8px;
  padding: 4px;
}

.workstation-dropzone.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
}

.workstation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.workstation-card.priority-low,
.pipeline-card.priority-low {
  box-shadow: inset 4px 0 0 #2e9d5a;
}

.workstation-card.priority-medium,
.pipeline-card.priority-medium {
  box-shadow: inset 4px 0 0 #d4a017;
}

.workstation-card.priority-high,
.pipeline-card.priority-high {
  box-shadow: inset 4px 0 0 #d64545;
}

.priority-strip {
  display: none;
}

.pipeline-card-priority,
.ws-designer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.priority-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.priority-badge.priority-low {
  background: #d8f3e3;
  color: #1f6b3f;
}

.priority-badge.priority-medium {
  background: #fff3cd;
  color: #8a6d00;
}

.priority-badge.priority-high {
  background: #fde2e2;
  color: #9b2c2c;
}

.priority-picker {
  position: relative;
}

.priority-trigger {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 600;
}

.priority-trigger.priority-low {
  background: #d8f3e3;
  border-color: #2e9d5a;
  color: #1f6b3f;
}

.priority-trigger.priority-medium {
  background: #fff3cd;
  border-color: #d4a017;
  color: #8a6d00;
}

.priority-trigger.priority-high {
  background: #fde2e2;
  border-color: #d64545;
  color: #9b2c2c;
}

.priority-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.priority-menu[hidden] {
  display: none !important;
}

.priority-option {
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
}

.priority-option:hover,
.priority-option.active {
  background: var(--surface-2);
}

.priority-option.priority-low { color: #1f6b3f; }
.priority-option.priority-medium { color: #8a6d00; }
.priority-option.priority-high { color: #9b2c2c; }
.priority-option.priority-clear { color: var(--muted); }

.workstation-card.dragging {
  opacity: 0.55;
}

.workstation-card-handle {
  cursor: grab;
  color: var(--muted);
  user-select: none;
  padding: 2px 4px;
}

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

.workstation-card-head {
  font-weight: 600;
  margin-bottom: 8px;
}

.ws-field {
  margin-bottom: 8px;
}

.ws-field label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.ws-input {
  width: 100%;
  box-sizing: border-box;
}

.ws-meta,
.ws-task,
.ws-comment {
  font-size: 0.85rem;
  margin: 0 0 6px;
  line-height: 1.35;
}

.ws-files {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  font-size: 0.85rem;
}

.ws-photos {
  margin: 6px 0 4px;
}

.ws-photos-empty {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
}

.ws-photos-group {
  margin-bottom: 8px;
}

.ws-photos-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 4px;
}

.ws-photos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ws-photos-grid--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
}

.ws-photo-item {
  position: relative;
}

.ws-photo-download {
  position: absolute;
  right: 2px;
  bottom: 2px;
  font-size: 0.6rem;
  line-height: 1;
  padding: 2px 4px;
  background: var(--bg, rgba(0, 0, 0, 0.5));
  border-radius: 4px;
  color: var(--text, #fff);
  text-decoration: none;
}

.workstation-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 12px 8px;
}

.ws-advance {
  width: 100%;
  margin-top: 8px;
}

.pipeline-dropzone.drag-over {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.pipeline-empty {
  flex: 1;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.pipeline-col-more {
  width: 100%;
  margin-top: 6px;
  font-size: 0.8rem;
}

.orders-table-more td,
.orders-table-more {
  text-align: center;
  padding: 10px 8px;
  color: var(--muted);
}

.orders-table-more-hint {
  margin-left: 8px;
  font-size: 0.8rem;
}

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  min-height: 130px;
  cursor: default;
  font-size: 0.85rem;
  user-select: none;
  transition: opacity 0.15s, transform 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  overflow: hidden;
}

.pipeline-card-handle {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--muted);
  cursor: grab;
  font-size: 1rem;
  border-right: 1px solid var(--border);
  writing-mode: vertical-rl;
  letter-spacing: 2px;
}

.pipeline-card-handle:active { cursor: grabbing; }

.pipeline-card-body {
  flex: 1;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  min-width: 0;
}

.pipeline-card-body:hover {
  background: rgba(13, 92, 77, 0.03);
}

.pipeline-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(13, 92, 77, 0.08);
}

.pipeline-card.dragging {
  opacity: 0.45;
  transform: scale(0.98);
}

.pipeline-card.long-press-pending {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  animation: pipeline-hold-pulse 0.45s ease-out;
}

@keyframes pipeline-hold-pulse {
  from { outline-color: transparent; }
  to { outline-color: var(--accent); }
}

.pipeline-drag-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  opacity: 0.94;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transform: scale(1.02);
  border-color: var(--accent);
}

body.pipeline-touch-dragging {
  touch-action: none;
  user-select: none;
}

.pipeline-col.drag-target h3 {
  color: var(--accent);
}

.pipeline.pipeline--accordion .pipeline-col.drag-target .pipeline-dropzone {
  display: flex;
}

.pipeline-card-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.pipeline-add-position {
  flex: 0 0 auto;
  min-width: 28px;
  min-height: 28px;
  padding: 0 6px;
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 600;
  color: var(--accent);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.pipeline-add-position:hover {
  border-color: var(--accent);
  background: rgba(13, 92, 77, 0.06);
}

.pipeline-card--position {
  min-height: 0;
  font-size: 0.78rem;
  opacity: 0.98;
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent, #1a6b5c) 35%, var(--border));
  border-left-width: 3px;
  border-left-color: var(--accent, #1a6b5c);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent, #1a6b5c) 8%);
  box-shadow: none;
}

.pipeline-card-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 10px;
}

.pipeline-card-group > .pipeline-card:not(.pipeline-card--position) {
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.pipeline-pos-block {
  margin: 0 0 0 8px;
  padding: 2px 0 4px 8px;
  border-left: 2px solid color-mix(in srgb, var(--accent, #1a6b5c) 45%, transparent);
}

.pipeline-pos-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  max-width: 100%;
  margin: 0 0 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
}

.pipeline-pos-toggle:hover {
  color: var(--accent, #1a6b5c);
}

.pipeline-pos-chevron {
  font-size: 0.65rem;
  opacity: 0.85;
}

.pipeline-pos-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: stretch;
}

.pipeline-card-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pipeline-card--pos-mini {
  margin: 0;
  padding: 0;
  min-height: 0;
  border-radius: 6px;
  border-left-width: 2px;
}

.pipeline-card--pos-chip {
  min-height: 28px;
}

.pipeline-card--pos-row,
.pipeline-card--pos-orphan {
  min-height: 32px;
}

.pipeline-card--pos-mini .pipeline-card-handle {
  flex: 0 0 20px;
  font-size: 0.65rem;
  padding: 0;
  letter-spacing: 0;
  writing-mode: horizontal-tb;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  opacity: 0.75;
}

.pipeline-card--pos-mini .pipeline-card-body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 6px;
  padding: 3px 6px 3px 2px;
  min-width: 0;
}

.pipeline-card--pos-chip {
  flex: 0 1 auto;
  max-width: 100%;
}

.pipeline-card--pos-chip .pipeline-card-body {
  flex-wrap: nowrap;
  padding: 2px 6px 2px 2px;
}

.pipeline-pos-chip-label {
  font-size: 0.68rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 9.5em;
}

.pipeline-card--pos-row,
.pipeline-card--pos-orphan {
  width: 100%;
}

.pipeline-card--pos-row .pipeline-card-body,
.pipeline-card--pos-orphan .pipeline-card-body {
  padding: 4px 8px 4px 2px;
}

.pipeline-pos-row-meta {
  flex: 1 1 100%;
  font-size: 0.66rem;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-pos-name {
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text);
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.pipeline-pos-name--empty {
  font-weight: 500;
  color: var(--muted);
  font-style: italic;
}

.pipeline-position-badge {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent, #1a6b5c) 12%, var(--surface-2, #eef2f1));
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  flex-shrink: 0;
}

.pipeline-position-parent {
  display: inline-block;
  margin: 0;
  font-size: 0.66rem;
  color: var(--muted);
  vertical-align: middle;
  max-width: 7em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-card--position {
  border-style: dashed;
}

.order-positions-section {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2, rgba(13, 92, 77, 0.03));
}

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

.order-positions-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.order-positions-add {
  min-width: 32px;
  min-height: 32px;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
}

.order-positions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-position-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.order-position-open {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.order-position-badge {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.75rem;
}

.order-position-sku {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

.order-position-name {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.order-position-delete {
  flex: 0 0 36px;
  min-width: 36px;
  font-size: 1.1rem;
}

.order-parent-link {
  margin-bottom: 12px;
}

.orders-actions-cell {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
}

.pipeline-card-id {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}

.pipeline-deadline {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1.3;
  width: fit-content;
}

.orders-deadline {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  line-height: 1.3;
  white-space: nowrap;
}

.deadline-ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.deadline-urgent {
  background: #fef3c7;
  color: var(--warn);
}

.deadline-overdue {
  background: #fee2e2;
  color: var(--danger);
}

.deadline-none {
  background: var(--surface-2);
  color: var(--muted);
}

.pipeline-card-task {
  margin: 0;
  flex: 1;
  line-height: 1.45;
  font-size: 0.84rem;
  color: var(--text);
  word-break: break-word;
}

.pipeline-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.meta-chip {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.meta-chip-accent {
  background: rgba(13, 148, 136, 0.12);
  color: var(--accent);
  border-color: rgba(13, 148, 136, 0.25);
}

.order-params-line {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.order-params-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.order-params-summary[hidden] {
  display: none !important;
}

.order-drawer-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.order-drawer-summary[hidden] {
  display: none !important;
}

.alerts-box .alert-security {
  color: #b45309;
  margin: 0 0 6px;
  font-size: 0.85rem;
}

.pipeline-card-comment {
  margin: 0 0 6px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
  font-style: italic;
  word-break: break-word;
}

.pipeline-card-date {
  font-size: 0.72rem;
  color: var(--muted);
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; gap: 4px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-note { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.08);
  padding: 20px;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 40;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-top {
  flex-shrink: 0;
  position: relative;
  z-index: 6;
  background: var(--surface);
  margin: -4px -4px 0;
  padding: 4px 4px 0;
}

.drawer h2 { margin: 0 0 12px; font-size: 1.1rem; }

.drawer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  position: relative;
  z-index: 7;
}

.drawer-tab {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  pointer-events: auto;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}

.drawer-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.drawer-tab:active {
  transform: scale(0.98);
}

.drawer-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.drawer #orderEditForm {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.drawer-panel.active {
  display: block;
}

.drawer-panel[hidden] {
  display: none !important;
}

.drawer-footer {
  flex-shrink: 0;
  margin-top: auto;
}

.drawer-hotkeys {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, #2a2f3a);
  font-size: 0.72rem;
  color: var(--muted, #8a93a6);
}

.drawer-hotkeys span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.drawer-hotkeys kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--border, #2a2f3a);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2, #1b1f29);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.4;
  text-align: center;
  color: var(--text, #e6e9f0);
}

/* ===== Error log ===== */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--danger, #e5484d);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
}

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

.errorlog-item {
  border: 1px solid var(--border, #2a2f3a);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface, #141821);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.errorlog-item:hover {
  background: var(--surface-2, #1b1f29);
}

.errorlog-item.err-critical {
  border-left-color: var(--danger, #e5484d);
}

.errorlog-item.err-error {
  border-left-color: #f5a524;
}

.errorlog-item.err-warning {
  border-left-color: #eac54f;
}

.errorlog-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 0.82rem;
}

.errorlog-sev {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.errorlog-rid {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.errorlog-rid-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2, #1b1f29);
  color: var(--accent, #6ea8fe);
  letter-spacing: 0.02em;
}

.errorlog-rid-copy {
  padding: 0 4px;
  min-height: 24px;
  min-width: 24px;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.7;
}

.errorlog-rid-copy:hover {
  opacity: 1;
}

.error-detail-rid {
  margin: 0 0 8px;
}

.errorlog-time {
  color: var(--muted, #8a93a6);
  font-size: 0.74rem;
}

.errorlog-path {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--accent, #6ea8fe);
}

.errorlog-status {
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-2, #1b1f29);
  font-size: 0.74rem;
  font-weight: 600;
}

.errorlog-msg {
  flex: 1 1 100%;
  color: var(--text, #e6e9f0);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.backup-hint {
  margin: 4px 0 12px;
}

.backup-monthly {
  margin-bottom: 10px;
}

.backup-monthly-card {
  padding: 10px 12px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  background: var(--surface, #141821);
  font-size: 0.85rem;
  color: var(--muted, #8a93a6);
}

.backup-item {
  cursor: default;
}

.backup-item:hover {
  background: var(--surface, #141821);
}

.backup-name {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(420px, 100%);
}

.backup-size {
  color: var(--muted, #8a93a6);
  font-size: 0.78rem;
  white-space: nowrap;
}

.backup-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.backup-upload {
  display: flex;
}

.error-box {
  padding: 12px;
  border: 1px solid var(--danger, #e5484d);
  border-radius: 8px;
  color: var(--danger, #e5484d);
}

.error-detail-card {
  position: relative;
  width: min(880px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface, #141821);
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 12px;
  padding: 18px;
}

.error-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.error-detail-meta {
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--text, #e6e9f0);
}

.error-traceback {
  background: #0c0f16;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.74rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: #cdd3e0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.funnel-row {
  display: grid;
  grid-template-columns: 120px 1fr 32px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.funnel-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.funnel-count { text-align: right; color: var(--muted); }

.alerts-box .alert-warn { color: var(--warn); margin: 0 0 6px; font-size: 0.85rem; }
.alerts-box .alert-act { color: var(--warn); margin: 0 0 6px; font-size: 0.85rem; font-weight: 600; }
.alerts-box .alert-list { margin: 0 0 12px; padding-left: 18px; font-size: 0.8rem; }
.alerts-box .muted { color: var(--muted); font-size: 0.85rem; }

.stat-card--stale strong { color: var(--warn); }

.stuck-orders-box .stuck-orders-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.stuck-orders-box .stuck-order-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.stuck-orders-box .stuck-order-sla {
  color: var(--warn);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stuck-orders-box .stuck-orders-more {
  margin: 4px 0 0;
  font-size: 0.8rem;
}

.analytics-month-box .analytics-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.analytics-month-box .analytics-kpi {
  background: var(--surface-2, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  min-width: 0;
}

.analytics-month-box .analytics-kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.analytics-month-box .analytics-kpi strong {
  display: block;
  margin-top: 4px;
  font-size: 1.15rem;
}

.analytics-month-box .analytics-bottleneck {
  margin: 0 0 12px;
  font-size: 0.85rem;
  line-height: 1.35;
}

.analytics-month-box .month-bars {
  min-width: 0;
}

@keyframes act-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.act-pulse {
  animation: act-pulse 1.5s ease-in-out infinite;
}

.meta-chip--paid {
  background: color-mix(in srgb, var(--ok, #2f9e44) 18%, transparent);
  color: var(--ok, #2f9e44);
  font-weight: 600;
}

.order-pay-meta {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 4px 0 10px;
}

.order-docs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.order-docs-list {
  margin-top: 8px;
}

.receipts-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.receipts-filter-chip.active {
  background: var(--accent, #2563eb);
  color: #fff;
  border-color: transparent;
}

.toolbar--receipts .panel-title {
  margin-bottom: 4px;
}

.badge-act-needed {
  margin-left: 8px;
  vertical-align: middle;
  font-size: 0.75rem;
}

.order-needs-act {
  border-left: 4px solid var(--warn) !important;
}

.pipeline-card.order-needs-act {
  border-color: var(--warn);
  box-shadow: inset 4px 0 0 var(--warn);
}

.order-card.order-needs-act {
  border-left: 4px solid var(--warn);
}

tr.order-needs-act td:first-child {
  box-shadow: inset 4px 0 0 var(--warn);
}

.chat-bubble--act .chat-bubble-body {
  border-left: 3px solid var(--warn);
  padding-left: 10px;
  background: var(--warning-bg);
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.drawer label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

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

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--text);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 45;
}

#toast {
  z-index: 45;
}

.toast.show { opacity: 1; }
.toast.toast-success { background: #16a34a; color: #fff; }
.toast.toast-error   { background: #dc2626; color: #fff; }
.toast.toast-warning { background: #d97706; color: #fff; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 15;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

/* ——— Формы: вертикальный стек ——— */
.form-page {
  max-width: 720px;
}

.form-card {
  padding: 28px 32px;
}

.form-card-wide {
  max-width: 560px;
}

.form-page-title {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
}

.form-page-lead {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.form-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.form-section:first-of-type {
  padding-top: 0;
}

.form-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.form-section-title {
  margin: 0 0 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.form-stack .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-stack .field:last-child {
  margin-bottom: 0;
}

.form-stack label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-stack textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.45;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  min-height: 1.2em;
}

.telegram-chat-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.telegram-chat-link:hover {
  text-decoration: underline;
}

.field-narrow {
  max-width: 200px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Position orders: .field/.form-row-2 set display:flex|grid which overrides [hidden]. */
[data-hide-for-position][hidden],
[data-hide-for-position].is-hidden-for-position,
body.drawer-order-is-position [data-hide-for-position] {
  display: none !important;
}

/* Caster drawer: hide finance/tabs/save; .field flex would otherwise ignore [hidden]. */
body.drawer-caster-readonly .caster-hidden-field,
.form-stack .caster-hidden-field[hidden],
body.drawer-caster-readonly .drawer-tab[data-tab="costs"],
body.drawer-caster-readonly .drawer-tab[data-tab="stock"],
body.drawer-caster-readonly .drawer-tab[data-tab="files"],
body.drawer-caster-readonly .drawer-tab[data-tab="client"],
body.drawer-caster-readonly .drawer-tab[data-tab="integrations"],
body.drawer-caster-readonly .drawer-footer-save,
body.drawer-caster-readonly #btnDuplicateOrder,
body.drawer-caster-readonly #btnDeleteOrder,
body.drawer-caster-readonly #btnConfirmDeleteOrder,
body.drawer-caster-readonly #btnCancelDeleteOrder,
body.drawer-caster-readonly #btnDeleteArchived,
body.drawer-caster-readonly #btnConfirmDeleteArchived,
body.drawer-caster-readonly #btnCancelDeleteArchived,
body.drawer-caster-readonly #btnArchiveNow,
body.drawer-caster-readonly #btnActSigned,
body.drawer-caster-readonly .drawer-hotkeys {
  display: none !important;
}

@media (max-width: 520px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.file-drop {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.file-drop:hover,
.file-drop.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-drop-text {
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  padding-top: 8px;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-primary.is-saving,
.drawer-footer-save.is-saving {
  opacity: 0.85;
  cursor: wait;
  pointer-events: none;
}

.btn-lg {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
}

.form-actions .secondary {
  padding: 12px 20px;
  border-radius: 10px;
}

.history-box {
  font-size: 0.82rem;
  color: var(--muted);
  max-height: 140px;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.attachments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.attachments-empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.attachment-item {
  position: relative;
  width: 88px;
}

.attachment-item--model {
  width: 120px;
}

.attachment-item--gcode {
  width: 100%;
  max-width: 100%;
  flex: 1 1 100%;
}

.file-drop-chips {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  pointer-events: auto;
}

.file-drop-chips[hidden] {
  display: none !important;
}

.file-drop-chip,
.chat-pending-chips .file-drop-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.75rem;
}

.file-drop-chip-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
}

.file-drop-chip-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.file-drop-chip-name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop-chip-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.chat-pending-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-pending-chips[hidden] {
  display: none !important;
}

.attachment-thumb-btn {
  display: block;
  padding: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  border-radius: 8px;
}

.attachment-thumb-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.attachment-thumb {
  display: block;
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.pending-uploads {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.pending-uploads:empty {
  display: none;
}

.pending-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  max-width: 140px;
}

.pending-card-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  word-break: break-word;
}

.pending-card--gcode {
  max-width: none;
  width: 100%;
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  grid-column: 1 / -1;
}

.pending-card--gcode .pending-card-label {
  text-align: left;
}

.pending-preview-btn {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.photo-overlay {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.photo-overlay[hidden] {
  display: none;
}

.photo-lightbox-img {
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.photo-overlay-close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.attachment-remove:hover {
  background: var(--danger);
}

.attachment-stl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 88px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  gap: 6px;
  padding: 6px;
}

.attachment-item--gcode .attachment-stl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  justify-content: start;
  min-height: 0;
  text-align: left;
  gap: 8px 10px;
}

.attachment-item--gcode .pending-card-label {
  text-align: left;
}

@media (max-width: 767px) {
  .attachment-item--gcode,
  .pending-card--gcode {
    width: 100%;
    max-width: 100%;
  }

  .attachment-item--gcode .attachment-stl {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .attachment-item--gcode .attachment-stl .linkish {
    grid-column: 2;
  }

  .file-drop-chip-name {
    max-width: 42vw;
  }
}

.attachment-stl-icon {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.attachment-view-stl {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.viewer-overlay[hidden] {
  display: none;
}

.viewer-shell {
  position: relative;
  width: min(960px, 100%);
  height: min(80vh, 720px);
  background: #1a1a1e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

.viewer-shell iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.viewer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 768px) {
  .viewer-overlay {
    padding: 0;
    align-items: stretch;
  }
  .viewer-shell {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
  .viewer-close {
    top: max(8px, env(safe-area-inset-top));
    right: max(8px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }

  .drawer {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-left));
    padding-bottom: max(12px, var(--safe-bottom));
  }

  .drawer-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 10px;
  }

  .drawer-tab {
    flex-shrink: 0;
    min-height: var(--touch-min);
    padding: 8px 14px;
  }

  .drawer-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin: 0 -12px -12px;
    padding: 8px 12px;
    padding-bottom: max(8px, var(--safe-bottom));
    z-index: 2;
  }

  .drawer-footer button,
  .drawer-tab,
  .drawer-close-btn {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
  }

  .drawer-footer .drawer-footer-save {
    min-height: var(--touch-min);
    min-width: 0;
  }

  #panel-new-order .form-row-2,
  #panel-new-order .form-row-3 {
    grid-template-columns: 1fr;
  }

  #panel-new-order .file-drop {
    width: 100%;
  }

  /* See owned sticky block near end of file: «OMS: new-order sticky submit above bottom-nav» */
  #panel-new-order .form-actions--sticky {
    position: sticky;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    background: linear-gradient(transparent, var(--bg) 24%);
    margin: 0 -16px;
    padding: 16px;
    z-index: 4;
  }

  #panel-pipeline {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 8px);
  }

  .pipeline {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 8px;
    min-height: auto;
  }

  .pipeline.pipeline--accordion {
    flex-direction: column;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .pipeline:not(.pipeline--accordion) .pipeline-col {
    scroll-snap-align: start;
    min-width: min(88vw, 320px);
    flex: 0 0 min(88vw, 320px);
  }

  .table-scroll {
    margin: 0 -4px;
    padding-bottom: 4px;
  }

  .card .table-scroll table {
    min-width: 560px;
  }

  .models-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
  }

  .models-tab {
    flex-shrink: 0;
    min-height: var(--touch-min);
  }

  .models-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .models-upload {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .model-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .token-modal {
    width: min(360px, calc(100vw - 32px - var(--safe-left) - var(--safe-right)));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding-bottom: max(24px, var(--safe-bottom));
  }

  .token-modal input,
  .token-modal button {
    min-height: var(--touch-min);
  }
}

.drawer .form-stack {
  padding-bottom: 24px;
}

.drawer .form-page-title {
  font-size: 1.15rem;
  margin-bottom: 20px;
}

.token-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 10001;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(360px, 92vw);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.token-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.token-modal h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

#tokenOverlay.show {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10000;
  opacity: 1;
  pointer-events: auto;
}

body.auth-required .content,
body.auth-required .layout {
  pointer-events: none;
  user-select: none;
}

body.auth-required .app-header,
body.auth-required #tokenOverlay,
body.auth-required #tokenModal,
body.auth-required .auth-banner {
  pointer-events: auto;
  filter: none;
}

#btnLogin:not([hidden]) {
  font-weight: 700;
}

.models-intro {
  margin-bottom: 16px;
}

.models-intro-lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.models-intro-lead a {
  color: var(--accent);
}

.models-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.models-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.models-tab:hover {
  border-color: var(--accent);
}

.models-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.models-section-title {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
}

.models-toolbar {
  margin-bottom: 16px;
  align-items: center;
}

.models-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.models-order-pick {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 360px;
}

.models-order-pick label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.models-order-pick select {
  width: 100%;
}

.model-card-library {
  color: var(--muted);
  font-size: 0.88rem;
}

.models-file-drop {
  min-width: 220px;
  flex: 0 1 auto;
}

.model-library {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.models-empty {
  color: var(--muted);
  margin: 0;
}

.model-month {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.model-month-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.model-month-count {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.model-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(13, 92, 77, 0.1);
}

.model-card-thumb-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
}

.model-card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(180deg, #dce1e6, #eef1f4);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.model-card-thumb-btn:hover .model-card-thumb {
  filter: brightness(1.03);
}

.model-card-thumb iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.model-card-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f8fafc;
}

.model-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #1a6bb5 0%, #0d4a82 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
}

.model-card-placeholder small {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.85;
  letter-spacing: 0;
}

.model-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent);
}

.model-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.model-card-name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-meta {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
}

.model-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}

.model-card-actions button,
.model-card-actions a {
  font-size: 0.72rem;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.model-card-actions button.primary,
.model-card-actions a.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.model-card-actions button.danger-outline {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

.model-card-actions button:hover,
.model-card-actions a:hover {
  filter: brightness(0.97);
}

/* ── Mobile utilities ── */
.touch-target {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  touch-action: manipulation;
}

/* Primary actions + form submits always meet 44px hit area */
.btn-primary,
.drawer-footer button,
.drawer-footer .btn-primary,
.form-actions button[type="submit"],
button[type="submit"].btn-primary {
  min-height: var(--touch-min, 44px);
  touch-action: manipulation;
}

.safe-pad {
  padding-left: max(12px, var(--safe-left));
  padding-right: max(12px, var(--safe-right));
}

.safe-pad-top {
  padding-top: max(12px, var(--safe-top));
}

.safe-pad-bottom {
  padding-bottom: max(8px, var(--safe-bottom));
}

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

.mobile-only { display: none !important; }
.desktop-only { display: block; }

.brand-short { display: none; }
.brand-full { display: inline; }
.brand-sub { display: block; }

.panel-lead,
.pipeline-hint {
  color: var(--muted);
  margin-top: 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.header-refresh {
  font-size: 1.25rem;
  padding: 0 12px;
}

.btn-refresh-icon { display: none; }
.btn-refresh-label { display: inline; }

/* Order cards (mobile lists) */
.order-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
}

.order-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.order-card-id {
  font-weight: 700;
  font-size: 0.95rem;
}

.order-card-task {
  margin: 0 0 6px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}

.order-card-meta {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.order-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.order-card-open {
  margin-top: 8px;
  width: 100%;
}

.order-card-extra {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Bottom navigation: 4 tabs + menu button (dashboard | pipeline | orders | new-order | menu) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
  padding-top: 4px;
  /* Ensure nav receives taps even if a toast overlaps its box */
  pointer-events: auto;
}

/* Order drawer open: bottom-nav must not steal taps under overlay/footer */
body.drawer-open .bottom-nav {
  pointer-events: none;
  visibility: hidden;
}

.bottom-nav-main {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-width: 0;
}

.bottom-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.62rem;
  padding: 6px 2px;
  cursor: pointer;
  min-width: 0;
}

.bottom-nav-label {
  line-height: 1.15;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav-menu-btn {
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.bottom-nav-menu-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.bottom-nav-btn.active {
  color: var(--accent);
  font-weight: 600;
}

.bottom-nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

/* Side menu (slides from right) — only on phone */
.side-menu-overlay,
.side-menu {
  display: none;
}

.side-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 45;
}

.side-menu-overlay:not([hidden]) {
  display: block;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 46;
  width: min(300px, 88vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
  padding: max(12px, var(--safe-top)) 16px max(16px, var(--safe-bottom));
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
}

.side-menu.open {
  transform: translateX(0);
}

.side-menu:not([hidden]) {
  display: flex;
}

body.side-menu-open {
  overflow: hidden;
}

.side-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.side-menu-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.side-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.side-nav-btn {
  width: 100%;
  min-height: var(--touch-min);
  text-align: left;
  font-size: 0.95rem;
}

.side-nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.side-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.drawer-close-btn {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.pipeline-status-select {
  width: 100%;
  margin-top: 8px;
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.filters-toggle {
  width: 100%;
}

.toolbar-filters.filters-collapsed {
  display: none;
}

@media (max-width: 767px) {
  .bottom-nav.mobile-only { display: flex !important; }
  .order-card-list.mobile-only { display: flex !important; }
  .filters-toggle.mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }

  .side-menu-overlay[hidden],
  .side-menu[hidden] {
    display: none !important;
    pointer-events: none !important;
  }

  body:not(.embed) {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  body:not(.embed) .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  /* !important: beat @media (max-width:1000px) { .sidebar { display:flex } } */
  body:not(.embed) .sidebar {
    display: none !important;
  }

  .app-header {
    padding: 10px 16px;
    padding-top: max(10px, var(--safe-top));
  }

  .brand h1 { font-size: 1.1rem; }
  .brand-short { display: inline; }
  .brand-full { display: none; }
  .brand-sub { display: none; }

  .header-actions-extra { display: none; }
  .org-switcher {
    max-width: 48vw;
  }
  .org-switcher select {
    min-width: 110px;
    max-width: 34vw;
  }

  .btn-refresh-label { display: none; }
  .btn-refresh-icon { display: inline; }

  .content {
    padding: 12px 16px calc(24px + var(--bottom-nav-h) + var(--safe-bottom));
  }

  .form-card-wide {
    max-width: none;
  }

  .app-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .app-header .brand {
    min-width: 0;
    flex: 1 1 120px;
  }

  .header-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .header-actions .touch-target {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
  }

  .bottom-nav {
    padding-bottom: 0;
    min-height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }

  .bottom-nav-btn,
  .bottom-nav-menu-btn {
    min-height: var(--touch-min);
  }

  .side-menu-nav .side-nav-btn {
    min-height: var(--touch-min);
  }

  .form-page-lead {
    margin-bottom: 16px;
  }

  .file-drop {
    min-height: var(--touch-min);
  }

  input[type="file"] {
    min-height: var(--touch-min);
  }

  .toolbar--orders,
  .toolbar--archive {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding-bottom: 8px;
    margin: -4px 0 12px;
  }

  .toolbar-search {
    width: 100%;
    min-height: var(--touch-min);
  }

  .toolbar-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .toolbar-filters select,
  .toolbar-filters input {
    width: 100%;
    min-height: var(--touch-min);
  }

  .toolbar--archive .toolbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* Drawer above bottom-nav (z=30); covers full viewport including nav area */
  .drawer,
  .drawer.open,
  #drawer.open {
    z-index: 40;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    padding: max(12px, var(--safe-top)) max(12px, var(--safe-right)) max(12px, var(--safe-left));
    padding-bottom: max(12px, var(--safe-bottom));
  }

  .drawer-hotkeys {
    display: none !important;
  }

  .drawer .form-row-2 {
    grid-template-columns: 1fr;
  }

  .drawer-panel[data-panel="files"] .form-row-2 {
    grid-template-columns: 1fr;
  }

  .drawer-panel[data-panel="files"] .file-drop {
    width: 100%;
  }

  .drawer-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 10px;
  }

  .drawer-tab {
    flex-shrink: 0;
    min-height: var(--touch-min);
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  /* Sticky footer: bottom-nav covered by drawer → only safe-area inset */
  .drawer-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    margin: 0 -12px -12px;
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px), var(--safe-bottom));
    z-index: 2;
    pointer-events: auto;
  }

  .drawer-footer .btn-primary {
    flex: 0 0 auto;
    min-height: var(--touch-min);
    touch-action: manipulation;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  /* Shared sticky base; new-order owned overrides live in «OMS: new-order sticky submit…» */
  .form-actions--sticky {
    position: sticky;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    background: linear-gradient(transparent, var(--bg) 20%);
    padding-top: 16px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 4;
  }

  .token-modal {
    width: min(360px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding-bottom: max(24px, var(--safe-bottom));
  }

  /* Pipeline accordion on phone */
  .pipeline.pipeline--accordion {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
  }

  .pipeline.pipeline--accordion .pipeline-col {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .pipeline.pipeline--accordion .pipeline-col h3 {
    cursor: pointer;
    user-select: none;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: 8px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .pipeline.pipeline--accordion .pipeline-col h3::after {
    content: "▾";
    color: var(--muted);
    transition: transform 0.15s;
  }

  .pipeline.pipeline--accordion .pipeline-col.collapsed h3::after {
    transform: rotate(-90deg);
  }

  .pipeline.pipeline--accordion .pipeline-col.collapsed .pipeline-dropzone {
    display: none;
  }

  /* Handles shown on phone — see appended «OMS mobile pipeline polish» */
  .pipeline.pipeline--accordion .pipeline-dropzone {
    margin-top: 8px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .sidebar .nav-btn {
    font-size: 0.82rem;
    padding: 8px 10px;
  }

  .layout {
    grid-template-columns: 180px 1fr;
  }

  .pipeline-status-select {
    display: block;
    margin-top: 6px;
  }
}

@media (max-width: 767px) {
  .funnel-row {
    grid-template-columns: 90px 1fr 28px;
    font-size: 0.75rem;
  }
}

/* Desktop embedded browser (PC only, ≥1025px) */
.desktop-browser-only {
  display: none !important;
}

@media (min-width: 1025px) {
  .desktop-browser-only {
    display: block !important;
  }

  #btnOpenOrderBrowser.desktop-browser-only {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  #btnOpenOrderBrowser.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
  }

  .form-page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 4px;
  }

  .form-page-head .form-page-lead {
    margin-top: 6px;
  }

  #panel-new-order {
    position: relative;
  }

  .browser-dock-overlay {
    position: fixed;
    top: 72px;
    right: 0;
    bottom: 0;
    width: min(44vw, 780px);
    min-width: 400px;
    max-width: 100vw;
    z-index: 260;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border);
    background: var(--surface);
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
    transform: translateX(100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.24s ease, visibility 0.24s;
  }

  .browser-dock-overlay.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .browser-dock-overlay[hidden]:not(.is-open) {
    display: none !important;
  }

  .browser-dock-overlay:not([hidden]),
  .browser-dock-overlay.is-open {
    display: flex !important;
    flex-direction: column;
  }

  .workspace {
    min-width: 0;
    display: block;
  }

  .browser-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .browser-nav {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
  }

  .browser-icon-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 4px 8px;
    font-size: 1rem;
    line-height: 1;
  }

  .browser-url-input {
    flex: 1;
    min-width: 0;
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
  }

  .browser-go-btn {
    flex-shrink: 0;
    padding: 8px 12px;
  }

  .browser-bookmarks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .browser-bookmark {
    font: inherit;
    font-size: 0.78rem;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    color: var(--text);
  }

  .browser-bookmark:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .browser-hint {
    margin: 0;
    padding: 6px 10px;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.35;
    flex-shrink: 0;
  }

  .browser-auto-order {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 8px;
    font-size: 0.78rem;
    color: var(--muted);
    flex-shrink: 0;
    cursor: pointer;
  }

  .browser-companion {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    margin: 8px 10px 10px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    min-height: 200px;
  }

  .browser-companion--active {
    border-color: var(--accent);
    background: var(--accent-soft);
  }

  .browser-companion--blocked {
    border-color: #c2410c;
    background: #fff7ed;
  }

  .browser-companion--closed {
    border-style: solid;
  }

  .browser-companion-title {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
  }

  .browser-companion-sub {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
  }

  .browser-companion-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
  }

  .browser-companion-actions .btn-primary,
  .browser-companion-actions .secondary,
  .browser-companion-actions .ghost {
    flex: 1 1 auto;
    min-width: 120px;
  }

  .browser-frame-wrap {
    position: relative;
    flex: 1;
    min-height: 280px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
  }

  .browser-viewport {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
    background: var(--surface-2);
  }

  .browser-viewport--active {
    background: var(--accent-soft);
    border: 2px dashed var(--accent);
    margin: 8px;
    inset: 8px;
    border-radius: 10px;
  }

  .browser-viewport--blocked {
    background: #fff7ed;
    border: 2px dashed #c2410c;
    margin: 8px;
    inset: 8px;
    border-radius: 10px;
  }

  .browser-viewport-title {
    margin: 0;
    font-weight: 600;
    font-size: 0.95rem;
  }

  .browser-viewport-msg {
    margin: 0;
    max-width: 320px;
    font-size: 0.82rem;
    color: var(--muted);
    line-height: 1.45;
  }

  .browser-viewport-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 4px;
  }

  .browser-viewport-actions .btn-primary,
  .browser-viewport-actions .secondary,
  .browser-viewport-actions .ghost {
    min-width: 120px;
  }
}

/* Omnichannel inbox (mobile-first) */
.toolbar--inbox {
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chat-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2, #f5f0e8);
  border: 1px solid var(--border, #e7e0d4);
}
.chat-tab {
  min-height: 40px;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted, #78716c);
}
.chat-tab.active {
  background: var(--surface, #fffdf9);
  color: var(--text, #1c1917);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.chat-panel[hidden] { display: none !important; }

.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-height: 60vh;
}
@media (min-width: 900px) {
  .chat-layout { grid-template-columns: minmax(240px, 34%) 1fr; }
}
.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-sidebar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chat-room-search {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(13, 92, 77, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text, #1c1917);
  font: inherit;
  font-size: 0.92rem;
}
.chat-room-search::placeholder {
  color: var(--muted, #78716c);
}
.chat-room-search:focus {
  outline: none;
  border-color: rgba(13, 92, 77, 0.45);
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.12);
}
.chat-room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 65vh;
  overflow-y: auto;
}
.chat-room-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(240, 253, 250, 0.78));
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.05);
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}
.chat-room-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.1);
}
.chat-room-item.active {
  border-color: var(--accent, #0d5c4d);
  background: linear-gradient(135deg, #ecfdf5, #dff7ff);
}
.chat-room-item.unread { border-color: rgba(13, 92, 77, 0.35); }
.chat-room-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chat-room-preview { font-size: 0.8rem; color: var(--muted, #78716c); }
.chat-room-title,
.chat-room-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-room-title {
  color: var(--text, #1c1917);
}
.chat-room-badge,
.nav-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent, #0d5c4d);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
}
.chat-room-mention {
  justify-self: end;
  color: var(--accent, #0d5c4d);
  font-weight: 800;
}
.nav-unread-badge {
  margin-left: 6px;
  min-width: 18px;
  height: 18px;
  font-size: 0.68rem;
  pointer-events: none;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--accent-soft, #d1ebe4);
  color: var(--accent, #0d5c4d);
  font-weight: 800;
  overflow: hidden;
  border: 1px solid rgba(13, 92, 77, 0.16);
}
.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-avatar--group {
  background: linear-gradient(135deg, #bae6fd, #99f6e4);
  color: #075985;
}

.chat-main {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 50vh;
  border: 1px solid rgba(13, 92, 77, 0.12);
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 12%, rgba(125, 211, 252, 0.28), transparent 28%),
    radial-gradient(circle at 88% 18%, rgba(167, 243, 208, 0.36), transparent 30%),
    linear-gradient(135deg, #f8fffb 0%, #eef9ff 46%, #fef7ed 100%);
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 18px 44px rgba(15, 118, 110, 0.08);
}
.chat-main-header {
  min-height: 32px;
  padding: 4px 4px 8px;
}
.chat-main-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-main-title-row--clickable {
  cursor: pointer;
}
.chat-main-title-row--clickable .chat-avatar {
  box-shadow: 0 0 0 3px rgba(13, 92, 77, 0.08);
}
.chat-main-title-row--clickable:hover .chat-avatar {
  box-shadow: 0 0 0 4px rgba(13, 92, 77, 0.16);
}
.chat-main-title { margin: 0; font-size: 1.05rem; }
.chat-members-btn {
  margin-left: auto;
}
.chat-main-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted, #78716c);
}
.chat-pinned {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff7db;
  border: 1px solid #f0d98c;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  font-size: 0.85rem;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 55vh;
  padding: 14px 8px;
  border-radius: 18px;
  background:
    radial-gradient(circle, rgba(13, 92, 77, 0.08) 1px, transparent 1.5px) 0 0 / 22px 22px,
    rgba(255, 255, 255, 0.34);
}
.chat-bubble {
  max-width: min(88%, 520px);
  display: flex;
  gap: 8px;
  padding: 0;
  border-radius: 14px;
  background: transparent;
  align-self: flex-start;
}
.chat-bubble--mine {
  align-self: flex-end;
}
.chat-bubble--flash .chat-bubble-content {
  outline: 2px solid var(--accent, #0d5c4d);
}
.chat-bubble-avatar {
  width: 30px;
  height: 30px;
  align-self: flex-end;
}
.chat-bubble--mine .chat-bubble-avatar {
  order: 2;
}
.chat-bubble-content {
  padding: 10px 12px;
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #1c1917;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.08);
  min-width: 0;
}
.chat-bubble-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: #57534e;
  margin-bottom: 4px;
}
.chat-bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: inherit;
}
.chat-bubble--mine .chat-bubble-content {
  background: linear-gradient(135deg, #d9fdd3, #c9f7e8);
  color: #1c1917;
  border-bottom-right-radius: 6px;
}
.chat-photo {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  cursor: zoom-in;
}
.chat-photo img {
  display: block;
  max-width: min(100%, 360px);
  max-height: 360px;
  object-fit: contain;
}
.chat-video {
  display: block;
  margin-bottom: 6px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #111;
  max-width: min(100%, 360px);
}
.chat-video video {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #111;
}
.chat-voice {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 10px;
  min-width: min(72vw, 280px);
  margin-bottom: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(13, 92, 77, 0.08);
  border: 1px solid rgba(13, 92, 77, 0.12);
}
.chat-voice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent, #0d5c4d);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}
.chat-voice audio {
  width: 100%;
  height: 34px;
}
.chat-bubble-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
  opacity: 1;
}
.chat-bubble-more {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted, #78716c);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-bubble-more:hover,
.chat-bubble-more[aria-expanded="true"] {
  background: rgba(13, 92, 77, 0.08);
  color: var(--accent, #0d5c4d);
}
.chat-bubble-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface, #fff);
  border: 1px solid rgba(13, 92, 77, 0.16);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.16);
}
.chat-bubble-menu[hidden] {
  display: none !important;
}
.chat-bubble-menu button,
.chat-bubble-menu .chat-bubble-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text, #1c1917);
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 44px;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}
.chat-bubble-menu button:hover,
.chat-bubble-menu button:focus-visible,
.chat-bubble-menu .chat-bubble-menu-item:hover {
  background: rgba(13, 92, 77, 0.08);
}
.chat-bubble-menu-danger {
  color: #b91c1c;
}
.chat-bubble-edited {
  margin-left: 6px;
  font-size: 0.72rem;
  opacity: 0.65;
}
.chat-bubble--deleted .chat-bubble-body {
  opacity: 0.72;
  font-style: italic;
}
.chat-bubble-actions .ghost {
  min-height: 28px;
  padding: 2px 6px;
  font-size: 0.72rem;
}
.chat-reply-quote,
.chat-compose-reply {
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid var(--accent, #0d5c4d);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 6px;
  color: var(--text, #1c1917);
}
.chat-reply-quote span,
.chat-compose-reply span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted, #78716c);
}
.chat-reply-quote strong {
  display: block;
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-mention {
  color: var(--accent, #0d5c4d);
  font-weight: 800;
}
.chat-compose {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  position: relative;
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(13, 92, 77, 0.12);
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.08);
}
.chat-compose-edit,
.chat-compose-reply,
.chat-compose .chat-pending-chips {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}

.chat-compose .chat-pending-chips {
  justify-content: flex-start;
  flex-wrap: wrap;
}
.chat-compose-edit {
  border-left: 3px solid #ca8a04;
  background: rgba(254, 249, 195, 0.55);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text, #1c1917);
  font-size: 0.82rem;
  font-weight: 600;
}
.chat-compose-edit[hidden] {
  display: none !important;
}
.chat-compose-edit-cancel {
  min-width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}
.chat-compose-attach {
  display: contents;
}
.chat-attach-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  touch-action: manipulation;
}
.chat-attach-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}
.chat-compose-attach:has(.chat-voice-btn.recording) .chat-attach-btn {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.16);
}
.chat-compose-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.chat-compose textarea,
.chat-compose #teamChatInput {
  width: 100%;
  min-width: 0;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.35;
  field-sizing: content;
  overflow-y: auto;
}
.chat-photo-btn,
.chat-file-btn,
.chat-voice-btn {
  border-radius: 999px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  flex-shrink: 0;
}
.chat-voice-btn.recording {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
  box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.16);
}
@media (max-width: 640px) {
  .chat-compose {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .chat-compose .chat-send-btn,
  .chat-compose .btn-primary.chat-send-btn {
    grid-column: auto;
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
    justify-self: end;
  }
}
.chat-mention-menu {
  position: absolute;
  left: 0;
  right: 80px;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 12px;
  background: var(--surface, #fffdf9);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.chat-mention-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 7px 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.chat-mention-menu button:hover {
  background: var(--surface-2, #f5f0e8);
}
.modal-overlay.chat-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(28, 25, 23, 0.42);
  backdrop-filter: blur(3px);
}
.chat-picker-overlay .modal {
  width: min(96vw, 560px);
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 18px;
  background: var(--surface, #fffdf9);
  border: 1px solid var(--border, #e7e0d4);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  padding: 18px;
}
.chat-picker-overlay .chat-picker-modal {
  width: min(96vw, 420px);
  max-height: 85vh;
  overflow: auto;
}
.chat-picker-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 40vh;
  overflow-y: auto;
  margin: 12px 0;
}
.chat-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 10px;
  cursor: pointer;
}
.chat-group-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.chat-group-title-wrap input {
  min-height: 44px;
  padding: 8px 10px;
}
.chat-picker-members-label {
  margin: 0 0 6px;
  font-weight: 600;
}
.chat-members-lifecycle {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}
.chat-profile-modal {
  width: min(96vw, 480px);
}
.chat-members-modal {
  width: min(96vw, 560px);
  max-height: 86vh;
  overflow: auto;
}
.chat-members-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.chat-member-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 12px;
  background: var(--surface-2, #f5f0e8);
}
.chat-member-row small {
  display: block;
  color: var(--muted, #78716c);
}
.chat-add-member {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 12px;
}
.chat-add-member label {
  grid-column: 1 / -1;
  margin: 0;
}
.chat-add-member select {
  min-height: 44px;
}
.ghost.danger {
  color: #b91c1c;
}
.chat-profile-modal label {
  display: block;
  margin: 10px 0 4px;
  font-weight: 600;
}
.chat-profile-modal input[type="url"],
.chat-profile-modal textarea {
  width: 100%;
}
.chat-pref-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500 !important;
}

.inbox-intro { margin: 0 0 12px; padding: 0 4px; }
.inbox-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .inbox-layout { grid-template-columns: minmax(240px, 36%) 1fr; }
}
.inbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
}
.inbox-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 12px;
  background: var(--surface, #fffdf9);
  cursor: pointer;
  min-height: 44px;
}
.inbox-item.active { border-color: var(--accent, #0d5c4d); }
.inbox-phone { font-size: 0.85rem; color: var(--muted, #78716c); }
.inbox-preview { font-size: 0.8rem; color: var(--muted, #78716c); }

.actor-badge {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.account-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1px;
  max-width: min(46vw, 280px);
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--text);
}

.account-chip--personal {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.account-chip-line {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-chip-primary {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--accent);
}

.account-chip-secondary {
  font-size: 0.72rem;
  color: var(--muted);
}

.account-info-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 8px;
}

.account-info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-info-k {
  font-size: 0.75rem;
  color: var(--muted);
}

.actor-account-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.actor-account-actions .secondary {
  width: 100%;
}

.actor-pick-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.actor-pick-login {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: normal;
}

.side-menu-push-status {
  margin: 0 0 8px;
  padding: 0 4px;
  font-size: 0.78rem;
  color: var(--muted, #6b7280);
  line-height: 1.35;
}

.side-menu-account {
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.side-menu-account-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.side-menu-account-primary {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.side-menu-account-secondary {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 767px) {
  .account-chip-secondary {
    display: none;
  }

  .account-chip {
    max-width: 38vw;
    padding: 6px 10px;
  }
}
.actor-modal { max-width: 420px; }
.actor-user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  max-height: 50vh;
  overflow-y: auto;
}
.actor-pick-btn {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 10px;
  background: var(--surface, #fffdf9);
  cursor: pointer;
  text-align: left;
}
.actor-pick-btn:hover { border-color: var(--accent, #0d5c4d); }
.actor-pick-role { font-size: 0.85rem; color: var(--muted, #78716c); }
.draft-restore-bar {
  position: fixed;
  bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  padding: 10px 14px;
  border-radius: 12px;
  background: #1c1917;
  color: #fafaf9;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: min(96vw, 560px);
  pointer-events: auto;
}
.draft-restore-bar[hidden] {
  display: none !important;
}
.draft-restore-msg {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.35;
}
.draft-restore-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}
@media (max-width: 520px) {
  .draft-restore-bar {
    flex-wrap: wrap;
    left: 8px;
    right: 8px;
    transform: none;
    max-width: none;
  }
  .draft-restore-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
button.danger, .ghost.danger { color: #b91c1c; }
button.danger:hover { background: #fef2f2; }
.role-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.role-checkboxes label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.user-edit-modal { max-width: 440px; }
.inbox-detail-card { padding: 12px; border: 1px solid var(--border, #e7e0d4); border-radius: 12px; background: var(--surface, #fffdf9); }
.inbox-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.inbox-reply-input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border, #e7e0d4); font: inherit; margin-bottom: 8px; }
.inbox-hint { margin-top: 8px; font-size: 0.75rem; }

/* ============================================================================
   OPEN DESIGN SYSTEM — новые компоненты v1.0
   Пастельная палитра, soft elevation, Inter Variable.
   ============================================================================ */

/* === BADGES / PILLS (для статусов заказов) === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: var(--tracking-wide);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--neutral { background: var(--grey-100);  color: var(--grey-700); }
.badge--primary { background: var(--primary-100); color: var(--primary-700); }
.badge--lavender{ background: rgba(181, 168, 201, 0.18); color: var(--accent-lavender); }
.badge--rose    { background: rgba(212, 168, 171, 0.18); color: var(--accent-rose); }
.badge--cream   { background: rgba(239, 227, 208, 0.30); color: #8B7355; }

/* === AVATARS === */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  border: 1.5px solid var(--surface);
  flex-shrink: 0;
  font-feature-settings: "tnum";
}
.avatar--sm { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar--lg { width: 48px; height: 48px; font-size: var(--text-lg); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar:not(:first-child) { margin-left: -8px; }

/* === SKELETON LOADERS === */
.skeleton-block {
  background: linear-gradient(90deg,
    var(--grey-100) 0%,
    var(--grey-200) 50%,
    var(--grey-100) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px;
  width: 100%;
}
.skeleton-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grey-200);
  animation: shimmer 1.5s infinite;
}

/* === BENTO GRID для dashboard === */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: minmax(120px, auto);
  gap: var(--space-4);
}
.bento-stat { grid-column: span 3; grid-row: span 1; }
.bento-funnel { grid-column: span 8; grid-row: span 2; }
.bento-alerts { grid-column: span 4; grid-row: span 2; }
.bento-recent { grid-column: span 12; grid-row: span 2; }
.bento-chart { grid-column: span 6; grid-row: span 2; }
.bento-stock { grid-column: span 6; grid-row: span 1; }

@media (max-width: 1024px) {
  .bento-stat { grid-column: span 6; }
  .bento-funnel,
  .bento-alerts { grid-column: span 12; }
  .bento-chart,
  .bento-stock { grid-column: span 12; }
}
@media (max-width: 640px) {
  .bento-stat { grid-column: span 12; }
}

/* === ACTIVITY FEED === */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.activity-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--grey-200);
  transition: all var(--duration-fast) var(--ease-out);
}
.activity-item:hover {
  background: var(--surface-2);
  border-color: var(--grey-300);
}
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-400);
  flex-shrink: 0;
  margin-top: 6px;
}
.activity-content {
  flex: 1;
  min-width: 0;
}
.activity-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--grey-800);
  margin: 0 0 2px;
}
.activity-meta {
  font-size: var(--text-xs);
  color: var(--grey-500);
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  animation: slide-in-right var(--duration-base) var(--ease-out-quart);
  pointer-events: auto;
}
.toast--success { border-left: 3px solid var(--success); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--danger  { border-left: 3px solid var(--danger); }
.toast--info    { border-left: 3px solid var(--info); }
.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--grey-900);
  margin: 0;
}
.toast-body {
  font-size: var(--text-xs);
  color: var(--grey-600);
  margin: 2px 0 0;
}

/* === FOCUS RING (WCAG 2.2 AAA) === */
.btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* === UTILITY CLASSES === */
.text-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.text-tabular { font-variant-numeric: tabular-nums; }
.text-muted { color: var(--muted); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-semibold { font-weight: var(--weight-semibold); }
.uppercase-label {
  text-transform: uppercase;
  letter-spacing: var(--tracking-widest);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--muted);
}
.surface {
  background: var(--surface);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-xs);
}
.divider {
  height: 1px;
  background: var(--grey-200);
  margin: var(--space-4) 0;
  border: none;
}

/* === SIDEBAR с иконками (опционально) === */
.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: none;
  background: transparent;
  color: var(--grey-600);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: inherit;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  min-height: var(--touch-min);
}
.nav-btn:hover {
  background: var(--surface-2);
  color: var(--grey-900);
}
.nav-btn.active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: var(--weight-semibold);
}
.nav-btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* === META THEME-COLOR === */
:root {
  --meta-color: #7B9E89;
}

/* === PRODUCTION TYPE SELECTOR === */
.production-type-group {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.production-type-btn {
  flex: 1;
  padding: 10px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--grey-700);
  font-weight: var(--weight-medium);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: center;
  min-height: var(--touch-min);
}
.production-type-btn:hover {
  border-color: var(--grey-300);
  background: var(--surface-2);
}
.production-type-btn.active {
  border-color: var(--primary-500);
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: var(--weight-semibold);
}
.production-type-btn.express.active {
  border-color: var(--danger);
  background: #fef2f2;
  color: #b91c1c;
}
.production-type-btn.express:hover:not(.active) {
  border-color: #fca5a5;
  background: #fff5f5;
}

/* === CHECKBOX LABEL (for self_invoice) === */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-500);
}

/* === FORM SECTION NUMBER HINT === */
.form-section-title {
  counter-increment: form-section;
}

/* === INVENTORY CODE / SKU chip === */
.inv-code {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent, #0d5c4d);
  letter-spacing: 0.02em;
}

.sku-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--accent, #0d5c4d) 35%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent, #0d5c4d) 10%, transparent);
  color: var(--accent, #0d5c4d);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}
.sku-chip:hover,
.sku-chip:focus-visible {
  background: color-mix(in srgb, var(--accent, #0d5c4d) 18%, transparent);
  outline: none;
}
.sku-chip--empty {
  cursor: default;
  opacity: 0.65;
  border-style: dashed;
}

.rework-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.35;
  vertical-align: middle;
  color: var(--accent, #0d5c4d);
  background: color-mix(in srgb, var(--accent, #0d5c4d) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #0d5c4d) 28%, transparent);
}

.history-event + .history-event {
  margin-top: 8px;
}

.history-event-line {
  line-height: 1.45;
}

.history-event-changes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.history-change-chip {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.order-paid-by {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #5a6a66);
  margin: 0 0 2px;
}

.orders-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 8px 4px;
  flex-wrap: wrap;
}
.orders-pager-label {
  font-size: 0.85rem;
  color: var(--text-muted, #5a6a66);
  min-width: 7.5rem;
  text-align: center;
}
.orders-pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === ORDER CHAT (per-order team discussion) === */
.order-chat {
  display: flex;
  flex-direction: column;
  height: 60vh;
  min-height: 320px;
}
.order-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 4px 12px;
}
.order-chat-messages .chat-bubble {
  margin: 0;
}
.order-chat-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 10px;
  margin-top: 4px;
}
.order-chat-compose .chat-pending-chips {
  flex: 1 1 100%;
}
.order-chat-compose .chat-compose-tools {
  flex: 0 0 auto;
}
.order-chat-compose textarea {
  flex: 1 1 140px;
  resize: vertical;
  min-height: 42px;
}
.chat-file-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 6px;
}
.chat-file-name {
  grid-column: 1;
  font-weight: 600;
  word-break: break-word;
}
.chat-file-type {
  grid-column: 1;
  font-size: 0.72rem;
  color: var(--muted);
}
.chat-file-card .linkish {
  grid-column: 2;
  grid-row: 1 / span 2;
}
.order-chat-compose .btn-primary {
  flex: 0 0 auto;
  align-self: stretch;
}
.chat-bubble-img {
  display: block;
  max-width: min(100%, 320px);
  border-radius: 12px;
  margin-bottom: 6px;
}

/* === ORDER CHAT UNREAD DOT (blue) === */
.chat-unread-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18);
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}
.chat-unread-dot--card {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  margin: 0;
  box-shadow: 0 0 0 2px var(--surface, #fff);
}
.pipeline-card {
  position: relative;
}
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: #2563eb;
  border-radius: 999px;
}
.tab-badge:empty {
  display: none;
}

/* === New-order form: extra controls (priority, deadlines, payment, ship) === */
.hidden {
  display: none !important;
}

.deadline-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.deadline-preset {
  font-size: 0.72rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  line-height: 1.2;
}

.deadline-preset:hover {
  background: var(--surface);
  border-color: var(--accent, #2e9d5a);
}

.priority-picker-form {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.priority-picker-form .priority-option {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 600;
}

.priority-picker-form .priority-option.active {
  background: var(--surface);
  border-color: currentColor;
}

.priority-picker-form .priority-option.priority-low.active {
  background: #d8f3e3;
  border-color: #2e9d5a;
}

.priority-picker-form .priority-option.priority-medium.active {
  background: #fff3cd;
  border-color: #d4a017;
}

.priority-picker-form .priority-option.priority-high.active {
  background: #fde2e2;
  border-color: #d64545;
}

[data-prepayment-field].hidden {
  display: none !important;
}

.delivery-payment-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.delivery-speed-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.85rem;
}

.radio-pill input[type="radio"] {
  margin: 0;
  cursor: pointer;
}

.ship-date-row .ship-date-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.ship-date-row .ship-date-controls input[type="date"] {
  flex: 1 1 160px;
}

/* ── PWA / mobile polish (iOS standalone + small phones) ── */
/* Prevent iOS Safari auto-zoom on focus: inputs must be >=16px. */
@media (max-width: 767px) {
  .form-stack input,
  .form-stack textarea,
  .form-stack select,
  #orderForm input,
  #orderForm textarea,
  #orderForm select,
  .panel input,
  .panel textarea,
  .panel select,
  #drawer input,
  #drawer textarea,
  #drawer select,
  .drawer input,
  .drawer textarea,
  .drawer select,
  .toolbar-filters input,
  .toolbar-filters select,
  .order-chat-compose textarea,
  .chat-compose textarea {
    font-size: 16px;
  }

  .order-chat-compose textarea,
  .chat-compose textarea,
  .chat-compose #teamChatInput,
  #orderChatInput {
    min-height: 48px;
    padding: 12px 14px;
  }

  .chat-compose-attach {
    display: block;
    position: relative;
    z-index: 4;
    flex-shrink: 0;
  }
  .chat-attach-btn {
    display: inline-flex;
  }
  .chat-compose-tools {
    display: none;
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 30;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-width: 176px;
    padding: 8px;
    border-radius: 14px;
    background: var(--surface, #fffdf9);
    border: 1px solid var(--border, #e7e0d4);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  }
  .chat-compose-attach.is-open .chat-compose-tools {
    display: flex;
  }
  .chat-compose-tools .chat-photo-btn,
  .chat-compose-tools .chat-file-btn,
  .chat-compose-tools .chat-voice-btn {
    width: 100%;
    justify-content: flex-start;
    min-height: 48px;
    border-radius: 12px;
    padding: 0 14px;
    font-size: 1rem;
  }
  .order-chat-compose {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
  }
  .order-chat-compose .chat-pending-chips {
    grid-column: 1 / -1;
  }

  .chat-main {
    min-height: 62dvh;
  }

  .order-chat-compose {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  /* Install button: keep compact, only shown when beforeinstallprompt fires
     (Android Chrome / desktop). Hidden on iOS where the event never fires. */
  #btnInstallPWA {
    padding: 0 10px;
    font-size: 1.2rem;
    line-height: 1;
  }
}

/* ── Install PWA button + modal ── */
.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent, #0d5c4d);
  color: #fffdf9;
  border: 1px solid var(--accent, #0d5c4d);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch-min);
  white-space: nowrap;
}
.btn-install:hover { filter: brightness(0.95); }
.btn-install-icon { font-size: 1.1rem; line-height: 1; }

.install-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.install-modal[hidden] { display: none !important; }
.install-modal-card {
  position: relative;
  background: var(--surface, #fffdf9);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  padding: 22px;
  padding-top: max(22px, env(safe-area-inset-top));
  max-width: 460px;
  width: 100%;
  max-height: 90dvh;
  overflow: auto;
}
.install-modal-card h2 { margin: 0 0 8px; font-size: 1.15rem; }
.install-modal-sub { margin: 0 0 14px; color: var(--muted, #78716c); font-size: 0.9rem; line-height: 1.45; }
.install-steps { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.install-step {
  margin: 0;
  padding: 10px 12px 10px 34px;
  background: var(--surface-2, #f3efe6);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  counter-increment: install-step;
}
.install-steps { counter-reset: install-step; }
.install-step::before {
  content: counter(install-step);
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent, #0d5c4d);
  color: #fffdf9;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
}
.install-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.install-modal-actions button { min-height: var(--touch-min); }

@media (max-width: 767px) {
  .btn-install-label { display: none; }
  .btn-install { padding: 0 10px; }
  .btn-install-icon { font-size: 1.2rem; }
}

/* ——— Native-feel global ——— */
html, body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}
button, .touch-target, .nav-btn, .bottom-nav-btn {
  touch-action: manipulation;
}
.app-panels, .panel {
  -webkit-overflow-scrolling: touch;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

/* ——— Push enable banner ——— */
.push-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2, #eef4f1);
  border-bottom: 1px solid var(--border);
}
.push-banner[hidden] { display: none !important; }
.push-banner-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 180px;
  font-size: 0.88rem;
  line-height: 1.3;
}
.push-banner-body strong { font-weight: 650; }
.push-banner-body span { color: var(--muted, #5a6b64); font-size: 0.82rem; }
.push-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ——— Offline / SW update chrome ——— */
.offline-bar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: #5c3a0d;
  color: #fff8ee;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}
.offline-bar[hidden] { display: none !important; }
body.is-offline .app-header {
  box-shadow: inset 0 -2px 0 #5c3a0d;
}

.pwa-update-bar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--accent, #0d5c4d);
  color: #fffdf9;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  flex-wrap: wrap;
}
.pwa-update-bar[hidden] { display: none !important; }
.pwa-update-bar .btn-primary {
  white-space: nowrap;
  min-height: var(--touch-min, 44px);
  padding: 6px 12px;
  font-size: 0.82rem;
}

.sw-update-toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-nav-h, 56px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 16px);
  transform: translateX(-50%);
  /* Below bottom-nav (30) and side-menu (45+) so toasts never steal nav taps */
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface, #fffdf9);
  color: var(--ink, #0d1f1a);
  border: 1px solid var(--border, #d5ddd8);
  box-shadow: 0 8px 28px rgba(13, 31, 26, 0.18);
  font-size: 0.9rem;
  pointer-events: auto;
}
.sw-update-toast[hidden] { display: none !important; }
.sw-update-toast .btn-primary {
  white-space: nowrap;
  min-height: var(--touch-min, 44px);
  padding: 8px 14px;
  touch-action: manipulation;
}

@media (display-mode: standalone) {
  .offline-bar,
  .push-banner,
  .pwa-update-bar {
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
  }
  .install-banner,
  .install-modal,
  .btn-install,
  #btnInstallPWA {
    display: none !important;
  }
}

/* ——— Mobile install banner ——— */
.install-banner {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--bottom-nav-h, 56px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 20px);
  background: var(--accent, #0d5c4d);
  color: #fffdf9;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Below bottom-nav so install CTA never blocks menu / tab taps */
  z-index: 25;
  pointer-events: none;
}
.install-banner button,
.install-banner .btn-primary,
.install-banner .ghost {
  pointer-events: auto;
}
.install-banner[hidden] { display: none !important; }
.install-banner-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.install-banner-icon { font-size: 1.3rem; }
.install-banner-text { font-size: 0.85rem; line-height: 1.3; }
.install-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.install-banner-actions .btn-primary {
  background: #fffdf9;
  color: var(--accent, #0d5c4d);
  border: none;
  padding: 0 12px;
  min-height: 36px;
  font-size: 0.85rem;
}
.install-banner-actions .ghost {
  color: #fffdf9;
  min-height: 36px;
  min-width: 36px;
  font-size: 1.2rem;
}

/* ——— Window-controls-overlay (desktop) ——— */
.titlebar-drag { display: none; }
@media (display-mode: window-controls-overlay) {
  body.wco .app-header {
    -webkit-app-region: drag;
    app-region: drag;
    padding-left: env(titlebar-area-x, 0px);
    padding-right: env(titlebar-area-width-right, 0px);
    padding-top: env(titlebar-area-y, 0px);
    height: env(titlebar-area-height, 56px);
  }
  body.wco .app-header button,
  body.wco .app-header select,
  body.wco .app-header a,
  body.wco .app-header .account-chip {
    -webkit-app-region: no-drag;
    app-region: no-drag;
  }
  body.wco .titlebar-drag {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
}

/* ==========================================================================
   CHAT / INBOX — mobile master-detail (≤767px)
   Owned section: do not mix with drawer z-index or unrelated layout rules.
   Classes: .chat-thread-open (team chat), .inbox-detail-open (client inbox).
   ========================================================================== */
.chat-back-btn,
.inbox-back-btn {
  display: none;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin: 0 0 4px;
  min-height: var(--touch-min, 44px);
  padding: 8px 12px;
  border: 1px solid var(--border, #e7e0d4);
  border-radius: 12px;
  background: var(--surface, #fffdf9);
  color: var(--text, #1c1917);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.inbox-detail-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

@media (min-width: 768px) {
  .chat-layout {
    grid-template-columns: minmax(240px, 34%) 1fr;
  }
  .inbox-layout {
    grid-template-columns: minmax(240px, 36%) 1fr;
  }
  .chat-back-btn,
  .inbox-back-btn {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .chat-layout {
    position: relative;
    min-height: 0;
    gap: 0;
  }

  .chat-layout > .chat-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
  }

  .chat-layout > .chat-main {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    min-height: 100%;
    max-height: none;
    overflow: hidden;
    border-radius: 16px;
  }

  .chat-layout.chat-thread-open > .chat-sidebar,
  #teamChatPanel.chat-thread-open .chat-layout > .chat-sidebar {
    visibility: hidden;
    pointer-events: none;
  }

  .chat-layout.chat-thread-open > .chat-main,
  #teamChatPanel.chat-thread-open .chat-layout > .chat-main {
    display: flex;
  }

  #teamChatPanel.chat-thread-open .chat-back-btn {
    display: inline-flex;
  }

  .chat-layout.chat-thread-open .chat-room-list {
    max-height: none;
  }

  .chat-layout.chat-thread-open .chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .inbox-layout {
    position: relative;
    min-height: 0;
    gap: 0;
  }

  .inbox-layout > .inbox-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: none;
  }

  .inbox-layout > .inbox-detail-pane {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 10px;
    border: 1px solid var(--border, #e7e0d4);
    border-radius: 16px;
    background: var(--surface, #fffdf9);
    overflow: auto;
  }

  .inbox-layout.inbox-detail-open > .inbox-list,
  #clientInboxPanel.inbox-detail-open .inbox-layout > .inbox-list {
    visibility: hidden;
    pointer-events: none;
  }

  .inbox-layout.inbox-detail-open > .inbox-detail-pane,
  #clientInboxPanel.inbox-detail-open .inbox-layout > .inbox-detail-pane {
    display: flex;
  }

  #clientInboxPanel.inbox-detail-open .inbox-back-btn {
    display: inline-flex;
  }

  .inbox-detail-open .inbox-detail {
    flex: 1 1 auto;
    min-height: 0;
  }
}

/* === OMS: chat immersive mobile (Telegram-like) ===
   Phone shell (header + bottom-nav) stays visible on dashboard/orders/etc.
   Full-screen immersion ONLY while #panel-inbox is active AND
   body.chat-thread-open / body.inbox-detail-open.
   :has(#panel-inbox.active) prevents stuck body classes from hiding chrome.
   body.chat-panel-active is a JS marker only — no global layout side-effects.
   Hardware history back (pushState/popstate) skipped: SPA panel routing risk. */
@media (max-width: 767px) {
  /* —— Immersive thread (team chat) —— */
  body.chat-thread-open:has(#panel-inbox.active),
  body.inbox-detail-open:has(#panel-inbox.active) {
    padding-bottom: 0 !important;
  }

  body.chat-thread-open:has(#panel-inbox.active) .content,
  body.inbox-detail-open:has(#panel-inbox.active) .content {
    padding: 0 !important;
  }

  body.chat-thread-open:has(#panel-inbox.active) .app-header,
  body.chat-thread-open:has(#panel-inbox.active) .bottom-nav,
  body.chat-thread-open:has(#panel-inbox.active) #panel-inbox .toolbar--inbox {
    display: none !important;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-layout,
  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main {
    position: fixed;
    inset: 0;
    z-index: 35;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-layout {
    background: var(--bg, #f5f0e8);
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    padding-top: var(--safe-top);
    border: 0;
    box-shadow: none;
    background:
      radial-gradient(circle, rgba(13, 92, 77, 0.06) 1px, transparent 1.5px) 0 0 / 22px 22px,
      linear-gradient(180deg, #f8fffb 0%, #eef9ff 46%, #fef7ed 100%);
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main-header {
    position: relative;
    flex-shrink: 0;
    min-height: 52px;
    margin: 0;
    padding: 8px 12px 8px 48px;
    background: var(--surface, #fffdf9);
    border-bottom: 1px solid var(--border, #e7e0d4);
    box-shadow: none;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main-title-text {
    min-width: 0;
    flex: 1 1 auto;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-main-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-back-btn {
    position: absolute;
    left: 4px;
    top: calc(var(--safe-top) + 4px);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--accent, #0d5c4d);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-members-btn {
    flex-shrink: 0;
    min-width: 44px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    border-radius: 0;
    padding: 12px 10px;
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-compose {
    flex-shrink: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    margin: 0;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    background: var(--surface, #fffdf9);
  }

  body.chat-thread-open:has(#panel-inbox.active) #teamChatPanel .chat-pinned {
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  /* —— Immersive client inbox detail —— */
  body.inbox-detail-open:has(#panel-inbox.active) .app-header,
  body.inbox-detail-open:has(#panel-inbox.active) .bottom-nav,
  body.inbox-detail-open:has(#panel-inbox.active) #panel-inbox .toolbar--inbox {
    display: none !important;
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-layout,
  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-detail-pane {
    position: fixed;
    inset: 0;
    z-index: 35;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-layout {
    background: var(--bg, #f5f0e8);
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-detail-pane {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    padding-top: var(--safe-top);
    border: 0;
    background: var(--surface, #fffdf9);
    overflow: hidden;
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-back-btn {
    position: absolute;
    left: 4px;
    top: calc(var(--safe-top) + 4px);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent, #0d5c4d);
    font-size: 1.35rem;
    font-weight: 600;
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-detail {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 12px 12px 12px 12px;
    padding-top: 52px;
    -webkit-overflow-scrolling: touch;
  }

  body.inbox-detail-open:has(#panel-inbox.active) #clientInboxPanel .inbox-detail-pane::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: var(--safe-top);
    height: 52px;
    background: var(--surface, #fffdf9);
    border-bottom: 1px solid var(--border, #e7e0d4);
    z-index: 1;
    pointer-events: none;
  }
}

/* === OMS: mobile pipeline polish === */
@media (max-width: 767px) {
  .pipeline.pipeline--accordion .pipeline-card-handle {
    display: flex;
    flex: 0 0 36px;
    min-height: 44px;
    font-size: 1.15rem;
    color: var(--accent);
    background: var(--surface-2);
  }

  .pipeline.pipeline--accordion .pipeline-count {
    opacity: 1;
    font-weight: 600;
    margin-left: 4px;
  }

  .pipeline.pipeline--accordion .pipeline-col h3 {
    gap: 8px;
  }

  .pipeline.pipeline--accordion .pipeline-status-select,
  .pipeline.pipeline--accordion .pipeline-status-label {
    display: block;
    width: 100%;
  }

  .pipeline.pipeline--accordion .pipeline-status-select {
    min-height: 44px;
  }

  .pipeline-dnd-hint-mobile {
    margin: 0 0 10px;
    font-size: 0.82rem;
  }
}

/* === OMS: archive card actions === */
.order-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.order-card-actions .order-card-open,
.order-card-actions .order-card-delete {
  margin-top: 0;
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
}

.archive-sort-select {
  min-height: 40px;
}

.archive-sort-bar {
  display: flex;
  align-items: center;
  min-width: min(100%, 200px);
}

.archive-sort-bar .archive-sort-select {
  width: 100%;
}

@media (max-width: 767px) {
  .archive-sort-bar {
    width: 100%;
    order: 2;
  }

  #panel-archive .toolbar--archive {
    align-items: stretch;
  }

  #panel-archive .order-card .order-card-delete {
    min-height: 44px;
  }
}

/* === OMS: dashboard mobile polish (owned section — do not merge into other mobile blocks) === */
@media (max-width: 767px) {
  #panel-dashboard {
    overflow-x: clip;
  }

  #panel-dashboard .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  #panel-dashboard .stat-card {
    padding: 12px 14px;
    min-height: var(--touch-min, 44px);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  #panel-dashboard .stat-card span {
    font-size: 0.78rem;
    line-height: 1.25;
    word-break: break-word;
  }

  #panel-dashboard .stat-card strong {
    font-size: 1.35rem;
    margin-top: 6px;
  }

  #panel-dashboard .dashboard-grid {
    gap: 12px;
    margin-bottom: 14px;
  }

  #panel-dashboard .dashboard-grid > .card,
  #panel-dashboard > .card {
    min-width: 0;
    max-width: 100%;
    overflow-x: clip;
  }

  #panel-dashboard .funnel-chart {
    min-width: 0;
    max-width: 100%;
  }

  #panel-dashboard .funnel-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label count"
      "bar bar";
    gap: 4px 8px;
    margin-bottom: 10px;
    font-size: 0.78rem;
  }

  #panel-dashboard .funnel-label {
    grid-area: label;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.3;
  }

  #panel-dashboard .funnel-count {
    grid-area: count;
    align-self: start;
    min-width: 1.5ch;
    text-align: right;
  }

  #panel-dashboard .funnel-bar {
    grid-area: bar;
    min-width: 0;
    width: 100%;
  }

  #panel-dashboard .alerts-box {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #panel-dashboard .alerts-box .alert-warn,
  #panel-dashboard .alerts-box .alert-act,
  #panel-dashboard .alerts-box .alert-security {
    line-height: 1.35;
  }

  #panel-dashboard .alerts-box .alert-list {
    padding-left: 16px;
    margin-bottom: 14px;
  }

  #panel-dashboard .alerts-box .alert-list li {
    margin-bottom: 8px;
    line-height: 1.4;
  }

  #panel-dashboard .alerts-box .ghost {
    min-height: var(--touch-min, 44px);
    min-width: var(--touch-min, 44px);
    padding: 8px 10px;
    margin: -4px 0;
    vertical-align: middle;
  }

  #panel-dashboard .stuck-orders-box .stuck-order-item {
    gap: 8px;
    margin-bottom: 12px;
  }

  #panel-dashboard .stuck-orders-box .ghost {
    min-height: var(--touch-min, 44px);
    min-width: var(--touch-min, 44px);
    padding: 8px 10px;
    margin: -4px 0;
  }

  #panel-dashboard .analytics-month-box .analytics-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  #panel-dashboard .analytics-month-box .analytics-kpi {
    padding: 10px;
  }

  #panel-dashboard .analytics-month-box .analytics-kpi strong {
    font-size: 1.05rem;
  }

  #panel-dashboard .analytics-month-box .month-bar-row.funnel-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label count"
      "bar bar";
    gap: 4px 8px;
    margin-bottom: 10px;
    font-size: 0.78rem;
  }

  #panel-dashboard #dashboardOrdersCards.order-card-list {
    gap: 12px;
  }

  #panel-dashboard #dashboardOrdersCards .order-card {
    padding: 14px 16px;
  }

  #panel-dashboard #dashboardOrdersCards .order-card-open {
    min-height: var(--touch-min, 44px);
  }

  #panel-dashboard #dashboardOrdersCards .order-card-task {
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

@media (max-width: 360px) {
  #panel-dashboard .stats {
    grid-template-columns: 1fr;
  }
}

/* === OMS: new-order sticky submit above bottom-nav ===
   Owned section: do not mix with drawer z-index, chat-thread-open, pipeline, archive, dashboard.
   Ensures #panel-new-order / #orderForm .form-actions--sticky clears fixed bottom-nav. */
@media (max-width: 767px) {
  #panel-new-order #orderForm {
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  }

  #panel-new-order .form-actions--sticky,
  #panel-new-order #orderForm .form-actions.form-actions--sticky {
    position: sticky;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: max(16px, calc(8px + var(--safe-bottom)));
    z-index: 4;
    /* Sticky bar itself must not swallow taps meant for bottom-nav below */
    pointer-events: none;
  }

  #panel-new-order .form-actions--sticky > *,
  #panel-new-order #orderForm .form-actions.form-actions--sticky > * {
    pointer-events: auto;
    min-height: var(--touch-min);
    touch-action: manipulation;
  }
}

/* === OMS: OD design polish ===
   Visual tokens/patterns from Open Design mock oms-admin-mobile
   (cream surfaces, pastel pills, accent nav, pill drawer tabs, ghost back).
   Mobile-only additive polish — does not rewrite layout/z-index sections.
   Accent kept at brand #0d5c4d. */
@media (max-width: 767px) {
  /* 1. Soften card surfaces → cream aesthetic */
  .card,
  .stat-card,
  .order-card,
  .pipeline-card,
  .pending-card,
  .org-list .org-card,
  .inbox-detail-card {
    background: #fffdf9;
    border-color: #e7e0d4;
    border-radius: 12px;
  }

  .pipeline-card {
    border-radius: 10px; /* slightly tighter, matches mock .kanban-card */
  }

  /* 2. Pastel status pills — enhance existing .badge / .status-pill only */
  .badge {
    height: auto;
    min-height: 0;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    border-radius: 999px;
    letter-spacing: 0.01em;
  }

  .badge::before {
    width: 5px;
    height: 5px;
  }

  .badge--success {
    background: #edf3ec;
    color: #3d5c3d;
  }

  .badge--warning,
  .badge-warn {
    background: #fbf3db;
    color: #7c5e10;
  }

  .badge--danger {
    background: #fdebec;
    color: #8b3a3a;
  }

  .badge--info {
    background: #e1f3fe;
    color: #1e5a7a;
  }

  .status-pill {
    display: inline-block;
    margin: 0;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    border-radius: 999px;
    background: #edf3ec;
    color: #3d5c3d;
  }

  /* 3. Bottom-nav active — brand accent weight */
  .bottom-nav-btn.active,
  .bottom-nav-menu-btn.active {
    color: #0d5c4d;
    font-weight: 600;
  }

  /* 4. Side menu / list items — 44px touch + mock padding */
  .side-menu-nav .side-nav-btn {
    min-height: 56px;
    padding: 14px 16px;
    border-radius: 12px;
  }

  .side-menu-actions .side-menu-auth-btn,
  .side-menu-actions .btn-primary,
  .side-menu-actions .secondary {
    min-height: 56px;
    padding: 12px 16px;
  }

  .inbox-item,
  .chat-room-item {
    min-height: 56px;
    padding: 14px 16px;
  }

  /* 5. Drawer tab pills — rounded + scroll-friendly (mock .dtabs) */
  .drawer-tabs {
    gap: 6px;
    padding: 8px 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .drawer-tabs::-webkit-scrollbar {
    display: none;
  }

  .drawer-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #e7e0d4;
    background: #f3efe6;
    color: var(--text, #1c1917);
    font-size: 0.78rem;
  }

  .drawer-tab:hover {
    background: #faf8f3;
    color: var(--text, #1c1917);
  }

  .drawer-tab.active {
    background: #0d5c4d;
    border-color: #0d5c4d;
    color: #fff;
    font-weight: 600;
  }

  /* 6. Chat / inbox back — cleaner ghost accent (mock .back) */
  .chat-back-btn,
  .inbox-back-btn {
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #0d5c4d;
    font-size: 0.92rem;
    font-weight: 500;
    min-height: 44px;
    min-width: 44px;
    padding: 0 4px;
    border-radius: 0;
  }
}

/* === OMS: OD polish mobile (port 2) ===
   Additive styles ported from Open Design mock oms-admin-mobile.
   Sections: bottom-nav SVG icons, side-menu sections + Входящие badge,
   drawer back button, circular chat send, new-order file-pick cards.
   Does not revert existing mobile blocks. Accent #0d5c4d. */

/* Drawer back button — works on mobile + desktop (drawer is shared). */
.drawer-back-btn {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #0d5c4d;
  font-size: 0.92rem;
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  padding: 0 8px 0 0;
  border-radius: 0;
  flex-shrink: 0;
}

/* Circular chat send button — mobile + desktop consistent (mock .compose arrow). */
.chat-send-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #0d5c4d;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.chat-send-btn:hover {
  background: #0a4a3e;
}
.chat-send-btn:active {
  background: #083a30;
}
.chat-send-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}
.chat-compose .chat-send-btn {
  grid-column: auto;
}

@media (max-width: 767px) {
  /* 7. Bottom-nav SVG line icons (replace emoji) — accent active state */
  .bottom-nav-btn .bottom-nav-icon,
  .bottom-nav-menu-btn .bottom-nav-icon {
    width: 22px;
    height: 22px;
    display: block;
    font-size: 0;
    line-height: 0;
  }

  .bottom-nav-btn.active .bottom-nav-icon,
  .bottom-nav-menu-btn.active .bottom-nav-icon {
    color: #0d5c4d;
  }

  /* 8. Side-menu section headers (mock .menu-section) */
  .side-menu-nav .side-menu-section {
    padding: 12px 16px 4px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #78716c;
    font-weight: 600;
  }

  .side-menu-nav .side-menu-section:first-child {
    padding-top: 4px;
  }

  /* 9. Входящие unread badge in side menu */
  .side-nav-btn .side-nav-badge {
    margin-left: auto;
    background: #0d5c4d;
    color: #fff;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    min-width: 22px;
    padding: 2px 8px;
    text-align: center;
    line-height: 1.2;
  }

  .side-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* 10. New-order file-pick cards — dashed card with icon + label (mock .file-pick) */
  #panel-new-order .file-drop.file-pick-card {
    border: 1px dashed #e7e0d4;
    border-radius: 10px;
    padding: 16px;
    background: #fffdf9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 96px;
    position: relative;
  }

  #panel-new-order .file-drop.file-pick-card::before {
    content: "";
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    color: #78716c;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
  }

  #panel-new-order .file-drop.file-pick-card--photo::before {
    background-color: #78716c;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='18' rx='2'/><circle cx='8.5' cy='8.5' r='1.5'/><path d='M21 15l-5-5L5 21'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='3' width='18' height='18' rx='2'/><circle cx='8.5' cy='8.5' r='1.5'/><path d='M21 15l-5-5L5 21'/></svg>");
  }

  #panel-new-order .file-drop.file-pick-card--model::before {
    background-color: #78716c;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/><polyline points='3.27 6.96 12 12.01 20.73 6.96'/><line x1='12' y1='22.08' x2='12' y2='12'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/><polyline points='3.27 6.96 12 12.01 20.73 6.96'/><line x1='12' y1='22.08' x2='12' y2='12'/></svg>");
  }

  #panel-new-order .file-drop.file-pick-card--gcode::before {
    background-color: #78716c;
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/><path d='M14 2v6h6M10 13h4M10 17h4M8 9h2'/></svg>");
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/><path d='M14 2v6h6M10 13h4M10 17h4M8 9h2'/></svg>");
  }

  #panel-new-order .file-drop.file-pick-card .file-drop-text {
    font-size: 0.82rem;
    color: #78716c;
    pointer-events: none;
  }

  #panel-new-order .file-drop.file-pick-card:hover,
  #panel-new-order .file-drop.file-pick-card.drag-over {
    border-color: #0d5c4d;
    background: #e7f3ef;
  }

  #panel-new-order .file-drop.file-pick-card:hover .file-drop-text {
    color: #0d5c4d;
    font-weight: 600;
  }

  /* 11. Mobile chat compose — attach menu | wide textarea | circular send */
  .chat-compose {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
  }
  .chat-compose .chat-send-btn {
    grid-column: auto;
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    height: 48px;
  }
}

/* === OMS mobile: inventory inline edit form (append-only, do not revert) === */
.inventory-edit-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 4px 4px;
  margin-top: 10px;
  border-top: 1px dashed var(--border, #e2d8c8);
}

.inventory-edit-form[hidden] {
  display: none !important;
}

.inventory-edit-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.inventory-edit-field span {
  font-size: 0.72rem;
  color: var(--muted, #8a8074);
  letter-spacing: 0.01em;
}

.inventory-edit-field input {
  font-size: 16px; /* iOS 16px — prevents zoom-on-focus */
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border, #e2d8c8);
  border-radius: 8px;
  background: #fffdf9;
  color: var(--text, #1c1917);
  width: 100%;
  box-sizing: border-box;
}

.inventory-edit-field input:disabled {
  background: #f4efe6;
  color: var(--muted, #8a8074);
}

.inventory-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.inventory-edit-actions button {
  flex: 1 1 0;
  min-height: 44px;
  font-size: 16px;
}

@media (min-width: 768px) {
  /* Desktop: inline form is mobile-only by parent (.mobile-only), keep tidy */
  .inventory-edit-form {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* === OMS mobile: workstation drag handles visible + long-press ghost === */
.workstation-card-handle {
  touch-action: pan-y;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.workstation-card.long-press-pending {
  background: #f7f3ea;
}

.workstation-drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.85;
  transform: rotate(-1.5deg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  border-radius: 12px;
}

body.workstation-touch-dragging {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

@media (max-width: 767px) {
  .workstation-card-handle {
    color: var(--accent, #0d5c4d);
    background: #f0ece2;
    border-radius: 8px;
  }

  .ws-advance {
    min-height: 44px;
    font-size: 16px;
  }
}

/* === OMS mobile: accounts card delete button (mobile-only) === */
@media (max-width: 767px) {
  .order-card-actions [data-account-delete] {
    flex: 1 1 100%;
    min-height: 44px;
    font-size: 16px;
    border: 1px solid rgba(139, 58, 58, 0.25);
  }
}


/* === [mobile-parity] ORDERS mobile sort select + search/filter chrome (≤767px) === */
.df-icon {
  display: none;
}

@media (max-width: 767px) {
  #panel-orders .toolbar--orders {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
  }

  .order-sort-select {
    width: 100%;
    min-height: var(--touch-min, 44px);
    font-size: 16px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border, #2a2f3a);
    background: var(--surface-2, #1b1f29);
    color: var(--text, #e6e9f0);
    font-family: inherit;
  }
  .order-sort-select.mobile-only {
    display: block !important;
  }

  #orderSearch.toolbar-search {
    width: 100%;
    min-height: var(--touch-min, 44px);
    font-size: 16px;
    padding-left: 36px;
    background-repeat: no-repeat;
    background-position: left 10px center;
    background-size: 18px 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='16.5' y1='16.5' x2='21' y2='21'/></svg>");
  }

  /* Filter toggle → 44px icon-only button (text hidden via font-size:0) */
  #btnToggleOrderFilters.filters-toggle {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
  }
  #btnToggleOrderFilters.filters-toggle::before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    font-size: 16px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 4h18l-7 8v9l-4-2v-7L3 4z' fill='black'/></svg>") center/contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M3 4h18l-7 8v9l-4-2v-7L3 4z' fill='black'/></svg>") center/contain no-repeat;
  }
  #btnToggleOrderFilters.filters-toggle[aria-expanded="true"] {
    border-color: var(--accent, #0d5c4d);
    color: var(--accent, #0d5c4d);
  }
}

/* === [mobile-parity] ERRORLOG cards (≤767px) === */
@media (max-width: 767px) {
  .errorlog-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--border, #2a2f3a);
    border-left-width: 4px;
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--surface, #141821);
    cursor: pointer;
    transition: background 0.15s ease;
  }
  .errorlog-card:hover {
    background: var(--surface-2, #1b1f29);
  }
  .errorlog-card.err-critical { border-left-color: var(--danger, #e5484d); }
  .errorlog-card.err-error { border-left-color: #f5a524; }
  .errorlog-card.err-warning { border-left-color: #eac54f; }

  .errorlog-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }
  .errorlog-card-sev {
    font-weight: 700;
    letter-spacing: 0.03em;
    font-size: 0.78rem;
  }
  .errorlog-card-time {
    color: var(--muted, #8a93a6);
    font-size: 0.74rem;
  }
  .errorlog-card-status {
    padding: 0 6px;
    border-radius: 4px;
    background: var(--surface-2, #1b1f29);
    font-size: 0.74rem;
    font-weight: 600;
  }
  .errorlog-card-path {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    color: var(--accent, #6ea8fe);
    font-size: 0.76rem;
    word-break: break-all;
  }
  .errorlog-card-msg {
    margin: 0;
    color: var(--text, #e6e9f0);
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }
  .errorlog-card-trace {
    align-self: flex-start;
    min-height: var(--touch-min, 44px);
    padding: 6px 12px;
    font-size: 0.82rem;
  }
  .errorlog-card-trace .df-icon {
    display: inline-block;
    margin-right: 4px;
  }
}

/* === [mobile-parity] MODELS panel mobile (≤767px) === */
.models-intro-details {
  margin-bottom: 16px;
}
.models-intro-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
}
.models-intro-summary::-webkit-details-marker {
  display: none;
}
.models-intro-summary .card-title {
  margin: 0;
}
.models-intro-toggle {
  display: none;
  font-size: 0.9rem;
  color: var(--muted, #8a93a6);
  transition: transform 0.15s ease;
}
.models-intro-details[open] .models-intro-toggle {
  transform: rotate(180deg);
}

@media (max-width: 767px) {
  #panel-models .models-intro-details {
    margin-bottom: 12px;
  }
  #panel-models .models-intro-summary {
    padding: 10px 12px;
  }
  #panel-models .models-intro-summary .card-title {
    font-size: 1rem;
  }
  #panel-models .models-intro-toggle {
    display: inline-block;
  }
  #panel-models .models-intro-lead {
    margin: 0;
    padding: 0 12px 12px;
    font-size: 0.84rem;
    line-height: 1.5;
  }
  #panel-models .model-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }
}

/* === [mobile-parity] DRAWER FOOTER compact (≤767px) === */
@media (max-width: 767px) {
  .drawer-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  /* Actions first; small flat Save bar pinned at the bottom of the footer */
  .drawer-footer-actions {
    order: 0;
  }
  .drawer-footer .drawer-footer-save {
    order: 1;
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    min-height: var(--touch-min, 52px);
    max-height: none;
    padding: 0 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1;
    border-radius: 6px;
    box-shadow: none;
    border: 1px solid color-mix(in srgb, var(--accent, #1a6b5c) 70%, #000 10%);
  }
  .drawer-footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: space-between;
  }
  .drawer-footer-btn {
    flex: 1 1 calc(33.333% - 4px);
    min-width: 0;
    min-height: var(--touch-min, 44px);
    padding: 6px 8px;
    font-size: 0;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0;
  }
  .drawer-footer-btn .df-icon {
    display: inline-block;
    font-size: 1.1rem;
    line-height: 1;
  }
  .drawer-footer-btn .df-label {
    display: none;
  }
  /* Delete actions: keep readable label (do not font-size:0 the whole button) */
  #btnDeleteOrder.drawer-footer-btn,
  #btnDeleteArchived.drawer-footer-btn,
  #btnConfirmDeleteOrder.drawer-footer-btn,
  #btnConfirmDeleteArchived.drawer-footer-btn,
  #btnCancelDeleteOrder.drawer-footer-btn,
  #btnCancelDeleteArchived.drawer-footer-btn {
    font-size: 0.72rem;
    gap: 4px;
    flex: 1 1 calc(50% - 4px);
  }
  #btnDeleteOrder.drawer-footer-btn .df-label,
  #btnDeleteArchived.drawer-footer-btn .df-label,
  #btnConfirmDeleteOrder.drawer-footer-btn .df-label,
  #btnConfirmDeleteArchived.drawer-footer-btn .df-label,
  #btnCancelDeleteOrder.drawer-footer-btn .df-label,
  #btnCancelDeleteArchived.drawer-footer-btn .df-label {
    display: inline;
    font-size: inherit;
    line-height: 1.2;
    white-space: nowrap;
  }
  .drawer-footer-btn[style*="display:none"] {
    display: none !important;
  }
}

/* === OMS: mobile touch & responsiveness ===
   Larger hit targets, instant press feedback, snappier UI on ≤767px. */
@media (max-width: 767px) {
  :root {
    --touch-min: 52px;
    --bottom-nav-h: 68px;
  }

  /* Instant press feedback — no hover-only feel */
  button,
  .touch-target,
  .nav-btn,
  .side-nav-btn,
  .bottom-nav-btn,
  .bottom-nav-menu-btn,
  .order-card,
  .pipeline-card,
  .drawer-tab,
  .filters-toggle,
  .btn-primary,
  .secondary,
  .ghost,
  .account-chip,
  a.btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s ease, opacity 0.08s ease, background 0.12s ease, filter 0.08s ease;
  }

  button:active,
  .touch-target:active,
  .nav-btn:active,
  .side-nav-btn:active,
  .bottom-nav-btn:active,
  .bottom-nav-menu-btn:active,
  .order-card:active,
  .pipeline-card:active,
  .drawer-tab:active,
  .filters-toggle:active,
  .btn-primary:active,
  .secondary:active,
  .ghost:active,
  .account-chip:active {
    transform: scale(0.97);
    opacity: 0.92;
  }

  .btn-primary:active,
  .btn-install:active,
  .btn-login-prominent:active {
    filter: brightness(0.92);
  }

  /* Header icon buttons — square 48px, easier to hit */
  .header-actions {
    gap: 8px;
  }
  .header-actions .touch-target,
  .header-actions button.secondary,
  .header-actions .btn-install,
  .header-actions .header-refresh {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
  }
  .header-actions .btn-login-prominent {
    min-height: var(--touch-min);
    padding: 0 16px;
  }

  /* Bottom nav — full column is tappable, including Home Indicator strip */
  .bottom-nav {
    min-height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-top: 6px;
    padding-bottom: 0;
  }
  .bottom-nav-btn,
  .bottom-nav-menu-btn {
    align-self: stretch;
    min-height: 100%;
    padding: 8px 4px var(--safe-bottom, env(safe-area-inset-bottom, 0px));
    gap: 4px;
  }
  .bottom-nav-icon,
  .bottom-nav-btn svg,
  .bottom-nav-menu-btn svg {
    width: 22px;
    height: 22px;
    font-size: 1.25rem;
  }
  .bottom-nav-label {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.01em;
  }
  .bottom-nav-btn.active .bottom-nav-label {
    font-weight: 700;
  }
  .bottom-nav-menu-btn {
    flex: 0 0 58px;
  }

  /* Side menu rows */
  .side-menu-nav .side-nav-btn {
    min-height: 56px;
    padding: 14px 16px;
    gap: 10px;
  }

  /* Cards & list rows — full-width press area */
  .order-card,
  .archive-card,
  .qc-card,
  .inventory-card,
  .account-card,
  .errorlog-card,
  .inbox-item,
  .chat-room-item {
    min-height: 56px;
    cursor: pointer;
  }

  /* Form controls */
  button.btn-primary,
  button.secondary,
  .form-actions button,
  .drawer-footer button,
  .drawer-footer-save,
  .drawer-footer-btn {
    min-height: var(--touch-min);
  }

  .drawer-footer .drawer-footer-save,
  .drawer-footer .btn-primary {
    height: auto;
    min-height: var(--touch-min);
    max-height: none;
  }

  .order-positions-add,
  .chat-back-btn,
  .inbox-back-btn {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
  }

  .install-banner-actions .btn-primary,
  .install-banner-actions .ghost {
    min-height: var(--touch-min);
    min-width: var(--touch-min);
  }

  /* Drawer tabs — easier swipe/tap */
  .drawer-tabs button,
  .drawer-tab {
    min-height: 48px;
    min-width: 64px;
    padding: 10px 14px;
  }

  /* Pipeline / workstation advance & selects */
  .pipeline-card select,
  .ws-advance,
  .pipeline-status-select {
    min-height: var(--touch-min);
    font-size: 16px;
  }

  /* Reduce motion lag on panel switch */
  .panel {
    transition: opacity 0.12s ease;
  }
}

/* === Dark theme contrast fixes (forms + chat) === */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chat-messages {
    background:
      radial-gradient(circle, rgba(156, 190, 167, 0.12) 1px, transparent 1.5px) 0 0 / 22px 22px,
      rgba(24, 24, 27, 0.55);
  }
  :root:not([data-theme="light"]) .chat-bubble-content {
    background: #27272a;
    color: #fafafa;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  }
  :root:not([data-theme="light"]) .chat-bubble-meta {
    color: #a1a1aa;
  }
  :root:not([data-theme="light"]) .chat-bubble--mine .chat-bubble-content {
    background: linear-gradient(135deg, #1f3d32, #243d38);
    color: #f4f4f5;
  }
  :root:not([data-theme="light"]) .chat-pinned {
    background: #2a2418;
    border-color: #5c4a28;
    color: #f4f4f5;
  }
  :root:not([data-theme="light"]) .chat-photo {
    background: #18181b;
    border-color: rgba(255, 255, 255, 0.08);
  }
  :root:not([data-theme="light"]) .order-chat-compose {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
  :root:not([data-theme="light"]) .drawer input,
  :root:not([data-theme="light"]) .drawer select,
  :root:not([data-theme="light"]) .drawer textarea,
  :root:not([data-theme="light"]) .field input,
  :root:not([data-theme="light"]) .field select,
  :root:not([data-theme="light"]) .field textarea,
  :root:not([data-theme="light"]) .form-stack input,
  :root:not([data-theme="light"]) .form-stack select,
  :root:not([data-theme="light"]) .form-stack textarea {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
  }
}

[data-theme="dark"] .chat-messages {
  background:
    radial-gradient(circle, rgba(156, 190, 167, 0.12) 1px, transparent 1.5px) 0 0 / 22px 22px,
    rgba(24, 24, 27, 0.55);
}
[data-theme="dark"] .chat-bubble-content {
  background: #27272a;
  color: #fafafa;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .chat-bubble-meta {
  color: #a1a1aa;
}
[data-theme="dark"] .chat-bubble--mine .chat-bubble-content {
  background: linear-gradient(135deg, #1f3d32, #243d38);
  color: #f4f4f5;
}
[data-theme="dark"] .chat-pinned {
  background: #2a2418;
  border-color: #5c4a28;
  color: #f4f4f5;
}
[data-theme="dark"] .chat-photo {
  background: #18181b;
  border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .order-chat-compose {
  border-top-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .drawer input,
[data-theme="dark"] .drawer select,
[data-theme="dark"] .drawer textarea,
[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea,
[data-theme="dark"] .form-stack input,
[data-theme="dark"] .form-stack select,
[data-theme="dark"] .form-stack textarea {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Technical panel: ops snapshot + backup upload */
.panel-subtitle {
  margin: 1.15rem 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.ops-box {
  padding: 10px 12px;
  border: 1px solid var(--border, #2a2f3a);
  border-radius: 8px;
  background: var(--surface, #141821);
  font-size: 0.85rem;
  line-height: 1.45;
}

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

.ops-box .ops-alert-list {
  margin: 0;
  padding-left: 1.15rem;
}

.backup-upload-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
