/* ═══════════════════════════════════════════════════════
   ADMIN CONSOLE
   ═══════════════════════════════════════════════════════ */
.admin-root {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: #f4f7f5; font-family: var(--font-body);
}
.admin-root.active { display: flex; flex-direction: column; }
body.admin-open { overflow: hidden; }

.admin-topbar {
  height: 58px; background: #0f2a18; display: flex; align-items: center;
  gap: 14px; padding: 0 18px; flex-shrink: 0; color: #fff;
}
.admin-brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 800; font-size: 1rem; }
.admin-brand-icon { width: 28px; height: 28px; border-radius: 7px; background: var(--green-600); display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 800; }
.admin-brand small { display: block; font-size: .68rem; font-weight: 500; color: rgba(255,255,255,.5); letter-spacing: .04em; text-transform: uppercase; }
.admin-stats { display: flex; gap: 8px; margin-left: 18px; }
.admin-stat {
  background: rgba(255,255,255,.08); border-radius: 8px; padding: 5px 12px; text-align: center; min-width: 62px;
}
.admin-stat-val { font-family: var(--font-display); font-size: .95rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.admin-stat-lbl { font-size: .6rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.5); }
.admin-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.team-toggle {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12); border-radius: 100px; padding: 5px 12px 5px 10px;
  cursor: pointer; font-size: .8rem; font-weight: 600; color: #fff; transition: background .15s;
}
.team-toggle:hover { background: rgba(255,255,255,.16); }
.team-toggle-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; }
.team-toggle.online .team-toggle-dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.admin-exit {
  background: rgba(255,255,255,.1); border: none; color: #fff; border-radius: 8px;
  padding: 7px 14px; font-family: var(--font-display); font-size: .8rem; font-weight: 600; cursor: pointer; transition: background .15s;
}
.admin-exit:hover { background: rgba(255,255,255,.2); }

.admin-body { flex: 1; display: grid; grid-template-columns: 320px 1fr; min-height: 0; }

/* conversation list */
.admin-list { background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.admin-list-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.admin-search {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-size: .85rem; font-family: var(--font-body); outline: none; color: var(--text-1);
}
.admin-search:focus { border-color: var(--green-600); }
.admin-filters { display: flex; gap: 6px; margin-top: 10px; }
.admin-filter {
  flex: 1; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--bg-alt);
  font-size: .74rem; font-weight: 600; color: var(--text-2); cursor: pointer; font-family: var(--font-display); transition: all .15s;
}
.admin-filter:hover { border-color: var(--green-600); }
.admin-filter.active { background: var(--green-600); color: #fff; border-color: var(--green-600); }
.admin-convos { flex: 1; overflow-y: auto; }
.convo-item {
  padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  display: flex; gap: 11px; transition: background .13s; position: relative;
}
.convo-item:hover { background: var(--bg-alt); }
.convo-item.active { background: var(--green-50); box-shadow: inset 3px 0 0 var(--green-600); }
.convo-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: .8rem; font-weight: 800;
}
.convo-main { flex: 1; min-width: 0; }
.convo-top { display: flex; align-items: baseline; gap: 8px; }
.convo-name { font-family: var(--font-display); font-size: .87rem; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-time { font-size: .68rem; color: var(--text-3); margin-left: auto; flex-shrink: 0; }
.convo-preview { font-size: .78rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.convo-tags { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.convo-pill { font-size: .65rem; font-weight: 700; padding: 2px 8px; border-radius: 100px; text-transform: uppercase; letter-spacing: .04em; }
.pill-open { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-100); }
.pill-pending { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.pill-closed { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.convo-topic { font-size: .68rem; color: var(--text-3); }
.convo-unread {
  min-width: 19px; height: 19px; padding: 0 5px; background: #ef4444; color: #fff;
  border-radius: 100px; font-size: .66rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; align-self: center; flex-shrink: 0;
}
.admin-empty-list { padding: 46px 24px; text-align: center; color: var(--text-3); font-size: .85rem; line-height: 1.7; }

/* thread pane */
.admin-thread { display: flex; flex-direction: column; min-height: 0; background: #f4f7f5; }
.thread-head {
  background: #fff; border-bottom: 1px solid var(--border); padding: 12px 20px;
  display: flex; align-items: center; gap: 12px; flex-shrink: 0; flex-wrap: wrap;
}
.thread-title { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--text-1); }
.thread-sub { font-size: .76rem; color: var(--text-3); margin-top: 1px; }
.thread-controls { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.thread-select {
  padding: 6px 10px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff;
  font-size: .78rem; font-weight: 600; font-family: var(--font-display); color: var(--text-2); cursor: pointer; outline: none;
}
.thread-select:focus { border-color: var(--green-600); }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-2); transition: all .15s;
}
.icon-btn:hover { border-color: var(--green-600); color: var(--green-700); background: var(--green-50); }
.icon-btn.danger:hover { border-color: #ef4444; color: #dc2626; background: #fef2f2; }

.thread-scroll { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.amsg { display: flex; flex-direction: column; gap: 3px; max-width: 68%; }
.amsg.user { align-self: flex-start; }
.amsg.admin { align-self: flex-end; }
.amsg-bubble { padding: 11px 15px; font-size: .88rem; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); }
.amsg.user .amsg-bubble { background: #fff; border: 1px solid var(--border); color: var(--text-1); border-radius: 4px 15px 15px 15px; }
.amsg.admin .amsg-bubble { background: var(--green-600); color: #fff; border-radius: 15px 4px 15px 15px; }
.amsg-meta { font-size: .68rem; color: var(--text-3); }
.amsg.admin .amsg-meta { text-align: right; }
.amsg-system { align-self: center; font-size: .74rem; color: var(--text-3); background: #e8ede9; border-radius: 100px; padding: 5px 15px; }

.thread-composer { background: #fff; border-top: 1px solid var(--border); padding: 12px 20px 16px; flex-shrink: 0; }
.canned-row { display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; }
.canned-btn {
  padding: 5px 12px; border-radius: 100px; border: 1px solid var(--border); background: var(--bg-alt);
  font-size: .75rem; font-weight: 600; color: var(--text-2); cursor: pointer; font-family: var(--font-display); transition: all .15s;
}
.canned-btn:hover { background: var(--green-50); border-color: var(--green-600); color: var(--green-700); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer-input {
  flex: 1; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font-family: var(--font-body); font-size: .89rem; color: var(--text-1); outline: none;
  resize: none; line-height: 1.5; max-height: 132px; transition: border-color .15s;
}
.composer-input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(34,197,94,.1); }
.composer-input:disabled { background: var(--bg-alt); cursor: not-allowed; }
.composer-send {
  padding: 11px 22px; border-radius: 12px; border: none; background: var(--green-600); color: #fff;
  font-family: var(--font-display); font-size: .88rem; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 7px; transition: background .15s;
}
.composer-send:hover:not(:disabled) { background: var(--green-700); }
.composer-send:disabled { background: var(--border-md); cursor: not-allowed; }
.composer-hint { font-size: .72rem; color: var(--text-3); margin-top: 7px; }

.admin-blank {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--text-3); text-align: center; padding: 40px;
}
.admin-blank-icon { width: 60px; height: 60px; border-radius: 16px; background: #e8ede9; display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.admin-blank h3 { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; color: var(--text-2); }
.admin-blank p { font-size: .87rem; max-width: 320px; line-height: 1.65; }

/* gate */
.admin-gate { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.gate-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 38px 34px; max-width: 380px; width: 100%; box-shadow: var(--shadow-lg); text-align: center;
}
.gate-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--green-50); border: 1px solid var(--green-100); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; color: var(--green-600); }
.gate-card h2 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; color: var(--text-1); margin-bottom: 6px; }
.gate-card p { font-size: .86rem; color: var(--text-3); margin-bottom: 22px; line-height: 1.6; }
.gate-error { color: #dc2626; font-size: .8rem; margin-top: 10px; min-height: 18px; font-weight: 500; }

.admin-banner {
  padding: 9px 18px; font-size: .8rem; font-weight: 500; display: flex; align-items: center; gap: 9px; flex-shrink: 0;
}
.admin-banner.warn { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }

@media (max-width: 860px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-list { display: none; }
  .admin-list.mobile-visible { display: flex; }
  .admin-thread.mobile-hidden { display: none; }
  .admin-stats { display: none; }
  .thread-back { display: flex !important; }
}
.thread-back { display: none; }

/* ── settings modal ──────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 10050;
  background: rgba(8,26,15,.55); align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop.open { display: flex; animation: fadeIn .18s ease; }
.modal-card {
  background: #fff; border-radius: var(--r-xl); width: 100%; max-width: 440px;
  box-shadow: var(--shadow-xl); max-height: 88vh; overflow-y: auto; padding: 24px 26px 26px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; color: var(--text-1); }
.modal-section h4 { font-family: var(--font-display); font-size: .9rem; font-weight: 700; color: var(--text-1); margin-bottom: 5px; }
.modal-note { font-size: .78rem; color: var(--text-3); line-height: 1.6; margin-bottom: 12px; }
.modal-msg { font-size: .79rem; margin-top: 9px; min-height: 17px; font-weight: 500; }
.modal-msg.ok { color: var(--green-700); }
.modal-msg.bad { color: #dc2626; }

/* ── attachments ─────────────────────────────────────── */
.attach-btn {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.65); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.attach-btn:hover:not(:disabled) { background: rgba(255,255,255,.14); color: #fff; border-color: #2d9e5f; }
.attach-btn:disabled { opacity: .4; cursor: not-allowed; }
.attach-btn.light {
  border-color: var(--border); background: #fff; color: var(--text-2);
}
.attach-btn.light:hover:not(:disabled) { border-color: var(--green-600); color: var(--green-700); background: var(--green-50); }

.attach-tray { display: none; gap: 8px; flex-wrap: wrap; padding: 9px 11px 0; }
.attach-tray.has-items { display: flex; }
.attach-chip {
  display: flex; align-items: center; gap: 8px; position: relative;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.13);
  border-radius: 10px; padding: 6px 30px 6px 8px; max-width: 190px;
}
.attach-chip.light { background: var(--bg-alt); border-color: var(--border); }
.attach-thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; flex-shrink: 0; display: block; }
.attach-fileicon {
  width: 32px; height: 32px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(45,158,95,.2); color: #4ade80; font-size: .58rem; font-weight: 800; letter-spacing: .02em;
}
.attach-chip.light .attach-fileicon { background: var(--green-50); color: var(--green-700); }
.attach-meta { min-width: 0; }
.attach-name {
  font-size: .74rem; font-weight: 600; color: #e8f5ec;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px;
}
.attach-chip.light .attach-name { color: var(--text-1); }
.attach-size { font-size: .66rem; color: rgba(255,255,255,.45); }
.attach-chip.light .attach-size { color: var(--text-3); }
.attach-remove {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 50%; border: none; cursor: pointer; line-height: 1;
  background: rgba(0,0,0,.4); color: #fff; font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
}
.attach-remove:hover { background: #dc2626; }
.attach-chip.light .attach-remove { background: rgba(0,0,0,.25); }

.attach-error {
  padding: 7px 12px; margin: 8px 11px 0; border-radius: 9px;
  background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5; font-size: .74rem; line-height: 1.5;
}
.attach-error.light { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* attachments inside a message bubble */
.msg-files { display: flex; flex-direction: column; gap: 6px; }
.msg-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.msg-images.single { grid-template-columns: 1fr; }
.msg-img {
  width: 100%; border-radius: 10px; cursor: zoom-in; display: block;
  object-fit: cover; max-height: 240px; background: rgba(0,0,0,.2);
}
.msg-images.single .msg-img { max-height: 300px; object-fit: contain; }
.file-chip {
  display: flex; align-items: center; gap: 9px; text-align: left; width: 100%;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; transition: background .15s;
  font-family: var(--font-body);
}
.file-chip:hover { background: rgba(255,255,255,.18); }
.chat-msg.me .file-chip { background: rgba(0,0,0,.18); border-color: rgba(255,255,255,.2); }
.chat-msg.me .file-chip:hover { background: rgba(0,0,0,.28); }
.amsg .file-chip { background: var(--bg-alt); border-color: var(--border); }
.amsg .file-chip:hover { background: var(--green-50); border-color: var(--green-600); }
.amsg.admin .file-chip { background: rgba(0,0,0,.14); border-color: rgba(255,255,255,.22); }
.amsg.admin .file-chip:hover { background: rgba(0,0,0,.22); }
.file-chip-name { font-size: .78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-sub { font-size: .68rem; opacity: .7; }
.file-chip-body { min-width: 0; flex: 1; }

/* drop target */
.drop-active { outline: 2px dashed #2d9e5f; outline-offset: -6px; }
.drop-hint {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 8px;
  background: rgba(13,26,16,.92); color: #4ade80;
  font-family: var(--font-display); font-weight: 700; font-size: .95rem; pointer-events: none;
}
.drop-hint.show { display: flex; }
.drop-hint small { font-weight: 500; color: rgba(255,255,255,.5); font-family: var(--font-body); font-size: .76rem; }

/* lightbox */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 10100;
  background: rgba(6,16,10,.93); align-items: center; justify-content: center; padding: 32px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 84vh; border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.lightbox-bar {
  position: absolute; top: 18px; left: 0; right: 0; padding: 0 22px;
  display: flex; align-items: center; gap: 12px; color: #fff;
}
.lightbox-title { font-size: .86rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-btn {
  margin-left: auto; background: rgba(255,255,255,.14); border: none; color: #fff;
  border-radius: 9px; padding: 8px 15px; font-family: var(--font-display);
  font-size: .82rem; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.lightbox-btn:hover { background: rgba(255,255,255,.26); }
.lightbox-close { margin-left: 8px; }

/* storage meter */
.storage-bar { height: 6px; border-radius: 100px; background: var(--border); overflow: hidden; margin: 8px 0 6px; }
.storage-fill { height: 100%; background: var(--green-600); transition: width .3s ease; }
.storage-fill.warn { background: #f59e0b; }
.storage-fill.full { background: #dc2626; }
