:root {
  --bg: #eef5f8;
  --surface: #ffffff;
  --text: #2a3642;
  --text-secondary: #5c6d7a;
  --accent: #2c5282;
  --accent-hover: #234e77;
  --accent-soft: rgba(44, 82, 130, 0.14);
  --border: rgba(45, 90, 110, 0.1);
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(45, 90, 110, 0.08);
  --bip-bg-image: url('/illustrations/bg-logistics-mix.png');
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; }
body {
  font-family: 'Comfortaa', sans-serif;
  background: transparent;
  min-height: 100vh;
  padding: 16px;
  color: var(--text);
  position: relative;
  -webkit-text-size-adjust: 100%;
}

.bip-page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #e8f2f6;
  background-image: var(--bip-bg-image);
  background-size: cover;
  background-position: center;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.card {
  background: rgba(255,255,255,0.88);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
}

h1 { font-size: 22px; margin-bottom: 6px; }
h2 { font-size: 17px; margin-bottom: 12px; }

.sub,
.hint,
.ac-hint {
  font-size: 13px;
  color: #5d6d7e;
  line-height: 1.5;
  margin-bottom: 14px;
}

label,
.ac-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

select,
input[type="text"],
input[type="password"],
textarea,
.ac-field input,
.ac-field select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  background: #fff;
  color: #2c3e50;
}

.ac-field { margin-bottom: 14px; }

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  border: 2px solid #d5dce3;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn,
.ac-btn.block {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  background: #27ae60;
  color: #fff;
}

.btn:hover,
.ac-btn.block:hover { filter: brightness(1.03); }
.btn:disabled,
.ac-btn:disabled { opacity: 0.6; cursor: wait; }

.btn-outline,
.ac-btn.secondary {
  background: #fff;
  color: var(--accent);
  border: 2px solid var(--accent);
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.msg,
.ac-msg {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  display: none;
}

.msg.ok,
.ac-msg.ok { display: block; background: #d5f5e3; color: #1e6f43; }
.msg.err,
.ac-msg.err { display: block; background: #fdecea; color: #922b21; }

.hidden { display: none !important; }

#cabinetScreen { display: none; }
#cabinetScreen.active { display: block; }

.profile {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.profile-name { font-size: 18px; font-weight: 700; }
.profile-meta { font-size: 12px; color: #666; margin-top: 4px; line-height: 1.4; }

.cabinet-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cabinet-tab {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: #ecf0f1;
  color: #444;
}

.cabinet-tab.active { background: var(--accent); color: #fff; }
.cabinet-tab-wrap { position: relative; display: inline-block; }
.cabinet-tab-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
  animation: access-badge-blink 1s ease-in-out infinite;
}

@keyframes access-badge-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.92); }
}

.panel,
.ac-panel { display: none; }
.panel.active,
.ac-panel.active { display: block; }

.ac-chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ac-chat-head h2 {
  margin: 0;
  font-size: 17px;
  flex: 1;
}

.ac-identity-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 12px;
  color: #6b7280;
}

.ac-identity-bar select {
  flex: 1;
  min-width: 140px;
}

.ac-messages {
  width: 100%;
  min-height: 280px;
  max-height: 48vh;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid #e0e7ef;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,249,251,0.95));
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ac-chat-day-group {
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(255,255,255,0.45);
}

.ac-chat-day-group.today {
  border-color: #aed6f1;
  background: rgba(255,255,255,0.55);
}

.ac-chat-day-group.collapsed .ac-chat-day-messages { display: none; }

.ac-chat-day-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: #e8ecef;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #2c3e50;
  text-align: left;
  font-family: inherit;
}

.ac-chat-day-group.today .ac-chat-day-header {
  background: #d4e6f1;
  color: #1a5276;
}

.ac-chat-day-header:hover { filter: brightness(0.97); }

.ac-chat-day-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: #7f8c8d;
}

.ac-chat-day-count {
  font-size: 11px;
  background: rgba(0,0,0,0.08);
  padding: 2px 8px;
  border-radius: 10px;
}

.ac-chat-day-chevron {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
}

.ac-chat-day-group.collapsed .ac-chat-day-chevron { transform: rotate(-90deg); }

.ac-chat-day-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 10px 10px;
}

.ac-msg-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.ac-msg-bubble.me {
  align-self: flex-end;
  background: #d6eaf8;
  border: 1px solid #aed6f1;
}

.ac-msg-bubble.them {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #d9e3ea;
}

.ac-msg-bubble.system {
  align-self: center;
  background: #fff4d6;
  border: 1px solid #f7d58b;
  font-size: 12px;
}

.ac-msg-meta {
  font-size: 10px;
  color: #7f8c8d;
  margin-bottom: 4px;
  font-weight: 600;
}

.ac-msg-shop {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #5d6d7e;
  color: #fff;
  margin-right: 4px;
}

.courier-chat-compose,
.ac-compose {
  margin-top: 10px;
}

.courier-chat-compose textarea,
.ac-compose textarea {
  width: 100%;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  margin-bottom: 10px;
}

.ac-thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 48vh;
  overflow: auto;
}

.ac-thread-btn {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 0;
  padding: 12px 14px;
  border: 2px solid #c5dde6;
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.ac-thread-btn:hover { background: #f4fafc; border-color: var(--accent); }
.ac-thread-btn.active {
  background: #f0f8fb;
  color: #1f3340;
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.ac-thread-btn.unread {
  background: #fff5f5;
  border-color: #f1a9a0;
}

.ac-thread-title { font-size: 14px; font-weight: 700; }
.ac-thread-preview { font-size: 12px; color: #566573; margin-top: 6px; line-height: 1.35; }

.ac-thread-view { display: none; }
.ac-thread-view.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ac-list-view.hidden-by-thread { display: none; }

.ac-list-view.hidden-by-thread { display: none; }

.ac-compose-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ac-emoji-wrap { position: relative; }

.ac-emoji-btn,
.ac-attach-btn {
  border: 1px solid #d5dce3;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}

.ac-attach-btn { display: inline-flex; align-items: center; }

.ac-emoji-picker {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 8px;
  width: 260px;
  max-height: 180px;
  overflow-y: auto;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.ac-emoji-picker.open { display: grid; }

.ac-emoji-picker button {
  border: none;
  background: transparent;
  font-size: 20px;
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
}

.ac-emoji-picker button:hover { background: #ecf0f1; }

.ac-attach-preview {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #f4f8fb;
  font-size: 12px;
  color: #566573;
}

.ac-reply-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #eef6ff;
  border: 1px solid #c5dff5;
  font-size: 12px;
}

.ac-reply-banner.hidden { display: none !important; }

.ac-reply-banner-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ac-reply-cancel {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #7f8c8d;
  padding: 2px 6px;
}

.ac-msg-reply-quote {
  margin-bottom: 6px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.55);
  border-radius: 8px;
  font-size: 11px;
  color: #5d6d7e;
}

.ac-msg-text { word-break: break-word; }

.ac-msg-image {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-top: 8px;
}

.ac-msg-file {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f4f6f8;
  color: #2c3e50;
  text-decoration: none;
  font-size: 13px;
}

.ac-msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ac-reaction-chip {
  border: 1px solid #dfe6e9;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.4;
}

.ac-reaction-count { font-size: 11px; color: #666; margin-left: 2px; }

.ac-mention {
  font-weight: 700;
  padding: 0 2px;
  border-radius: 4px;
}

.ac-mention-staff { color: #d35400; background: rgba(230,126,34,0.18); }
.ac-mention-shop { color: #fff; }

.ac-context-menu {
  display: none;
  position: fixed;
  z-index: 200;
  min-width: 200px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 10px;
}

.ac-context-menu.open { display: block; }

.ac-context-reply {
  width: 100%;
  border: none;
  background: #f4f6f8;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
  text-align: left;
}

.ac-context-label { font-size: 11px; color: #888; margin-bottom: 6px; }

.ac-context-reactions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.ac-context-reactions button {
  border: none;
  background: #f4f6f8;
  border-radius: 8px;
  padding: 8px 0;
  font-size: 20px;
  cursor: pointer;
}

@media (max-width: 640px) {
  body { padding: 12px 12px calc(88px + env(safe-area-inset-bottom, 0px)); }
  .wrap { max-width: 100%; }
  .card { padding: 18px 16px; }
  .cabinet-tabs { gap: 8px; }
  .cabinet-tab { font-size: 12px; padding: 8px 12px; }
}

/* Admin cabinet layout */
body { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }

.ac-header-card { margin-bottom: 10px; }
.ac-header-card .profile { margin-bottom: 0; }

.ac-panel-card {
  margin-bottom: 0;
  min-height: calc(100vh - 200px);
}

.ac-panel { display: none; }
.ac-panel.active { display: block; }

.ac-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  background: rgba(255,255,255,0.96);
  border-top: 1px solid var(--border);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(44, 82, 130, 0.1);
  backdrop-filter: blur(10px);
}

.ac-nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 14px;
  padding: 8px 4px;
  font-family: inherit;
  cursor: pointer;
  position: relative;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ac-nav-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.ac-nav-icon { font-size: 22px; line-height: 1; }
.ac-nav-label { font-size: 10px; font-weight: 700; }

.ac-nav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 28px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e74c3c;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.ac-filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.ac-filter-btn {
  flex: 1;
  border: 2px solid #d5dce3;
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.ac-filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ac-account-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ac-account-card {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,0.9);
}

.ac-account-card.pending { border-left: 4px solid #f59e0b; }
.ac-account-card.approved { border-left: 4px solid #22c55e; }
.ac-account-card.rejected { border-left: 4px solid #94a3b8; }

.ac-account-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.ac-account-meta { font-size: 12px; color: #64748b; line-height: 1.45; margin-bottom: 10px; }

.ac-account-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ac-account-actions .btn,
.ac-account-actions .btn-outline {
  flex: 1;
  min-width: 100px;
  width: auto;
  padding: 10px 12px;
  font-size: 13px;
}

.ac-account-actions .btn-outline.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.ac-thread-list { display: flex; flex-direction: column; gap: 8px; }

.ac-thread-btn {
  width: 100%;
  text-align: left;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
}

.ac-thread-btn.unread { border-color: #fca5a5; background: #fff5f5; }
.ac-thread-btn.active { border-color: var(--accent); background: var(--accent-soft); }

.ac-thread-title { font-weight: 700; font-size: 15px; }
.ac-thread-preview { font-size: 12px; color: #64748b; margin-top: 4px; }

.ac-thread-view { display: none; }
.ac-thread-view.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ac-list-view.hidden-by-thread { display: none; }

.ac-thread-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ac-back-btn { flex-shrink: 0; }

.ac-admin-tools { margin-bottom: 10px; }

.ac-courier-broadcast {
  border: 1px solid #aed6f1;
  border-radius: 12px;
  background: linear-gradient(135deg, #ebf5fb 0%, #fff 100%);
  padding: 10px 12px 12px;
  margin-bottom: 10px;
}

.ac-courier-broadcast-title {
  font-size: 14px;
  font-weight: 800;
  color: #1a5276;
  cursor: pointer;
  list-style: none;
}

.ac-courier-broadcast-title::-webkit-details-marker { display: none; }

.ac-courier-broadcast[open] .ac-courier-broadcast-title { margin-bottom: 8px; }

.ac-courier-broadcast-hint {
  margin: 0 0 8px !important;
  font-size: 12px !important;
}

.ac-courier-broadcast-input {
  width: 100%;
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid #d5dce3;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  margin-bottom: 8px;
  background: #fff;
}

.ac-courier-broadcast-btn {
  width: 100%;
  background: #2980b9 !important;
  border-color: #2471a3 !important;
}

.ac-courier-broadcast-open .ac-courier-broadcast-title {
  margin-bottom: 8px;
}

.ac-courier-search-wrap {
  margin: 0 0 10px;
}

.ac-courier-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d5dce3;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}

.ac-thread-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-family: inherit;
  cursor: pointer;
}

.ac-thread-btn.unread {
  border-color: #f5b7b1;
  background: #fff8f7;
}

.ac-thread-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ac-thread-preview {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.35;
}

#panelCouriers.active #adminCourierListView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#panelCouriers.active #adminCourierThreads {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.ac-courier-thread-mode #adminCourierListView.hidden-by-thread {
  display: none !important;
}

body.ac-courier-thread-mode #adminCourierThreadView.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ac-tools-toggle {
  width: 100%;
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--accent);
}

.ac-tools-panel {
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.ac-tools-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.ac-tools-tab {
  flex: 1;
  border: none;
  border-radius: 10px;
  padding: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #f1f5f9;
  color: #475569;
}

.ac-tools-tab.active { background: var(--accent); color: #fff; }

.ac-tool-pane { display: none; max-height: 160px; overflow-y: auto; }
.ac-tool-pane.active { display: block; }

.ac-tool-item {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
}

.ac-tool-item-title { font-weight: 700; margin-bottom: 4px; }
.ac-tool-item-preview { font-size: 12px; color: #64748b; }

.ac-tool-input,
.ac-tool-textarea {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid #d5dce3;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
}

.ac-tool-textarea { min-height: 80px; resize: vertical; }

.ac-tool-editor-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ac-add-tool-btn { width: 100%; }

.ac-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
}

.ac-compose textarea {
  flex: 1;
  min-height: 52px;
  max-height: 120px;
  resize: vertical;
  padding: 12px;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
}

.ac-compose .btn {
  width: auto;
  flex-shrink: 0;
  padding: 12px 16px;
}

.ac-sub { font-size: 13px; color: #5d6d7e; line-height: 1.5; margin-bottom: 14px; }
.ac-field { margin-bottom: 14px; }
.ac-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ac-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
}

.ac-chat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ac-chat-head h2 { margin: 0; font-size: 17px; flex: 1; }

.ac-messages {
  width: 100%;
  min-height: 240px;
  max-height: 42vh;
  overflow-y: auto;
  border-radius: 14px;
  border: 1px solid #e0e7ef;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(244,249,251,0.95));
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#panelGlobal .ac-messages { max-height: 46vh; }

.ac-msg-bubble.admin-msg {
  border-left: 3px solid #7c3aed;
  background: rgba(124, 58, 237, 0.06);
}

.ac-status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.ac-status-pill.pending { background: #fef3c7; color: #92400e; }
.ac-status-pill.approved { background: #dcfce7; color: #166534; }
.ac-status-pill.rejected { background: #f1f5f9; color: #475569; }

.ac-curator-dm {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
}

.ac-curator-dm-preview {
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ac-curator-dm-preview .ac-chat-day-group {
  margin-bottom: 0;
}

.ac-curator-dm-preview .ac-chat-day-header {
  padding: 6px 10px;
  font-size: 11px;
}

.ac-curator-dm-preview .ac-chat-day-messages {
  gap: 6px;
  padding: 6px 4px 4px;
}

.ac-curator-dm-msg {
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
}

.ac-curator-dm-msg.admin {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.2);
}

.ac-curator-dm-msg-meta {
  font-size: 10px;
  color: #64748b;
  margin-bottom: 3px;
}

.ac-curator-dm-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ac-curator-dm-compose textarea {
  flex: 1;
  min-height: 48px;
  max-height: 100px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid #d5dce3;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
}

.ac-curator-dm-compose .btn {
  width: auto;
  flex-shrink: 0;
  padding: 10px 14px;
  font-size: 13px;
}

.ac-curator-dm-actions {
  margin-bottom: 8px;
}

.ac-msg-video {
  display: block;
  max-width: 100%;
  max-height: 220px;
  margin-top: 8px;
  border-radius: 10px;
  background: #000;
}

.ac-curator-dm-msg .ac-msg-image {
  max-width: 100%;
  max-height: 120px;
  border-radius: 8px;
  margin-top: 4px;
  display: block;
}

.ac-curator-dm-msg .ac-msg-video {
  max-height: 140px;
}

.ac-curator-dm-hint {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
  line-height: 1.4;
}

.ac-password-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.ac-password-row input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
}

.ac-btn-danger {
  border-color: #fecaca !important;
  color: #b91c1c !important;
}

.ac-stat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(70vh, 640px);
  overflow-y: auto;
  padding: 4px 2px 12px;
}

.ac-stat-msg {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.ac-stat-meta {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
  font-weight: 700;
}

.ac-stat-text {
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.ac-stat-subpanel { display: none; }
.ac-stat-subpanel.active { display: block; }
.ac-stat-tabs { margin-bottom: 10px; }
.ac-heat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 0 0 10px;
}
.ac-heat-label {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
}
.ac-heat-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  background: #fff;
}
.ac-heat-search {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
}
.ac-heat-count { font-size: 12px; color: #64748b; font-weight: 600; margin: 0 0 8px; }
.ac-heat-status-err { color: #b91c1c !important; font-weight: 700; }
.ac-heat-wrap { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.ac-heat-block {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}
.ac-heat-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ac-heat-head h3 { margin: 0; font-size: 14px; font-weight: 800; color: #0f172a; }
.ac-heat-shopno { font-size: 11px; color: #64748b; font-weight: 700; }
.ac-heat-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-heat-pill {
  font-size: 11px; font-weight: 700; padding: 4px 8px; border-radius: 999px; border: 1px solid transparent;
}
.ac-heat-pill.orders { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.ac-heat-pill.failed { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.ac-heat-pill.hot { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.ac-heat-scroll-hint { text-align: center; font-size: 11px; color: #94a3b8; font-weight: 600; margin: 0 0 6px; }
.ac-heat-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.ac-heat-row { display: grid; grid-template-columns: 72px 1fr; gap: 6px; align-items: center; margin-bottom: 4px; min-width: 560px; }
.ac-heat-row-label { font-size: 10px; font-weight: 700; color: #475569; display: flex; align-items: center; gap: 3px; }
.ac-heat-cells { display: grid; grid-template-columns: repeat(24, minmax(18px, 1fr)); gap: 2px; }
.ac-heat-cell {
  min-height: 24px; border-radius: 6px; font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(148,163,184,.2); user-select: none;
}
.ac-heat-cell.ac-heat-l-0 { background: #f8fafc; color: #cbd5e1; }
.ac-heat-cell--orders.ac-heat-l-1 { background: #eff6ff; color: #1e40af; }
.ac-heat-cell--orders.ac-heat-l-2 { background: #dbeafe; color: #1e3a8a; }
.ac-heat-cell--orders.ac-heat-l-3 { background: #93c5fd; color: #fff; }
.ac-heat-cell--orders.ac-heat-l-4 { background: #3b82f6; color: #fff; }
.ac-heat-cell--orders.ac-heat-l-5 { background: #1d4ed8; color: #fff; }
.ac-heat-cell--failed.ac-heat-l-1 { background: #fef2f2; color: #991b1b; }
.ac-heat-cell--failed.ac-heat-l-2 { background: #fecaca; color: #7f1d1d; }
.ac-heat-cell--failed.ac-heat-l-3 { background: #f87171; color: #fff; }
.ac-heat-cell--failed.ac-heat-l-4 { background: #ef4444; color: #fff; }
.ac-heat-cell--failed.ac-heat-l-5 { background: #dc2626; color: #fff; }
.ac-heat-cell--couriers.ac-heat-l-1 { background: #ecfdf5; color: #065f46; }
.ac-heat-cell--couriers.ac-heat-l-2 { background: #a7f3d0; color: #064e3b; }
.ac-heat-cell--couriers.ac-heat-l-3 { background: #34d399; color: #fff; }
.ac-heat-cell--couriers.ac-heat-l-4 { background: #10b981; color: #fff; }
.ac-heat-cell--couriers.ac-heat-l-5 { background: #059669; color: #fff; }
.ac-heat-cell--hot.ac-heat-l-1 { background: #fff7ed; color: #9a3412; }
.ac-heat-cell--hot.ac-heat-l-2 { background: #fed7aa; color: #7c2d12; }
.ac-heat-cell--hot.ac-heat-l-3 { background: #fb923c; color: #fff; }
.ac-heat-cell--hot.ac-heat-l-4 { background: #f97316; color: #fff; }
.ac-heat-cell--hot.ac-heat-l-5 { background: #ea580c; color: #fff; }
.ac-heat-hour { font-size: 8px; color: #94a3b8; text-align: center; font-weight: 700; }
.ac-heat-hour--sum { color: #475569; }

/* Матрица просрочек: строка = ТТ, столбец = час */
.ac-heat-tt-matrix {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}
.ac-heat-tt-title {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px;
}
.ac-heat-tt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  margin: 0 0 8px;
}
.ac-heat-tt-legend span { display: inline-flex; align-items: center; gap: 4px; }
.ac-heat-tt-swatch {
  width: 12px; height: 12px; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(148,163,184,.35);
}
.ac-heat-tt-row {
  grid-template-columns: 76px 1fr;
  min-width: 620px;
}
.ac-heat-tt-label {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.ac-heat-cells--tt {
  grid-template-columns: repeat(24, minmax(18px, 1fr)) 32px;
  grid-auto-flow: column;
  grid-auto-columns: unset;
}
.ac-heat-cell--sum {
  font-weight: 900;
  border-left: 2px solid #cbd5e1;
}
.ac-heat-cell--ttfail.ac-heat-tt-l-0 { background: #f1f5f9; color: #94a3b8; }
.ac-heat-cell--ttfail.ac-heat-tt-l-1 { background: #bbf7d0; color: #14532d; }
.ac-heat-cell--ttfail.ac-heat-tt-l-2 { background: #fde047; color: #713f12; }
.ac-heat-cell--ttfail.ac-heat-tt-l-3 { background: #fdba74; color: #7c2d12; }
.ac-heat-cell--ttfail.ac-heat-tt-l-4 { background: #ef4444; color: #fff; }
.ac-heat-tt-swatch.ac-heat-tt-l-0 { background: #f1f5f9; }
.ac-heat-tt-swatch.ac-heat-tt-l-1 { background: #bbf7d0; }
.ac-heat-tt-swatch.ac-heat-tt-l-2 { background: #fde047; }
.ac-heat-tt-swatch.ac-heat-tt-l-3 { background: #fdba74; }
.ac-heat-tt-swatch.ac-heat-tt-l-4 { background: #ef4444; }

.ac-heat-tooltip {
  position: fixed; z-index: 10060; max-width: min(320px, calc(100vw - 16px));
  background: rgba(15,23,42,.95); color: #f8fafc; padding: 12px 14px; border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,.28); font-size: 12px; line-height: 1.4;
}
.ac-heat-tooltip.open { pointer-events: auto; }
.ac-heat-tip-title { font-weight: 800; margin-bottom: 2px; }
.ac-heat-tip-sub { font-size: 11px; color: #94a3b8; margin-bottom: 6px; }
.ac-heat-tip-val { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.ac-heat-tip-list-title { font-size: 11px; color: #cbd5e1; font-weight: 700; margin-bottom: 4px; }
.ac-heat-tip-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.ac-heat-tip-list li { padding: 6px 0; border-top: 1px solid rgba(148,163,184,.25); }
.ac-heat-tip-head { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.ac-heat-tip-head b { color: #fca5a5; }
.ac-heat-tip-orders { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ac-heat-tip-order {
  font-size: 10px; font-weight: 700; color: #fecaca;
  background: rgba(239,68,68,.18); border: 1px solid rgba(252,165,165,.35);
  padding: 2px 6px; border-radius: 6px;
}

/* Сравнение руководителей (направление 3) — мобильные карточки без цветовых подсветок */
.ac-ldr-report { display: flex; flex-direction: column; gap: 12px; }
.ac-ldr-banner {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-radius: 12px;
  background: #f1f5f9; border: 1px solid #e2e8f0;
}
.ac-ldr-banner-main { font-size: 13px; color: #0f172a; line-height: 1.35; }
.ac-ldr-banner-side { font-size: 12px; color: #334155; }
.ac-ldr-banner-sub { font-size: 11px; color: #64748b; margin-top: 2px; font-weight: 500; }
.ac-ldr-title { margin: 4px 0 0; font-size: 14px; font-weight: 800; color: #0f172a; }
.ac-ldr-cards, .ac-ldr-svc-list { display: flex; flex-direction: column; gap: 8px; }
.ac-ldr-card, .ac-ldr-svc-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px 12px;
}
.ac-ldr-card--me { border-color: #94a3b8; box-shadow: inset 3px 0 0 #64748b; }
.ac-ldr-card-top { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.ac-ldr-rank { flex: 0 0 auto; font-weight: 800; font-size: 13px; color: #475569; min-width: 2.2em; }
.ac-ldr-name { font-size: 13px; font-weight: 700; color: #0f172a; line-height: 1.3; }
.ac-ldr-name em { font-style: normal; font-size: 11px; color: #64748b; font-weight: 600; }
.ac-ldr-metrics {
  display: flex; flex-wrap: wrap; gap: 6px 10px;
  font-size: 12px; font-weight: 600; color: #334155;
}
.ac-ldr-svc-name { font-size: 13px; font-weight: 800; color: #0f172a; margin-bottom: 8px; }
.ac-ldr-svc-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
}
.ac-ldr-svc-cell {
  background: #f8fafc; border-radius: 8px; padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.ac-ldr-svc-lab { font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .02em; }
.ac-ldr-svc-num { font-size: 15px; font-weight: 800; color: #0f172a; }
.ac-ldr-svc-pct { font-size: 12px; font-weight: 600; color: #475569; }
.ac-ldr-svc-total {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #e2e8f0;
  font-size: 12px; font-weight: 700; color: #334155;
}
.ac-ldr-svc-card--total { background: #f8fafc; border-style: dashed; }
.ac-leader-create { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0 12px; }
.ac-account-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

body.ac-cabinet-on #panelStatistics.active #statisticsHeatPanel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
body.ac-cabinet-on #panelStatistics.active #acHeatWrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Мобильный чат: на всю высоту экрана */
:root {
  --ac-bottom-nav-h: calc(68px + env(safe-area-inset-bottom, 0px));
}

.ac-chat-footer {
  flex-shrink: 0;
  background: #fff;
  position: relative;
  z-index: 6;
  padding-top: 4px;
  border-top: 1px solid #e8eef2;
}

body.ac-cabinet-on {
  padding: 0;
  height: 100dvh;
  overflow: hidden;
}

body.ac-cabinet-on .wrap {
  max-width: none;
  height: 100%;
  display: flex;
  flex-direction: column;
  margin: 0;
}

body.ac-cabinet-on .ac-header-card {
  margin: 0;
  border-radius: 0;
  flex-shrink: 0;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-left: none;
  border-right: none;
  border-top: none;
}

body.ac-cabinet-on .ac-panel-card {
  flex: 1;
  min-height: 0;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 16px var(--ac-bottom-nav-h);
  overflow: hidden;
  border-left: none;
  border-right: none;
}

body.ac-cabinet-on #cabinetScreen.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.ac-cabinet-on .ac-panel.active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.ac-cabinet-on #panelCurators.active,
body.ac-cabinet-on #panelStatistics.active {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

body.ac-cabinet-on #panelStatistics.active .ac-stat-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
}

body.ac-cabinet-on #panelGlobal.active .ac-messages,
body.ac-cabinet-on #warehouseThreadView.active .ac-messages {
  flex: 1;
  min-height: 0;
  max-height: none;
}

body.ac-cabinet-on #panelGlobal.active .ac-chat-footer,
body.ac-cabinet-on #warehouseThreadView.active .ac-chat-footer {
  flex-shrink: 0;
}

body.ac-cabinet-on #warehouseThreadView.active > .ac-thread-toolbar,
body.ac-cabinet-on #warehouseThreadView.active > .ac-admin-tools {
  flex-shrink: 0;
}

body.ac-cabinet-on #panelGlobal.active,
body.ac-cabinet-on #panelWarehouses.active {
  display: flex;
  flex-direction: column;
}

body.ac-cabinet-on #warehouseListView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.ac-cabinet-on #warehouseListView.hidden-by-thread {
  display: none;
}

body.ac-cabinet-on #warehouseListView .ac-thread-list {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.ac-cabinet-on #warehouseThreadView.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

body.ac-thread-mode.ac-cabinet-on .ac-header-card {
  display: none;
}

body.ac-thread-mode.ac-cabinet-on .ac-panel-card {
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

body.ac-cabinet-on .ac-bottom-nav {
  max-width: 560px;
  margin: 0 auto;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--ac-kb-offset, 0);
  z-index: 40;
}

body.ac-input-focus.ac-cabinet-on .ac-chat-footer {
  margin-bottom: var(--ac-kb-offset, 0);
}

body.ac-thread-mode .ac-bottom-nav,
body.ac-courier-thread-mode .ac-bottom-nav {
  display: none;
}

body.ac-thread-mode .ac-panel-card,
body.ac-courier-thread-mode .ac-panel-card {
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.ac-messages {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.ac-compose textarea {
  font-size: 16px;
  resize: none;
}

.ac-msg-bubble {
  touch-action: manipulation;
}

.ac-msg-image {
  max-height: min(50vh, 420px);
  object-fit: contain;
}

@media (max-width: 640px) {
  body.ac-cabinet-on { padding: 0; }
  #panelGlobal .hint,
  #panelWarehouses .hint,
  #panelCouriers .hint,
  #panelStatistics .hint,
  #panelCurators .hint { display: none; }
  .ac-msg-bubble { max-width: 92%; font-size: 15px; }
  .ac-compose .btn {
    min-width: 48px;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 18px;
    line-height: 1;
  }
}

@media (min-width: 641px) {
  body.ac-cabinet-on .wrap {
    max-width: 560px;
    margin: 0 auto;
  }
  body.ac-cabinet-on {
    padding: 16px;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  body.ac-cabinet-on .ac-header-card,
  body.ac-cabinet-on .ac-panel-card {
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    border: 1px solid var(--border);
  }
  body.ac-cabinet-on .ac-bottom-nav {
    position: sticky;
    transform: none;
    left: auto;
    max-width: none;
    margin-top: 8px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
  }
}


.ac-direction-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.ac-direction-pill {
  border: 2px solid #e2e8f0; background: #fff; color: #0f172a; border-radius: 999px;
  padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 38px;
}
.ac-direction-pill.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }

.ac-direction-pills[hidden] { display: none !important; }

