:root {
  --navy: #0f172a;
  --gold: #facc15;
  --sapphire: #2563eb;
  --bg: #0b1220;
  --surface: #151d2e;
  --surface-2: #1a2438;
  --text: #f8fafc;
  --muted: #94a3b8;
  --on-surface: #cbd5e1;
  --border: #243044;
  --outline: #334155;
  --primary: #3b82f6;
  --on-primary: #ffffff;
  --danger: #f87171;
  --ok: #34d399;
  --edit: #1e2a44;
  --tile-end: #0e1626;
  --chevron-bg: rgba(255, 255, 255, 0.12);
  --tile-blue: #15233b;
  --tile-teal: #0f2a2a;
  --tile-orange: #2a1d0f;
  --tile-purple: #201535;
  --tile-cyan: #0f2430;
  --accent-blue: #3b82f6;
  --accent-teal: #14b8a6;
  --accent-orange: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-cyan: #22d3ee;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --nav-h: 88px;
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --dur: 240ms;
  --dur-med: 360ms;
  --dur-slow: 480ms;
  color-scheme: dark;
}

html.light {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --on-surface: #475569;
  --border: #d8e0ec;
  --outline: #cbd5e1;
  --primary: #2563eb;
  --danger: #ef4444;
  --ok: #059669;
  --edit: #e2e8f0;
  --tile-end: #f1f5f9;
  --chevron-bg: rgba(15, 23, 42, 0.06);
  --tile-blue: #e8f0fe;
  --tile-teal: #ddf5f2;
  --tile-orange: #fff0db;
  --tile-purple: #f0e8ff;
  --tile-cyan: #dff6fc;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--dur-slow) var(--ease);
}

body.is-auth {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.28) 0%, var(--bg) 52%);
}

html.light body.is-auth {
  background: linear-gradient(180deg, #dbeafe 0%, #f8fafc 55%);
}

[hidden] { display: none !important; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { touch-action: manipulation; }

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-top)) 16px calc(var(--nav-h) + var(--safe-bot));
  min-height: 100dvh;
}

body.is-auth #app {
  padding-bottom: calc(20px + var(--safe-bot));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 60px;
  margin: 0 -4px 14px;
  gap: 8px;
}

body.is-auth .top { display: none; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.goc-mark {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  transition: transform 200ms var(--ease);
}
button.goc-mark:active { transform: scale(0.94); }

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 15px;
  text-transform: uppercase;
  color: var(--text);
}

.sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.org-head {
  min-width: 0;
}

.org-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 0;
}

.org-select-top {
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  min-height: 42px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2394A3B8' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 200ms var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#btnTheme .theme-sun,
#btnTheme .theme-moon { grid-area: 1 / 1; }
html.light #btnTheme .theme-sun { display: none; }
html:not(.light) #btnTheme .theme-moon { display: none; }

.icon-btn:active { transform: scale(0.94); }

.bell-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  animation: popIn 320ms var(--ease) both;
}

.org-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}

.org-card .org-ico {
  --accent: var(--accent-blue);
  color: var(--accent-blue);
  background: color-mix(in srgb, var(--accent-blue) 16%, transparent);
}

.org-card-body { min-width: 0; }

.org-card select {
  width: 100%;
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  appearance: none;
}

.org-hint { margin: 8px 0 0; }

.section-label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.panel.enter .dash-grid > * {
  animation: riseIn 380ms var(--ease) both;
}
.panel.enter .dash-grid > *:nth-child(1) { animation-delay: 20ms; }
.panel.enter .dash-grid > *:nth-child(2) { animation-delay: 50ms; }
.panel.enter .dash-grid > *:nth-child(3) { animation-delay: 80ms; }
.panel.enter .dash-grid > *:nth-child(4) { animation-delay: 110ms; }
.panel.enter .dash-grid > *:nth-child(5) { animation-delay: 140ms; }
.panel.enter .dash-grid > *:nth-child(6) { animation-delay: 170ms; }

.dash-tile {
  grid-template-columns: 1fr;
  justify-items: start;
  min-height: 108px;
  padding: 16px;
  align-content: start;
  gap: 14px;
}

.dash-tile h3 {
  font-size: 15px;
  line-height: 1.25;
}

.back-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.back-row h2 {
  margin: 0;
  font-size: 17px;
}

.chat-msgs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 240px;
  max-height: calc(100dvh - 280px);
  overflow: auto;
  padding: 8px 0 12px;
}

.chat-bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
}

.panel.enter .chat-msgs > * {
  animation: riseIn 300ms var(--ease) both;
}

.chat-bubble.mine {
  align-self: flex-end;
  background: color-mix(in srgb, var(--sapphire) 28%, var(--surface));
  border-color: color-mix(in srgb, var(--sapphire) 40%, transparent);
}

.chat-bubble .meta { margin-top: 4px; }

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-form input { flex: 1; }

#viewAuth { width: 100%; }

.auth-card {
  width: min(400px, 100%);
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px 22px 22px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.38);
  border: 1px solid var(--border);
  animation: authIn var(--dur-slow) var(--ease);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.auth-mark,
.auth-logo .goc-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  font-size: 28px;
  box-shadow: 0 14px 32px rgba(37, 99, 235, 0.38);
  cursor: default;
}

#authTitle {
  margin: 18px 0 0;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-lead {
  display: block;
  text-align: center;
  margin: 6px auto 22px;
  max-width: 16.5rem;
  line-height: 1.4;
}

.auth-card .stack { gap: 14px; }

#regStep1, #regStep2 {
  display: grid;
  gap: 14px;
}

.auth-card input:not([type="checkbox"]) {
  min-height: 52px;
  border-radius: 14px;
  font-size: 16px;
  background: var(--surface-2);
}

html.light .auth-card input:not([type="checkbox"]) {
  background: #fff;
}

.auth-code {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.42em;
  padding-right: 0;
  font-variant-numeric: tabular-nums;
}

.auth-more {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2px 14px 4px;
}

.auth-more summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 0;
  list-style: none;
}

.auth-more summary::-webkit-details-marker { display: none; }

.auth-more[open] summary { padding-bottom: 4px; }

.auth-more label { margin: 0 0 12px; }

.auth-switch {
  width: 100%;
  margin-top: 8px;
  color: var(--primary);
  font-weight: 700;
}

.auth-card .primary { border-radius: 14px; min-height: 52px; }

.auth-card .row { align-items: stretch; margin-top: 2px; }

.primary:disabled, .secondary:disabled {
  opacity: 0.62;
  cursor: default;
  transform: none;
  filter: none;
}

html.light .auth-card {
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.1);
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: 16px;
  padding: 4px;
  margin: 16px 0 18px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 9px 8px;
  font-weight: 600;
  font-size: 13px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform 160ms var(--ease);
}

.tab:active { transform: scale(0.97); }

.tab.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.stack { display: grid; gap: 12px; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  outline: none;
  min-height: 48px;
}

html.light input,
html.light select,
html.light textarea {
  background: #fff;
}

input, select, textarea {
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--sapphire);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--on-surface);
  font-weight: 500;
  font-size: 13px;
}

.check input { width: auto; min-height: 0; }

.primary, .secondary, .ghost, .danger, .open-tg-btn {
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-md);
  min-height: 50px;
  padding: 0 16px;
  font-weight: 700;
  transition: transform 180ms var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), filter 180ms var(--ease), opacity var(--dur) var(--ease);
}

.primary, .open-tg-btn {
  background: var(--sapphire);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.32);
}

a.primary, a.open-tg-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.open-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.28) 0%, var(--bg) 52%);
}

.open-gate[hidden] { display: none !important; }

.open-gate .auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  justify-items: stretch;
  text-align: center;
}

.primary:active, .secondary:active, .ghost:active, .danger:active { transform: scale(0.97); }

@media (hover: hover) {
  .primary:hover { filter: brightness(1.06); box-shadow: 0 10px 24px rgba(37, 99, 235, 0.4); }
}

.secondary {
  background: var(--edit);
  color: var(--text);
  border: 1px solid var(--border);
}

.ghost {
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  font-weight: 600;
}

.danger { background: #3f1d2a; color: var(--danger); }

.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }

.row { display: flex; gap: 8px; align-items: end; }

.order-cp-list {
  max-height: 168px;
  overflow: auto;
  margin: 0 0 4px;
}

#createOrder .row label { flex: 1; min-width: 0; }
#createOrder .row .ghost {
  flex-shrink: 0;
  align-self: end;
  min-height: 42px;
}
#orderCpChips .chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.grow { flex: 1; min-width: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 0; font-weight: 400; }
.error { color: var(--danger); margin: 10px 0 0; font-size: 13px; text-align: center; }
a { color: var(--primary); }

.panel { display: block; }
.stage {
  display: grid;
  min-height: 0;
}
.stage > .panel {
  grid-area: 1 / 1;
  min-width: 0;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#docsListPane > label { margin-bottom: 12px; display: block; }
#docsCatalog .chips { margin-bottom: 12px; }
#edmStatusChips { margin: 8px 0 12px; }
.edm-preview {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.4;
  max-height: 220px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

#edmVatWrap .chips { margin-top: 2px; }

#edmItemsList {
  display: grid;
  gap: 10px;
}

.edm-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.edm-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.edm-item-n {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.edm-item-grid {
  display: grid;
  grid-template-columns: minmax(72px, 0.8fr) 1fr 1fr;
  gap: 8px;
}

.edm-item-grid input,
.edm-item-grid select {
  min-height: 44px;
  padding: 8px 10px;
}

.edm-items-total {
  margin: 4px 0 0;
  text-align: right;
  font-weight: 700;
}

#btnEdmAddItem { justify-self: start; }

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  min-height: 34px;
  font-size: 12px;
  font-weight: 650;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 160ms var(--ease);
}

.chip:active { transform: scale(0.96); }

.chip.on {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

html.light .chip.on {
  background: #dbeafe;
  color: #1e3a8a;
  border-color: #93c5fd;
}

.list { display: grid; gap: 10px; }

.card, .tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  overflow: hidden;
}

.tile {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, var(--tile, var(--surface)) 0%, color-mix(in srgb, var(--tile, var(--surface)) 92%, transparent) 42%, var(--tile-end) 100%);
  border-color: color-mix(in srgb, var(--accent, var(--border)) 22%, transparent);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent, #000) 18%, transparent);
  cursor: pointer;
  transform: translateZ(0);
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease), filter 260ms var(--ease);
}

.tile:active { transform: scale(0.985); }

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px color-mix(in srgb, var(--accent, #000) 28%, transparent);
  }
}

.tile-ico {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent, var(--primary)) 16%, transparent);
  color: var(--accent, var(--primary));
  transition: transform 280ms var(--ease);
}

.tile:active .tile-ico { transform: scale(0.92); }

.tile-ico svg { width: 22px; height: 22px; fill: currentColor; }

.tile h3, .card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
}

.meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--edit);
  color: var(--on-surface);
  justify-self: end;
}

.status.done { background: rgba(16, 185, 129, 0.16); color: var(--ok); }
.status.warn { background: rgba(245, 158, 11, 0.16); color: var(--accent-orange); }
.status.bad { background: rgba(248, 113, 113, 0.16); color: var(--danger); }
.edm-card-flags { display: grid; gap: 4px; justify-items: end; align-content: start; }
.tile-invoice { --tile: #15233b; --accent: #3b82f6; }

.tile-tasks { --tile: var(--tile-purple); --accent: var(--accent-purple); }
.tile-orders { --tile: var(--tile-cyan); --accent: var(--accent-cyan); }
.tile-receipt { --tile: var(--tile-blue); --accent: var(--accent-blue); }
.tile-check { --tile: var(--tile-orange); --accent: var(--accent-orange); }
.tile-ship { --tile: var(--tile-teal); --accent: var(--accent-teal); }
.tile-docs { --tile: var(--tile-orange); --accent: var(--gold); }
.edm-invoice { --tile: #15233b; --accent: #3b82f6; }
.edm-invoice-vat { --tile: #1e1b4b; --accent: #818cf8; }
.edm-waybill { --tile: #0f2a2a; --accent: #14b8a6; }
.edm-ttn { --tile: #042f2e; --accent: #2dd4bf; }
.edm-upd { --tile: #0f2430; --accent: #22d3ee; }
.edm-work { --tile: #2a1d0f; --accent: #f59e0b; }
.edm-service { --tile: #201535; --accent: #8b5cf6; }
.edm-ks { --tile: #2a1810; --accent: #fb923c; }
.edm-ks3 { --tile: #2a2210; --accent: #fbbf24; }
.edm-supply { --tile: #12203a; --accent: #60a5fa; }
.edm-svc-contract { --tile: #132a24; --accent: #34d399; }
.edm-contractor { --tile: #1a2438; --accent: #94a3b8; }
.edm-work-contract { --tile: #241a10; --accent: #d97706; }
.edm-employment { --tile: #152a1d; --accent: #10b981; }
.edm-proposal { --tile: #2a2410; --accent: #facc15; }
.edm-spec { --tile: #1b2033; --accent: #93c5fd; }
.edm-addendum { --tile: #23182a; --accent: #c084fc; }
.edm-purchase { --tile: #1a2a18; --accent: #84cc16; }
.edm-handover { --tile: #1a2228; --accent: #38bdf8; }
.edm-receipt { --tile: #12261f; --accent: #4ade80; }
.edm-claim { --tile: #2a1518; --accent: #f87171; }
.edm-notice { --tile: #2a2010; --accent: #fbbf24; }
.edm-warranty { --tile: #10202a; --accent: #67e8f9; }
.edm-letter { --tile: #1a2030; --accent: #a5b4fc; }
.edm-legal { --tile: #24151f; --accent: #fb7185; }

html.light .edm-invoice { --tile: #e8f0fe; --accent: #2563eb; }
html.light .edm-invoice-vat { --tile: #eef2ff; --accent: #4f46e5; }
html.light .edm-waybill { --tile: #ddf5f2; --accent: #0f766e; }
html.light .edm-ttn { --tile: #ccfbf1; --accent: #0d9488; }
html.light .edm-upd { --tile: #dff6fc; --accent: #0891b2; }
html.light .edm-work { --tile: #fff0db; --accent: #d97706; }
html.light .edm-service { --tile: #f0e8ff; --accent: #7c3aed; }
html.light .edm-ks { --tile: #ffedd5; --accent: #ea580c; }
html.light .edm-ks3 { --tile: #fef3c7; --accent: #ca8a04; }
html.light .edm-supply { --tile: #dbeafe; --accent: #2563eb; }
html.light .edm-svc-contract { --tile: #d1fae5; --accent: #059669; }
html.light .edm-contractor { --tile: #e2e8f0; --accent: #475569; }
html.light .edm-work-contract { --tile: #ffedd5; --accent: #b45309; }
html.light .edm-employment { --tile: #dcfce7; --accent: #047857; }
html.light .edm-proposal { --tile: #fef9c3; --accent: #ca8a04; }
html.light .edm-spec { --tile: #e0e7ff; --accent: #4338ca; }
html.light .edm-addendum { --tile: #f3e8ff; --accent: #9333ea; }
html.light .edm-purchase { --tile: #ecfccb; --accent: #65a30d; }
html.light .edm-handover { --tile: #e0f2fe; --accent: #0284c7; }
html.light .edm-receipt { --tile: #d1fae5; --accent: #16a34a; }
html.light .edm-claim { --tile: #fee2e2; --accent: #dc2626; }
html.light .edm-notice { --tile: #fef3c7; --accent: #d97706; }
html.light .edm-warranty { --tile: #cffafe; --accent: #0e7490; }
html.light .edm-letter { --tile: #e0e7ff; --accent: #6366f1; }
html.light .edm-legal { --tile: #ffe4e6; --accent: #e11d48; }

#edmTypeGrid .dash-tile {
  grid-template-columns: 44px 1fr;
  align-items: center;
  min-height: 86px;
  padding: 12px;
  gap: 10px 12px;
}
#edmTypeGrid .tile-ico { grid-row: 1 / span 2; }
#edmTypeGrid h3 { margin: 0; font-size: 13px; line-height: 1.25; grid-column: 2; }
#edmTypeGrid .hint { font-size: 11px; grid-column: 2; margin: 0; }
.tile-chat { --tile: var(--tile-blue); --accent: var(--accent-blue); }
.tile-hit { outline: 2px solid var(--accent-cyan); }

.scan-bar {
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--tile-blue), var(--tile-end));
  border-color: rgba(59, 130, 246, 0.22);
}

#stockReceipt, #stockShipment, #stockCheck { display: grid; gap: 12px; margin-top: 12px; }
#btnConfirmReceipt, #btnConfirmShip { width: 100%; }
.doc-pane {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.doc-pane .row { align-items: stretch; }
.doc-pane .grow { min-height: 44px; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: linear-gradient(135deg, var(--tile-blue), var(--tile-end));
  border: 1px solid rgba(59, 130, 246, 0.22);
  border-radius: var(--radius-lg);
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(37, 99, 235, 0.2);
  color: var(--primary);
  font-weight: 800;
  font-size: 20px;
}

.profile-hero h2 { margin: 0; font-size: 18px; }
.actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

#btnOrgCreate { width: 100%; margin-top: 12px; }

.tile-org {
  --tile: var(--tile-blue);
  --accent: var(--accent-blue);
  grid-template-columns: 1fr auto;
  align-items: start;
  cursor: default;
}
.tile-org:active, .tile-org:hover { transform: none; box-shadow: 0 8px 22px color-mix(in srgb, var(--accent, #000) 18%, transparent); }

.org-form { margin-top: 8px; padding-bottom: 12px; }
.org-block-title {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
#viewOrgForm h2 { margin: 0 0 4px; font-size: 20px; }
.org-form .row { align-items: end; }
.org-form .secondary { min-height: 52px; flex: 0 0 auto; }
.tile-org .org-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}
.tile-org .org-actions button { min-height: 40px; flex: 1; }
.tile-org.is-active { border-color: rgba(59, 130, 246, 0.45); }

.nav {
  --nav-x: 0px;
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(8px + var(--safe-bot));
  z-index: 30;
  max-width: 492px;
  margin: 0 auto;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 8px 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  transform: translate3d(var(--nav-x), 0, 0);
  will-change: transform, opacity;
}

.nav.is-on { animation: navIn var(--dur-slow) var(--ease) both; }

.nav-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 4px 2px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  transition: color 280ms var(--ease), transform 200ms var(--ease);
}

.nav-btn:active { transform: scale(0.94); }

.nav-ico {
  width: 56px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  position: relative;
}

.nav-ico svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: transform 320ms var(--ease);
}

.nav-ico::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.55), rgba(37, 99, 235, 0.12) 55%, transparent 72%);
  opacity: 0;
  transform: scale(0.78);
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}

.nav-btn.on { color: var(--sapphire); }
.nav-btn.on .nav-ico::before { opacity: 1; transform: scale(1); }
.nav-btn.on .nav-ico svg { transform: scale(1.08); }

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  z-index: 40;
  display: grid;
  align-items: end;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 380ms var(--ease), visibility 380ms;
}

.sheet.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sheet-card {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + var(--safe-bot));
  max-height: 88dvh;
  overflow: auto;
  border-top: 1px solid var(--border);
  transform: translate3d(0, 36%, 0);
  transition: transform 460ms var(--ease);
  will-change: transform;
}

.sheet.open .sheet-card { transform: translate3d(0, 0, 0); }

.sheet-card h2 { margin: 0 0 14px; font-size: 18px; }

body:not(.is-auth) .top {
  animation: viewIn 420ms var(--ease) both;
}

.panel.enter {
  animation: viewIn 380ms var(--ease) both;
  z-index: 3;
}
.panel.is-leave {
  animation: viewOut 240ms var(--ease-in) both;
  pointer-events: none;
  z-index: 2;
}

.stack.enter,
#authTitle.swap,
.error:not([hidden]),
#stockReceipt.enter,
#stockShipment.enter,
#stockCheck.enter { animation: riseIn 340ms var(--ease) both; }

.panel.enter .list > * {
  animation: riseIn 340ms var(--ease) both;
}
.panel.enter .list > *:nth-child(1) { animation-delay: 24ms; }
.panel.enter .list > *:nth-child(2) { animation-delay: 48ms; }
.panel.enter .list > *:nth-child(3) { animation-delay: 72ms; }
.panel.enter .list > *:nth-child(4) { animation-delay: 96ms; }
.panel.enter .list > *:nth-child(5) { animation-delay: 120ms; }
.panel.enter .list > *:nth-child(6) { animation-delay: 144ms; }
.panel.enter .list > *:nth-child(7) { animation-delay: 168ms; }
.panel.enter .list > *:nth-child(8) { animation-delay: 192ms; }
.panel.enter .list > *:nth-child(n+9) { animation-delay: 216ms; }

@keyframes riseIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes viewIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes viewOut {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0; transform: translate3d(0, -6px, 0); }
}

@keyframes authIn {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.985); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes navIn {
  from { opacity: 0; transform: translate3d(var(--nav-x), 18px, 0); }
  to { opacity: 1; transform: translate3d(var(--nav-x), 0, 0); }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

@media (min-width: 540px) {
  .nav { left: 50%; right: auto; width: 492px; --nav-x: -50%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }
}
