:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --surface-soft: #f8fafb;
  --ink: #182025;
  --muted: #69747c;
  --line: #d9dee2;
  --accent: #147d64;
  --accent-2: #0f6fae;
  --danger: #bd2b2b;
  --warning: #b7791f;
  --critical: #8f1d45;
  --hot: #d85d17;
  --shadow: 0 18px 46px rgba(16, 24, 32, 0.08);
  --shadow-soft: 0 10px 28px rgba(16, 24, 32, 0.055);
  --ring: 0 0 0 3px rgba(15, 111, 174, 0.14);
  --background: #f5f6fb;
  --surfaceHover: #f4f6fb;
  --surfaceSelected: #eef2ff;
  --borderSubtle: #e5e7ef;
  --textPrimary: #1f2328;
  --textSecondary: #616b7a;
  --brandPrimary: #6264a7;
  --brandHover: #55589a;
  --success: #107c41;
  --radiusSmall: 6px;
  --radiusMedium: 10px;
  --radiusLarge: 14px;
  --shadowCard: 0 8px 24px rgba(31, 35, 40, 0.08);
  --shadowPanel: 0 20px 48px rgba(31, 35, 40, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(20, 125, 100, 0.08), transparent 340px),
    linear-gradient(180deg, #f9fbfc 0, var(--bg) 300px);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

body.auth-locked .app-shell {
  display: none;
}

body:not(.auth-locked) .login-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
.nav-item:focus-visible,
.quick-filter:focus-visible,
.kanban-card:focus-visible,
.shipment-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(380px, 0.65fr);
  gap: 28px;
  align-items: center;
  padding: 34px;
  background:
    radial-gradient(circle at 22% 24%, rgba(20, 125, 100, 0.28), transparent 360px),
    radial-gradient(circle at 75% 18%, rgba(15, 111, 174, 0.22), transparent 320px),
    linear-gradient(135deg, #0d171d 0%, #101d24 45%, #14242c 100%);
  overflow: hidden;
  position: relative;
}

.login-screen:before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(90deg, #000 0%, rgba(0, 0, 0, 0.76) 58%, transparent 100%);
  pointer-events: none;
}

.login-control-tower,
.login-panel-wrap {
  position: relative;
  z-index: 1;
}

.login-control-tower {
  display: grid;
  gap: 14px;
  min-height: min(720px, calc(100vh - 68px));
  align-content: center;
}

.login-quiet-panel {
  min-height: 560px;
  display: grid;
  align-content: end;
  border: 1px solid rgba(195, 222, 225, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(150deg, rgba(17, 35, 43, 0.88), rgba(9, 20, 27, 0.74)),
    radial-gradient(circle at 32% 34%, rgba(20, 125, 100, 0.18), transparent 280px);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.32);
  overflow: hidden;
  position: relative;
  padding: 34px;
}

.login-quiet-panel:before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(121, 226, 196, 0.12) 42% 42.4%, transparent 42.4%),
    linear-gradient(135deg, transparent 0 56%, rgba(91, 174, 225, 0.12) 56% 56.35%, transparent 56.35%),
    linear-gradient(155deg, transparent 0 68%, rgba(204, 242, 80, 0.1) 68% 68.3%, transparent 68.3%);
}

.login-lines {
  position: absolute;
  inset: 24px;
  border: 1px solid rgba(215, 232, 235, 0.08);
  border-radius: 14px;
}

.login-lines span {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #bdf21a;
  box-shadow: 0 0 18px rgba(189, 242, 26, 0.32);
}

.login-lines span:nth-child(1) {
  left: 18%;
  top: 28%;
}

.login-lines span:nth-child(2) {
  left: 42%;
  top: 45%;
  background: #4fe1b4;
}

.login-lines span:nth-child(3) {
  right: 22%;
  top: 30%;
}

.login-lines span:nth-child(4) {
  right: 30%;
  bottom: 24%;
  background: #5baee1;
}

.login-system-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  display: grid;
  gap: 8px;
}

.login-system-copy span {
  color: #b7f2d9;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.login-system-copy strong {
  color: #f8fbfb;
  font-size: clamp(30px, 4vw, 56px);
  line-height: 1.04;
  letter-spacing: 0;
}

.login-system-copy p {
  color: #b7c7cc;
  font-size: 17px;
}

.login-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.login-trust-row span {
  border: 1px solid rgba(215, 232, 235, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #d7e4e7;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

.login-card {
  width: min(420px, 100%);
  margin-left: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.34);
  display: grid;
  gap: 14px;
  backdrop-filter: blur(18px);
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 0;
}

.login-heading {
  display: grid;
  gap: 5px;
}

.login-heading span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.login-heading p {
  color: var(--muted);
  line-height: 1.45;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-weight: 800;
  color: #3b464d;
}

.login-brand {
  color: var(--ink);
  border-bottom-color: var(--line);
  padding-bottom: 14px;
}

.login-brand span {
  color: var(--muted);
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
}

.login-trust-row {
  gap: 6px;
}

.login-trust-row span {
  background: #eef7f3;
  border-color: #cde6dc;
  color: #0f684f;
  padding: 5px 9px;
}


.twofa-box {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fa;
  padding: 12px;
}

.twofa-secret {
  display: block;
  white-space: normal;
  word-break: break-all;
  border-radius: 6px;
  background: #e9eff2;
  padding: 8px;
  font-size: 12px;
}

.small-text {
  font-size: 13px;
}

.sidebar {
  background: #11191f;
  color: #f8fafb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  color: #aeb8bf;
  font-size: 13px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
  padding: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.field-label {
  color: #b8c1c7;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.control {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.control:focus {
  border-color: var(--accent-2);
  box-shadow: var(--ring);
}

.sidebar .control {
  background: #1b252c;
  border-color: #2d3b45;
  color: #f8fafb;
}

.account-box {
  display: grid;
  gap: 5px;
  padding: 12px;
  padding-right: 58px;
  background: #1b252c;
  border: 1px solid #2d3b45;
  border-radius: 8px;
  position: relative;
  min-height: 88px;
  align-content: start;
  flex: 0 0 auto;
}

.account-box strong {
  overflow-wrap: anywhere;
  padding-right: 4px;
}

.account-box .account-role {
  color: #aeb8bf;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.full-button {
  width: 100%;
}

.logout-icon-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(174, 184, 191, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #edf4f7;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.logout-icon-button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(237, 244, 247, 0.58);
  color: #ffffff;
  transform: translateY(-1px);
}

.logout-icon-button:focus-visible {
  outline: 3px solid rgba(29, 139, 110, 0.42);
  outline-offset: 3px;
}

.nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(174, 184, 191, 0.28) transparent;
}

.nav::-webkit-scrollbar {
  width: 4px;
}

.nav::-webkit-scrollbar-thumb {
  background: rgba(174, 184, 191, 0.28);
  border-radius: 999px;
}

.nav-item {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #ced6db;
  text-align: left;
  padding: 9px 10px;
  font-weight: 700;
  position: relative;
  cursor: grab;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.nav-item:active {
  cursor: grabbing;
}

.nav-item:hover,
.nav-item.active {
  background: #26333b;
  color: #fff;
}

.nav-item:hover {
  transform: translateX(2px);
}

.nav-item.dragging {
  opacity: 0.56;
  transform: scale(0.98);
}

.nav-item.drag-over {
  outline: 2px solid rgba(42, 187, 144, 0.8);
  outline-offset: 2px;
}

.sidebar-menu-reset {
  flex: 0 0 auto;
  min-height: 32px;
  border: 1px solid rgba(206, 214, 219, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: #9fabac;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-menu-reset:hover {
  background: rgba(42, 187, 144, 0.12);
  border-color: rgba(42, 187, 144, 0.28);
  color: #e8fff7;
}

.sidebar-guide-link {
  flex: 0 0 auto;
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(206, 214, 219, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: #b9c6cc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.sidebar-guide-link:hover,
.sidebar-guide-link.active {
  background: rgba(42, 187, 144, 0.14);
  border-color: rgba(42, 187, 144, 0.34);
  color: #eafff8;
  transform: translateY(-1px);
}

.sidebar-guide-link.hidden {
  display: none;
}

.sidebar-guide-icon {
  width: 19px;
  height: 19px;
  border-radius: 999px;
  background: rgba(42, 187, 144, 0.18);
  color: #dffbf4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
}

.nav-dot {
  display: none;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #e73333;
  box-shadow: 0 0 0 3px rgba(231, 51, 51, 0.18);
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.nav-dot.visible {
  display: block;
}

.sidebar-status {
  flex: 0 0 auto;
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

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

.topbar h1 {
  font-size: 26px;
  line-height: 1.15;
}

.topbar p,
.muted {
  color: var(--muted);
}

body.popup-mode:not(.auth-locked) {
  background: #f4f7f8;
}

body.popup-mode:not(.auth-locked) .app-shell {
  grid-template-columns: minmax(0, 1fr);
}

body.popup-mode:not(.auth-locked) .sidebar,
body.popup-mode:not(.auth-locked) .topbar,
body.popup-mode:not(.auth-locked) #appStatus {
  display: none;
}

body.popup-mode:not(.auth-locked) .main {
  padding: 12px;
}

body.popup-mode:not(.auth-locked) .chat-shell {
  min-height: calc(100vh - 24px);
  border-radius: 10px;
}

body.popup-mode:not(.auth-locked) .direct-shell {
  grid-template-columns: minmax(150px, 0.45fr) minmax(0, 1fr);
  min-height: calc(100vh - 24px);
}

body.popup-mode:not(.auth-locked) .chat-head .popout-button {
  display: none;
}

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

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.icon-button:hover {
  border-color: #c6d0d6;
  transform: translateY(-1px);
}

.notify-device {
  font-size: 18px;
  font-weight: 900;
  position: relative;
}

.notify-device.notify-on {
  background: #e5f4ee;
  border-color: #b9dfd1;
  color: #0d684f;
}

.notify-device.notify-blocked {
  background: #fff0f0;
  border-color: #f1c9c9;
  color: var(--danger);
}

.notify-device.notify-hint {
  background: #fff8db;
  border-color: #ead38c;
  color: #755313;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

#tvView:not(.active) {
  display: none !important;
}

body.tv-active:not(.auth-locked) {
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  overflow: hidden;
  background: #091015;
}

body.tv-active.tv-view-active:not(.auth-locked) .app-shell {
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  overflow: hidden;
}

body.tv-active.tv-view-active:not(.auth-locked) .main {
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  overflow: hidden;
}

body.tv-active.tv-view-active:not(.auth-locked) .topbar,
body.tv-active.tv-view-active:not(.auth-locked) #appStatus {
  display: none;
}

.app-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #33414a;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 850;
  box-shadow: var(--shadow-soft);
}

.app-status-loading {
  border-color: #c8dce8;
  background: #f1f7fb;
  color: #175d91;
}

.app-status-success {
  border-color: #bfe2d1;
  background: #eef8f2;
  color: #0d684f;
}

.app-status-error {
  border-color: #efc8ce;
  background: #fff5f6;
  color: #8b1f31;
}

.app-status-warning {
  border-color: #ead1a1;
  background: #fff8ea;
  color: #7b4f08;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  justify-items: start;
  gap: 7px;
  padding: 18px;
  border: 1px dashed #cfd9de;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.loading-state {
  display: flex;
  align-items: center;
  color: #175d91;
  border-style: solid;
  background: #f2f8fc;
}

.loading-state span {
  width: 15px;
  height: 15px;
  border: 2px solid #c7ddec;
  border-top-color: #175d91;
  border-radius: 999px;
  animation: spin 0.85s linear infinite;
}

.empty-state strong,
.error-state strong {
  color: var(--ink);
  font-size: 15px;
}

.empty-state p,
.error-state p {
  margin: 0;
}

.error-state {
  border-style: solid;
  border-color: #efc8ce;
  background: #fff7f8;
  color: #8b1f31;
}

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 160px auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.shipment-toolbar {
  grid-template-columns: minmax(360px, 1.8fr) minmax(190px, 0.65fr) minmax(160px, 0.45fr) minmax(160px, 0.45fr);
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfb 100%);
  border-color: #d9e2e6;
  box-shadow: 0 10px 26px rgba(15, 37, 46, 0.06);
}

.shipment-toolbar .control {
  min-height: 38px;
  height: 38px;
  border-radius: 7px;
  border-color: #d5dee3;
  background: #fff;
  color: #17232a;
  font-size: 14px;
  font-weight: 700;
  padding: 7px 10px;
}

.shipment-toolbar .control::placeholder {
  color: #8f9aa2;
  font-weight: 650;
}

.shipment-toolbar .search {
  min-width: 260px;
}

.shipment-toolbar #shipmentCreatorFilter {
  min-width: 160px;
}

.shipment-toolbar select.control {
  cursor: pointer;
  padding-right: 32px;
}

@media (max-width: 1180px) {
  .shipment-toolbar {
    grid-template-columns: minmax(240px, 1fr) minmax(180px, 0.7fr);
  }
}

@media (max-width: 780px) {
  .shipment-toolbar {
    grid-template-columns: 1fr;
    padding: 9px;
  }

  .shipment-toolbar .search,
  .shipment-toolbar #shipmentCreatorFilter {
    min-width: 0;
  }
}

.orders-toolbar {
  grid-template-columns:
    minmax(240px, 1.2fr)
    repeat(3, minmax(130px, 0.75fr))
    repeat(2, minmax(145px, 0.75fr))
    repeat(2, minmax(150px, 0.75fr));
  align-items: end;
}

.search {
  min-width: 0;
}

.toggle {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.new-offer-badge {
  background: linear-gradient(135deg, #dff0ff, #b7dcff);
  border: 1px solid #6eb7ff;
  color: #0a4d82;
  box-shadow: 0 0 0 3px rgba(42, 142, 238, 0.12), 0 0 14px rgba(42, 142, 238, 0.28);
  animation: offerPulse 1.8s ease-in-out infinite;
}

.withdrawn-offer-badge {
  background: linear-gradient(135deg, #ffe7e7, #ffd0d0);
  border: 1px solid #ff9b9b;
  color: #9f1239;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1), 0 0 14px rgba(220, 38, 38, 0.22);
  animation: withdrawnOfferPulse 1.8s ease-in-out infinite;
}

@keyframes offerPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(42, 142, 238, 0.12), 0 0 12px rgba(42, 142, 238, 0.22);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(42, 142, 238, 0.2), 0 0 20px rgba(42, 142, 238, 0.42);
  }
}

@keyframes withdrawnOfferPulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1), 0 0 12px rgba(220, 38, 38, 0.18);
  }

  50% {
    box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.18), 0 0 20px rgba(220, 38, 38, 0.34);
  }
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.quick-filter {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #34424a;
  padding: 6px 12px;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.quick-filter.active {
  background: #123c47;
  border-color: #123c47;
  color: #fff;
}

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

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 14px;
  align-items: start;
}

#shipmentsView .split {
  align-items: stretch;
  min-height: min(720px, calc(100vh - 220px));
}

#shipmentsView .split > .panel,
#shipmentsView .detail-panel {
  max-height: calc(100vh - 220px);
  min-height: 0;
}

#shipmentsView .split > .panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#shipmentsView .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

#shipmentsView .detail-panel {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.panel,
.detail-panel,
.form-section,
.chat-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.panel {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

#shipmentsView table {
  min-width: 1180px;
}

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

th {
  background: var(--surface-2);
  font-size: 12px;
  color: #4e5a62;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef7f3;
}

tbody tr.selected {
  box-shadow: inset 3px 0 0 var(--accent);
}

tbody tr.risk-warning-row {
  box-shadow: inset 4px 0 0 var(--hot);
}

tbody tr.risk-critical-row {
  background: #fff8fb;
  box-shadow: inset 4px 0 0 var(--critical);
}

tbody tr.risk-critical-row:hover,
tbody tr.risk-critical-row.selected {
  background: #fff0f5;
}

.route {
  color: #26333b;
  font-weight: 700;
}

.subline {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.table-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.table-pills .pill {
  min-height: 20px;
  padding: 2px 7px;
  font-size: 11px;
}

.risk-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 260px;
}

.risk-pill {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 11px;
}

.risk-info {
  background: #eef5ff;
  color: #155e93;
  border-color: #c9def3;
}

.risk-warning {
  background: #fff7e8;
  color: #8a520d;
  border-color: #ecd19a;
}

.risk-critical {
  background: #fff0f4;
  color: #8f1d45;
  border-color: #efb8c8;
}

.risk-success {
  background: #eaf8f0;
  color: #176944;
  border-color: #bfe5ce;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.icon-mini {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #20313a;
  font-weight: 1000;
  line-height: 1;
}

.icon-mini:hover {
  border-color: #bfd0d8;
  background: #f4f8fa;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  background: #e5f4ee;
  color: #0d684f;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.muted-pill {
  background: #edf0f2;
  color: #59656d;
}

.status-pill {
  background: #e8f1fa;
  color: #175d91;
}

.priority-normal {
  background: #edf0f2;
  color: #59656d;
}

.priority-dolezita {
  background: #fff2d2;
  color: #815711;
}

.priority-hot {
  background: #ffe3d1;
  color: #a13e08;
}

.priority-kriticka {
  background: #fbe0ea;
  color: #8f1d45;
}

.detail-panel {
  min-height: 640px;
  padding: 16px;
  position: sticky;
  top: 22px;
}

.detail-empty {
  color: var(--muted);
  padding: 20px 0;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  font-size: 20px;
  line-height: 1.2;
}

.detail-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: 46%;
}

.detail-head-value {
  white-space: nowrap;
  text-align: right;
  font-size: 17px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.detail-risk-pill {
  font-size: 11.5px;
  line-height: 1.2;
}

.detail-role-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: 12px 0 4px;
  padding: 12px;
  border: 1px solid #dfe8e6;
  border-radius: 8px;
  background: #f8fbfa;
}

.detail-role-banner strong {
  display: block;
  margin-top: 2px;
  font-size: 16px;
}

.detail-role-banner p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.risk-panel {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e1e8eb;
  border-radius: 10px;
  background: #fbfcfd;
}

.risk-panel-critical {
  border-color: #efb8c8;
  background: #fff8fb;
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 8px;
}

.risk-item {
  display: grid;
  gap: 3px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.risk-item strong {
  color: currentColor;
  font-size: 13px;
}

.risk-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.detail-fact-groups {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.fact-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.fact-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  margin: 0;
  color: #4e5a62;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  font-weight: 1000;
}

.fact-group summary::-webkit-details-marker {
  display: none;
}

.fact-group summary:after {
  content: "+";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf3f5;
}

.fact-group[open] summary {
  margin-bottom: 9px;
}

.fact-group[open] summary:after {
  content: "-";
  color: var(--accent);
  background: #e8f6f0;
}

.fact-group .facts {
  margin: 0;
}

.fact {
  background: #f7f8f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  min-height: 60px;
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.fact strong {
  overflow-wrap: anywhere;
}

.stops-fact-list {
  display: grid;
  gap: 6px;
}

.stops-fact-item {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid #dce7eb;
  border-radius: 7px;
  background: #fff;
}

.stops-fact-item span {
  margin: 0;
  color: #60707a;
  font-size: 11px;
  font-weight: 900;
}

.stops-fact-item strong {
  color: #1d2a32;
  font-size: 13px;
  line-height: 1.25;
}

.stops-fact-item small {
  color: #667681;
  font-size: 12px;
  font-weight: 800;
}

.multi-line-value {
  display: block;
  white-space: pre-wrap;
}

.cargo-detail-toggle {
  display: block;
  max-width: 100%;
}

.cargo-detail-toggle summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
}

.cargo-detail-toggle summary::-webkit-details-marker {
  display: none;
}

.cargo-detail-toggle summary span {
  display: block;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cargo-detail-toggle summary em {
  padding: 2px 7px;
  border-radius: 999px;
  background: #e8f6f0;
  color: var(--accent);
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
}

.cargo-detail-full {
  max-height: 180px;
  margin-top: 8px;
  padding: 9px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
}

.action-row,
.form-actions,
.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-row {
  margin: 12px 0;
}

.detail-tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 0 12px;
}

.primary-detail-tools {
  margin: 12px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.primary-detail-tools .compact-copy,
.primary-detail-tools .detail-action-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.detail-action-panel {
  display: grid;
  gap: 5px;
  min-width: min(280px, 100%);
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.detail-action-panel .action-row {
  margin: 0;
}

.detail-action-panel .primary,
.detail-action-panel .secondary,
.detail-action-panel .danger {
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
}

.detail-section {
  margin-top: 10px;
  border-top: 1px solid var(--line);
}

.detail-section summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  cursor: pointer;
  font-weight: 1000;
}

.detail-section summary::-webkit-details-marker {
  display: none;
}

.detail-section summary:after {
  content: "+";
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #edf3f5;
  color: var(--muted);
  font-weight: 1000;
}

.detail-section[open] summary:after {
  content: "-";
  background: #e8f6f0;
  color: var(--accent);
}

.detail-section summary em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.detail-section-body {
  padding-bottom: 10px;
}

.detail-section-body > :first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.primary,
.secondary,
.danger {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 13px;
  font-weight: 800;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.primary:hover,
.secondary:hover,
.danger:hover {
  transform: translateY(-1px);
}

.primary.is-busy,
.secondary.is-busy,
.danger.is-busy {
  transform: none;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: #106b55;
}

.secondary {
  background: #eef3f6;
  border-color: #d6dde2;
  color: #22303a;
}

.secondary:hover {
  background: #e1e9ee;
}

.danger {
  background: #fff0f0;
  border-color: #f1c9c9;
  color: var(--danger);
}

.price-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.price-box label,
.input-grid label,
.admin-form label {
  display: grid;
  gap: 5px;
  color: #3b464d;
  font-size: 13px;
  font-weight: 700;
}

.price-box label:last-of-type {
  grid-column: 1 / -1;
}

.checklist-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  padding: 12px;
  margin-top: 12px;
}

.checklist-box p {
  color: #4e5a62;
  overflow-wrap: anywhere;
}

.comments {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.quick-copy-panel,
.price-history {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.compact-copy {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.copy-trigger {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.copy-trigger span {
  font-size: 10px;
  color: var(--muted);
}

.copy-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: min(250px, calc(100vw - 40px));
  display: grid;
  gap: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(16, 24, 30, 0.14);
}

.copy-menu.hidden {
  display: none;
}

.copy-menu button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #1c252b;
  padding: 8px 9px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.copy-menu button:hover {
  background: #eef4f6;
}

.copy-language-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.copy-menu .copy-language-pill {
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid #d5e0e4;
  border-radius: 999px;
  background: #f7fafb;
  color: #50616b;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 900;
}

.copy-menu .copy-language-pill.active {
  border-color: #1f6f5b;
  background: #e7f3ee;
  color: #174f42;
}

.offer-entry-box {
  align-items: end;
}

.offer-entry-box .section-head {
  grid-column: 1 / -1;
}

.shipment-edit-box .section-head {
  grid-column: 1 / -1;
}

.shipment-edit-box button {
  align-self: end;
  min-height: 38px;
}

.shipment-edit-box .inline-toggle {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.price-submit {
  min-height: 38px;
}

.inline-toggle {
  min-height: 38px;
  align-self: end;
}

.form-toggle {
  align-self: end;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.credit-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.comments h3,
.dashboard-layout h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.comment-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  overflow: auto;
  padding-right: 3px;
}

.comment {
  background: #f7f8f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
}

.comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.comment strong {
  display: block;
  font-size: 13px;
}

.comment-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.comment:hover .comment-actions,
.comment:focus-within .comment-actions {
  opacity: 1;
}

.comment-icon-btn {
  display: inline-grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  border: 1px solid #d7e0e6;
  border-radius: 999px;
  background: #fff;
  color: #2f4b42;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transform: none;
}

.comment-icon-btn:hover {
  background: #eef6f3;
  border-color: #b8d3c9;
  transform: none;
}

.comment-icon-btn.comment-icon-danger {
  color: #a33a3a;
}

.comment-icon-btn.comment-icon-danger:hover {
  background: #fff0f0;
  border-color: #efc3c3;
}

.comment p {
  margin-top: 3px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.comment-edit-form {
  display: none;
  gap: 8px;
  margin-top: 8px;
}

.comment.editing .comment-view {
  display: none;
}

.comment.editing .comment-edit-form {
  display: grid;
}

.comment-edit-form textarea.control {
  min-height: 72px;
  resize: vertical;
}

.comment-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.comment-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.8fr) auto;
  gap: 8px;
  margin-top: 10px;
}

.file-control {
  padding: 6px 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
  align-items: start;
}

.form-section {
  padding: 14px;
}

.form-section.wide {
  min-width: 0;
  padding: 12px 14px 14px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(23, 33, 40, 0.04);
}

#newShipmentForm .form-section.wide > .section-head {
  display: none;
}

#newShipmentForm .form-section.wide > .section-head h2 {
  position: relative;
  padding-left: 11px;
  font-size: 18px;
}

#newShipmentForm .form-section.wide > .section-head h2:before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.section-head,
.dashboard-head,
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2,
.dashboard-head h2,
.chat-head h2 {
  font-size: 20px;
  line-height: 1.2;
}

.compact {
  width: auto;
  min-width: 160px;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.new-shipment-bar {
  display: grid;
  grid-template-columns: minmax(150px, 1.08fr) minmax(132px, 0.9fr) max-content max-content 92px minmax(210px, 1fr);
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
  padding: 8px 9px;
  border: 1px solid #dde6ea;
  border-radius: 8px;
  background: #f5f8f9;
  box-shadow: none;
}

.new-shipment-bar:before,
.shipment-core-grid:before,
.cargo-grid:before {
  content: "Nastavenia ponuky";
  grid-column: 1 / -1;
  color: #66737b;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: none;
}

.shipment-core-grid:before {
  content: "Obchodné údaje";
}

.cargo-grid:before {
  content: "Náklad";
}

.new-shipment-bar label:not(.regular-switch),
.load-type-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: #3b464d;
  font-size: 11.5px;
  font-weight: 850;
  line-height: 1.15;
}

.new-shipment-bar .control {
  min-height: 38px;
  padding: 6px 9px;
  font-size: 13.5px;
  border-radius: 7px;
}

.timed-offer-minutes .control {
  min-height: 38px;
  padding: 6px 8px;
}

.timed-offer-countdown {
  font-variant-numeric: tabular-nums;
}

.timed-edit-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbfa;
}

.regular-switch {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #d4dde2;
  border-radius: 7px;
  background: #fff;
  color: #2c3941;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.regular-switch input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.regular-switch:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 125, 100, 0.42);
}

.regular-switch:has(input:checked) {
  background: #e5f4ee;
  border-color: #add7c8;
  color: #0d684f;
}

.load-type-field {
  min-width: 0;
}

.shipment-core-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 0 10px;
  border: 0;
  border-bottom: 1px solid #e4ebee;
  border-radius: 0;
  background: transparent;
}

.shipment-core-grid label,
.shipment-stop-grid label,
.cargo-grid label {
  display: grid;
  gap: 4px;
  color: #3f4a51;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.shipment-core-grid .control,
.shipment-stop-grid .control,
.cargo-grid .control {
  min-height: 40px;
  font-size: 13.5px;
  border-color: #d8e1e5;
  border-radius: 7px;
  background: #fff;
  padding-top: 7px;
  padding-bottom: 7px;
}

.shipment-stop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.stop-card {
  display: grid;
  grid-template-columns: minmax(118px, 0.72fr) minmax(118px, 0.72fr) minmax(0, 1fr);
  column-gap: 9px;
  row-gap: 9px;
  margin: 0;
  padding: 10px;
  border: 1px solid #e1e8ec;
  border-radius: 8px;
  background: #fcfdfd;
  box-shadow: none;
}

.stop-card label:nth-of-type(4) {
  margin-top: 0;
}

.stop-card input[type="date"],
.stop-card input[type="time"] {
  cursor: pointer;
}

.stop-card legend {
  padding: 0 5px;
  color: #26343b;
  font-size: 12.5px;
  font-weight: 900;
}

.cargo-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(128px, 0.48fr) minmax(108px, 0.38fr) minmax(170px, 0.64fr);
  align-items: end;
  gap: 10px;
  padding: 9px 10px;
  margin-top: 0;
  border: 1px solid #e1e8ec;
  border-radius: 8px;
  background: #fcfdfd;
}

#newShipmentForm .form-actions {
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid #dbe4e8;
}

#newShipmentForm .form-actions button {
  min-height: 38px;
  border-radius: 7px;
  padding-inline: 15px;
  font-size: 13px;
  font-weight: 900;
}

#newShipmentForm > .form-section:not(.wide) {
  padding: 14px;
  border-radius: 8px;
}

#newShipmentForm > .form-section:not(.wide) > h2 {
  font-size: 17px;
  line-height: 1.15;
  margin-bottom: 8px;
}

#newShipmentForm .new-shipment-actions .primary {
  min-width: 174px;
}

#newShipmentForm .new-shipment-actions .secondary {
  min-width: 198px;
  background: #f5f8f9;
}

#newPriceIntelligence {
  margin-top: 10px;
  border-radius: 8px;
  font-size: 13px;
  padding: 9px 11px;
  border-color: #cfe0e6;
  background: #f7fbfc;
}

.segmented-mini {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid #d4dde2;
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
  min-height: 38px;
}

.segmented-mini label {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-right: 1px solid #e1e7ea;
  font-size: 12px;
  font-weight: 1000;
  color: #53616a;
}

.segmented-mini label:last-child {
  border-right: 0;
}

.segmented-mini input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-mini label:has(input:checked) {
  background: #123f35;
  color: #fff;
}

.flag-row {
  margin-top: 12px;
}

.form-actions {
  margin-top: 14px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.email-box {
  min-height: 226px;
  resize: vertical;
  line-height: 1.45;
  margin-bottom: 9px;
}

.screenshot-ocr {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.screenshot-ocr h3 {
  font-size: 15px;
  line-height: 1.2;
}

.screenshot-ocr label {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.dropzone {
  min-height: 96px;
  border: 1.5px dashed #b8c4cc;
  border-radius: 8px;
  background: #f8fafb;
  display: grid;
  place-items: center;
  gap: 5px;
  padding: 12px;
  text-align: center;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.dropzone strong {
  font-size: 15px;
}

.dropzone span,
.dropzone small {
  color: var(--muted);
  font-weight: 700;
}

.dropzone:hover,
.dropzone:focus,
.dropzone.drag-over {
  border-color: var(--accent);
  background: #edf7f3;
  outline: none;
}

.dropzone.drag-over {
  transform: scale(1.01);
}

.dropzone.has-file {
  border-style: solid;
  border-color: rgba(20, 125, 100, 0.45);
  background: #f1fbf7;
}

/* New shipment command-center layout */
#newView {
  --new-field-h: 38px;
  --new-border: #d8e2e7;
  --new-border-soft: #e5ecef;
  --new-panel: #ffffff;
}

#newShipmentForm.new-shipment-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 28%);
  gap: 16px;
  align-items: stretch;
}

#newShipmentForm .new-shipment-panel,
#newShipmentForm .new-capture-panel {
  padding: 14px;
  border: 1px solid var(--new-border);
  border-radius: 12px;
  background: var(--new-panel);
  box-shadow: 0 14px 36px rgba(24, 37, 45, 0.06);
}

#newShipmentForm .new-shipment-panel,
#newShipmentForm .new-capture-panel,
#newShipmentForm .new-command-section,
#newShipmentForm .capture-card {
  display: grid;
}

#newShipmentForm .new-shipment-panel {
  gap: 10px;
}

#newShipmentForm .new-capture-panel {
  align-content: start;
  gap: 12px;
}

#newShipmentForm .new-command-section {
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--new-border-soft);
}

#newShipmentForm .new-command-section:last-of-type {
  padding-bottom: 0;
  border-bottom: 0;
}

#newShipmentForm .new-section-label {
  color: #596873;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.075em;
  line-height: 1;
  text-transform: uppercase;
}

#newShipmentForm .new-shipment-bar {
  grid-template-columns:
    minmax(132px, 1fr)
    minmax(126px, 0.85fr)
    minmax(150px, auto)
    minmax(132px, auto)
    minmax(92px, 0.45fr)
    minmax(210px, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#newShipmentForm .new-shipment-bar label:not(.regular-switch),
#newShipmentForm .load-type-field {
  grid-template-columns: 1fr;
  gap: 4px;
  min-width: 0;
  color: #33414a;
  font-size: 11.5px;
  font-weight: 850;
}

#newShipmentForm .control,
#newShipmentForm .new-shipment-bar .control,
#newShipmentForm .shipment-core-grid .control,
#newShipmentForm .shipment-stop-grid .control,
#newShipmentForm .cargo-grid .control {
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  padding: 6px 10px;
  border-color: var(--new-border);
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.2;
  box-shadow: none;
}

#newShipmentForm textarea.control {
  height: auto;
}

#newShipmentForm .regular-switch {
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  padding: 0 10px;
  border-color: var(--new-border);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 850;
}

#newShipmentForm .regular-switch input {
  width: 14px;
  height: 14px;
}

#newShipmentForm .segmented-mini {
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  border-color: var(--new-border);
  border-radius: 8px;
}

#newShipmentForm .segmented-mini label {
  font-size: 12px;
  font-weight: 900;
}

#newShipmentForm .segmented-mini label:has(input:checked) {
  background: var(--accent);
  color: #fff;
}

#newShipmentForm .shipment-core-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#newShipmentForm .shipment-core-grid label,
#newShipmentForm .shipment-stop-grid label,
#newShipmentForm .cargo-grid label {
  gap: 4px;
  color: #34434c;
  font-size: 12px;
  font-weight: 850;
}

#newShipmentForm .shipment-stop-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

#newShipmentForm .stop-card {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 11px;
  border: 1px solid var(--new-border);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
}

#newShipmentForm .stop-card h3 {
  margin: 0;
  color: #1d2a32;
  font-size: 13px;
  font-weight: 950;
  line-height: 1.1;
}

#newShipmentForm .stop-card-fields {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(118px, 0.85fr) minmax(0, 1.45fr);
  gap: 8px;
}

#newShipmentForm .cargo-grid {
  grid-template-columns: minmax(0, 1.65fr) minmax(128px, 0.48fr) minmax(104px, 0.38fr) minmax(170px, 0.62fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

#newShipmentForm .new-shipment-actionbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--new-border-soft);
}

#newShipmentForm #newPriceIntelligence {
  min-height: 38px;
  display: flex;
  align-items: center;
  margin: 0;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.25;
}

#newShipmentForm .new-shipment-actions {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

#newShipmentForm .new-shipment-actions button {
  min-height: 38px;
  height: 38px;
  border-radius: 8px;
  padding-inline: 14px;
  font-size: 12.5px;
}

#newShipmentForm .capture-card {
  gap: 8px;
}

#newShipmentForm .capture-card + .capture-card {
  padding-top: 12px;
  border-top: 1px solid var(--new-border-soft);
}

#newShipmentForm .email-box {
  min-height: 242px;
  margin: 0;
  resize: vertical;
  line-height: 1.38;
}

#newShipmentForm #parseEmailBtn,
#newShipmentForm #parseScreenshotBtn {
  min-height: 38px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 900;
}

#newShipmentForm .screenshot-ocr {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--new-border-soft);
}

#newShipmentForm .dropzone {
  min-height: 116px;
  border-color: #b8c7cf;
  border-radius: 10px;
  background: linear-gradient(180deg, #fbfcfd 0%, #f5f8fa 100%);
}

#newShipmentForm .dropzone strong {
  font-size: 14px;
}

#newShipmentForm .dropzone span,
#newShipmentForm .dropzone small,
#newShipmentForm #screenshotOcrStatus {
  font-size: 12px;
}

/* New shipment command-center redesign */
#newView {
  --new-field-h: 36px;
  --new-border: #d8e2e6;
  --new-border-soft: #e8eef1;
  --new-section-bg: #fbfcfd;
  --new-label: #5b6972;
  --new-text: #1d2a32;
}

#newView .page-title h1,
#newView > h1 {
  font-size: 24px;
  letter-spacing: 0;
}

#newShipmentForm.new-shipment-layout {
  grid-template-columns: minmax(0, 72fr) minmax(300px, 28fr);
  gap: 14px;
  align-items: start;
}

#newShipmentForm .new-shipment-panel,
#newShipmentForm .new-capture-panel {
  border: 1px solid var(--new-border);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfe 100%);
  box-shadow: 0 12px 26px rgba(22, 34, 42, 0.05);
}

#newShipmentForm > .form-section.wide.new-shipment-panel {
  gap: 11px;
  padding: 12px;
  border-left: 4px solid var(--accent);
}

#newShipmentForm > .form-section.new-capture-panel {
  gap: 12px;
  padding: 12px;
  position: sticky;
  top: 12px;
}

#newShipmentForm .new-panel-head,
#newShipmentForm .new-capture-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--new-border-soft);
}

#newShipmentForm .new-panel-head div,
#newShipmentForm .new-capture-head {
  min-width: 0;
}

#newShipmentForm .new-panel-head span,
#newShipmentForm .new-capture-head span {
  display: block;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 1000;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

#newShipmentForm .new-panel-head strong,
#newShipmentForm .new-capture-head strong {
  display: block;
  margin-top: 3px;
  color: var(--new-text);
  font-size: 15px;
  font-weight: 950;
  line-height: 1.1;
}

#newShipmentForm .new-panel-head em {
  display: none;
}

#newShipmentForm .new-command-section {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--new-border-soft);
}

#newShipmentForm .new-command-section:last-of-type {
  border-bottom: 0;
}

#newShipmentForm .new-section-label {
  position: sticky;
  top: 12px;
  align-self: start;
  padding-top: 8px;
  color: var(--new-label);
  font-size: 10.5px;
  font-weight: 1000;
  letter-spacing: 0.095em;
  line-height: 1.15;
  text-transform: uppercase;
}

#newShipmentForm .new-section-label:before {
  content: "";
  display: block;
  width: 18px;
  height: 3px;
  margin-bottom: 7px;
  border-radius: 999px;
  background: var(--accent);
}

#newShipmentForm .new-shipment-bar {
  display: grid;
  grid-template-columns:
    minmax(134px, 1fr)
    minmax(126px, 0.9fr)
    minmax(142px, auto)
    minmax(126px, auto)
    minmax(78px, 0.42fr)
    minmax(214px, 0.95fr);
  align-items: end;
  gap: 8px;
}

#newShipmentForm .new-shipment-bar,
#newShipmentForm .shipment-core-grid,
#newShipmentForm .shipment-stop-grid,
#newShipmentForm .cargo-grid {
  min-width: 0;
}

#newShipmentForm .new-shipment-bar label:not(.regular-switch),
#newShipmentForm .load-type-field,
#newShipmentForm .shipment-core-grid label,
#newShipmentForm .shipment-stop-grid label,
#newShipmentForm .cargo-grid label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #38464f;
  font-size: 11.5px;
  font-weight: 850;
  line-height: 1.1;
}

#newShipmentForm .control,
#newShipmentForm .new-shipment-bar .control,
#newShipmentForm .shipment-core-grid .control,
#newShipmentForm .shipment-stop-grid .control,
#newShipmentForm .cargo-grid .control {
  width: 100%;
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  padding: 5px 9px;
  border: 1px solid var(--new-border);
  border-radius: 7px;
  background: #fff;
  color: var(--new-text);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

#newShipmentForm .control:focus {
  border-color: rgba(20, 125, 100, 0.55);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.11);
}

#newShipmentForm .regular-switch {
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  padding: 0 9px;
  border: 1px solid var(--new-border);
  border-radius: 7px;
  background: #fff;
  color: #2f3f47;
  font-size: 11.8px;
  font-weight: 900;
  white-space: nowrap;
}

#newShipmentForm .regular-switch:has(input:checked) {
  border-color: #9ed2c1;
  background: #e9f7f1;
  color: #0f6d55;
}

#newShipmentForm .segmented-mini {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  min-width: 0;
  min-height: var(--new-field-h);
  height: var(--new-field-h);
  border: 1px solid var(--new-border);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

#newShipmentForm .segmented-mini label {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: 0;
  border-right: 1px solid var(--new-border-soft);
  background: #fff;
  color: #40505a;
  font-size: 11.8px;
  font-weight: 950;
}

#newShipmentForm .segmented-mini label:last-child {
  border-right: 0;
}

#newShipmentForm .segmented-mini label span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: inherit;
  line-height: 1;
}

#newShipmentForm .segmented-mini label:has(input:checked) {
  background: #163f35;
  color: #fff;
}

#newShipmentForm .segmented-mini label:has(input:checked) span {
  color: #fff;
}

#newShipmentForm .shipment-core-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(150px, 1fr) minmax(190px, 1fr);
  gap: 9px;
}

#newShipmentForm .shipment-stop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

#newShipmentForm .stop-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--new-border);
  border-radius: 8px;
  background: var(--new-section-bg);
  align-content: start;
  min-width: 0;
}

#newShipmentForm .stop-card h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #1d2a32;
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
}

#newShipmentForm .stop-card h3:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

#newShipmentForm .stop-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#newShipmentForm .stop-add-btn,
#newShipmentForm .stop-remove-btn {
  display: inline-grid;
  width: 28px;
  height: 28px;
  min-width: 28px;
  place-items: center;
  border: 1px solid #cfdce2;
  border-radius: 8px;
  background: #fff;
  color: #173f35;
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
}

#newShipmentForm .stop-add-btn:hover,
#newShipmentForm .stop-remove-btn:hover {
  border-color: #9eb7af;
  background: #edf7f4;
}

#newShipmentForm .stop-list {
  display: grid;
  gap: 7px;
  min-width: 0;
}

#newShipmentForm .stop-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.62fr) minmax(96px, 0.8fr) minmax(140px, 1.35fr) minmax(104px, 0.86fr) minmax(104px, 0.86fr) minmax(82px, 0.66fr) minmax(82px, 0.66fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
}

#newShipmentForm .extra-stop-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  padding: 8px;
  border: 1px solid #d9e3e7;
  border-radius: 8px;
  background: #fff;
}

#newShipmentForm .extra-stop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#newShipmentForm .stop-card .control {
  min-width: 0;
  width: 100%;
}

#newShipmentForm .stop-card {
  container-type: inline-size;
}

#newShipmentForm .stop-card .stop-row {
  grid-template-columns: minmax(72px, 0.72fr) minmax(92px, 0.9fr) minmax(130px, 1.55fr) minmax(102px, 1fr) minmax(102px, 1fr);
}

#newShipmentForm .stop-card .stop-time-from {
  grid-column: 1 / span 2;
}

#newShipmentForm .stop-card .stop-time-to {
  grid-column: 3 / span 1;
}

@container (max-width: 560px) {
  #newShipmentForm .stop-card .stop-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #newShipmentForm .stop-card .stop-city,
  #newShipmentForm .stop-card .stop-date-from,
  #newShipmentForm .stop-card .stop-date-to,
  #newShipmentForm .stop-card .stop-time-from,
  #newShipmentForm .stop-card .stop-time-to {
    grid-column: auto;
  }

}

#newShipmentForm .stop-row-index {
  align-self: center;
  color: #667681;
  font-size: 11px;
  font-weight: 950;
  line-height: 1.1;
}

#newShipmentForm .stop-remove-btn {
  align-self: end;
  color: #9b1c1c;
  font-size: 17px;
}

#newShipmentForm .stop-card-fields {
  display: grid;
  grid-template-columns: minmax(76px, 0.65fr) minmax(110px, 0.85fr) minmax(0, 1.45fr);
  gap: 8px;
}

#newShipmentForm .stop-card-fields label:nth-child(4),
#newShipmentForm .stop-card-fields label:nth-child(5) {
  max-width: 160px;
}

#newShipmentForm .cargo-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.65fr) minmax(120px, 0.45fr) minmax(96px, 0.35fr) minmax(150px, 0.62fr);
  gap: 9px;
  align-items: end;
}

#newShipmentForm .cargo-description-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: end;
  min-width: 0;
}

#newShipmentForm .cargo-description-field label,
#newShipmentForm .initial-comment-field {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: #38464f;
  font-size: 11.5px;
  font-weight: 850;
  line-height: 1.1;
}

#newShipmentForm .cargo-grid .cargo-description-input,
#newShipmentForm .initial-comment-field textarea.control {
  min-height: 42px;
  height: 42px;
  resize: vertical;
  line-height: 1.25;
}

#newShipmentForm .initial-comment-field {
  grid-column: 1 / -1;
}

#newShipmentForm .new-shipment-actionbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-top: 11px;
  border-top: 1px solid var(--new-border-soft);
}

#newShipmentForm #newPriceIntelligence {
  min-height: 36px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #cfe0e6;
  border-radius: 7px;
  background: #f7fbfc;
  color: #26343b;
  font-size: 12.5px;
}

#newShipmentForm .new-shipment-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
  border: 0;
}

#newShipmentForm .new-shipment-actions button {
  min-height: 36px;
  height: 36px;
  padding-inline: 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 950;
}

#newShipmentForm .new-shipment-actions .secondary {
  order: 1;
  min-width: 176px;
}

#newShipmentForm .new-shipment-actions .primary {
  order: 2;
  min-width: 164px;
}

#newShipmentForm .new-capture-head {
  display: block;
}

#newShipmentForm .capture-card {
  display: grid;
  gap: 8px;
}

#newShipmentForm .capture-card .new-section-label {
  position: static;
  padding: 0;
}

#newShipmentForm .capture-card .new-section-label:before {
  display: none;
}

#newShipmentForm .capture-card + .capture-card {
  padding-top: 12px;
  border-top: 1px solid var(--new-border-soft);
}

#newShipmentForm .email-box {
  min-height: 250px;
  height: 250px;
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
  resize: vertical;
}

#newShipmentForm #parseEmailBtn,
#newShipmentForm #parseScreenshotBtn {
  width: fit-content;
  min-height: 36px;
  padding-inline: 13px;
  border-radius: 7px;
  font-size: 12.5px;
}

#newShipmentForm .screenshot-ocr {
  margin: 0;
  padding-top: 12px;
}

#newShipmentForm .dropzone {
  min-height: 106px;
  padding: 10px;
  border: 1px dashed #b8c7cf;
  border-radius: 8px;
  background: #f8fafb;
}

#newShipmentForm .dropzone strong {
  font-size: 13.5px;
}

#newShipmentForm .dropzone span,
#newShipmentForm .dropzone small,
#newShipmentForm #screenshotOcrStatus {
  font-size: 11.5px;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.my-work-focus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.my-work-focus strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  margin-top: 4px;
}

.my-work-focus p {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.work-focus-score {
  min-width: 130px;
  border-left: 1px solid var(--line);
  padding-left: 16px;
}

.work-focus-score span,
.work-focus-score small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.work-focus-score strong {
  font-size: 30px;
  margin: 2px 0;
}

.my-work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.work-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 7px 12px;
  font-weight: 900;
}

.work-action:hover {
  border-color: rgba(20, 125, 100, 0.38);
  background: #f1f8f5;
}

.list-more-button {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(20, 125, 100, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, #f6fbf9, #edf7f3);
  color: #123b31;
  padding: 8px 11px;
  font-weight: 900;
}

.list-more-button:hover {
  border-color: rgba(20, 125, 100, 0.46);
  background: #e7f4ef;
}

.list-more-button strong {
  min-width: 54px;
  text-align: center;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  padding: 4px 8px;
  font-size: 12px;
  box-shadow: inset 0 0 0 1px rgba(20, 125, 100, 0.14);
}

.workbench-shell {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 128px);
  gap: 12px;
}

.workbench-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f7faf9);
  box-shadow: 0 12px 34px rgba(17, 24, 39, 0.05);
}

.workbench-head h2 {
  margin: 2px 0 2px;
  font-size: 24px;
  line-height: 1.1;
}

.workbench-back {
  min-width: 92px;
}

.workbench-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.workbench-kpis > div {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workbench-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.workbench-kpis strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
}

.workbench-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.workbench-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.workbench-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf9;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.workbench-list .shipment-card {
  min-height: 122px;
  margin: 0;
}

.workbench-list .empty-state {
  grid-column: 1 / -1;
}

.workbench-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 0 0;
}

.workbench-pager span {
  min-width: 88px;
  text-align: center;
  color: var(--muted);
  font-weight: 900;
}

@media (max-width: 980px) {
  .workbench-shell {
    min-height: auto;
  }

  .workbench-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workbench-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .workbench-head,
  .workbench-tools {
    grid-template-columns: 1fr;
  }

  .workbench-back {
    width: fit-content;
  }

  .workbench-kpis {
    grid-template-columns: 1fr;
  }

  .workbench-list {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .workbench-pager {
    justify-content: space-between;
  }
}

.my-work-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) repeat(3, minmax(230px, 1fr));
  gap: 14px;
  align-items: start;
}

.work-panel-primary {
  border-color: rgba(20, 125, 100, 0.28);
  background: #fbfefd;
}

.muted-empty {
  color: var(--muted);
  font-weight: 800;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.status-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.status-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 160px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.status-column h4 {
  margin: 0 0 10px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.stack {
  display: grid;
  gap: 10px;
}

.compact-stack {
  margin-bottom: 18px;
}

.shipment-card,
.mini-row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.shipment-card.has-order-action {
  padding-right: 46px;
}

.status-column .shipment-card {
  box-shadow: none;
  margin-bottom: 8px;
}

.kanban-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kanban-toolbar > div {
  display: grid;
  gap: 3px;
}

.kanban-toolbar strong {
  color: var(--ink);
  font-size: 18px;
}

.kanban-toolbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kanban-scope-field {
  min-width: min(320px, 42vw);
  display: grid;
  gap: 5px;
}

.kanban-scope-field .control {
  min-height: 38px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.kanban-column {
  min-width: 220px;
  display: flex;
  flex-direction: column;
  max-height: min(72vh, 760px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.kanban-column h3 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 16px;
}

.kanban-column h3 span {
  color: var(--muted);
}

.kanban-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.kanban-card {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
}

.kanban-card:hover {
  border-color: var(--accent);
  background: #eef7f3;
}

.kanban-list .list-more-button {
  margin-top: 2px;
}

.shipment-card strong,
.mini-row strong {
  display: block;
  margin-bottom: 4px;
}

.shipment-card small,
.mini-row small {
  color: var(--muted);
}

.order-card-actions {
  position: absolute;
  top: 9px;
  right: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.order-edit-icon,
.order-detail-edit {
  width: 34px;
  height: 34px;
}

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

.chat-shell {
  max-width: 980px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafb 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.chat-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.direct-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 900px);
  gap: 14px;
  align-items: start;
}

.direct-users,
.order-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.direct-users h2,
.order-panel h2 {
  margin-bottom: 12px;
}

.direct-user {
  cursor: pointer;
}

.direct-user.active {
  border-color: var(--accent);
  background: #eef7f3;
}

.messages-center {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr) minmax(240px, 300px);
  gap: 14px;
  align-items: stretch;
}

.messages-sidebar,
.messages-thread-panel,
.messages-detail-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.messages-sidebar {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
}

.messages-sidebar-head,
.messages-thread-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messages-sidebar-head h2,
.messages-thread-head h2 {
  margin: 0;
}

.messages-sidebar-head p,
.messages-thread-head p {
  color: var(--muted);
  margin: 2px 0 0;
  font-size: 13px;
}

.messages-sidebar-head > div,
.messages-thread-head > div {
  min-width: 0;
  flex: 1;
}

.conversation-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.conversation-filters button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #52616a;
  font-size: 12px;
  font-weight: 900;
}

.conversation-filters button.active {
  background: #173e36;
  color: #fff;
  border-color: #173e36;
}

.conversation-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 7px;
}

.conversation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  padding: 9px;
  text-align: left;
}

.conversation-item:hover,
.conversation-item.active {
  background: #eef7f3;
  border-color: #c6ded5;
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #e4f3ef, #d7e5ec);
  color: #173e36;
  font-size: 12px;
  font-weight: 950;
}

.conversation-avatar-wrap {
  position: relative;
  width: 42px;
  height: 42px;
}

.conversation-avatar.large {
  width: 48px;
  height: 48px;
}

.presence-dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 999px;
  background: #9aa5ac;
  border: 2px solid #fff;
}

.conversation-avatar-wrap .presence-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
}

.presence-dot.online {
  background: #16a36a;
}

.conversation-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.conversation-title-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.conversation-title-row strong,
.conversation-last,
.conversation-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title-row small,
.conversation-meta,
.conversation-last {
  color: var(--muted);
  font-size: 12px;
}

.conversation-last {
  color: #46555d;
}

.conversation-unread {
  min-width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e73333;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
}

.messages-thread-panel {
  min-width: 0;
  overflow: hidden;
}

.messages-thread-shell {
  min-height: calc(100vh - 120px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
}

.messages-thread-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.messages-back-button {
  display: none;
}

.messages-active-list {
  max-height: none;
  min-height: 0;
}

.message-search-box {
  display: grid;
  gap: 6px;
}

.message-search-card {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px;
}

.message-search-card button,
.detail-message-link {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f7faf9;
  padding: 8px;
  text-align: left;
  color: var(--ink);
}

.message-search-card button:hover,
.detail-message-link:hover {
  border-color: #c6ded5;
  background: #eef7f3;
}

.message-search-card span,
.detail-message-link span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #52616a;
  font-size: 12px;
}

.empty-search {
  color: var(--muted);
  font-weight: 800;
}

.typing-indicator {
  min-height: 18px;
  color: #147d64;
  font-size: 12px;
  font-weight: 900;
  padding-left: 8px;
}

.message-read-state {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  margin-top: 4px;
  color: #8a98a5;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-align: right;
}

.read-checks {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  min-width: 18px;
  height: 13px;
}

.read-check {
  width: 13px;
  height: 13px;
  margin-left: -3px;
}

.read-check:first-child {
  margin-left: 0;
}

.read-check path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-read-state.sent .read-check path {
  stroke-width: 2.15;
}

.message-read-state.delivered {
  color: #64748b;
}

.message-read-state.delivered .read-check path {
  stroke-width: 1.85;
}

.message-read-state.read {
  color: #111827;
}

.message-read-state.read .read-check path {
  stroke-width: 3.15;
}

.chat-message.own .message-read-state.read {
  color: #111827;
}

.message-read-state.sending {
  color: #94a3b8;
}

.read-pending {
  display: inline-block;
  min-width: 13px;
  font-size: 13px;
  line-height: 1;
}

.message-read-state small {
  margin-left: 2px;
  color: inherit;
  font-size: 10px;
  letter-spacing: 0;
}

.chat-message.message-highlight .chat-bubble {
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.18), var(--shadow);
}

.messages-detail-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
  overflow: auto;
}

.messages-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.messages-detail-head h3,
.messages-detail-panel h4 {
  margin: 0;
}

.messages-detail-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.messages-detail-panel section {
  display: grid;
  gap: 8px;
}

.detail-members {
  display: grid;
  gap: 8px;
}

.detail-members > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: center;
}

.detail-members small {
  grid-column: 2;
  color: var(--muted);
}

.detail-attachment {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  color: var(--ink);
  padding: 8px;
  text-decoration: none;
  font-weight: 900;
}

.detail-attachment-main {
  border: 0;
  background: transparent;
  color: inherit;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.detail-attachment-main strong,
.detail-attachment-main small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-attachment small {
  color: var(--muted);
  font-weight: 700;
}

.detail-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.conversation-storage-actions {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.messages-thread-empty {
  height: 100%;
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 24px;
}

.chat-messages {
  min-height: 420px;
  max-height: 58vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(244, 248, 249, 0.9)),
    #f5f7f8;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.chat-message {
  width: fit-content;
  max-width: min(78%, 720px);
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.chat-head h2 {
  margin-right: auto;
}

.popout-button {
  width: 36px;
  min-height: 36px;
  border-radius: 50%;
  font-size: 16px;
}

.chat-message.pinned {
  border-color: transparent;
}

.chat-message.own {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr) 34px;
}

.chat-message.own .chat-avatar {
  grid-column: 2;
}

.chat-message.own .chat-bubble {
  grid-column: 1;
  grid-row: 1;
  background: #147d64;
  color: #fff;
  border-color: #147d64;
  border-bottom-right-radius: 4px;
}

.chat-message.own .chat-message-meta,
.chat-message.own .chat-message-meta strong,
.chat-message.own .message-reply span,
.chat-message.own .message-reply strong,
.chat-message.own .edited-tag,
.chat-message.own .urgent-tag,
.chat-message.own .attachment-link small {
  color: rgba(255, 255, 255, 0.78);
}

.chat-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dfe8e6;
  color: #21343b;
  font-size: 12px;
  font-weight: 900;
}

.chat-bubble {
  position: relative;
  width: fit-content;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: #fff;
  padding: 8px 11px;
  box-shadow: 0 6px 16px rgba(27, 39, 45, 0.06);
}

.urgent-message .chat-bubble {
  border-color: rgba(217, 82, 55, 0.45);
  box-shadow: 0 8px 22px rgba(217, 82, 55, 0.11);
}

.chat-message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 4px;
  color: #71808a;
  font-size: 11px;
  font-weight: 800;
}

.chat-message-meta strong {
  color: #27353c;
  font-size: 12px;
}

.chat-message p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.38;
}

.pinned-messages {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.pinned-message {
  width: 100%;
  display: grid;
  gap: 3px;
  text-align: left;
  border: 1px solid #ead38c;
  border-radius: 8px;
  background: #fff8db;
  color: #3e3420;
  padding: 9px 10px;
}

.pinned-message span,
.message-reply span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.message-reply {
  display: grid;
  gap: 2px;
  border-left: 3px solid #b9dfd1;
  background: rgba(20, 125, 100, 0.08);
  padding: 6px 8px;
  border-radius: 6px;
  margin-bottom: 7px;
}

.attachments {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.attachment-link {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f9;
  color: #123c47;
  padding: 7px 9px;
  text-decoration: none;
  font-weight: 800;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.attachment-link small {
  color: var(--muted);
  white-space: nowrap;
}

.attachment-preview-card {
  width: min(920px, calc(100vw - 28px));
  max-height: min(86vh, 840px);
}

.attachment-preview-body {
  min-height: 220px;
  max-height: 62vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  display: grid;
  place-items: center;
  padding: 12px;
}

.attachment-preview-image {
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
  border-radius: 10px;
}

.attachment-preview-frame {
  width: 100%;
  height: 58vh;
  border: 0;
  border-radius: 10px;
  background: white;
}

.attachment-preview-fallback {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.attachment-type-icon.large {
  width: 64px;
  height: 64px;
  font-size: 18px;
}

.reply-preview {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  border: 1px solid #b9dfd1;
  border-radius: 6px;
  background: #eef7f3;
  padding: 6px 8px;
  font-size: 13px;
}

.reply-preview.hidden {
  display: none;
}

.reply-preview button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 18px;
  font-weight: 900;
}

.unread-divider {
  justify-self: center;
  border-radius: 999px;
  background: #fff0f0;
  color: var(--danger);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.deleted-message {
  opacity: 0.72;
}

.deleted-message p {
  color: var(--muted);
  font-style: italic;
}

.edited-tag {
  color: var(--muted);
  font-weight: 700;
  margin-left: 6px;
}

.urgent-tag {
  color: #b12d1b;
  font-weight: 950;
  text-transform: uppercase;
}

.reaction-row,
.reaction-summary,
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.chat-actions {
  position: absolute;
  right: 8px;
  top: -34px;
  z-index: 3;
  flex-wrap: nowrap;
  margin-top: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(22, 34, 40, 0.14);
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.chat-message.own .chat-actions {
  left: 8px;
  right: auto;
}

.chat-message:hover .chat-actions,
.chat-message:focus .chat-actions,
.chat-message:focus-within .chat-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.reaction-picker.hidden {
  display: none;
}

.reaction-summary .reaction-chip {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #34424a;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 800;
  cursor: default;
  outline: none;
}

.reaction-summary .reaction-chip.active {
  background: #e5f4ee;
  border-color: #b9dfd1;
  color: #0d684f;
}

.reaction-chip-content {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.reaction-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 25;
  min-width: 220px;
  max-width: min(320px, 80vw);
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(134, 148, 160, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  color: #1f2a33;
  box-shadow: 0 18px 42px rgba(22, 34, 40, 0.18);
  opacity: 0;
  transform: translate(-50%, 6px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.reaction-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgba(134, 148, 160, 0.2);
  border-bottom: 1px solid rgba(134, 148, 160, 0.2);
  background: rgba(255, 255, 255, 0.98);
  transform: translateX(-50%) rotate(45deg);
}

.reaction-chip:hover .reaction-tooltip,
.reaction-chip:focus .reaction-tooltip,
.reaction-chip:focus-within .reaction-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.chat-message:not(.own) .reaction-summary .reaction-tooltip {
  left: 0;
  right: auto;
  transform: translate(0, 6px);
}

.chat-message:not(.own) .reaction-chip:hover .reaction-tooltip,
.chat-message:not(.own) .reaction-chip:focus .reaction-tooltip,
.chat-message:not(.own) .reaction-chip:focus-within .reaction-tooltip {
  transform: translate(0, 0);
}

.chat-message:not(.own) .reaction-tooltip::after {
  left: 26px;
  transform: rotate(45deg);
}

.chat-message.own .reaction-summary .reaction-tooltip {
  left: auto;
  right: 0;
  transform: translate(0, 6px);
}

.chat-message.own .reaction-chip:hover .reaction-tooltip,
.chat-message.own .reaction-chip:focus .reaction-tooltip,
.chat-message.own .reaction-chip:focus-within .reaction-tooltip {
  transform: translate(0, 0);
}

.chat-message.own .reaction-tooltip::after {
  left: auto;
  right: 26px;
  transform: rotate(45deg);
}

.reaction-tooltip-title {
  color: #6b7680;
  font-size: 12px;
  font-weight: 800;
}

.reaction-user-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  color: #1f2a33;
  font-size: 14px;
  font-weight: 800;
}

.reaction-user-row.muted {
  display: block;
  color: #73808a;
  font-size: 12px;
}

.reaction-user-avatar {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #e8eefb;
  color: #4756a5;
  font-size: 11px;
  font-weight: 950;
}

.reaction-row button,
.chat-actions button {
  min-height: 26px;
  border: 1px solid rgba(110, 126, 136, 0.26);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #34424a;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.chat-actions .chat-icon-action {
  width: 28px;
  min-width: 28px;
  padding: 3px 0;
  font-size: 14px;
}

.chat-actions .danger-icon {
  color: #b12d1b;
}

.reaction-row button.active {
  background: #e5f4ee;
  border-color: #b9dfd1;
  color: #0d684f;
}

.reaction-row span {
  margin-left: 3px;
}

.chat-form {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  position: relative;
}

.chat-compose-row {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 7px;
  box-shadow: 0 8px 22px rgba(27, 39, 45, 0.06);
}

.chat-text-input {
  flex: 1 1 auto;
  min-width: 120px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  padding: 7px 10px 7px 12px;
  box-shadow: none;
}

.chat-text-input:focus {
  border-color: transparent;
  box-shadow: none;
}

.emoji-toggle {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  font-size: 18px;
  line-height: 1;
  border-radius: 50%;
}

.attach-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #2d4854;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.urgent-toggle {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid #edc6bf;
  border-radius: 50%;
  background: #fff5f3;
  color: #b12d1b;
  cursor: pointer;
}

.urgent-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.urgent-toggle span {
  font-weight: 950;
}

.urgent-toggle:has(input:checked) {
  background: #b12d1b;
  border-color: #b12d1b;
  color: #fff;
}

.send-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}

.emoji-panel {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  box-shadow: var(--shadow);
}

.emoji-panel.hidden {
  display: none;
}

.emoji-panel button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f8f9;
  font-size: 18px;
  line-height: 1;
}

.emoji-panel button:hover {
  background: #eef7f3;
  border-color: #b9dfd1;
}

.message-preview-toast {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 2200;
  width: min(360px, calc(100vw - 28px));
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid #bfdad2;
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  padding: 12px 14px;
  box-shadow: 0 18px 48px rgba(20, 32, 38, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.message-preview-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message-preview-toast span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.message-preview-toast strong {
  font-size: 15px;
}

.message-preview-toast small {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.urgent-modal {
  z-index: 2600;
}

.urgent-modal-card {
  max-width: 520px;
  border-top: 5px solid #b12d1b;
}

.urgent-modal-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.urgent-modal-head p {
  color: var(--muted);
  line-height: 1.4;
}

.urgent-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #b12d1b;
  color: #fff;
  font-weight: 950;
  font-size: 22px;
}

.urgent-message-card {
  display: grid;
  gap: 5px;
  border: 1px solid #edc6bf;
  border-radius: 10px;
  background: #fff8f6;
  padding: 12px;
  margin-bottom: 12px;
}

.urgent-message-card p {
  line-height: 1.45;
}

.urgent-message-card small {
  color: var(--muted);
}

.urgent-reply-form {
  display: grid;
  gap: 10px;
}

.tv-screen {
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  min-height: 0;
  background: #091015;
  color: #f6fafb;
  border-radius: 0;
  padding: clamp(12px, 1.35vw, 22px);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows:
    clamp(58px, 8vh, 92px)
    clamp(70px, 10vh, 106px)
    minmax(0, 1fr)
    clamp(118px, 19vh, 198px)
    clamp(32px, 4.2vh, 44px);
  gap: clamp(8px, 0.95vh, 12px);
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active {
  display: grid !important;
  height: var(--tv-height, 100dvh) !important;
  max-height: var(--tv-height, 100dvh) !important;
}

.tv-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  min-height: 0;
  overflow: hidden;
}

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

.tv-brand img {
  width: clamp(42px, 4vw, 66px);
  height: clamp(42px, 4vw, 66px);
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

.tv-head h2 {
  font-size: clamp(26px, 3.35vw, 46px);
  line-height: 0.98;
}

.tv-head p {
  font-size: clamp(12px, 1vw, 15px);
}

.tv-head strong {
  font-size: clamp(30px, 4.8vw, 62px);
  line-height: 1;
}

.tv-clock-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tv-fullscreen-btn,
.tv-logout-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #334650;
  border-radius: 10px;
  background: #111c23;
  color: #f6fafb;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.tv-logout-btn {
  width: 34px;
  height: 34px;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #c8d3d8;
  font-size: 16px;
}

.tv-fullscreen-btn:hover,
.tv-logout-btn:hover {
  background: #17252d;
}

.tv-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: clamp(8px, 0.8vw, 12px);
  min-height: 0;
  height: auto;
}

.tv-metric,
.tv-panel {
  background: #111c23;
  border: 1px solid #26343d;
  border-radius: 8px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.22);
}

.tv-metric {
  padding: clamp(9px, 1vw, 13px);
  min-height: 0;
  display: grid;
  align-content: center;
  overflow: hidden;
}

.tv-metric span {
  display: block;
  color: #9fb0bb;
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
}

.tv-metric strong {
  display: block;
  font-size: clamp(22px, 2.35vw, 34px);
  margin-top: 4px;
  line-height: 1.02;
}

.tv-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(280px, 0.82fr) minmax(280px, 0.82fr);
  gap: clamp(8px, 0.9vw, 12px);
  align-items: stretch;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.tv-motivation-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: clamp(8px, 0.9vw, 12px);
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.tv-panel {
  padding: clamp(9px, 1vw, 13px);
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tv-panel h3 {
  margin-bottom: 7px;
  font-size: clamp(13px, 1.15vw, 18px);
  line-height: 1.12;
  flex: 0 0 auto;
}

.tv-panel .section-head {
  flex: 0 0 auto;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.tv-list {
  display: grid;
  gap: 6px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 2px;
}

.tv-screen #tvRiskList,
.tv-screen #tvUnassignedList {
  overflow: hidden;
}

.tv-screen #tvRiskList .tv-shipment,
.tv-screen #tvUnassignedList .tv-shipment {
  min-height: clamp(52px, 6.2vh, 72px);
}

.tv-screen .tv-list.compact-stack {
  margin-bottom: 0;
}

.tv-panel > h3 + .tv-list {
  flex: 1 1 0;
}

.tv-panel > h3 + .tv-list + h3 {
  margin-top: 8px;
}

.tv-panel > h3 + .tv-list + h3 + .tv-list {
  flex: 1 1 0;
}

.tv-shipment {
  display: grid;
  gap: 3px;
  background: #17252d;
  border: 1px solid #2d404b;
  border-radius: 7px;
  padding: 8px 9px;
  min-height: 0;
}

.tv-shipment.celebration {
  background: linear-gradient(135deg, #17382f, #192837);
  border-color: #2d705b;
}

.tv-shipment strong {
  font-size: clamp(14px, 1.25vw, 20px);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-shipment span {
  font-weight: 800;
  font-size: clamp(12px, 1vw, 15px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-shipment small,
.tv-screen .mini-row small,
.tv-screen .muted {
  color: #9fb0bb;
  font-size: clamp(10px, 0.86vw, 12px);
}

.tv-screen .mini-row {
  background: #17252d;
  border-color: #2d404b;
  color: #f6fafb;
  padding: 8px 9px;
  min-height: 0;
  font-size: clamp(12px, 1vw, 14px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-screen #tvSalesLeaders,
.tv-screen #tvDispatcherLeaders {
  flex: 0 0 auto;
  max-height: none;
  overflow: hidden;
}

.tv-screen #tvSalesLeaders .mini-row,
.tv-screen #tvDispatcherLeaders .mini-row {
  min-height: clamp(34px, 3.8vh, 46px);
}

.tv-ticker {
  height: auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #26343d;
  border-radius: 8px;
  background: #111c23;
  display: flex;
  align-items: center;
}

.ticker-track {
  display: inline-flex;
  gap: 28px;
  width: max-content;
  min-width: max-content;
  white-space: nowrap;
  padding: 8px 12px;
  animation: ticker 32s linear infinite;
  font-weight: 900;
  font-size: clamp(12px, 1.05vw, 15px);
}

.ticker-track.ticker-idle {
  width: 100%;
  min-width: 100%;
  animation: none;
  color: #9fb0bb;
}

@keyframes ticker {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.tv-kiosk-user .app-shell {
  display: block;
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  min-height: var(--tv-height, 100dvh);
  overflow: hidden;
}

.tv-kiosk-user .sidebar,
.tv-kiosk-user .topbar {
  display: none;
}

.tv-kiosk-user .main {
  padding: 0;
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  overflow: hidden;
}

.tv-kiosk-user .tv-screen {
  border-radius: 0;
  height: var(--tv-height, 100dvh);
  max-height: var(--tv-height, 100dvh);
  padding: clamp(12px, 1.35vw, 22px);
  box-shadow: none;
}

.tv-kiosk-user .tv-head {
  margin-bottom: 0;
}

@media (min-width: 1600px) and (min-height: 900px) and (max-aspect-ratio: 17 / 9) {
  .tv-screen {
    grid-template-rows:
      clamp(72px, 8vh, 96px)
      clamp(84px, 9.5vh, 110px)
      minmax(0, 1fr)
      clamp(130px, 18vh, 210px)
      clamp(34px, 4vh, 46px);
    gap: 12px;
    padding: 18px 22px;
  }

  .tv-grid,
  .tv-motivation-grid {
    gap: 12px;
  }

  .tv-panel {
    padding: 13px;
  }

  .tv-metric {
    min-height: 0;
  }

}

@media (max-width: 1400px), (max-height: 820px) {
  .tv-screen {
    grid-template-rows:
      clamp(48px, 7.5vh, 64px)
      clamp(54px, 8.5vh, 70px)
      minmax(0, 1fr)
      clamp(82px, 16vh, 122px)
      clamp(26px, 4vh, 34px);
    gap: 7px;
    padding: 10px 12px;
  }

  .tv-brand img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
  }

  .tv-head h2 {
    font-size: 30px;
  }

  .tv-head strong {
    font-size: 42px;
  }

  .tv-head p {
    font-size: 11px;
  }

  .tv-fullscreen-btn,
  .tv-logout-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 15px;
  }

  .tv-metrics {
    gap: 7px;
  }

  .tv-metric {
    min-height: 0;
    padding: 8px;
  }

  .tv-metric span {
    font-size: 10px;
  }

  .tv-metric strong {
    font-size: 24px;
  }

  .tv-grid {
    grid-template-columns: minmax(0, 1.38fr) minmax(220px, 0.82fr) minmax(220px, 0.82fr);
    gap: 7px;
  }

  .tv-motivation-grid {
    gap: 7px;
  }

  .tv-panel {
    padding: 8px;
  }

  .tv-panel h3 {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .tv-panel > h3 + .tv-list + h3 {
    margin-top: 6px;
  }

  .tv-list {
    gap: 5px;
  }

  .tv-shipment {
    padding: 6px 7px;
  }

  .tv-shipment strong {
    font-size: 13px;
  }

  .tv-shipment span,
  .tv-screen .mini-row {
    font-size: 11px;
  }

  .tv-shipment small,
  .tv-screen .mini-row small,
  .tv-screen .muted {
    font-size: 10px;
  }

  .tv-ticker {
    height: 100%;
  }

  .ticker-track {
    padding: 6px 10px;
    font-size: 11px;
  }
}

.directory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.directory-grid.single-directory {
  grid-template-columns: minmax(0, 1fr);
}

.directory-panel {
  padding: 16px;
}

.directory-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.directory-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.directory-row p {
  margin-top: 6px;
  color: var(--muted);
}

.price-intelligence {
  margin-top: 14px;
  border-color: #c8dbe2;
  background: #f6fbfc;
}

.intelligence-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr) minmax(0, 1.2fr);
  gap: 10px;
}

.intelligence-grid h3 {
  margin-bottom: 6px;
  font-size: 14px;
}

.intelligence-grid strong,
.intelligence-grid small {
  display: block;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
}

.admin-grid .panel {
  padding: 18px;
  border-radius: 10px;
}

.admin-panel-wide {
  grid-column: 1 / -1;
}

#adminView {
  --admin-surface: #ffffff;
  --admin-muted-surface: #f7faf9;
  --admin-line: #d9e2e6;
  --admin-soft-line: #edf2f4;
  --admin-shadow: 0 16px 44px rgba(15, 23, 42, 0.06);
}

#adminView .admin-grid {
  align-items: start;
  gap: 14px;
}

#adminView .panel {
  border: 1px solid var(--admin-line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--admin-surface), #fbfdfc);
  box-shadow: var(--admin-shadow);
}

#adminView .section-head {
  min-height: 0;
  align-items: center;
  gap: 12px;
}

#adminView .section-head h2 {
  font-size: 21px;
  letter-spacing: -0.01em;
}

#adminView .section-head h3 {
  font-size: 17px;
  letter-spacing: -0.01em;
}

#adminView .section-head .subline,
#adminView .muted {
  font-size: 12px;
  line-height: 1.35;
}

#adminView .input-grid label,
#adminView form label {
  color: #3c4850;
  font-size: 12px;
  font-weight: 850;
}

#adminView .control {
  min-height: 38px;
  height: 38px;
  border-radius: 9px;
  border-color: var(--admin-line);
  background: #fff;
  font-size: 14px;
}

#adminView button.primary,
#adminView button.secondary,
#adminView button.danger {
  min-height: 40px;
  border-radius: 10px;
  font-size: 14px;
}

#adminView .settings-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}

#adminView .settings-form .primary {
  min-width: 150px;
}

#adminView .sound-studio-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--admin-line);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbfa, #ffffff);
}

#adminView .sound-studio-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

#adminView .sound-studio-head h3 {
  margin: 0;
  color: #172127;
  font-size: 16px;
  letter-spacing: -0.01em;
}

#adminView .sound-studio-head p {
  margin: 3px 0 0;
  color: #6b757d;
  font-size: 12px;
  font-weight: 700;
}

#adminView .sound-volume-control {
  min-width: min(320px, 100%);
  display: grid;
  gap: 7px;
  color: #334047;
}

#adminView .sound-volume-control span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#adminView .sound-volume-control input {
  width: 100%;
  accent-color: var(--accent);
}

#adminView .sound-studio-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

#adminView .sound-studio-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 11px;
  border: 1px solid var(--admin-soft-line);
  border-radius: 10px;
  background: #fff;
}

#adminView .sound-studio-item strong,
#adminView .sound-studio-item span {
  display: block;
}

#adminView .sound-studio-item strong {
  color: #182229;
  font-size: 13px;
  line-height: 1.2;
}

#adminView .sound-studio-item span {
  margin-top: 2px;
  color: #6f7b83;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.25;
}

#adminView .sound-preview-btn {
  min-width: 78px;
  min-height: 34px;
  padding: 7px 10px;
  white-space: nowrap;
}

#adminView .danger-zone {
  border-color: rgba(185, 28, 28, 0.18);
  background: linear-gradient(180deg, #fff, #fff8f8);
}

#adminView .danger-zone .danger {
  width: auto;
  min-width: 190px;
  background: #fff1f1;
  border-color: rgba(185, 28, 28, 0.24);
}

#adminView .inline-form {
  min-width: min(100%, 360px);
}

#adminView .inline-form .control {
  min-width: 0;
}

#adminView .inline-form .secondary {
  flex: 0 0 auto;
  min-width: 90px;
}

#adminView #groupsList,
#adminView #alertRulesList,
#adminView #auditList {
  max-height: 360px;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
}

#adminView #groupsList > *,
#adminView #alertRulesList > *,
#adminView #auditList > * {
  border-radius: 10px;
}

#adminView .section-head {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.settings-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.settings-toggle {
  align-self: end;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.health-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 6px;
  min-height: 104px;
}

.health-card strong {
  font-size: 20px;
}

.health-card small,
.health-card span {
  color: var(--muted);
  font-weight: 700;
}

.health-card.health-bad {
  border-color: rgba(189, 43, 43, 0.45);
  background: #fff7f7;
}

.health-alerts {
  grid-column: 1 / -1;
  border: 1px solid rgba(183, 121, 31, 0.4);
  border-radius: 10px;
  background: #fffaf0;
  padding: 16px 18px;
}

.permissions-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
  background: #f7f8f9;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.permission-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-weight: 700;
}

.permission-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.orders-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.documents-shell {
  display: grid;
  gap: 12px;
}

.documents-head {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(460px, 760px);
  gap: 14px;
  align-items: end;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, #f7faf9);
  box-shadow: 0 14px 36px rgba(17, 24, 39, 0.05);
}

.documents-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.documents-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.documents-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px auto;
  gap: 8px;
  align-items: center;
}

.documents-toolbar .control,
.documents-toolbar .secondary {
  min-height: 40px;
}

.documents-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 82px;
}

.document-stat {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 82px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.04);
}

.document-stat span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.document-stat strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.document-stat small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.document-stat.status-ok {
  border-color: rgba(20, 125, 100, 0.22);
  background: linear-gradient(180deg, #ffffff, #f2fbf7);
}

.document-stat.status-wait {
  border-color: rgba(180, 83, 9, 0.22);
  background: linear-gradient(180deg, #ffffff, #fffaf0);
}

.document-stat.attention {
  border-color: rgba(185, 28, 28, 0.22);
  background: linear-gradient(180deg, #ffffff, #fff7f7);
}

.documents-list {
  display: grid;
  gap: 8px;
  min-height: 360px;
}

.document-card {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
  min-height: 126px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.035);
}

.document-card.status-missing {
  border-color: rgba(185, 28, 28, 0.18);
}

.document-card.status-wait {
  border-color: rgba(180, 83, 9, 0.2);
}

.document-card.status-ok {
  border-color: rgba(20, 125, 100, 0.2);
}

.document-status-rail {
  width: 4px;
  border-radius: 999px;
  background: #94a3b8;
}

.document-card.status-missing .document-status-rail {
  background: #b91c1c;
}

.document-card.status-wait .document-status-rail {
  background: #b45309;
}

.document-card.status-ok .document-status-rail {
  background: var(--accent);
}

.document-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

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

.document-number {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.document-number > span:first-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-title-row strong {
  font-size: 18px;
  line-height: 1.15;
}

.document-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.document-status-pill.missing {
  color: #9f1239;
  background: #fce7f3;
}

.document-status-pill.requested {
  color: #92400e;
  background: #ffedd5;
}

.document-status-pill.uploaded {
  color: #11624f;
  background: #dff6ed;
}

.document-route {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.document-meta strong {
  color: var(--ink);
}

.document-attachments .attachments {
  margin: 0;
}

.document-empty-doc {
  padding: 9px 11px;
  border: 1px dashed #cbd5e1;
  border-radius: 9px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.document-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.document-actions button {
  min-width: 126px;
  min-height: 40px;
}

.alert-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 14px;
}

.alert-form .secondary,
.alert-form .primary,
.admin-form .secondary,
.admin-form .danger {
  width: 100%;
  white-space: normal;
}

#adminView .alert-form {
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, 0.8fr) minmax(110px, 0.55fr) minmax(140px, 0.7fr) minmax(220px, 1.35fr) repeat(3, minmax(104px, 0.55fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--admin-soft-line);
  border-radius: 12px;
  background: var(--admin-muted-surface);
}

#adminView .alert-form button {
  width: auto;
  min-width: 112px;
  padding-inline: 12px;
}

#adminView .alert-form .settings-toggle {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--admin-line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
}

.admin-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.admin-form .admin-group-field {
  align-self: stretch;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-form .admin-group-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  height: 144px;
  min-height: 144px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  scrollbar-width: thin;
}

.admin-form .group-choice {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fa;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  min-width: 0;
}

.admin-form .group-choice:hover {
  background: #eef6f3;
  border-color: rgba(20, 125, 100, 0.35);
}

.admin-form .group-choice:has(input:checked),
.admin-form .group-choice.selected {
  background: #e7f4ef;
  border-color: rgba(20, 125, 100, 0.58);
  box-shadow: inset 3px 0 0 var(--accent);
}

.admin-form .group-choice input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  flex: 0 0 auto;
  margin: 0;
}

.admin-form .group-choice span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scoped-permissions-box {
  margin-top: 12px;
  padding: 12px;
}

.scoped-permissions-box .section-head {
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(214, 224, 228, 0.9);
}

.scoped-permissions-box h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.group-scoped-permission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 8px;
  max-height: clamp(260px, 42vh, 500px);
  overflow: auto;
  padding: 1px 4px 2px 1px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.scoped-permission-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.025);
}

.scoped-permission-head {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.scoped-permission-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.2;
  color: var(--text);
}

.scoped-permission-head span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scoped-permission-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.scoped-permission-option {
  min-height: 30px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf9;
  color: var(--text);
  font-size: 11px;
  line-height: 1.15;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.scoped-permission-option:hover {
  background: #eef6f3;
  border-color: rgba(20, 125, 100, 0.35);
}

.scoped-permission-option.selected,
.scoped-permission-option:has(input:checked) {
  background: #e8f4ef;
  border-color: rgba(20, 125, 100, 0.5);
  box-shadow: inset 3px 0 0 var(--accent);
}

.scoped-permission-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.scoped-permission-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .group-scoped-permission-list {
    grid-template-columns: 1fr;
    max-height: 360px;
  }

  .scoped-permission-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .scoped-permission-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (max-width: 560px) {
  .scoped-permissions-box {
    padding: 10px;
  }

  .scoped-permission-options {
    grid-template-columns: 1fr;
  }
}

.admin-users-panel {
  display: grid;
  gap: 14px;
}

.admin-users-panel > .section-head {
  margin-bottom: 0;
}

.admin-users-panel .admin-form {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.72fr);
  gap: 12px;
  align-items: stretch;
  margin: 0 0 12px;
}

.admin-user-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8faf9);
  padding: 14px;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.035);
}

.admin-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.admin-card-title span,
.admin-group-field > span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
}

.admin-card-title small,
.admin-group-field > small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.admin-user-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.admin-users-panel .admin-form label {
  min-width: 0;
  color: #39454d;
  font-size: 12px;
  font-weight: 850;
}

.admin-users-panel .admin-form .control {
  min-height: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 14px;
}

.admin-switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.admin-switch-row .toggle {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.admin-switch-row .toggle input {
  width: 16px;
  height: 16px;
}

.admin-users-panel .admin-group-field {
  display: grid;
  gap: 6px;
  height: 100%;
}

.admin-users-panel .admin-group-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 6px;
  max-height: 158px;
  min-height: 118px;
  overflow: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  scrollbar-width: thin;
}

.admin-users-panel .group-choice {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fa;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  font-weight: 850;
  cursor: pointer;
  min-width: 0;
}

.admin-users-panel .group-choice:hover {
  background: #eef6f3;
  border-color: rgba(20, 125, 100, 0.35);
}

.admin-users-panel .group-choice:has(input:checked),
.admin-users-panel .group-choice.selected {
  background: #e8f4ef;
  border-color: rgba(20, 125, 100, 0.55);
  box-shadow: inset 3px 0 0 var(--accent);
}

.admin-users-panel .group-choice input {
  width: 15px;
  height: 15px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.admin-users-panel .group-choice span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.admin-user-actions button {
  width: auto;
  min-width: 124px;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.admin-user-actions .danger {
  margin-left: auto;
  color: #b42323;
  border-color: rgba(185, 28, 28, 0.22);
  background: #fff7f7;
}

.admin-users-panel .permissions-box {
  padding: 13px;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8faf9);
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.03);
}

.admin-users-panel .permission-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.admin-users-panel .permission-item {
  min-height: 36px;
  border-radius: 9px;
  font-size: 12px;
}

.admin-users-panel .table-wrap {
  max-height: 440px;
  overflow: auto;
}

.offers {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.offer-row p {
  color: var(--muted);
  margin-top: 5px;
}

.offer-row-withdrawn {
  border-color: rgba(190, 24, 93, 0.24);
  background: linear-gradient(135deg, rgba(255, 241, 242, 0.85), rgba(255, 255, 255, 0.9));
}

.offer-row-withdrawn strong,
.offer-row-withdrawn small {
  color: #8f1237;
}

.request-card {
  overflow: hidden;
}

.request-card .section-head {
  align-items: flex-start;
  gap: 10px;
}

.request-card p,
.request-card .subline {
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.35;
}

.request-card .pill {
  flex: 0 0 auto;
  white-space: nowrap;
}

.sales-credit-box {
  margin: 0 0 12px;
}

.credit-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
  gap: 12px;
  border: 1px solid rgba(20, 125, 100, 0.25);
  border-radius: 8px;
  background: #f1fbf7;
  padding: 12px;
}

.credit-card strong {
  display: block;
  font-size: 24px;
  margin-top: 3px;
}

.credit-card small {
  color: var(--muted);
  font-weight: 700;
}

.credit-users {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.credit-users span {
  border: 1px solid rgba(20, 125, 100, 0.18);
  border-radius: 999px;
  background: #fff;
  padding: 5px 8px;
  color: #344049;
  font-size: 12px;
  font-weight: 800;
}

.kpi-credit-card {
  margin-bottom: 14px;
}

.credit-history {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.credit-current-summary {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 76px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(20, 125, 100, 0.2);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

.credit-current-summary span,
.credit-current-summary small {
  color: var(--muted);
  font-weight: 800;
}

.credit-current-summary strong {
  font-size: 15px;
  margin: 0;
}

.credit-history-details {
  margin-top: 8px;
}

.credit-history-details summary {
  cursor: pointer;
  list-style: none;
  border: 1px solid rgba(20, 125, 100, 0.16);
  border-radius: 999px;
  background: #fff;
  color: #234451;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 900;
}

.credit-history-details summary::-webkit-details-marker {
  display: none;
}

.credit-history-details summary:after {
  content: "⌄";
  float: right;
  color: var(--muted);
}

.credit-history-details[open] summary:after {
  content: "⌃";
}

.credit-history-row {
  display: grid;
  grid-template-columns: 90px 70px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(20, 125, 100, 0.14);
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
  font-size: 13px;
}

.credit-history-row span,
.credit-history-row small {
  color: var(--muted);
  font-weight: 800;
}

.credit-history-row strong {
  font-size: 14px;
  margin: 0;
}

.credit-users-table {
  margin-top: 8px;
}

.kpi-toolbar {
  grid-template-columns: 160px 160px 160px auto auto;
}

.kpi-status-message {
  margin: -2px 0 12px;
  padding: 10px 12px;
  border: 1px solid #dfe7eb;
  border-radius: 8px;
  background: #f7fafb;
  color: #53616a;
  font-size: 13px;
  font-weight: 800;
}

.kpi-status-message.error {
  border-color: #f0b7b7;
  background: #fff5f5;
  color: #9d2323;
}

.requests-panel {
  padding: 26px;
  min-height: 320px;
}

.requests-panel .section-head {
  align-items: center;
  margin-bottom: 16px;
}

.request-card {
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid #dfe7eb;
  background: #fff;
}

#requestsList {
  min-height: 160px;
  align-content: start;
}

#requestsList .loading-state,
#requestsList .empty-state,
#requestsList > .mini-row:only-child {
  min-height: 96px;
}

.request-card p {
  margin: 0;
  max-width: 72ch;
  color: #26343b;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.request-card .action-row {
  margin-top: 2px;
}

.audit-list {
  max-height: 520px;
  overflow: auto;
}

.audit-row {
  display: grid;
  gap: 5px;
}

.audit-row code {
  white-space: pre-wrap;
  color: #4a5660;
  font-size: 12px;
}

.audit-change {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid #eef2f4;
}

.audit-change span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.audit-change b {
  color: var(--muted);
}

.audit-change code {
  background: #f6f9fa;
  border: 1px solid #e3e9ec;
  border-radius: 6px;
  padding: 5px 7px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #11191f;
  color: #fff;
  border-radius: 8px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
  max-width: min(520px, calc(100vw - 30px));
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.app-notification-stack {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  right: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100vw - 28px));
  max-height: min(380px, calc(100vh - 36px));
  pointer-events: none;
}

.app-notification {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: start;
  padding: 12px 12px 12px 14px;
  border: 1px solid rgba(39, 86, 75, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(16, 32, 39, 0.16);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
  overflow: hidden;
}

.app-notification::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--green);
}

.app-notification.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.app-notification.leaving {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}

.app-notification-body {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.app-notification-body strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-notification-body span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.app-notification-close {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 126, 98, 0.09);
  color: #2f6f60;
  cursor: pointer;
  font-size: 19px;
  font-weight: 800;
  line-height: 1;
}

.app-notification-close:hover {
  background: rgba(23, 126, 98, 0.16);
}

.app-notification-summary {
  justify-self: end;
  width: fit-content;
  padding: 6px 10px;
  border: 1px solid rgba(39, 86, 75, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  box-shadow: 0 12px 26px rgba(16, 32, 39, 0.12);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 640px) {
  .app-notification-stack {
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    left: 10px;
    width: auto;
  }

  .app-notification {
    border-radius: 12px;
    padding: 11px 11px 11px 13px;
  }
}

.deal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(10, 14, 18, 0.86);
  z-index: 50;
  padding: 24px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(10, 14, 18, 0.58);
  z-index: 45;
  padding: 20px;
}

.modal-overlay.visible {
  display: grid;
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.shipment-edit-modal-card {
  width: min(900px, 100%);
}

.shipment-edit-modal-card .shipment-edit-box {
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.shipment-edit-modal-card .shipment-edit-box label {
  min-width: 0;
}

.app-modal-card {
  width: min(520px, 100%);
}

.modal-message {
  margin: 0;
  color: #33414a;
  line-height: 1.45;
  font-weight: 650;
}

.modal-input-label {
  display: grid;
  gap: 7px;
  color: #3b464d;
  font-size: 13px;
  font-weight: 850;
}

.modal-warning {
  margin: 0;
  border: 1px solid #efd1a5;
  border-radius: 8px;
  background: #fff8eb;
  color: #7b4b12;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.modal-body {
  display: grid;
  gap: 12px;
}

.kpi-preview-modal-card {
  width: min(1120px, 96vw);
  max-height: 88vh;
}

.kpi-preview-modal-card .modal-body {
  overflow: auto;
  padding-right: 2px;
}

.kpi-report-preview {
  display: grid;
  gap: 16px;
}

.kpi-report-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfa;
}

.kpi-report-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
}

.kpi-report-brand strong {
  display: block;
  font-size: 20px;
}

.kpi-report-brand span {
  color: var(--muted);
  font-weight: 750;
}

.kpi-report-metrics {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.kpi-report-metric {
  display: grid;
  gap: 6px;
  align-content: start;
}

.kpi-report-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.kpi-report-metric strong {
  display: block;
  white-space: nowrap;
  font-size: 22px;
  line-height: 1.1;
}

.kpi-report-chart {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.kpi-report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #fff;
}

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

.kpi-report-table th {
  color: #46535b;
  background: #f8fafb;
  font-size: 12px;
  text-transform: uppercase;
}

.kpi-report-table tr:last-child td {
  border-bottom: 0;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  margin-top: 5px;
}

.timeline-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.timeline-card strong {
  display: block;
}

.bar-chart {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

#kpiStatusCounts {
  display: block;
}

.bar-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) minmax(72px, auto);
  gap: 10px;
  align-items: center;
}

.bar-row > span {
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 82px;
}

.bar-track {
  height: 18px;
  border-radius: 999px;
  background: #e7ecef;
  border: 1px solid #cfd8de;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.deal-overlay.visible {
  display: grid;
}

.deal-content {
  width: min(680px, 100%);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: clamp(24px, 5vw, 46px);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.deal-content span {
  display: block;
  color: var(--hot);
  font-size: clamp(22px, 5vw, 42px);
  font-weight: 900;
  text-transform: uppercase;
}

.deal-content strong {
  display: block;
  font-size: clamp(46px, 12vw, 110px);
  line-height: 1;
  margin: 14px 0;
}

.deal-content p {
  font-size: clamp(16px, 3vw, 24px);
  margin-bottom: 8px;
}

.tracking-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #f9fbfb;
  margin: 12px 0;
}

.tracking-box-top {
  border-color: rgba(20, 125, 100, 0.42);
  box-shadow: 0 14px 34px rgba(20, 125, 100, 0.12);
}

.tracking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tracking-actions button {
  min-height: 36px;
  padding: 8px 12px;
}

.tracking-actions button.is-busy,
.tracking-actions button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.tracking-timeline {
  display: grid;
  gap: 8px;
}

.tracking-event {
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.tracking-event small {
  color: var(--muted);
}

.tracking-event p {
  margin: 0;
}

.driver-location-card {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  border: 1px solid rgba(15, 111, 174, 0.2);
  border-radius: 8px;
  background: linear-gradient(135deg, #f6fbff, #eef7f3);
  padding: 10px;
  margin-bottom: 10px;
}

.driver-location-card.muted-location {
  display: block;
  background: #f8fafb;
  border-color: var(--line);
}

.driver-location-card strong,
.driver-location-card small {
  display: block;
}

.driver-location-card small {
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}

.driver-map-preview {
  min-height: 112px;
  border-radius: 8px;
  border: 1px solid rgba(15, 111, 174, 0.18);
  background:
    linear-gradient(135deg, rgba(20, 125, 100, 0.14), rgba(15, 111, 174, 0.14)),
    repeating-linear-gradient(30deg, transparent 0 18px, rgba(15, 111, 174, 0.08) 18px 20px),
    #fff;
  position: relative;
  overflow: hidden;
}

.driver-map-preview:before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 54px;
  border-top: 5px dotted rgba(20, 125, 100, 0.45);
  transform: rotate(-14deg);
}

.driver-map-preview span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--danger);
  border: 3px solid #fff;
  box-shadow: 0 8px 18px rgba(16, 24, 32, 0.22);
  transform: translate(-50%, -50%);
}

.driver-location-main {
  min-width: 0;
}

.driver-location-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.map-button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 13px;
}

.driver-location-history {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.driver-location-history a {
  border: 1px solid rgba(15, 111, 174, 0.16);
  border-radius: 999px;
  background: #fff;
  color: #234451;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.guide-view {
  gap: 16px;
}

.view.guide-view.active {
  display: grid;
}

.guide-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.74fr);
  gap: 18px;
  align-items: center;
  padding: 22px;
  margin-bottom: 0;
}

.guide-hero-copy {
  display: grid;
  gap: 10px;
}

.guide-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.guide-hero h2,
.guide-section-head h2 {
  margin: 0;
}

.guide-hero p,
.guide-section-head p,
.guide-step-card p,
.guide-admin-card p,
.danger-zone p {
  margin: 0;
  color: var(--muted);
  line-height: 1.48;
}

.guide-role-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.guide-role-link,
.guide-mini-link {
  border: 1px solid transparent;
  background: transparent;
  color: #315b67;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  padding: 8px 10px;
  text-decoration: none;
}

.guide-role-link:hover,
.guide-role-link.active,
.guide-mini-link:hover {
  background: #e9f5f1;
  border-color: #b9ded3;
  color: #0f6b55;
}

.guide-map {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, #f8fbfc, #eef6f4);
  box-shadow: 0 18px 42px rgba(23, 33, 40, 0.08);
  display: grid;
  grid-template-columns: 1fr 20px 1fr 20px 1fr 20px 1fr;
  gap: 8px;
  padding: 16px;
  align-items: center;
}

.guide-map span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 1000;
  min-height: 44px;
  display: grid;
  place-items: center;
  text-align: center;
}

.guide-map i {
  height: 2px;
  background: #9fc8bd;
  border-radius: 999px;
}

.guide-section {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(23, 33, 40, 0.06);
  padding: 18px;
  scroll-margin-top: 18px;
}

.guide-section-head {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.guide-section-head > div {
  display: grid;
  gap: 6px;
}

.guide-learning-grid,
.guide-admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.guide-admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.guide-card,
.guide-step-card,
.guide-admin-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(23, 33, 40, 0.04);
}

.guide-card,
.guide-admin-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.guide-card h3,
.guide-step-card h3,
.guide-admin-card h3 {
  margin: 0;
}

.guide-card ol,
.guide-step-card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.45;
}

.guide-path {
  display: grid;
  gap: 12px;
}

.guide-step-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) minmax(230px, 0.46fr);
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.guide-step-number {
  align-items: center;
  background: #123f35;
  border-radius: 14px;
  color: #fff;
  display: flex;
  font-weight: 1000;
  justify-content: center;
  min-height: 46px;
}

.guide-step-card > div:nth-child(2) {
  display: grid;
  gap: 8px;
}

.guide-shot {
  border: 1px solid #d6e3e6;
  background: linear-gradient(135deg, #f8fbfc, #eef5f4);
  border-radius: 14px;
  color: var(--ink);
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 12px;
  align-content: start;
  position: relative;
  overflow: hidden;
}

.guide-shot:before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(20, 125, 100, 0.12), transparent 45%);
  pointer-events: none;
}

.guide-shot b,
.guide-shot em,
.guide-shot small,
.guide-shot strong {
  position: relative;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  display: block;
  font-style: normal;
  font-weight: 900;
  padding: 8px 10px;
}

.guide-shot em {
  background: #13745f;
  border-color: #13745f;
  color: #fff;
}

.guide-shot small {
  color: var(--muted);
  font-weight: 800;
}

.guide-shot-flow {
  grid-template-columns: 34px minmax(0, 1fr);
  align-content: center;
}

.guide-shot-flow span {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #13745f;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 1000;
}

.guide-shot-sidebar b {
  max-width: 74%;
}

.guide-shot-alerts strong:first-child {
  border-color: #f2c9d9;
  background: #fff1f6;
  color: #a8305d;
}

.guide-shot-form,
.guide-shot-offer,
.guide-shot-driver {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.guide-shot-form em,
.guide-shot-offer em,
.guide-shot-driver em {
  grid-column: 1 / -1;
}

.guide-shot-choice,
.guide-shot-order,
.guide-shot-price,
.guide-shot-chat,
.guide-shot-admin,
.guide-shot-health,
.guide-shot-tv,
.guide-shot-kanban {
  align-content: center;
}

.guide-checklist {
  display: grid;
  gap: 8px;
}

.guide-checklist span {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfc;
  color: var(--ink);
  font-weight: 900;
  padding: 9px 10px;
}

.danger-zone {
  border-color: rgba(200, 59, 74, 0.35);
  background: #fff8f9;
}

@media (max-width: 1500px) {
  #newShipmentForm.form-grid {
    grid-template-columns: 1fr;
  }

  #newShipmentForm > .form-section.new-capture-panel {
    position: static;
  }
}

@media (max-width: 1180px) {
  #newShipmentForm.form-grid {
    grid-template-columns: 1fr;
  }

  #newShipmentForm .new-capture-panel {
    position: static;
  }

  #newShipmentForm .new-command-section {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  #newShipmentForm .new-shipment-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #newShipmentForm .shipment-core-grid,
  #newShipmentForm .cargo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #newShipmentForm .shipment-stop-grid {
    grid-template-columns: 1fr;
  }

  .login-screen {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .login-control-tower {
    min-height: auto;
  }

  .login-quiet-panel {
    min-height: 360px;
  }

  .login-card {
    margin: 0 auto;
  }

  .split,
  .dashboard-layout,
  .form-grid,
  .admin-grid,
  .direct-shell,
  .orders-grid,
  .documents-toolbar,
  .my-work-grid,
  .directory-grid {
    grid-template-columns: 1fr;
  }

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

  .kanban-scope-field {
    min-width: 0;
  }

  .detail-panel {
    position: static;
  }

  #shipmentsView .split {
    min-height: 0;
  }

  #shipmentsView .split > .panel,
  #shipmentsView .detail-panel {
    max-height: none;
    overflow: visible;
  }

  .metric-grid,
  .status-board,
  .tv-metrics,
  .intelligence-grid,
  .health-grid,
  .new-shipment-bar,
  .guide-learning-grid,
  .guide-admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guide-hero,
  .guide-step-card,
  .kanban-board,
  .tv-grid,
  .tv-motivation-grid {
    grid-template-columns: 1fr;
  }

  .guide-map {
    grid-template-columns: 1fr;
  }

  .guide-map i {
    width: 2px;
    height: 18px;
    justify-self: center;
  }

  .admin-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-users-panel .admin-form {
    grid-template-columns: 1fr;
  }

  .admin-user-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .documents-head {
    grid-template-columns: 1fr;
  }

  .documents-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .document-card {
    grid-template-columns: 4px minmax(0, 1fr);
  }

  .document-actions {
    grid-column: 2;
    justify-content: stretch;
  }

  .document-actions button {
    width: 100%;
  }

  .settings-form,
  .alert-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #adminView .settings-form,
  #adminView .alert-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #newShipmentForm .new-shipment-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #newShipmentForm .new-shipment-actions .primary,
  #newShipmentForm .new-shipment-actions .secondary {
    min-width: 0;
  }

  .document-card {
    grid-template-columns: 1fr;
  }

  .document-actions {
    justify-content: stretch;
  }

  .document-actions button {
    width: 100%;
  }
}

@media (max-width: 760px) {
  body.tv-active:not(.auth-locked),
  body.tv-active.tv-view-active:not(.auth-locked) .app-shell,
  body.tv-active.tv-view-active:not(.auth-locked) .main {
    height: auto;
    max-height: none;
    overflow: auto;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active,
  .tv-screen {
    height: auto !important;
    max-height: none !important;
    min-height: var(--tv-height, 100dvh);
    overflow: auto;
    grid-template-rows: auto auto auto auto auto;
  }

  .tv-head {
    align-items: flex-start;
  }

  .tv-brand img {
    width: 42px;
    height: 42px;
  }

  .tv-head h2 {
    font-size: 28px;
  }

  .tv-head strong {
    font-size: 34px;
  }

  .tv-clock-box {
    gap: 6px;
  }

  .tv-metrics,
  .tv-grid,
  .tv-motivation-grid {
    grid-template-columns: 1fr;
  }

  .tv-grid,
  .tv-motivation-grid {
    overflow: visible;
  }

  .tv-panel {
    min-height: 120px;
  }

  .documents-head {
    padding: 12px;
    border-radius: 12px;
  }

  .documents-toolbar,
  .documents-kpis {
    grid-template-columns: 1fr;
  }

  .document-card {
    grid-template-columns: 4px minmax(0, 1fr);
    min-height: 0;
    padding: 10px;
  }

  .document-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .document-route {
    white-space: normal;
  }

  .document-actions {
    grid-column: 2;
  }
}

@media (max-width: 780px) {
  .login-screen {
    display: grid;
    place-items: center;
    padding: 18px;
    background:
      radial-gradient(circle at 20% 12%, rgba(20, 125, 100, 0.26), transparent 260px),
      linear-gradient(135deg, #0d171d 0%, #14242c 100%);
  }

  .login-screen:before,
  .login-control-tower {
    display: none;
  }

  .login-panel-wrap {
    width: 100%;
  }

  .login-card {
    width: 100%;
    max-width: 440px;
    padding: 22px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .main {
    padding: 14px;
  }

  .detail-role-banner {
    grid-template-columns: 1fr;
  }

  .detail-tool-row {
    display: grid;
  }

  .my-work-focus {
    grid-template-columns: 1fr;
  }

  .work-focus-score {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
  }

  .toolbar,
  .input-grid,
  .new-shipment-bar,
  .shipment-core-grid,
  .shipment-stop-grid,
  .stop-card,
  .cargo-grid,
  .price-box,
  .facts,
  .metric-grid,
  .status-board,
  .tv-metrics,
  .intelligence-grid,
  .health-grid,
  .guide-learning-grid,
  .guide-admin-grid,
  .guide-step-card,
  .admin-form {
    grid-template-columns: 1fr;
  }

  .guide-section {
    border-radius: 14px;
    padding: 12px;
  }

  .guide-section-head {
    flex-direction: column;
  }

  .guide-role-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .guide-role-link {
    white-space: nowrap;
  }

  .guide-hero {
    padding: 14px;
  }

  .guide-shot {
    min-height: 120px;
  }

  .admin-users-panel .admin-form,
  .admin-user-fields {
    grid-template-columns: 1fr;
  }

  .admin-users-panel .admin-group-picker {
    grid-template-columns: 1fr;
    max-height: 180px;
  }

  .admin-user-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .admin-user-actions .danger {
    margin-left: 0;
  }

  .admin-user-actions button {
    width: 100%;
  }

  .settings-form,
  .alert-form,
  .permission-grid {
    grid-template-columns: 1fr;
  }

  #adminView .settings-form,
  #adminView .alert-form,
  #adminView .permission-grid {
    grid-template-columns: 1fr;
  }

  #adminView .inline-form {
    width: 100%;
  }

  #adminView .inline-form .secondary,
  #adminView .settings-form .primary,
  #adminView .danger-zone .danger,
  #adminView .alert-form button {
    width: 100%;
  }

  #newShipmentForm.new-shipment-layout {
    gap: 10px;
  }

  #newShipmentForm .new-shipment-panel,
  #newShipmentForm .new-capture-panel {
    padding: 10px;
    border-radius: 8px;
  }

  #newShipmentForm .new-panel-head {
    align-items: flex-start;
  }

  #newShipmentForm .new-panel-head em {
    display: none;
  }

  #newShipmentForm .new-command-section {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 9px 0;
  }

  #newShipmentForm .new-section-label {
    position: static;
    padding-top: 0;
  }

  #newShipmentForm .new-section-label:before {
    display: inline-block;
    margin: 0 7px 1px 0;
    vertical-align: middle;
  }

  #newShipmentForm .new-shipment-bar,
  #newShipmentForm .shipment-core-grid,
  #newShipmentForm .shipment-stop-grid,
  #newShipmentForm .stop-card-fields,
  #newShipmentForm .cargo-grid,
  #newShipmentForm .new-shipment-actionbar {
    grid-template-columns: 1fr;
  }

  #newShipmentForm .new-shipment-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #newShipmentForm .new-shipment-actions button,
  #newShipmentForm #parseEmailBtn,
  #newShipmentForm #parseScreenshotBtn {
    width: 100%;
  }

  #newShipmentForm .email-box {
    min-height: 190px;
    height: 190px;
  }

  .comment-form,
  .chat-form,
  .directory-filters,
  .directory-form,
  .inline-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .chat-tools {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-section.wide {
    padding: 14px;
  }

  .new-shipment-bar {
    padding: 10px;
    gap: 10px;
  }

  .shipment-core-grid,
  .shipment-stop-grid,
  .cargo-grid {
    gap: 12px;
  }

  .stop-card,
  .cargo-grid {
    padding: 12px;
    border-radius: 10px;
  }

  #newShipmentForm .new-shipment-actions {
    grid-template-columns: 1fr;
  }

  #newShipmentForm .form-actions button {
    width: 100%;
  }

  .direct-shell {
    grid-template-columns: 1fr;
  }

  .messages-center {
    min-height: calc(100vh - 120px);
    display: block;
  }

  .messages-sidebar {
    min-height: calc(100vh - 120px);
  }

  .messages-thread-panel {
    display: none;
    min-height: calc(100vh - 120px);
  }

  .messages-detail-panel {
    display: none;
    min-height: calc(100vh - 120px);
  }

  #messagesView.conversation-open .messages-sidebar {
    display: none;
  }

  #messagesView.conversation-open .messages-thread-panel {
    display: block;
  }

  #messagesView.detail-open .messages-thread-panel {
    display: none;
  }

  #messagesView.detail-open .messages-detail-panel {
    display: grid;
  }

  .messages-thread-shell {
    min-height: calc(100vh - 120px);
    padding: 10px;
  }

  .messages-back-button {
    display: grid;
  }

  .direct-users {
    max-height: 220px;
    overflow: auto;
  }

  .chat-message {
    max-width: 96%;
  }

  .chat-compose-row {
    gap: 6px;
    padding: 6px;
  }

  .emoji-toggle,
  .emoji-panel {
    display: none !important;
  }

  .chat-text-input {
    min-width: 0;
  }

  .send-button,
  .attach-button,
  .urgent-toggle {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .chat-actions {
    top: -32px;
  }

  .kpi-report-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chat-shell {
    padding: 12px;
  }

  .chat-messages {
    min-height: 360px;
    padding: 12px;
  }

  .modal-grid,
  .credit-card,
  .driver-location-card {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: minmax(92px, 0.7fr) minmax(110px, 1fr) minmax(72px, auto);
    gap: 8px;
  }

  .regular-switch {
    justify-content: flex-start;
  }

  .credit-history-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .credit-current-summary {
    grid-template-columns: 1fr;
    gap: 3px;
  }

.audit-change {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

.messages-sidebar-head {
  align-items: center;
}

.global-message-search-card,
.message-search-card {
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.12);
}

.global-message-search-card button,
.message-search-card button {
  text-align: left;
}

.conversation-settings {
  display: grid;
  gap: 10px;
}

.conversation-settings textarea {
  min-height: 70px;
  resize: vertical;
}

.member-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-member-row {
  align-items: center;
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

.detail-member-row span:nth-child(2) {
  min-width: 0;
}

.detail-member-row strong,
.detail-member-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button.tiny {
  min-height: 30px;
  min-width: 30px;
  width: 30px;
  height: 30px;
  font-size: 15px;
}

.danger-soft {
  border-color: rgba(190, 24, 93, 0.22);
  color: #be185d;
}

.forward-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fbfc;
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.forward-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.attachment-draft-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
  padding: 8px 4px 4px;
}

.attachment-draft {
  align-items: start;
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 24px;
  grid-template-rows: auto auto;
  gap: 4px 8px;
  max-width: 100%;
  min-width: 0;
  padding: 8px;
}

.attachment-draft-thumb,
.attachment-type-icon {
  align-items: center;
  background: #e8f1f4;
  border-radius: 8px;
  color: var(--ink);
  display: inline-grid;
  font-size: 11px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  min-width: 34px;
  padding: 0 6px;
}

.attachment-draft-thumb {
  grid-row: 1 / span 2;
  height: 38px;
  min-width: 38px;
  overflow: hidden;
  padding: 0;
}

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

.attachment-draft strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.attachment-draft small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.attachment-draft button {
  grid-column: 3;
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 8px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.attachment-draft button:hover {
  background: #fee2e2;
  color: var(--danger);
}

.attachment-draft.error {
  border-color: rgba(190, 24, 93, 0.3);
  background: #fff5f7;
}

.attachment-link.image-attachment {
  align-items: start;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px 10px;
}

.attachment-link.image-attachment img {
  width: 72px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  grid-row: span 2;
}

.message-reply {
  background: rgba(255, 255, 255, 0.62);
  border: 0;
  border-left: 3px solid rgba(24, 94, 82, 0.45);
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 2px;
  margin: 4px 0 8px;
  max-width: 100%;
  padding: 7px 9px;
  text-align: left;
}

#messagesView.active .chat-message.own .message-reply,
.chat-message.own .message-reply {
  background: rgba(255, 255, 255, 0.88);
  border-left-color: #6fb5a8;
  color: #18222f;
}

#messagesView.active .chat-message.own .message-reply strong,
#messagesView.active .chat-message.own .message-reply span,
.chat-message.own .message-reply strong,
.chat-message.own .message-reply span {
  color: #18222f;
}

#messagesView.active .chat-message.own .message-reply span,
.chat-message.own .message-reply span {
  color: #4b5565;
}

.message-reply:hover {
  background: rgba(255, 255, 255, 0.9);
}

.message-highlight .chat-bubble {
  box-shadow: 0 0 0 3px rgba(18, 132, 117, 0.22), 0 18px 42px rgba(15, 23, 42, 0.13);
}

@media (max-width: 720px) {
  .member-add-row,
  .attachment-draft {
    grid-template-columns: 1fr;
  }

  .attachment-link.image-attachment {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .attachment-link.image-attachment img {
    width: 56px;
    height: 44px;
  }
}

#messagesView.active {
  height: calc(100vh - 92px);
  min-height: 680px;
  overflow: hidden;
}

body.popup-mode:not(.auth-locked) #messagesView.active {
  height: 100vh;
  min-height: 100vh;
}

body.popup-mode:not(.auth-locked) #messagesView .messages-center {
  height: calc(100vh - 24px);
  min-height: calc(100vh - 24px);
}

.messages-center {
  --messages-bg: var(--background);
  --messages-surface: var(--surface);
  --messages-hover: var(--surfaceHover);
  --messages-selected: var(--surfaceSelected);
  --messages-border: var(--borderSubtle);
  --messages-brand: var(--brandPrimary);
  --messages-brand-hover: var(--brandHover);
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 0;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusLarge);
  background: var(--messages-bg);
  box-shadow: var(--shadowPanel);
}

.messages-sidebar,
.messages-thread-panel,
.messages-detail-panel {
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: var(--messages-surface);
  box-shadow: none;
}

.messages-sidebar {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px 14px;
  border-right: 1px solid var(--messages-border);
  overflow: hidden;
}

.messages-sidebar-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(4, 36px);
  gap: 8px;
  align-items: center;
}

.messages-sidebar-head h2,
.messages-thread-head h2 {
  color: var(--textPrimary);
  font-size: 18px;
  font-weight: 760;
  letter-spacing: 0;
}

.messages-sidebar-head p,
.messages-thread-head p {
  color: var(--textSecondary);
  font-size: 12px;
  line-height: 1.35;
}

.messages-sidebar .control,
.message-search-box .control {
  height: 36px;
  border-color: var(--messages-border);
  border-radius: var(--radiusMedium);
  background: #fbfcfe;
  font-size: 13px;
}

.conversation-filters {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding-bottom: 2px;
}

.conversation-filters button {
  min-height: 30px;
  white-space: nowrap;
  border-color: transparent;
  border-radius: var(--radiusSmall);
  background: transparent;
  color: var(--textSecondary);
  padding: 0 10px;
  font-size: 12px;
}

.conversation-filters button:hover {
  background: var(--messages-hover);
}

.conversation-filters button.active {
  background: var(--messages-selected);
  color: var(--messages-brand);
  border-color: transparent;
}

.conversation-list {
  min-height: 0;
  overflow: auto;
  display: block;
  padding-right: 2px;
}

.conversation-item {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 0;
  border-radius: var(--radiusMedium);
  background: transparent;
  color: var(--textPrimary);
  margin: 2px 0;
  padding: 10px 10px 10px 12px;
  box-shadow: none;
  transition: background 0.12s ease, transform 0.12s ease;
}

.conversation-item:before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 99px;
  background: transparent;
}

.conversation-item:hover {
  background: var(--messages-hover);
}

.conversation-item.active {
  background: var(--messages-selected);
}

.conversation-item.active:before {
  background: var(--messages-brand);
}

.conversation-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radiusMedium);
  background: linear-gradient(135deg, #e8ebff, #f2f4ff);
  color: var(--messages-brand);
  font-size: 12px;
  font-weight: 800;
}

.conversation-avatar-wrap {
  width: 40px;
  height: 40px;
}

.conversation-avatar-wrap.large-wrap {
  width: 44px;
  height: 44px;
}

.conversation-avatar.large {
  width: 44px;
  height: 44px;
  border-radius: var(--radiusMedium);
}

.presence-dot {
  width: 9px;
  height: 9px;
  border-color: var(--surface);
  background: #a0a7b2;
}

.presence-dot.online {
  background: var(--success);
}

.conversation-title-row strong {
  color: var(--textPrimary);
  font-size: 13px;
  font-weight: 760;
}

.conversation-title-row small,
.conversation-meta,
.conversation-last {
  color: var(--textSecondary);
  font-size: 11px;
}

.conversation-last {
  color: #4d5562;
}

.conversation-unread {
  min-width: 18px;
  height: 18px;
  background: var(--messages-brand);
  font-size: 11px;
}

.messages-thread-panel {
  min-width: 0;
  overflow: hidden;
  background: #fafbff;
}

.messages-thread-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 0;
  padding: 0;
  background: #fafbff;
}

.messages-thread-head {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--messages-border);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  padding: 12px 18px;
}

.messages-thread-head .pill {
  border: 0;
  background: #edf7f2;
  color: var(--success);
  font-size: 11px;
}

.messages-thread-head .pill.muted-pill {
  background: #f1f3f7;
  color: var(--textSecondary);
}

.pinned-messages {
  padding: 8px 18px 0;
}

.pinned-message {
  border: 1px solid #ece8ff;
  border-radius: var(--radiusMedium);
  background: #f7f5ff;
  color: var(--textPrimary);
  padding: 8px 10px;
  text-align: left;
}

.message-search-box {
  padding: 8px 18px;
}

.message-search-card {
  border-color: var(--messages-border);
  border-radius: var(--radiusMedium);
  box-shadow: var(--shadowCard);
}

.messages-active-list {
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.chat-messages {
  min-height: 0;
  height: 100%;
  gap: 10px;
  padding: 18px 22px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at top left, rgba(98, 100, 167, 0.08), transparent 320px),
    linear-gradient(180deg, #fafbff 0%, #f6f7fb 100%);
}

.chat-message {
  position: relative;
  max-width: min(74%, 760px);
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
}

.chat-message.own {
  align-self: flex-end;
  grid-template-columns: minmax(0, 1fr);
}

.chat-message.own .chat-avatar {
  display: none;
}

.chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radiusSmall);
  background: #e8ebff;
  color: var(--messages-brand);
  font-size: 11px;
}

.chat-bubble {
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusMedium);
  background: #ffffff;
  color: var(--textPrimary);
  box-shadow: 0 1px 2px rgba(31, 35, 40, 0.04);
  padding: 9px 11px;
}

.chat-message.own .chat-bubble {
  background: #eef2ff;
  border-color: #dde3ff;
  color: var(--textPrimary);
}

.chat-message-meta {
  color: var(--textSecondary);
  font-size: 11px;
  gap: 6px;
}

.chat-message-meta strong {
  color: var(--textPrimary);
  font-size: 12px;
}

.chat-bubble p {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 14px;
}

.chat-actions {
  right: 8px;
  top: -34px;
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusMedium);
  background: #fff;
  box-shadow: var(--shadowCard);
}

.chat-icon-action {
  width: 30px;
  height: 30px;
  border-radius: var(--radiusSmall);
}

.modern-chat-form {
  position: sticky;
  bottom: 0;
  z-index: 4;
  border-top: 1px solid var(--messages-border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  padding: 10px 18px 14px;
}

.chat-compose-row {
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusLarge);
  background: #fff;
  padding: 6px;
}

.chat-text-input {
  height: 34px;
  min-height: 34px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.chat-text-input:focus {
  box-shadow: none;
}

.send-button,
.attach-button,
.urgent-toggle,
.emoji-toggle {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: var(--radiusMedium);
  box-shadow: none;
}

.send-button {
  background: var(--messages-brand);
  border-color: var(--messages-brand);
  color: #fff;
}

.send-button:hover {
  background: var(--messages-brand-hover);
}

.attach-button,
.emoji-toggle,
.urgent-toggle {
  border-color: transparent;
  background: transparent;
}

.attach-button:hover,
.emoji-toggle:hover,
.urgent-toggle:hover {
  background: var(--messages-hover);
}

.messages-detail-panel {
  border-left: 1px solid var(--messages-border);
  background: #ffffff;
  padding: 18px;
  overflow: auto;
}

.messages-detail-head {
  border-bottom-color: var(--messages-border);
  padding-bottom: 14px;
}

.messages-detail-head h3,
.messages-detail-panel h4 {
  color: var(--textPrimary);
  font-weight: 760;
}

.messages-detail-panel section {
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusMedium);
  background: #fbfcfe;
  padding: 12px;
}

.detail-attachment,
.detail-message-link,
.message-search-card button {
  border-radius: var(--radiusMedium);
  background: #fff;
}

.teams-empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--textSecondary);
  text-align: center;
  padding: 28px;
}

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

.teams-empty-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: var(--radiusLarge);
  background: var(--surfaceSelected);
  color: var(--messages-brand);
  font-size: 26px;
}

.virtualized-history-note {
  align-self: center;
  border: 1px solid var(--messages-border);
  border-radius: var(--radiusMedium);
  background: #fff;
  color: var(--textSecondary);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 10px;
}

@media (max-width: 1200px) {
  .messages-center {
    grid-template-columns: 320px minmax(0, 1fr);
  }

  .messages-detail-panel {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 8;
    width: min(360px, 92vw);
    transform: translateX(100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadowPanel);
  }

  #messagesView.detail-open .messages-detail-panel {
    transform: translateX(0);
    display: grid;
  }
}

@media (max-width: 768px) {
  #messagesView.active,
  body.popup-mode:not(.auth-locked) #messagesView.active {
    height: 100vh;
    min-height: 100vh;
  }

  .messages-center {
    grid-template-columns: 1fr;
    border-radius: 0;
    border: 0;
    height: 100vh;
  }

  .messages-sidebar {
    border-right: 0;
    height: 100vh;
  }

  .messages-thread-panel {
    height: 100vh;
  }

  .messages-thread-head {
    min-height: 62px;
    padding: 10px 12px;
  }

  .messages-detail-panel {
    width: 100vw;
  }

  .chat-message {
    max-width: 92%;
  }

  .modern-chat-form {
    padding: 8px 10px 10px;
  }

  .chat-compose-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

/* Messages stability patch: isolate the new message center from legacy chat styles. */
#messagesView.active {
  overflow: hidden;
}

#messagesView.active .messages-center {
  position: relative;
  grid-template-columns: 320px minmax(0, 1fr);
  height: calc(100vh - 132px);
  min-height: 620px;
  overflow: hidden;
  background: #f6f7fb;
}

body.popup-mode:not(.auth-locked) #messagesView.active .messages-center {
  height: calc(100vh - 24px);
  min-height: calc(100vh - 24px);
}

#messagesView.active .messages-thread-shell {
  height: 100%;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  position: relative;
}

#messagesView.active .messages-thread-shell.file-drop-active::before {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: 35;
  border: 2px dashed rgba(20, 125, 100, 0.55);
  border-radius: 18px;
  background: rgba(240, 253, 250, 0.86);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  pointer-events: none;
}

#messagesView.active .messages-thread-shell.file-drop-active::after {
  content: "Pustite súbory do chatu\A PDF, JPG, PNG, DOCX alebo XLSX";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 36;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 56px));
  border: 1px solid rgba(20, 125, 100, 0.22);
  border-radius: 16px;
  background: #ffffff;
  color: #10231f;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.45;
  padding: 20px 24px;
  text-align: center;
  white-space: pre-line;
  pointer-events: none;
}

#messagesView.active .messages-active-list {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

#messagesView.active .messages-detail-panel {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  width: min(360px, 92vw);
  border-left: 1px solid var(--borderSubtle);
  box-shadow: var(--shadowPanel);
}

#messagesView.active.detail-open .messages-detail-panel {
  display: grid;
}

#messagesView.active .messages-thread-head {
  flex-wrap: nowrap;
}

#messagesView.active .messages-thread-head > div {
  min-width: 0;
}

#messagesView.active .messages-thread-head h2,
#messagesView.active .messages-thread-head p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messagesView.active .chat-message {
  width: auto;
  max-width: min(74%, 760px);
  min-width: 0;
  margin: 0;
}

#messagesView.active .chat-message.own {
  justify-self: end;
}

#messagesView.active .chat-message.own .chat-bubble,
#messagesView.active .chat-message.own .chat-message-meta,
#messagesView.active .chat-message.own .chat-message-meta strong,
#messagesView.active .chat-message.own .edited-tag,
#messagesView.active .chat-message.own .urgent-tag {
  color: var(--textPrimary);
}

#messagesView.active .chat-message.own .message-read-state.delivered {
  color: #64748b;
}

#messagesView.active .chat-message.own .message-read-state.read {
  color: #111827;
}

#messagesView.active .chat-message.own .message-read-state.sent,
#messagesView.active .chat-message.own .message-read-state.sending {
  color: #94a3b8;
}

#messagesView.active .chat-message.own .chat-bubble {
  background: #eef2ff;
  border-color: #dfe4ff;
}

#messagesView.active .chat-bubble {
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
}

#messagesView.active .chat-bubble p {
  margin: 3px 0 0;
  color: var(--textPrimary);
  font-size: 14px;
  line-height: 1.42;
}

#messagesView.active .chat-actions {
  position: absolute;
  top: -34px;
  right: 4px;
  left: auto;
  z-index: 6;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  width: auto;
  max-width: min(280px, calc(100vw - 44px));
  padding: 3px;
  margin: 0;
  border-radius: 10px;
  background: #ffffff;
  color: var(--textPrimary);
  box-shadow: var(--shadowCard);
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

#messagesView.active .chat-message.own .chat-actions {
  right: 4px;
  left: auto;
}

#messagesView.active .chat-message:hover .chat-actions,
#messagesView.active .chat-message:focus .chat-actions,
#messagesView.active .chat-message:focus-within .chat-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#messagesView.active .chat-icon-action {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 0;
  color: var(--textPrimary);
  background: transparent;
}

#messagesView.active .chat-icon-action:hover {
  background: var(--surfaceHover);
}

#messagesView.active .reaction-picker {
  margin-top: 6px;
}

#messagesView.active .modern-chat-form {
  margin: 0;
  padding: 10px 16px 14px;
  position: relative;
}

#messagesView.active .chat-compose-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px 36px 36px;
  gap: 6px;
  min-height: 48px;
  border-radius: 14px;
  padding: 6px;
}

#messagesView.active #messagesForm:not(:has(#messagesUrgentInput)) .chat-compose-row {
  grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
}

#messagesView.active #messagesUrgentLabel {
  grid-column: auto;
}

#messagesView.active .messages-attach-button,
#messagesView.active .messages-emoji-button,
#messagesView.active .messages-urgent-toggle,
#messagesView.active .messages-send-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--textPrimary);
  padding: 0;
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}

#messagesView.active .messages-attach-button,
#messagesView.active .messages-urgent-toggle {
  cursor: pointer;
}

#messagesView.active .messages-attach-button:hover,
#messagesView.active .messages-emoji-button:hover,
#messagesView.active .messages-urgent-toggle:hover {
  background: var(--surfaceHover);
}

#messagesView.active .messages-urgent-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#messagesView.active .messages-urgent-toggle:has(input:checked) {
  background: #fff0ed;
  color: var(--danger);
}

#messagesView.active .messages-send-button {
  background: var(--accent);
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(20, 125, 100, 0.22);
  transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

#messagesView.active .messages-send-button:hover {
  background: #0f6a55;
  box-shadow: 0 10px 22px rgba(20, 125, 100, 0.28);
  transform: translateY(-1px);
}

#messagesView.active .messages-send-button[disabled] {
  color: #ffffff;
  opacity: 0.6;
  transform: none;
}

#messagesView.active .chat-text-input {
  width: 100%;
  height: 36px;
  min-height: 36px;
  max-height: 132px;
  color: var(--textPrimary);
  font-size: 14px;
  line-height: 1.35;
  resize: none;
  overflow-y: auto;
  white-space: pre-wrap;
}

#messagesView.active .emoji-panel {
  position: absolute;
  right: 58px;
  bottom: 64px;
  z-index: 20;
  width: 268px;
  max-width: calc(100vw - 32px);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  border: 1px solid var(--borderSubtle);
  border-radius: 14px;
  background: #ffffff;
  padding: 10px;
  box-shadow: var(--shadowPanel);
}

#messagesView.active .emoji-panel.hidden {
  display: none;
}

#messagesView.active .emoji-panel button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #f6f7fb;
  font-size: 18px;
}

#messagesView.active .emoji-panel button:hover {
  background: #eef2ff;
}

#messagesView.active .mention-menu {
  position: absolute;
  left: 58px;
  bottom: 72px;
  z-index: 26;
  display: grid;
  gap: 4px;
  width: min(360px, calc(100vw - 44px));
  max-height: 286px;
  overflow-y: auto;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  padding: 8px;
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.18);
}

#messagesView.active .mention-menu.hidden {
  display: none;
}

#messagesView.active .mention-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 46px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--textPrimary);
  padding: 6px 8px;
  text-align: left;
  cursor: pointer;
}

#messagesView.active .mention-option:hover,
#messagesView.active .mention-option.active {
  background: #eef7f3;
}

#messagesView.active .mention-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #e8f4ef;
  color: #147d64;
  font-size: 12px;
  font-weight: 900;
}

#messagesView.active .mention-option strong,
#messagesView.active .mention-option small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messagesView.active .mention-option strong {
  font-size: 14px;
  line-height: 1.15;
}

#messagesView.active .mention-option small {
  color: var(--textSecondary);
  font-size: 11px;
  line-height: 1.2;
}

#messagesView.active .mention-empty {
  padding: 10px 12px;
  color: var(--textSecondary);
  font-size: 13px;
  font-weight: 750;
}

#messagesView.active .message-mention {
  display: inline-block;
  border-radius: 999px;
  background: #e8f4ef;
  color: #0f6a55;
  padding: 0 6px;
  font-weight: 900;
  line-height: 1.25;
}

#messagesView.active .messages-detail-panel section,
#messagesView.active .conversation-settings {
  gap: 10px;
}

#messagesView.active .messages-detail-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 32px;
  gap: 10px;
  align-items: center;
}

#messagesView.active .messages-detail-head > div {
  min-width: 0;
}

#messagesView.active .messages-detail-head h3,
#messagesView.active .messages-detail-head p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#messagesView.active .messages-detail-head .tiny {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
}

.global-message-search-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--borderSubtle);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px;
  box-shadow: var(--shadowCard);
}

.global-message-search-panel.hidden {
  display: none;
}

.search-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  gap: 8px;
  align-items: center;
}

.search-panel-head strong {
  color: var(--textPrimary);
  font-size: 13px;
}

.modal-member-scroll {
  max-height: min(420px, 48vh);
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
}

.modal-member-scroll label {
  width: 100%;
}

#messagesView.active .detail-member-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
}

#messagesView.active .detail-member-row span {
  min-width: 0;
}

@media (max-width: 768px) {
  #messagesView.active .messages-center {
    grid-template-columns: 1fr;
    height: 100vh;
    min-height: 100vh;
  }

  #messagesView.active:not(.conversation-open) .messages-thread-panel,
  #messagesView.active:not(.conversation-open) .messages-detail-panel {
    display: none;
  }

  #messagesView.active.conversation-open .messages-sidebar {
    display: none;
  }

  #messagesView.active.conversation-open .messages-thread-panel {
    display: block;
  }

  #messagesView.active.detail-open .messages-thread-panel {
    display: none;
  }

  #messagesView.active.detail-open .messages-detail-panel {
    display: grid;
    width: 100vw;
  }

  #messagesView.active .messages-back-button {
    display: grid;
  }

  #messagesView.active .message-search-box {
    display: none;
  }

  #messagesView.active .chat-message {
    max-width: 92%;
  }

  #messagesView.active .chat-actions {
    top: -36px;
    right: 0;
  }

  #messagesView.active .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
  }

  #messagesView.active #messagesForm:not(:has(#messagesUrgentInput)) .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  #messagesView.active .messages-emoji-button,
  #messagesView.active .emoji-panel {
    display: none !important;
  }
}

/* Compact desktop popup mode: keep desktop chat tools even when the window is narrow. */
@media (max-width: 768px) and (hover: hover) and (pointer: fine) {
  #messagesView.active.conversation-open .messages-thread-panel {
    display: block;
  }

  #messagesView.active .message-search-box {
    display: grid;
  }

  #messagesView.active .chat-compose-row,
  #messagesView.active #messagesForm:not(:has(#messagesUrgentInput)) .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
  }

  #messagesView.active #messagesForm:has(#messagesUrgentInput) .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px 36px 36px;
  }

  #messagesView.active .messages-emoji-button {
    display: grid !important;
  }

  #messagesView.active .emoji-panel:not(.hidden) {
    display: grid !important;
  }
}

/* Real touch mobile: keep the native keyboard emoji and reduce clutter. */
@media (hover: none) and (pointer: coarse) {
  #messagesView.active .messages-emoji-button,
  #messagesView.active .emoji-panel {
    display: none !important;
  }
}

#messagesView.active .messages-thread-panel,
#messagesView.active .messages-thread-shell,
#messagesView.active .modern-chat-form {
  background: #ffffff;
}

#messagesView.active .modern-chat-form {
  border-top: 1px solid var(--borderSubtle);
  box-shadow: 0 -10px 28px rgba(31, 35, 40, 0.05);
}

#messagesView.active .chat-compose-row {
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
}

#messagesView.active .messages-send-button {
  font-size: 0;
}

#messagesView.active .messages-send-button span {
  width: 17px;
  height: 17px;
  display: block;
  background: #ffffff;
  clip-path: polygon(12% 8%, 92% 50%, 12% 92%, 25% 57%, 54% 50%, 25% 43%);
  transform: translateX(1px);
}

#messagesView.active .chat-icon-action {
  border: 1px solid transparent;
  background: #f7f8fc;
  color: #4b5565;
}

#messagesView.active .chat-icon-action[data-message-action="react_menu"] {
  color: #8a5a00;
  background: #fff7df;
}

#messagesView.active .chat-icon-action[data-message-action="reply"] {
  color: #2854a3;
  background: #edf3ff;
}

#messagesView.active .chat-icon-action[data-message-action="pin"] {
  color: #7b4bc4;
  background: #f3edff;
}

#messagesView.active .chat-icon-action[data-message-action="forward"] {
  color: #0f6fae;
  background: #eaf6ff;
}

#messagesView.active .chat-icon-action[data-message-action="copy"] {
  color: #147d64;
  background: #eaf8f3;
}

#messagesView.active .chat-icon-action[data-message-action="edit"] {
  color: #7a5a00;
  background: #fff6d8;
}

#messagesView.active .chat-icon-action.danger-icon {
  color: #b42318;
  background: #fff0ed;
}

#messagesView.active .chat-icon-action:hover {
  border-color: rgba(98, 100, 167, 0.18);
  filter: brightness(0.98);
  transform: translateY(-1px);
}

#messagesView.active .mobile-message-menu-button {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .sidebar {
    width: 92px;
    padding: 14px 8px;
  }

  .brand-copy,
  .sidebar-status,
  .sidebar-menu-reset,
  .sidebar-guide-text,
  .nav-item span,
  .sidebar .control {
    display: none;
  }

  .sidebar-guide-link {
    width: 44px;
    align-self: center;
    padding: 10px;
  }

  .nav-item {
    justify-content: center;
    min-height: 44px;
    padding: 10px;
    text-align: center;
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    min-height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav {
    display: flex;
    gap: 6px;
    min-width: max-content;
  }

  .nav-item {
    min-width: 92px;
  }
}

/* Mobile/PWA stability layer */
:root {
  --app-mobile-vh: 100vh;
}

@supports (height: 100dvh) {
  :root {
    --app-mobile-vh: 100dvh;
  }
}

@media (max-width: 820px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    min-height: var(--app-mobile-vh);
    overflow: hidden;
    overscroll-behavior: none;
  }

  body:not(.auth-locked):not(.popup-mode) .app-shell {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: var(--app-mobile-vh);
    min-height: var(--app-mobile-vh);
    overflow: hidden;
    padding: 0;
  }

  body:not(.auth-locked):not(.popup-mode) .sidebar {
    position: sticky;
    top: 0;
    z-index: 80;
    width: 100%;
    height: auto;
    max-height: 132px;
    min-height: 0;
    min-width: 0;
    display: block;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
  }

  body:not(.auth-locked):not(.popup-mode) .sidebar .brand {
    display: none;
  }

  body:not(.auth-locked):not(.popup-mode) .account-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    align-items: center;
    padding: 8px 10px;
    padding-right: 58px;
    margin: 0 0 8px;
    border-radius: 12px;
    min-height: 54px;
  }

  body:not(.auth-locked):not(.popup-mode) .account-box .field-label,
  body:not(.auth-locked):not(.popup-mode) .account-box span,
  body:not(.auth-locked):not(.popup-mode) .sidebar-menu-reset,
  body:not(.auth-locked):not(.popup-mode) .sidebar-status {
    display: none;
  }

  body:not(.auth-locked):not(.popup-mode) .sidebar-guide-link {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 8px;
  }

  body:not(.auth-locked):not(.popup-mode) .sidebar-guide-text {
    display: none;
  }

  body:not(.auth-locked):not(.popup-mode) .account-box strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }

  body:not(.auth-locked):not(.popup-mode) .account-box .logout-icon-button {
    top: 8px;
    right: 10px;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    font-size: 18px;
  }

  body:not(.auth-locked):not(.popup-mode) .nav {
    display: flex;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 2px 4px;
    margin: 0;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  body:not(.auth-locked):not(.popup-mode) .nav::-webkit-scrollbar {
    display: none;
  }

  body:not(.auth-locked):not(.popup-mode) .nav-item {
    flex: 0 0 auto;
    min-width: 86px;
    min-height: 40px;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 10px;
    scroll-snap-align: start;
    white-space: nowrap;
    font-size: 14px;
  }

  body:not(.auth-locked):not(.popup-mode) .main {
    height: auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 10px calc(20px + env(safe-area-inset-bottom, 0px));
  }

  body:not(.auth-locked):not(.popup-mode) .main:has(#messagesView.active) {
    padding: 0;
  }

  body:not(.auth-locked):not(.popup-mode) .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 0;
    margin: -12px 0 8px;
    background: rgba(246, 248, 250, 0.96);
    backdrop-filter: blur(10px);
  }

  body:not(.auth-locked):not(.popup-mode) .main:has(#messagesView.active) .topbar {
    display: none;
  }

  body:not(.auth-locked) #messagesView.active {
    height: calc(var(--app-mobile-vh) - 132px);
    min-height: 0;
    overflow: hidden;
  }

  body.popup-mode:not(.auth-locked) #messagesView.active {
    height: var(--app-mobile-vh);
  }

  #messagesView.active .messages-center {
    display: grid;
    grid-template-columns: 1fr;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #messagesView.active .messages-sidebar,
  #messagesView.active .messages-thread-panel,
  #messagesView.active .messages-detail-panel {
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  #messagesView.active .messages-sidebar {
    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr);
    overflow: hidden;
  }

  #messagesView.active .conversation-list {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #messagesView.active:not(.conversation-open) .messages-thread-panel,
  #messagesView.active:not(.conversation-open) .messages-detail-panel {
    display: none !important;
  }

  #messagesView.active.conversation-open .messages-sidebar {
    display: none !important;
  }

  #messagesView.active.conversation-open .messages-thread-panel {
    display: block !important;
  }

  #messagesView.active.detail-open .messages-thread-panel {
    display: none !important;
  }

  #messagesView.active.detail-open .messages-detail-panel {
    display: block !important;
    position: static;
    width: 100%;
    transform: none;
    box-shadow: none;
    overflow-y: auto;
  }

  #messagesView.active .messages-thread-shell {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #messagesView.active .messages-thread-head {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 42px 42px minmax(0, 1fr) auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    min-height: 58px;
  }

  #messagesView.active .messages-thread-head h2,
  #messagesView.active .messages-thread-head p {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #messagesView.active .message-search-box {
    display: none;
  }

  #messagesView.active.search-open .message-search-box {
    display: grid;
  }

  #messagesView.active .messages-active-list {
    min-height: 0;
    overflow-y: auto;
    padding: 10px 10px 12px;
    -webkit-overflow-scrolling: touch;
  }

  #messagesView.active .modern-chat-form {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--borderSubtle);
    background: #ffffff;
  }

  #messagesView.active .chat-compose-row,
  #messagesView.active #messagesForm:not(:has(#messagesUrgentInput)) .chat-compose-row {
    gap: 7px;
    min-height: 52px;
    padding: 7px;
    border-radius: 16px;
  }

  #messagesView.active .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
  }

  #messagesView.active #messagesForm:not(:has(#messagesUrgentInput)) .chat-compose-row {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  #messagesView.active .chat-text-input {
    min-width: 0;
    height: 38px;
    font-size: 16px;
  }

  #messagesView.active .messages-attach-button,
  #messagesView.active .messages-urgent-toggle,
  #messagesView.active .messages-send-button {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  #messagesView.active .messages-emoji-button,
  #messagesView.active .emoji-panel {
    display: none !important;
  }

  #messagesView.active .chat-message {
    max-width: 92%;
  }

  #messagesView.active .chat-actions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 8px;
    z-index: 9;
    width: auto;
    max-width: min(304px, calc(100vw - 40px));
    justify-content: flex-end;
    margin: 0;
    padding: 4px;
    opacity: 1;
    background: #ffffff;
    border: 1px solid var(--borderSubtle);
    border-radius: 14px;
    box-shadow: var(--shadowPanel);
    transform: none;
  }

  #messagesView.active .chat-icon-action {
    width: 30px;
    height: 30px;
  }

  #messagesView.active .mobile-message-menu-button {
    display: grid;
    place-items: center;
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 8;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--textSecondary);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    font-size: 22px;
    line-height: 1;
  }

  #messagesView.active .chat-message.actions-open {
    z-index: 12;
  }

  #messagesView.active .chat-message.actions-open .chat-actions {
    display: flex;
  }

  #messagesView.active .chat-message.actions-open .mobile-message-menu-button {
    color: #ffffff;
    background: var(--brandPrimary);
  }
}

@media (max-width: 430px) and (hover: none) and (pointer: coarse) {
  #messagesView.active .messages-thread-head {
    grid-template-columns: 40px 40px minmax(0, 1fr) 40px;
  }

  #messagesView.active .messages-thread-head .pill {
    display: none;
  }

  #messagesView.active .messages-thread-head .popout-button {
    display: none;
  }

  #messagesView.active .messages-active-list {
    padding: 8px 8px 10px;
  }

  #messagesView.active .chat-message {
    max-width: 96%;
  }

  #messagesView.active .chat-bubble {
    padding-right: 46px;
  }

  #messagesView.active .chat-actions {
    right: 4px;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 920px) and (orientation: landscape) {
  body:not(.auth-locked):not(.popup-mode) .sidebar {
    max-height: 92px;
  }

  body:not(.auth-locked):not(.popup-mode) .account-box {
    display: none;
  }

  body:not(.auth-locked) #messagesView.active {
    height: calc(var(--app-mobile-vh) - 92px);
  }
}

/* Compact desktop hover correction: a narrow browser window is not a touch phone. */
@media (max-width: 820px) and (hover: hover) and (pointer: fine) {
  #messagesView.active .messages-emoji-button {
    display: grid !important;
  }

  #messagesView.active .emoji-panel:not(.hidden) {
    display: grid !important;
  }

  #messagesView.active .chat-actions {
    position: absolute;
    top: -34px;
    right: 4px;
    left: auto;
    z-index: 6;
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    width: auto;
    max-width: min(280px, calc(100vw - 44px));
    padding: 3px;
    margin: 0;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--shadowCard);
    opacity: 0;
    pointer-events: none;
    transform: translateY(3px);
  }

  #messagesView.active .chat-message:hover .chat-actions,
  #messagesView.active .chat-message:focus .chat-actions,
  #messagesView.active .chat-message:focus-within .chat-actions {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  #messagesView.active .chat-icon-action {
    width: 28px;
    min-width: 28px;
    height: 28px;
    min-height: 28px;
  }
}

@media (max-width: 720px) {
  .attachment-preview-card {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 18px);
  }

  .attachment-preview-body {
    max-height: 58dvh;
    padding: 8px;
  }

  .attachment-preview-frame,
  .attachment-preview-image {
    max-height: 54dvh;
  }

  .attachment-preview-frame {
    height: 54dvh;
  }

  .detail-attachment {
    grid-template-columns: minmax(0, 1fr) 36px 36px;
  }
}

/* Messages action preview polish: Teams-like desktop hover and mobile bottom sheet. */
#messagesView.active .chat-bubble {
  position: relative;
}

#messagesView.active .chat-action-reactions,
#messagesView.active .chat-action-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

#messagesView.active .chat-action-reactions {
  padding-right: 7px;
  margin-right: 4px;
  border-right: 1px solid rgba(100, 116, 139, 0.2);
}

#messagesView.active .chat-icon-action .action-label {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  #messagesView.active .chat-actions {
    top: -42px;
    right: 10px;
    left: auto;
    z-index: 14;
    align-items: center;
    gap: 2px;
    padding: 4px 5px;
    border: 1px solid rgba(210, 214, 224, 0.92);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.99);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px) scale(0.98);
    transition: opacity 0.12s ease, transform 0.12s ease;
  }

  #messagesView.active .chat-messages {
    padding-top: 58px;
  }

  #messagesView.active .chat-message:hover .chat-actions,
  #messagesView.active .chat-message:focus .chat-actions {
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px) scale(0.98);
  }

  #messagesView.active .chat-bubble:hover .chat-actions,
  #messagesView.active .chat-bubble:focus-within .chat-actions,
  #messagesView.active .chat-message.actions-open .chat-actions,
  #messagesView.active .chat-actions:hover {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  #messagesView.active .chat-bubble:has(.reaction-summary:hover) .chat-actions,
  #messagesView.active .chat-bubble:has(.reaction-summary:focus-within) .chat-actions {
    opacity: 0;
    pointer-events: none;
    transform: translateY(4px) scale(0.98);
  }

  #messagesView.active .chat-message:first-child .chat-actions,
  #messagesView.active .chat-message:nth-child(2) .chat-actions {
    top: calc(100% + 8px);
    bottom: auto;
  }

  #messagesView.active .chat-message:first-child .floating-reaction-picker,
  #messagesView.active .chat-message:nth-child(2) .floating-reaction-picker {
    top: calc(100% + 8px);
    bottom: auto;
  }

  #messagesView.active .chat-icon-action {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent !important;
    color: #334155;
    font-size: 18px;
    box-shadow: none !important;
  }

  #messagesView.active .chat-icon-action:hover {
    background: #f3f4f8 !important;
    color: #4646a8;
  }

  #messagesView.active .chat-icon-action.danger-icon:hover {
    background: #fff1f2 !important;
    color: #be123c;
  }

  #messagesView.active .reaction-more-action {
    color: #475569;
  }

  #messagesView.active .chat-action-reactions {
    padding-right: 8px;
    margin-right: 5px;
    border-right: 1px solid rgba(100, 116, 139, 0.22);
  }

  #messagesView.active .chat-action-tools {
    gap: 2px;
  }

  #messagesView.active .floating-reaction-picker {
    position: absolute;
    top: -88px;
    right: 10px;
    z-index: 16;
    display: flex;
    flex-wrap: nowrap;
    gap: 5px;
    width: max-content;
    max-width: min(430px, calc(100vw - 52px));
    padding: 7px;
    margin: 0;
    border: 1px solid rgba(210, 214, 224, 0.95);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.99);
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.18);
  }

  #messagesView.active .chat-message:not(.own) .chat-actions {
    left: 10px;
    right: auto;
  }

  #messagesView.active .chat-message:not(.own) .floating-reaction-picker {
    left: 10px;
    right: auto;
  }

  #messagesView.active .floating-reaction-picker.hidden {
    display: none;
  }

  #messagesView.active .floating-reaction-picker button {
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: transparent;
    font-size: 19px;
    box-shadow: none;
  }

  #messagesView.active .floating-reaction-picker button:hover,
  #messagesView.active .floating-reaction-picker button.active {
    background: #eef2ff;
  }
}

@media (hover: none), (pointer: coarse) {
  #messagesView.active .chat-actions {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    z-index: 80;
    display: none !important;
    width: 100%;
    max-width: none;
    max-height: min(78dvh, 620px);
    overflow: auto;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 24px 24px 0 0;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -24px 60px rgba(15, 23, 42, 0.26);
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  #messagesView.active .floating-reaction-picker {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 4px 12px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  #messagesView.active .floating-reaction-picker.hidden {
    display: none;
  }

  #messagesView.active .floating-reaction-picker button {
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #f8fafc;
    font-size: 24px;
  }

  #messagesView.active .chat-message.actions-open .chat-actions {
    display: grid !important;
  }

  #messagesView.active .chat-action-reactions {
    justify-content: space-between;
    gap: 8px;
    padding: 2px 4px 14px;
    margin: 0;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  }

  #messagesView.active .chat-action-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
  }

  #messagesView.active .chat-icon-action {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 12px;
    justify-content: start;
    align-items: center;
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 0 8px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #111827;
    font-size: 21px;
    text-align: left;
  }

  #messagesView.active .chat-action-reactions .chat-icon-action {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    width: 52px;
    min-width: 52px;
    height: 52px;
    min-height: 52px;
    padding: 0;
    border-radius: 999px;
    background: #f8fafc;
  }

  #messagesView.active .chat-icon-action .action-label {
    display: inline;
    min-width: 0;
    overflow: hidden;
    font-size: 18px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #messagesView.active .chat-action-reactions .action-label {
    display: none;
  }

  #messagesView.active .chat-icon-action:active {
    background: #eef2ff;
  }

  #messagesView.active .chat-icon-action.danger-icon {
    color: #b42318;
  }

  #messagesView.active .mobile-message-menu-button {
    display: grid;
  }
}

/* Messages Teams-style overflow actions */
#messagesView.active .message-more-menu.hidden {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  #messagesView.active .chat-action-main-tools {
    gap: 2px;
  }

  #messagesView.active .more-menu-toggle .action-icon {
    font-size: 22px;
    line-height: 1;
  }

  #messagesView.active .message-more-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    z-index: 18;
    display: grid;
    min-width: 238px;
    padding: 7px;
    border: 1px solid rgba(214, 218, 228, 0.96);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.99);
    box-shadow: 0 18px 46px rgba(15, 23, 42, 0.18);
  }

  #messagesView.active .chat-message:not(.own) .message-more-menu {
    left: 0;
    right: auto;
  }

  #messagesView.active .message-more-menu button {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #334155;
    font-size: 14px;
    font-weight: 760;
    text-align: left;
    box-shadow: none;
  }

  #messagesView.active .message-more-menu button:hover,
  #messagesView.active .message-more-menu button:focus-visible {
    background: #f5f7fb;
    color: #26266f;
  }

  #messagesView.active .message-more-menu .action-icon {
    display: inline-flex;
    justify-content: center;
    color: #475569;
    font-size: 17px;
  }

  #messagesView.active .message-more-menu .danger-icon,
  #messagesView.active .message-more-menu .danger-icon .action-icon {
    color: #b42318;
  }

  #messagesView.active .message-more-menu::after {
    position: absolute;
    right: 16px;
    bottom: -6px;
    width: 10px;
    height: 10px;
    border-right: 1px solid rgba(214, 218, 228, 0.96);
    border-bottom: 1px solid rgba(214, 218, 228, 0.96);
    background: rgba(255, 255, 255, 0.99);
    content: "";
    transform: rotate(45deg);
  }
}

@media (hover: none), (pointer: coarse) {
  #messagesView.active .chat-action-main-tools {
    display: none;
  }

  #messagesView.active .chat-message.actions-open .message-more-menu,
  #messagesView.active .chat-message.actions-open .message-more-menu.hidden {
    position: static;
    display: grid;
    gap: 2px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #messagesView.active .message-more-menu button {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    min-height: 52px;
    padding: 0 8px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #111827;
    font-size: 18px;
    font-weight: 850;
    text-align: left;
    box-shadow: none;
  }

  #messagesView.active .message-more-menu button:active {
    background: #eef2ff;
  }

  #messagesView.active .message-more-menu .action-icon {
    display: inline-flex;
    justify-content: center;
    color: #334155;
    font-size: 22px;
  }

  #messagesView.active .message-more-menu .danger-icon,
  #messagesView.active .message-more-menu .danger-icon .action-icon {
    color: #b42318;
  }
}

/* TV dashboard viewport repair: keep TV mode isolated from normal responsive grids. */
body.tv-active.tv-view-active:not(.auth-locked),
body.tv-active.tv-view-active:not(.auth-locked) .app-shell,
body.tv-active.tv-view-active:not(.auth-locked) .main {
  width: 100vw !important;
  height: var(--tv-height, 100dvh) !important;
  max-height: var(--tv-height, 100dvh) !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #091015 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) .sidebar,
body.tv-active.tv-view-active:not(.auth-locked) .topbar,
body.tv-active.tv-view-active:not(.auth-locked) #appStatus {
  display: none !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active {
  --tv-gap-fixed: clamp(7px, 0.75vw, 14px);
  --tv-pad-x-fixed: clamp(12px, 1.2vw, 26px);
  --tv-pad-y-fixed: clamp(9px, 1.05vh, 18px);
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows:
    clamp(58px, 8.6vh, 104px)
    clamp(62px, 9.4vh, 104px)
    minmax(0, 1fr)
    clamp(96px, 16.2vh, 176px)
    clamp(28px, 3.8vh, 42px) !important;
  gap: var(--tv-gap-fixed) !important;
  width: 100vw !important;
  height: var(--tv-height, 100dvh) !important;
  max-height: var(--tv-height, 100dvh) !important;
  min-height: 0 !important;
  padding: var(--tv-pad-y-fixed) var(--tv-pad-x-fixed) !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden !important;
  background: #091015 !important;
  box-sizing: border-box !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-head,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metrics,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-motivation-grid,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-ticker {
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-head {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-brand img {
  width: clamp(42px, 4vw, 72px) !important;
  height: clamp(42px, 4vw, 72px) !important;
  flex: 0 0 auto !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-head h2 {
  font-size: clamp(30px, 3.7vw, 58px) !important;
  line-height: 0.95 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-head strong {
  font-size: clamp(38px, 5vw, 78px) !important;
  line-height: 0.92 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metrics {
  display: grid !important;
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  gap: var(--tv-gap-fixed) !important;
  height: 100% !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metric {
  display: grid !important;
  align-content: center !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: clamp(8px, 0.9vw, 14px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metric span {
  font-size: clamp(10px, 0.82vw, 14px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metric strong {
  font-size: clamp(24px, 2.7vw, 44px) !important;
  line-height: 1 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid {
  display: grid !important;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.92fr) minmax(0, 0.9fr) !important;
  gap: var(--tv-gap-fixed) !important;
  height: 100% !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-motivation-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: var(--tv-gap-fixed) !important;
  height: 100% !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-panel {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  padding: clamp(8px, 0.85vw, 14px) !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-panel h3 {
  flex: 0 0 auto !important;
  margin: 0 0 clamp(5px, 0.6vh, 9px) !important;
  font-size: clamp(13px, 1.15vw, 20px) !important;
  line-height: 1.08 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-list {
  display: grid !important;
  align-content: start !important;
  gap: clamp(4px, 0.6vh, 8px) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-panel > h3 + .tv-list {
  flex: 1 1 0 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .mini-row {
  min-width: 0 !important;
  padding: clamp(6px, 0.7vw, 10px) !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment strong,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment span,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment small,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .mini-row,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .mini-row small {
  display: block !important;
  max-width: 100% !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment strong {
  font-size: clamp(13px, 1.12vw, 20px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment span,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .mini-row {
  font-size: clamp(11px, 0.94vw, 15px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-shipment small,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .mini-row small {
  font-size: clamp(9px, 0.78vw, 12px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvRiskList,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvUnassignedList {
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid > .tv-panel:nth-child(3) {
  display: flex !important;
  flex-direction: column !important;
  gap: clamp(5px, 0.7vh, 9px) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid > .tv-panel:nth-child(3) > h3 {
  flex: 0 0 auto !important;
  margin: 0 !important;
  line-height: 1.06 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvSalesLeaders,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvDispatcherLeaders {
  flex: 0 0 auto !important;
  display: grid !important;
  grid-template-rows: repeat(3, clamp(50px, 6.5vh, 82px)) !important;
  gap: clamp(5px, 0.65vh, 9px) !important;
  max-height: none !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row {
  display: grid !important;
  align-content: center !important;
  gap: 2px !important;
  min-height: clamp(50px, 6.5vh, 82px) !important;
  height: clamp(50px, 6.5vh, 82px) !important;
  padding: clamp(8px, 0.9vh, 12px) clamp(10px, 0.9vw, 14px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row strong,
body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row small {
  display: block !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  line-height: 1.08 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row strong {
  font-size: clamp(13px, 1.05vw, 18px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row small {
  color: #b8c6cf !important;
  font-size: clamp(10px, 0.8vw, 13px) !important;
  font-weight: 800 !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvTopMargin {
  flex: 1 1 0 !important;
  display: grid !important;
  align-content: start !important;
  min-height: clamp(58px, 7.5vh, 96px) !important;
  overflow: hidden !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvTopMargin .tv-shipment {
  min-height: clamp(50px, 6.8vh, 88px) !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-ticker {
  display: flex !important;
  align-items: center !important;
  height: 100% !important;
}

body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .ticker-track {
  padding: 0 clamp(10px, 0.8vw, 14px) !important;
  font-size: clamp(11px, 0.95vw, 15px) !important;
  will-change: transform !important;
}

@media (max-width: 900px) {
  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active {
    grid-template-rows:
      clamp(54px, 8vh, 72px)
      clamp(116px, 18vh, 150px)
      minmax(0, 1fr)
      clamp(92px, 15vh, 130px)
      clamp(30px, 4vh, 40px) !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid .tv-panel:nth-child(n + 2) {
    display: none !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-motivation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-height: 820px) {
  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvSalesLeaders,
  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active #tvDispatcherLeaders {
    grid-template-rows: repeat(3, clamp(40px, 5.2vh, 54px)) !important;
    gap: 5px !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row {
    min-height: clamp(40px, 5.2vh, 54px) !important;
    height: clamp(40px, 5.2vh, 54px) !important;
    padding: 6px 9px !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row strong {
    font-size: clamp(10px, 0.82vw, 13px) !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-leader-row small {
    font-size: clamp(8px, 0.64vw, 10px) !important;
  }

  body.tv-active.tv-view-active:not(.auth-locked) #tvView.active .tv-grid > .tv-panel:nth-child(3) {
    gap: 4px !important;
  }
}

@media (hover: hover) and (pointer: fine) {
  #messagesView.active .chat-bubble:hover::before,
  #messagesView.active .chat-bubble:focus-within::before,
  #messagesView.active .chat-message.actions-open .chat-bubble::before {
    content: "";
    position: absolute;
    right: 0;
    left: auto;
    top: -54px;
    z-index: 13;
    width: min(440px, calc(100vw - 52px));
    height: 58px;
    background: transparent;
    pointer-events: auto;
  }

  #messagesView.active .chat-message:not(.own) .chat-bubble:hover::before,
  #messagesView.active .chat-message:not(.own) .chat-bubble:focus-within::before,
  #messagesView.active .chat-message:not(.own).actions-open .chat-bubble::before {
    right: auto;
    left: 0;
  }

  #messagesView.active .chat-message:first-child .chat-bubble:hover::after,
  #messagesView.active .chat-message:first-child .chat-bubble:focus-within::after,
  #messagesView.active .chat-message:first-child.actions-open .chat-bubble::after,
  #messagesView.active .chat-message:nth-child(2) .chat-bubble:hover::after,
  #messagesView.active .chat-message:nth-child(2) .chat-bubble:focus-within::after,
  #messagesView.active .chat-message:nth-child(2).actions-open .chat-bubble::after {
    content: "";
    position: absolute;
    right: 0;
    left: auto;
    bottom: -30px;
    z-index: 13;
    width: min(440px, calc(100vw - 52px));
    height: 34px;
    background: transparent;
    pointer-events: auto;
  }

  #messagesView.active .chat-message:not(.own):first-child .chat-bubble:hover::after,
  #messagesView.active .chat-message:not(.own):first-child .chat-bubble:focus-within::after,
  #messagesView.active .chat-message:not(.own):first-child.actions-open .chat-bubble::after,
  #messagesView.active .chat-message:not(.own):nth-child(2) .chat-bubble:hover::after,
  #messagesView.active .chat-message:not(.own):nth-child(2) .chat-bubble:focus-within::after,
  #messagesView.active .chat-message:not(.own):nth-child(2).actions-open .chat-bubble::after {
    right: auto;
    left: 0;
  }
}
