/* Admin app shell: top bar + left app rail (bottom bar on phones), Teams-like */
:root {
  --top-bg: #ebebeb; --top-line: #d6d6d6; --top-hover: #dcdcdc; --rail-bg: #fafafa; --rail-line: #e3e3e3; --rail-hover: #efeff6;
  --faint: #8a8a8a; --hover-bg: #f0f0f0; --row-hover: #f5f5f5; --thead-bg: #fafafa; --cell-line: #f0f0f0; --chip-bg: #f0f0f0;
  --dash: #c7c7c7; --well: #fafafa; --login-grad: linear-gradient(135deg, #e8ebfa 0%, #f5f5f5 55%);
  --ok-bg: #e7f4ea; --ok-ink: #0e5c0e; --warn-bg: #fff4ce; --warn-ink: #6b4f00; --ok: #107c10; --bad: #c4314b; --bad-bg: #fde7e9;
}
[data-bs-theme="dark"] {
  --top-bg: #202024; --top-line: #323238; --top-hover: #2e2e35; --rail-bg: #202024; --rail-line: #323238; --rail-hover: #2b2b33;
  --faint: #8f8f96; --hover-bg: #30303a; --row-hover: #2b2b32; --thead-bg: #2a2a30; --cell-line: #33333a; --chip-bg: #33333a;
  --dash: #4a4a52; --well: #222227; --login-grad: linear-gradient(135deg, #26274d 0%, #1b1b1f 60%);
  --ok-bg: rgba(108,203,95,.14); --ok-ink: #8fdc82; --warn-bg: rgba(255,200,61,.14); --warn-ink: #ffd166; --ok: #6ccb5f;
  --bad: #f1707b; --bad-bg: rgba(241,112,123,.15);
}
body.admin { background: var(--canvas); color: var(--ink); min-height: 100vh; }
.app-top { position: fixed; inset: 0 0 auto 0; height: 48px; background: var(--top-bg); border-bottom: 1px solid var(--top-line);
  display: flex; align-items: center; gap: .75rem; padding: 0 .75rem 0 .6rem; z-index: 1030; }
.app-top .app-name { font-weight: 600; font-size: .95rem; white-space: nowrap; }
.app-top .app-name small { font-weight: 400; color: var(--muted); }
.app-top .spacer { flex: 1; }
.app-top .top-btn { border: 0; background: transparent; color: var(--ink-2); padding: .3rem .6rem; border-radius: 4px; font-size: .875rem; }
.app-top .top-btn:hover { background: var(--top-hover); color: var(--ink); }
.app-top .top-btn { display: inline-flex; align-items: center; gap: .35rem; transition: background-color .15s, color .15s; }
.theme-toggle i { font-size: 1rem; transition: transform .3s ease; }
.theme-toggle:hover i { transform: rotate(-20deg); }
.user-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-pressed); font-weight: 600;
  display: grid; place-items: center; border: 0; transition: box-shadow .15s; }
.user-dot:hover { box-shadow: 0 0 0 3px var(--brand-soft); }
/* sidebar: icon + name + hint on desktop, icon rail on medium screens, bottom bar on phones */
.app-rail { position: fixed; top: 48px; bottom: 0; left: 0; width: 232px; background: var(--rail-bg); border-right: 1px solid var(--rail-line);
  display: flex; flex-direction: column; gap: 2px; padding: .9rem .6rem; z-index: 1020; overflow-y: auto; }
.rail-section { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 .7rem .4rem; }
.rail-item { position: relative; display: flex; align-items: center; gap: .75rem; padding: .55rem .7rem; border-radius: 6px;
  color: var(--ink-2); text-decoration: none; line-height: 1.2; transition: background .12s, color .12s; }
.rail-item i { font-size: 1.15rem; width: 1.3rem; text-align: center; color: var(--muted); flex: none; }
.rail-text { display: flex; flex-direction: column; min-width: 0; }
.rail-label { font-size: .9rem; font-weight: 600; }
.rail-hint { font-size: .72rem; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-item:hover { background: var(--rail-hover); color: var(--ink); } .rail-item:hover i { color: var(--brand); }
.rail-item.active { background: var(--brand-soft); color: var(--brand-pressed); }
.rail-item.active i, .rail-item.active .rail-hint { color: var(--brand); }
.rail-item.active::before { content: ""; position: absolute; left: -.6rem; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.rail-foot { margin-top: auto; border-top: 1px solid var(--rail-line); padding-top: .6rem; }
.app-main { margin: 48px 0 0 232px; min-height: calc(100vh - 48px); }
.page { max-width: 1760px; margin: 0 auto; padding: 1.6rem 2.2rem 3rem; animation: page-in .22s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (min-width: 768px) and (max-width: 1199.98px) {
  .app-rail { width: 76px; padding: .6rem .35rem; }
  .rail-section, .rail-hint { display: none; }
  .rail-item { flex-direction: column; gap: 3px; padding: .55rem 0 .5rem; text-align: center; }
  .rail-item i { font-size: 1.3rem; width: auto; }
  .rail-label { font-size: .66rem; font-weight: 600; }
  .rail-item.active::before { left: -.35rem; }
  .app-main { margin-left: 76px; } .page { padding: 1.4rem 1.5rem 3rem; }
}
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.4rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.card { border: 0; border-radius: 10px; box-shadow: var(--shadow); background: var(--surface); color: var(--ink); }
.card-body { padding: 1.15rem 1.25rem; }
.card-title-sm { font-size: .95rem; font-weight: 600; margin-bottom: .75rem; display: flex; align-items: center; gap: .45rem; }
.card-title-sm i { color: var(--brand); }
.review-toggle { width: 100%; background: none; border: 0; padding: 0; margin-bottom: 0; color: inherit; text-align: left; cursor: pointer; }
.review-toggle .review-chevron { transition: transform .2s; color: var(--bs-secondary-color); }
.review-toggle[aria-expanded="true"] .review-chevron { transform: rotate(180deg); }
.table { --bs-table-hover-bg: var(--row-hover); --bs-table-bg: transparent; margin: 0; }
.table tbody tr { transition: background-color .12s; }
.table thead th { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: none; border-bottom: 1px solid var(--line);
  background: var(--thead-bg); padding-top: .6rem; padding-bottom: .6rem; }
.table td { border-color: var(--cell-line); padding-top: .7rem; padding-bottom: .7rem; }
.doc-icon { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; font-size: 1.1rem; flex: none; }
.doc-icon.pdf { background: #fde7e9; color: #c4314b; } .doc-icon.docx { background: #e5eefb; color: #185abd; }
.doc-icon.csv { background: #e7f4ea; color: #107c41; } .doc-icon.md, .doc-icon.txt { background: var(--chip-bg); color: var(--muted); }
[data-bs-theme="dark"] .doc-icon.pdf { background: rgba(241,112,123,.15); color: #f1707b; }
[data-bs-theme="dark"] .doc-icon.docx { background: rgba(98,153,240,.16); color: #82adf5; }
[data-bs-theme="dark"] .doc-icon.csv { background: rgba(108,203,95,.14); color: #8fdc82; }
.doc-icon.faq { background: var(--brand-soft); color: var(--brand); }
.status-dot { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; font-weight: 600; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-ready { color: var(--ok); } .st-processing, .st-queued { color: var(--brand-light); } .st-failed { color: var(--bad); }
.icon-btn { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 6px; color: var(--ink-2); display: inline-grid; place-items: center;
  transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--hover-bg); color: var(--brand-light); } .icon-btn.danger:hover { color: var(--bad); background: var(--bad-bg); }
.dropzone { border: 1.5px dashed var(--dash); border-radius: 10px; padding: 1.6rem 1rem; text-align: center; color: var(--muted);
  cursor: pointer; transition: border-color .15s, background-color .15s, color .15s; background: var(--well); display: block; }
.dropzone i { transition: transform .2s ease; } .dropzone:hover i, .dropzone.over i { transform: translateY(-2px); }
.dropzone i { font-size: 1.9rem; color: var(--brand); display: block; margin-bottom: .2rem; }
.dropzone:hover, .dropzone.over, .dropzone:focus { border-color: var(--brand); background: var(--brand-soft); color: var(--ink); outline: none; }
.chunk-text { white-space: pre-wrap; font-size: .9rem; color: var(--ink-2); }
.stat { padding: .9rem 1rem; } .stat .label { font-size: .78rem; color: var(--muted); } .stat .value { font-size: 1.35rem; font-weight: 700; }
.timing-chip { display: inline-flex; gap: .3rem; align-items: baseline; padding: .25rem .65rem; border-radius: 1rem; background: var(--surface);
  box-shadow: var(--shadow); font-size: .82rem; color: var(--muted); } .timing-chip b { color: var(--ink); }
.timing-chip.total { background: var(--brand); color: #e8ebfa; } .timing-chip.total b { color: #fff; }
.verdict { display: flex; gap: .6rem; align-items: center; padding: .7rem 1rem; border-radius: var(--radius); font-size: .92rem; }
.verdict.ok { background: var(--ok-bg); color: var(--ok-ink); } .verdict.no { background: var(--warn-bg); color: var(--warn-ink); }
.hit-card { border-left: 3px solid var(--brand) !important; } .hit-card.dim { opacity: .55; border-left-color: var(--dash) !important; }
.score-pill { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 1rem; background: var(--brand-soft); color: var(--brand-pressed); }
.score-pill.low { background: var(--chip-bg); color: var(--muted); }
.voice-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 6px; cursor: pointer; }
.voice-item:hover { background: var(--row-hover); } .voice-item.active { background: var(--brand-soft); }
.engine-option { border: 1.5px solid var(--line); border-radius: 10px; padding: .75rem .9rem; cursor: pointer; height: 100%; display: block;
  transition: border-color .15s, background-color .15s, box-shadow .15s; }
.engine-option:hover { border-color: var(--dash); box-shadow: var(--shadow); } .engine-option.active { border-color: var(--brand); background: var(--brand-soft); }
.engine-option .title { font-weight: 600; } .engine-option small { color: var(--muted); }
.turn { border-left: 3px solid var(--line); padding-left: .9rem; }
.bubble-q { font-weight: 600; } .bubble-a { color: var(--ink-2); }
.meta-chips span { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 1rem; background: var(--chip-bg); color: var(--muted); margin: .15rem .25rem 0 0; }
.meta-chips b { color: var(--ink); font-weight: 600; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--login-grad); padding: 1rem; }
.login-card { width: min(400px, 100%); animation: page-in .3s ease-out; border-radius: 14px; }
@media (max-width: 767.98px) {
  .app-rail { top: auto; bottom: 0; width: 100%; height: 58px; flex-direction: row; justify-content: space-around; padding: 0;
    border-right: 0; border-top: 1px solid var(--top-line); overflow: hidden; }
  .rail-section, .rail-hint, .rail-foot { display: none; }
  .rail-item { flex: 1; flex-direction: column; gap: 2px; padding: .45rem 0; border-radius: 0; text-align: center; }
  .rail-item i { font-size: 1.2rem; width: auto; } .rail-label { font-size: .64rem; }
  .rail-item.active::before { left: 25%; right: 25%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .app-main { margin: 48px 0 58px 0; } .page { padding: 1rem .9rem 2rem; }
  .app-top .hide-sm { display: none; }
}
.provider-option { cursor: pointer; }
.provider-option .title { font-weight: 700; font-size: 1.02rem; }
.trace summary { cursor: pointer; }
.trace-body { margin-top: .35rem; padding: .5rem .75rem; border-radius: var(--radius); background: var(--brand-soft); display: grid; gap: .25rem; }
.trace-body > div > span:first-child { display: inline-block; min-width: 6.5rem; color: var(--muted); }

/* ---------- avatar page: steps, crop tool, previews, Anam status */
.step-no { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 700; margin-right: .3rem; }
.tips-box { background: var(--brand-soft); color: var(--ink); }
.photo-checks { list-style: none; padding: 0; }
.photo-checks li { margin: .15rem 0; }
.crop-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.crop-canvas { width: 360px; height: 360px; max-width: 100%; border-radius: 6px; background: #222; cursor: grab; touch-action: none; display: block; }
.crop-canvas:active { cursor: grabbing; }
.previews { flex: 1; min-width: 220px; }
.pv-img { width: 100%; height: 100%; background: #333 center / cover no-repeat; }
.pv-land { position: relative; width: 100%; max-width: 330px; aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; background: #222; }
.pv-plate { position: absolute; left: 6px; bottom: 6px; font-size: .7rem; color: #fff; background: rgba(0,0,0,.55); padding: .1rem .4rem; border-radius: 4px; }
.pv-phone { width: 130px; aspect-ratio: 2 / 3; border-radius: 14px; overflow: hidden; border: 4px solid #1b1b1b; background: #222; }
.created-land { width: 180px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; background: #222; }
.created-port { width: 80px; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px; background: #222; }
.status-list { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; }
.status-list dt { font-weight: 600; color: var(--bs-secondary-color); }
.status-list dd { margin: 0; word-break: break-all; }
.history-list { display: flex; flex-direction: column; gap: .5rem; }
.history-item { display: flex; gap: .6rem; align-items: center; padding: .35rem; margin: -.35rem; border-radius: 8px; transition: background-color .15s; }
.history-item:hover { background: var(--row-hover); }
.history-item img { width: 64px; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; background: #222; }
.history-item .grow { flex: 1; min-width: 0; }
.test-video { border-radius: 6px; overflow: hidden; background: #111; margin-bottom: .5rem; }
.test-video video { width: 100%; display: block; aspect-ratio: 3 / 2; object-fit: cover; }

/* "what calls use right now" + options that are not in use */
.in-use { border-left: 3px solid var(--brand) !important; }
.in-use-row { font-size: .82rem; margin: .15rem 0; }
.in-use-row .badge { margin-right: .35rem; }
.not-used { opacity: .5; filter: grayscale(1); }
.not-used, .not-used * { cursor: not-allowed !important; }
.not-used-note { font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); }
.backup-only { border-style: dashed !important; }

/* Avatar voice picker */
.voice-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--bs-border-color); border-radius: 6px; }
.voice-row { display: flex; align-items: center; gap: .6rem; padding: .45rem .6rem; border-bottom: 1px solid var(--bs-border-color); cursor: pointer; margin: 0;
  transition: background-color .12s; }
.voice-row:has(input:checked) { background: var(--brand-soft); }
.voice-row:last-child { border-bottom: 0; }
.voice-row:hover { background: var(--bs-tertiary-bg); }
.voice-row .voice-name { font-weight: 600; font-size: .875rem; }
.voice-row .voice-meta { font-size: .75rem; color: var(--bs-secondary-color); }
.voice-row audio { height: 28px; max-width: 170px; margin-left: auto; }
.clone-box { border-top: 1px dashed var(--bs-border-color); padding-top: .75rem; }

/* long badges (unsupported claims, sources, timings) wrap instead of making the page scroll sideways on phones */
.card .badge { white-space: normal; text-align: left; overflow-wrap: anywhere; max-width: 100%; }

/* slim scrollbars in lists and the page */
.voice-list, .app-rail, .chunk-text { scrollbar-width: thin; scrollbar-color: var(--dash) transparent; }
/* status line of the Anam card and other "dl" lists read better with a little air */
.status-list { row-gap: .3rem; }

/* show / hide password: the eye button looks like part of the field (same border, no heavy outline) */
.btn-reveal { border: var(--bs-border-width) solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-secondary-color); }
.btn-reveal:hover, .btn-reveal:focus-visible { background: var(--bs-tertiary-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
.input-group:focus-within .btn-reveal { border-color: var(--brand); }
.input-group:focus-within .form-control { box-shadow: none; }


/* Admin > Avatar: Choose an avatar */
.gallery-search { max-width: 20rem; }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; max-height: 560px;
  overflow-y: auto; padding: 3px; }
.avatar-tile { position: relative; display: flex; flex-direction: column; gap: .25rem; padding: .35rem; text-align: left;
  border: 1px solid var(--bs-border-color); border-radius: 10px; background: var(--bs-body-bg); color: inherit; cursor: pointer;
  transition: border-color .15s, box-shadow .15s; }
.avatar-tile:hover { border-color: var(--brand); }
.avatar-tile:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: var(--bs-tertiary-bg); }
.avatar-tile.picked { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.avatar-tile .tile-name { font-size: .8rem; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-tile .tile-tags { display: flex; gap: .25rem; flex-wrap: wrap; }
.avatar-tile .tile-tags .badge { font-weight: 500; font-size: .66rem; }
.avatar-tile .tile-active { position: absolute; top: .55rem; left: .55rem; font-size: .7rem; font-weight: 600; padding: .1rem .4rem;
  border-radius: 999px; background: var(--bs-success); color: #fff; }
.gallery-bar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
