/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #1d1f20;
  --bg-card:     #2c2d31;
  --bg-sidebar:  #1a1d21;
  --bg-hover:    #2a2d31;
  --border:      #373a3f;
  --border-input:#565859;
  --text:        #d1d2d3;
  --text-muted:  #9ea2a8;
  --text-white:  #f2f3f5;
  --accent:      #1164a3;
  --accent-h:    #1a73b8;
  --online:      #2bac76;
  --danger:      #e01e5a;
  --warn:        #e8912d;
  --radius:      6px;
  --radius-lg:   12px;
  --shadow:      0 4px 20px rgba(0,0,0,.5);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────────────── */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1d21, #2c1f4a);
}

.login-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 40px 36px; width: 380px; box-shadow: var(--shadow);
  animation: fadeUp .35s ease;
}

@keyframes fadeUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}

.login-logo {
  display: flex; align-items: center; gap: 12px; margin-bottom: 28px;
}

.admin-logo-img { width: 80px; height: 80px; object-fit: contain; flex-shrink: 0; }
.admin-logo-img.small { width: 40px; height: 40px; }

.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text-white); }
.login-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.back-link { text-align: center; margin-top: 16px; font-size: 13px; }

/* ── Fields ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .5px; }
.field input {
  padding: 10px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg);
  color: var(--text-white); font-size: 14px; outline: none; transition: border-color .2s;
}
.field input:focus { border-color: var(--accent); }

.form-error {
  background: rgba(224,30,90,.12); border: 1px solid var(--danger);
  border-radius: var(--radius); padding: 8px 12px;
  color: #ff6b8a; font-size: 13px; margin-bottom: 10px;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 9px 18px; border-radius: var(--radius);
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full { width: 100%; padding: 12px; margin-top: 4px; }

.btn-ghost {
  padding: 7px 14px; border-radius: var(--radius);
  background: transparent; color: var(--text-muted);
  border: 1.5px solid var(--border-input); font-size: 13px; cursor: pointer;
  transition: background .15s;
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm {
  padding: 4px 10px; border-radius: 4px; font-size: 12px;
  border: 1px solid var(--border-input); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s;
}
.btn-sm:hover { background: var(--bg-hover); color: var(--text-white); }
.btn-sm.danger { border-color: var(--danger); color: var(--danger); }
.btn-sm.danger:hover { background: rgba(224,30,90,.15); }
.btn-sm.success { border-color: var(--online); color: var(--online); }
.btn-sm.success:hover { background: rgba(43,172,118,.15); }

/* ── App Layout ──────────────────────────────────────────────────────── */
#admin-app {
  display: grid; grid-template-columns: 220px 1fr;
  height: 100vh; overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
#adm-sidebar {
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}

.adm-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.adm-brand strong { font-size: 15px; font-weight: 700; color: var(--text-white); display: block; }
.adm-label { font-size: 11px; color: var(--text-muted); }

.adm-nav { flex: 1; padding: 10px 8px; }
.adm-nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s; margin-bottom: 2px;
  text-decoration: none !important;
}
.adm-nav-item:hover { background: var(--bg-hover); color: var(--text); }
.adm-nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; }

.adm-footer {
  padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.adm-current-user { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.adm-footer-links { display: flex; align-items: center; justify-content: space-between; }
.adm-link { font-size: 12px; }
.adm-logout {
  background: transparent; border: none; color: var(--text-muted);
  font-size: 12px; cursor: pointer; padding: 2px; border-radius: 4px;
}
.adm-logout:hover { color: var(--danger); }

/* ── Main ────────────────────────────────────────────────────────────── */
#adm-main { overflow-y: auto; padding: 28px 32px; }
#adm-main::-webkit-scrollbar { width: 6px; }
#adm-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.adm-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.adm-page-header h1 { font-size: 22px; font-weight: 700; color: var(--text-white); }

/* ── Stats ───────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 20px 24px; border: 1px solid var(--border);
}
.stat-value { font-size: 36px; font-weight: 700; color: var(--text-white); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

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

.search-input {
  flex: 1; min-width: 200px; padding: 9px 14px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg-card);
  color: var(--text-white); font-size: 14px; outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }

.filter-select {
  padding: 9px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg-card);
  color: var(--text); font-size: 13px; outline: none; cursor: pointer;
}

/* ── Table ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border-radius: var(--radius-lg);
  overflow: hidden; border: 1px solid var(--border);
}

thead { background: rgba(255,255,255,.04); }
th {
  padding: 12px 16px; text-align: left; font-size: 11px;
  font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px; font-size: 13px; color: var(--text);
  border-bottom: 1px solid rgba(55,58,63,.5); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.025); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell-avatar {
  width: 32px; height: 32px; border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-cell-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-cell-name { font-weight: 600; color: var(--text-white); }
.user-cell-username { font-size: 12px; color: var(--text-muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge.admin   { background: rgba(17,100,163,.25); color: #36c5f0; }
.badge.user    { background: rgba(255,255,255,.08); color: var(--text-muted); }
.badge.active    { background: rgba(43,172,118,.2); color: #2bac76; }
.badge.suspended { background: rgba(224,30,90,.2);  color: #e01e5a; }
.badge.private   { background: rgba(155,89,182,.2); color: #9b59b6; font-size: 11px; }
.badge.draft     { background: rgba(236,178,46,.18); color: #ecb22e; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ── Private channel member management modal ─────────────────────────── */
.adm-member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.adm-member-row:last-child { border-bottom: none; }
.adm-member-row span:first-child { font-weight: 600; color: var(--text-primary); }
.adm-member-row span:nth-child(2) { flex: 1; }

.empty-state { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
#modal-box {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 28px; width: 440px; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: var(--shadow); animation: fadeUp .2s ease;
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-title { font-size: 19px; font-weight: 700; color: var(--text-white); margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.modal-field label { font-size: 12px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .5px; }
.modal-field input, .modal-field select {
  padding: 10px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg);
  color: var(--text-white); font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.modal-field input:focus, .modal-field select:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* ── Password reveal (in modal) ──────────────────────────────────────── */
.pw-reveal-box {
  background: var(--bg); border: 1.5px solid var(--online);
  border-radius: var(--radius); padding: 14px 16px; margin: 14px 0;
}
.pw-reveal-row { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; }
.pw-reveal-row span { font-size: 12px; color: var(--text-muted); }
.pw-reveal-row strong { font-size: 18px; letter-spacing: 2px; color: #2bac76; }
.pw-warn { font-size: 12px; color: var(--warn); margin-top: 6px; }

/* ── Call settings — video toggle row ─────────────────────────────────── */
.settings-row {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.settings-row-title { font-size: 16px; font-weight: 700; color: var(--text-white); margin-bottom: 4px; }
.settings-row-sub   { font-size: 13px; color: var(--text-muted); line-height: 1.45; max-width: 640px; }

/* Self Registration (Users section) */
.self-reg-panel { margin-bottom: 28px; }
.self-reg-head  { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.self-reg-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; }
.self-reg-status { font-size: 12px; font-weight: 600; color: #2ea043; opacity: 0; transition: opacity .2s; }
.self-reg-status.show { opacity: 1; }
.reg-domains-editor {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px;
}
.reg-domains-add { display: flex; gap: 8px; margin-bottom: 14px; }
.reg-domains-add .search-input { flex: 1; }
.reg-domains-list { display: flex; flex-wrap: wrap; gap: 8px; }
.reg-domain-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-hover); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 6px 6px 14px; font-size: 13px; color: var(--text-white);
}
.reg-domain-chip button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; }
.reg-domain-chip button:hover { color: #e5484d; }
.reg-domains-empty { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Customer Chat config pane (project editor) */
.cc-fields .modal-field { margin-bottom: 14px; }
.cc-fields label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.cc-fields input[type=text], .cc-fields input[type=password], .cc-fields textarea {
  width: 100%; box-sizing: border-box; padding: 9px 12px; font-size: 14px; font-family: inherit;
  border: 1.5px solid var(--border-input); border-radius: 8px; background: var(--bg); color: var(--text-white); outline: none;
}
.cc-fields textarea { resize: vertical; }
.cc-fields input:focus, .cc-fields textarea:focus { border-color: var(--accent); }
.cc-color { width: 56px; height: 38px; padding: 2px; cursor: pointer; }
.cc-secret-set { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.cc-embed {
  width: 100%; box-sizing: border-box; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
  padding: 10px 12px; border: 1.5px solid var(--border-input); border-radius: 8px;
  background: var(--bg); color: var(--text-white); resize: vertical;
}
.cc-block-add { display: flex; gap: 8px; margin-bottom: 10px; }
.cc-block-add select, .cc-block-add input {
  padding: 8px 10px; border: 1.5px solid var(--border-input); border-radius: 8px;
  background: var(--bg); color: var(--text-white); font-size: 13px;
}
.cc-block-add input { flex: 1; }
.cc-block-list { list-style: none; margin: 0; padding: 0; }
.cc-block-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cc-block-type { font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 72px; }
.cc-block-val { flex: 1; color: var(--text-primary); word-break: break-all; }
.cc-block-rm { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 13px; }
.cc-block-rm:hover { color: var(--danger); }

.settings-subhead {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .6px;
  margin: 8px 0 10px;
}

.toggle-switch {
  position: relative; display: inline-block; width: 50px; height: 28px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #565859; border-radius: 14px; transition: background .15s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 22px; height: 22px; background: #fff;
  border-radius: 50%; transition: transform .15s;
}
.toggle-switch input:checked + .toggle-slider { background: #2bac76; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ── Call settings — matting models ──────────────────────────────────── */
.section-intro {
  color: var(--text-muted); font-size: 14px; line-height: 1.5;
  margin-bottom: 20px; max-width: 720px;
}

.matting-model-card {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start;
  transition: border-color .15s;
}
.matting-model-card.active   { border-color: #2bac76; }
.matting-model-card.unavailable { opacity: .7; }

.mm-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mm-name   { font-size: 16px; font-weight: 700; color: var(--text-white); }
.mm-badge  {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .4px;
}
.mm-badge.active     { background: #2bac76; color: #fff; }
.mm-badge.missing    { background: #e01e5a; color: #fff; }

.mm-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; font-size: 12px; }
.mm-meta-item { color: var(--text-muted); }
.mm-meta-item strong { color: var(--text); font-weight: 600; }
.mm-meta-item.commercial-yes strong { color: #2bac76; }
.mm-meta-item.commercial-no  strong { color: #e01e5a; }

/* ── Shares (Loom-style async video) ──────────────────────────────────── */
.shares-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.shares-empty { color: var(--text-muted); font-size: 14px; padding: 8px 0; }
.share-card {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.share-card-main { flex: 1; min-width: 0; }
.share-card-title {
  display: block; color: var(--text-white); font-weight: 600; font-size: 15px;
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.share-card-title:hover { text-decoration: underline; }
.share-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.share-card-actions { display: flex; gap: 8px; flex-shrink: 0; }
.share-btn {
  padding: 7px 12px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border); color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.share-btn:hover { background: var(--bg-hover); border-color: var(--accent); }
.share-btn.danger { color: var(--danger); border-color: rgba(224,30,90,.4); }
.share-btn.danger:hover { background: rgba(224,30,90,.12); border-color: var(--danger); }
.shares-num-input {
  padding: 8px 10px; border-radius: var(--radius); border: 1.5px solid var(--border-input);
  background: var(--bg); color: var(--text-white); font-size: 14px; width: 90px;
}
.shares-save-status { font-size: 13px; font-weight: 600; }
@media (max-width: 768px) {
  .share-card { flex-direction: column; align-items: stretch; }
  .share-card-actions { justify-content: flex-end; }
}

.mm-pros, .mm-cons { font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
.mm-pros strong { color: #2bac76; }
.mm-cons strong { color: #ecb22e; }

.mm-instructions {
  background: var(--bg); border-left: 3px solid #ecb22e;
  padding: 10px 14px; border-radius: 4px; margin-top: 10px;
  font-size: 13px; color: var(--text);
}
.mm-instructions code {
  background: var(--bg-card); padding: 2px 6px; border-radius: 3px;
  font-family: monospace; font-size: 12px; word-break: break-all;
}
.mm-instructions a { color: var(--accent); text-decoration: none; }
.mm-instructions a:hover { text-decoration: underline; }

.mm-action {
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
.mm-action button {
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.mm-action button:hover:not(:disabled) { background: var(--accent-h); }
.mm-action button:disabled { background: var(--border); cursor: not-allowed; opacity: .6; }
.mm-action .current-label {
  font-size: 12px; color: #2bac76; font-weight: 600;
}

/* ── Storage settings ────────────────────────────────────────────────── */
.storage-provider-btns { display: flex; gap: 8px; flex-shrink: 0; }
.storage-opt {
  padding: 7px 18px; border-radius: 6px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.storage-opt:hover { border-color: var(--accent); color: var(--text-white); }
.storage-opt.active {
  background: var(--accent); border-color: var(--accent);
  color: #fff;
}
.storage-info-box {
  margin-top: 12px; padding: 12px 16px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; color: var(--text-muted);
  line-height: 1.5;
}
.storage-info-box code {
  background: rgba(255,255,255,.08); padding: 1px 5px; border-radius: 3px;
  font-family: monospace; font-size: 12px;
}
#storage-s3-form { margin-top: 16px; }
.s3-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 16px; }
.s3-actions { display: flex; gap: 10px; align-items: center; }
.field-hint { font-size: 11px; color: var(--text-muted); font-weight: 400; }

/* ── Reports — call logs ──────────────────────────────────────────────── */
.call-log {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px;
}
.call-log-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.call-log-head .call-type  { font-size: 16px; color: var(--text-muted); }
.call-log-head .call-label { font-size: 15px; font-weight: 700; color: var(--text-white); }
.call-log-head .call-live  { font-size: 11px; font-weight: 700; color: #2EB67D; }
.call-log-head .call-dur   { margin-left: auto; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.call-log-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
.call-log-meta b { color: var(--text-muted); font-weight: 600; margin-right: 4px; }
.call-timeline { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.call-timeline.tp-empty { color: var(--text-muted); font-size: 12px; font-style: italic; }
.tp-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.tp-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: 13px; }
.tp-time  { font-variant-numeric: tabular-nums; color: var(--text-muted); width: 96px; flex-shrink: 0; }
.tp-peers { color: var(--text-secondary); }
.tp-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 5px; min-width: 44px; text-align: center; }
.tp-badge.tp-p2p   { background: rgba(46,182,125,.16); color: #2EB67D; }
.tp-badge.tp-relay { background: rgba(236,178,46,.18); color: #ecb22e; }

/* ── Projects ─────────────────────────────────────────────────────────── */

/* Project list grid */
#proj-list-grid, #proj-archived-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

/* Archived projects — greyed section below the live list */
#proj-archived-section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.proj-archived-title { font-size: 14px; font-weight: 700; color: var(--text-muted); margin: 0 0 14px; }
.proj-card.archived { opacity: .6; }
.proj-card.archived:hover { opacity: .85; }

/* Project card */
.proj-card {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s;
}
.proj-card:hover { border-color: var(--accent); }

.proj-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.proj-card-name {
  font-size: 16px; font-weight: 700; color: var(--text-white);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-card-meta {
  display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.proj-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: auto; padding-top: 4px;
}

/* Form container (create + manage) */
.proj-form { max-width: 640px; }

/* Private toggle row within form */
.modal-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.modal-toggle-label {
  font-size: 14px; font-weight: 600; color: var(--text-white); margin-bottom: 3px;
}
.modal-toggle-sub { font-size: 12px; color: var(--text-muted); }

/* Column builder (create form) */
.col-builder { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.col-builder-row { display: flex; align-items: center; gap: 8px; }
.col-builder-input {
  flex: 1; padding: 9px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg);
  color: var(--text-white); font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.col-builder-input:focus { border-color: var(--accent); }

/* Manage panel — info block */
.proj-manage-meta {
  background: var(--bg-card); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 8px;
}
.proj-manage-info {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-muted); margin-top: 10px;
}
.proj-manage-info strong { color: var(--text-white); }

/* Manage panel — column list */
.pm-col-list  { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.pm-col-row   { display: flex; align-items: center; gap: 8px; }
.pm-col-name-input {
  flex: 1; padding: 8px 12px; border-radius: var(--radius);
  border: 1.5px solid var(--border-input); background: var(--bg);
  color: var(--text-white); font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .2s;
}
.pm-col-name-input:focus { border-color: var(--accent); }

/* ── Super admin & module badges ─────────────────────────────────────── */
.badge.sa-badge {
  background: rgba(236,178,46,.2); color: #ecb22e;
  border: 1px solid rgba(236,178,46,.35);
}
.badge.module-badge {
  background: rgba(54,197,240,.1); color: #36c5f0;
  border: 1px dashed rgba(54,197,240,.4);
  cursor: default;
}

/* Super admin row — subtle gold tint */
tr.sa-row td { background: rgba(236,178,46,.035); }
tr.sa-row:hover td { background: rgba(236,178,46,.07); }

/* Danger button (used in confirm modal) */
.btn-danger {
  padding: 9px 18px; border-radius: var(--radius);
  background: var(--danger); color: #fff; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: background .15s, transform .1s;
}
.btn-danger:hover { background: #c01a4f; }
.btn-danger:active { transform: scale(.98); }

/* Modules button */
.btn-sm.btn-modules {
  border-color: rgba(54,197,240,.5); color: #36c5f0;
}
.btn-sm.btn-modules:hover { background: rgba(54,197,240,.1); }

/* ── Module picker checklist (in modal) ──────────────────────────────── */
.modules-checklist {
  display: flex; flex-direction: column; gap: 2px;
  margin: 12px 0 16px;
  max-height: 340px; overflow-y: auto;
}
.module-check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; transition: background .12s;
  font-size: 14px; color: var(--text);
}
.module-check-row:hover { background: var(--bg-hover); }
.module-check-row input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer;
}
.module-check-row span { flex: 1; }

/* ── Confirm modal message ───────────────────────────────────────────── */
.modal-confirm-msg {
  font-size: 14px; color: var(--text); line-height: 1.5;
  margin-bottom: 20px;
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE  (≤ 768px) — chat-style drill-down: section menu → detail → back
   ══════════════════════════════════════════════════════════════════════ */
.adm-mobile-bar { display: none; }      /* shown only inside the media query */

@media (max-width: 768px) {
  /* Login card shouldn't overflow a small screen */
  .login-card { width: 100%; max-width: 92vw; }

  /* Single column: the sidebar is the full-screen "menu", main is the detail */
  #admin-app { display: block; height: 100dvh; overflow: visible; }

  /* ── Section menu (stacked blocks, like the chat list) ── */
  #adm-sidebar {
    position: fixed; inset: 0; width: 100%; z-index: 10; border-right: none;
    overflow-y: auto; -webkit-overflow-scrolling: touch;  /* full-screen menu scrolls (base is overflow:hidden) */
  }
  #adm-sidebar .adm-brand { padding-top: max(14px, env(safe-area-inset-top)); }
  .adm-nav { padding: 12px; display: flex; flex-direction: column; gap: 10px; flex: 0 0 auto; }
  .adm-nav-item {
    font-size: 16px; font-weight: 600; padding: 16px; margin-bottom: 0;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg-card); color: var(--text);
  }
  .adm-nav-item.active { background: var(--bg-card); color: var(--text); } /* no sticky highlight on mobile */
  .adm-nav-item:active { background: var(--bg-hover); }
  .adm-nav-item .nav-icon { font-size: 20px; width: 28px; text-align: center; }

  /* ── Menu footer — full-width tappable actions, clear of the home bar ── */
  .adm-footer { padding: 14px 16px max(16px, env(safe-area-inset-bottom)); }
  .adm-current-user { font-size: 13px; text-align: center; margin-bottom: 12px; }
  .adm-footer-links { gap: 10px; }
  .adm-footer-links .adm-link,
  .adm-footer-links .adm-logout {
    flex: 1 1 0; display: flex; align-items: center; justify-content: center;
    min-height: 48px; padding: 0 14px; border-radius: 12px;
    font-size: 15px; font-weight: 600; border: 1px solid var(--border);
    -webkit-tap-highlight-color: transparent;
  }
  .adm-footer-links .adm-link {
    background: var(--bg-card); color: var(--text); text-decoration: none !important;
  }
  .adm-footer-links .adm-link:active { background: var(--bg-hover); }
  .adm-footer-links .adm-logout { background: transparent; color: var(--danger); }
  .adm-footer-links .adm-logout:active { background: rgba(224,30,90,.12); }

  /* ── Detail view (a section opened) ── */
  #adm-main { display: none; }
  #admin-app.mobile-section-open #adm-sidebar { display: none; }
  #admin-app.mobile-section-open #adm-main {
    display: block; position: fixed; inset: 0; z-index: 20;
    padding: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }

  /* ── Mobile back bar (sticky at the top of the detail view) ── */
  .adm-mobile-bar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 5;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
    background: var(--bg-sidebar); border-bottom: 1px solid var(--border);
  }
  .adm-back-btn {
    background: transparent; border: none; color: var(--text);
    cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex;
  }
  .adm-back-btn:active { background: var(--bg-hover); }
  #adm-mobile-title { font-size: 17px; font-weight: 700; color: var(--text-white); }

  /* Section content padding + hide the redundant page title (shown in the bar) */
  .adm-section { padding: 16px; }
  .adm-page-header h1 { display: none; }
  .adm-page-header { justify-content: flex-end; margin-bottom: 16px; }

  /* Stats two-up; settings + toolbar stack; card grids single-column */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .settings-row { flex-direction: column; align-items: stretch; gap: 14px; }
  .settings-row-sub { max-width: none; }
  .toolbar { flex-direction: column; gap: 8px; }
  .toolbar > * { width: 100%; }
  .matting-model-card { grid-template-columns: 1fr; }
  .s3-fields { grid-template-columns: 1fr; }

  /* ── Tables → stacked cards ── */
  .table-wrap { overflow-x: visible; }
  .adm-section table { border: none; background: transparent; }
  .adm-section table thead { display: none; }
  .adm-section table,
  .adm-section table tbody,
  .adm-section table tr,
  .adm-section table td { display: block; }
  .adm-section table tr {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 12px; padding: 14px;
  }
  .adm-section table td { border: none !important; padding: 5px 0; }
  .adm-section table td:empty { display: none; }
  .adm-section table td[data-label]::before {
    content: attr(data-label); display: block;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted); margin-bottom: 2px;
  }
  /* Card title (first cell): prominent, divider underneath, no label */
  .adm-section table td.card-title-cell {
    padding-bottom: 12px; margin-bottom: 8px; font-size: 15px;
    border-bottom: 1px solid var(--border) !important;
  }
  /* Actions: label on its own line, buttons wrap ~2-up with comfy tap size */
  .adm-section table td.actions-cell {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 8px; padding-top: 12px;
    border-top: 1px solid var(--border) !important;
  }
  .adm-section table td.actions-cell::before { flex-basis: 100%; }
  .adm-section table td.actions-cell .btn-sm {
    flex: 1 1 auto; min-width: calc(50% - 4px); padding: 11px 10px; font-size: 13px;
  }
  tr.sa-row td { background: transparent; } /* don't tint each card cell */

  /* ── Modal → bottom sheet ── */
  #modal-overlay { align-items: flex-end; }
  #modal-box {
    width: 100%; max-width: 100%; border-radius: 16px 16px 0 0;
    max-height: 92vh; padding: 22px 18px max(18px, env(safe-area-inset-bottom));
  }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn-primary, .modal-actions .btn-ghost { flex: 1 1 auto; }
}
