/* ==========================================================================
   Hufan Admin — same design language as the studio, denser information
   ========================================================================== */

.admin .sidebar { background: #fbfbfb; }
.admin-mark { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; margin-left: 8px; }
.sb-group { font-size: 11px; font-weight: 500; color: var(--faint); letter-spacing: 0.04em; padding: 12px 10px 4px; }
.app-shell.is-collapsed .sb-group, .app-shell.is-collapsed .admin-mark { display: none; }
.admin .sb-nav { overflow-y: auto; margin-right: -6px; padding-right: 6px; scrollbar-width: thin; }
.admin .page { max-width: 1380px; }

.range-seg { background: var(--s3); }

/* KPI grid */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #fff; }
.kpi { position: relative; display: grid; gap: 6px; padding: 16px 18px 16px; border-left: 1px solid var(--line); border-top: 1px solid var(--line); min-width: 0; }
.kpi:nth-child(4n + 1) { border-left: 0; }
.kpi:nth-child(-n + 4) { border-top: 0; }
.kpi .k { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; }
.kpi .bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.delta .i { width: 13px; height: 13px; }
.delta.good { color: #1f7a45; }
.delta.bad { color: #b3261e; }
.delta .vs { color: var(--faint); font-weight: 400; margin-left: 4px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; }
.grid-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mt { margin-top: 20px; }
.mt-lg { margin-top: 32px; }

/* Tables */
.id { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell .who { display: grid; min-width: 0; }
.user-cell .who b { font-weight: 500; color: var(--ink); }
.user-cell .who span { font-size: 12px; color: var(--muted); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.table-wrap.has-foot .table tr:last-child td { border-bottom: 1px solid var(--line); }
.plan-tag { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: var(--s3); color: var(--ink-2); }
.plan-tag.pro { background: var(--ink); color: #fff; }
.plan-tag.agency { background: #2b2b2b; color: #fff; }
.chips-inline { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chips-inline span { font-size: 11.5px; padding: 1px 6px; border-radius: 5px; background: var(--s3); color: var(--ink-2); }
.margin-good { color: #1f7a45; font-weight: 500; }
.margin-mid { color: #8a5a00; font-weight: 500; }
.margin-bad { color: #b3261e; font-weight: 500; }

/* Routing chain */
.route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.route-node { display: inline-flex; align-items: center; gap: 9px; height: 40px; padding: 0 14px 0 10px; border-radius: 11px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; }
.route-node .n { width: 20px; height: 20px; border-radius: 6px; background: var(--s3); display: grid; place-items: center; font-size: 11px; font-weight: 500; color: var(--muted); }
.route-node.is-auto { background: var(--ink); color: #fff; border-color: var(--ink); }
.route-node.is-auto .n { background: rgba(255,255,255,0.14); color: #fff; }
.route-arrow { color: var(--ghost); }
.route-node .status { font-size: 11.5px; font-weight: 400; color: var(--muted); }

/* Providers */
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.prov { display: grid; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #fff; cursor: pointer; text-align: left; transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
.prov:hover { border-color: var(--line-3); box-shadow: var(--sh-2); transform: translateY(-1px); }
.prov-head { display: flex; align-items: center; gap: 12px; }
.prov-logo { width: 40px; height: 40px; border-radius: 11px; background: var(--s2); display: grid; place-items: center; font-size: 14px; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); flex: none; }
.prov-head b { font-size: 15px; font-weight: 500; display: block; }
.prov-head span { font-size: 12px; color: var(--muted); }
.prov-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.prov-stats div { display: grid; gap: 2px; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.prov-stats span { font-size: 11.5px; font-weight: 400; color: var(--faint); }
.key-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 11px; background: var(--s1); border: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; }
.key-row span { flex: 1; }

/* Content editor */
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 28px; align-items: start; }
.preview-card { position: sticky; top: 24px; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; }
.preview-card .bar { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--s1); }
.preview-card .bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--s4); }
.preview-hero { padding: 36px 24px 30px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.preview-hero h3 { font-size: 30px; line-height: 1.02; letter-spacing: -0.045em; font-weight: 500; }
.preview-hero p { font-size: 13px; color: var(--muted); max-width: 300px; }
.preview-hero .row .btn { pointer-events: none; }
.phrase-list { display: grid; gap: 8px; }
.phrase-row { display: flex; gap: 6px; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.feat-item { position: relative; cursor: pointer; border-radius: 12px; }
.feat-item .media { border-radius: 12px; }
.feat-item .check-badge { position: absolute; top: 8px; right: 8px; z-index: 3; width: 24px; height: 24px; border-radius: 7px; background: rgba(255,255,255,0.9); display: grid; place-items: center; color: transparent; box-shadow: var(--sh-1); transition: all var(--t) var(--ease); }
.feat-item .check-badge .i { width: 14px; height: 14px; }
.feat-item.is-on .check-badge { background: var(--ink); color: #fff; }
.feat-item:not(.is-on) .media { opacity: 0.55; }
.feat-item .cap { font-size: 12px; color: var(--ink-2); margin-top: 6px; }

/* Support inbox */
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-height: 620px; background: #fff; }
.inbox-list { border-right: 1px solid var(--line); overflow-y: auto; max-height: 72vh; }
.ticket { display: grid; gap: 4px; padding: 14px 16px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color var(--t-fast) var(--ease); text-align: left; width: 100%; }
.ticket:hover { background: var(--s1); }
.ticket.is-active { background: var(--s2); }
.ticket .top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.ticket b { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.ticket p { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket.unread b::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 2px; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.thread-body { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; max-height: 52vh; }
.msg { display: grid; gap: 6px; max-width: 620px; }
.msg .meta { font-size: 12px; color: var(--faint); }
.msg .bubble { padding: 12px 14px; border-radius: 14px; background: var(--s2); font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.msg.agent { justify-self: end; }
.msg.agent .bubble { background: var(--ink); color: #fff; }
.msg.agent .meta { text-align: right; }
.thread-reply { border-top: 1px solid var(--line); padding: 14px 20px; display: grid; gap: 10px; }
.thread-reply textarea { min-height: 80px; }

.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.sev .dot { width: 7px; height: 7px; }
.sev-high .dot { background: #c9372c; }
.sev-med .dot { background: #d38b12; }
.sev-low .dot { background: var(--ghost); }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(4n + 1) { border-left: 1px solid var(--line); }
  .kpi:nth-child(2n + 1) { border-left: 0; }
  .kpi:nth-child(-n + 4) { border-top: 1px solid var(--line); }
  .kpi:nth-child(-n + 2) { border-top: 0; }
  .grid-2, .grid-2-even, .content-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .preview-card { position: relative; top: 0; }
}
@media (max-width: 860px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list { max-height: 280px; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin .bottom-nav { display: none; }
  .admin .main { padding-bottom: 0; }
  .admin-mnav { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: 56px; background: rgba(255,255,255,0.94); z-index: 20; backdrop-filter: blur(10px); }
  .admin-mnav::-webkit-scrollbar { display: none; }
}
.admin-mnav { display: none; }
@media (max-width: 860px) { .admin .admin-mnav { display: flex; } }
@media (max-width: 1100px) and (min-width: 861px) {
  .admin .sb-group, .admin .sb-top .admin-mark { display: none; }
  .admin .sb-nav { padding-top: 4px; }
}
.admin .m-top .admin-mark { display: inline-flex; }
.admin .table td:first-child .list-title { min-width: 150px; }

/* ---------- Control center (live data) ---------- */
.kpi .d { font-size: 12px; color: var(--muted); line-height: 1.4; }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpis-5 .kpi:nth-child(4n + 1) { border-left: 1px solid var(--line); }
.kpis-5 .kpi:first-child { border-left: 0; }
.kpis-5 .kpi:nth-child(-n + 5) { border-top: 0; }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.kpis-3 .kpi:nth-child(4n + 1) { border-left: 1px solid var(--line); }
.kpis-3 .kpi:first-child { border-left: 0; }
.health-list { display: grid; }
.health-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.health-row:last-child { border-bottom: 0; }
.health-row b { font-weight: 500; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.filters .input-wrap { width: 220px; }
.filters .select { width: auto; max-width: 220px; }
.date-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.date-field .input { width: 150px; }
.am-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px 16px; align-items: start; }
.am-card { display: grid; gap: 10px; cursor: pointer; animation: riseSm 360ms var(--ease-out) both; }
.am-card .media { border-radius: 14px; transition: box-shadow var(--t) var(--ease), transform var(--t) var(--ease); }
.am-card:hover .media { box-shadow: var(--sh-2); }
.am-card:hover .media-actions, .am-card:focus-within .media-actions { opacity: 1; transform: none; }
.am-card.is-dim .media { opacity: 0.45; }
.am-meta { display: grid; gap: 3px; min-width: 0; font-size: 12px; color: var(--muted); }
.am-meta b { font-size: 13.5px; font-weight: 500; color: var(--ink); min-width: 0; }
.am-meta .row { gap: 8px; }
.am-meta .status { font-size: 11.5px; flex: none; }
.am-flag { position: absolute; left: 8px; bottom: 8px; z-index: 3; }
.am-placeholder { display: grid; place-items: center; background: var(--s2); color: var(--faint); font-size: 12px; }
.am-placeholder > span { display: grid; justify-items: center; gap: 6px; text-align: center; }
.am-placeholder.is-failed { background: #fbf1f0; color: #8c1d18; }
.am-preview { border-radius: 14px; overflow: hidden; background: #111; display: grid; place-items: center; max-height: 58vh; }
.am-preview video, .am-preview img { max-height: 58vh; width: auto; max-width: 100%; display: block; }
.am-preview .media { width: 220px; }
.am-specs div { min-width: 0; }
.am-specs .user-cell .who span { font-size: 11.5px; }
.am-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.am-mini-item { display: grid; gap: 4px; text-align: left; }
.am-mini-item .media { border-radius: 9px; }
.am-mini-item .status { font-size: 10.5px; }
.drawer-wide { width: min(640px, 100vw); }
.plan-edit td { padding: 8px 10px; }
.admin .notice-bar .btn { flex: none; }
@media (max-width: 1200px) { .kpis-5 { grid-template-columns: repeat(3, 1fr); } .kpis-5 .kpi:nth-child(-n + 5) { border-top: 1px solid var(--line); } .kpis-5 .kpi:nth-child(-n + 3) { border-top: 0; } }
@media (max-width: 860px) { .kpis-5, .kpis-3 { grid-template-columns: 1fr 1fr; } .filters .input-wrap { width: 100%; } }

/* ------------------------------------------------------------------ Model logos and the model editor */
.row-logo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-cell > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.form-sec { display: grid; gap: 2px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-sec b { font-size: 13.5px; font-weight: 600; }
.form-sec span { font-size: 12.5px; color: var(--muted); }
.q-table th, .q-table td { padding: 8px 10px; }
.q-table .input-sm { width: 100%; max-width: 130px; }
.adv-json { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px; }
.adv-json summary { list-style: none; cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 500; }
.adv-json summary::-webkit-details-marker { display: none; }
.adv-json[open] { padding-bottom: 14px; }
.adv-json .field + .field { margin-top: 12px; }


/* Settings → Email: the three Gmail steps */
.mail-steps { display: grid; gap: 6px; margin: 0; padding: 12px 14px 12px 34px; list-style: decimal; border: 1px solid var(--line); border-radius: 12px; background: var(--s1); font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.mail-steps b { font-weight: 500; color: var(--ink); }
#sEmail .seg { justify-self: start; }
