﻿:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #EFF6FF;
  --sidebar: #1E3A5F;
  --bg: #F1F5F9;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --muted: #64748B;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --r: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; font-size: 14px; }
a, a:hover, a:focus, a:active { text-decoration: none; }

/* ── UTILS ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-muted { color: var(--muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: none; border-radius: var(--r); font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s; white-space: nowrap; font-family: inherit; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }
.btn-outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--muted); border: none; }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], select, textarea {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 14px; font-family: inherit; outline: none; transition: border-color .2s; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; line-height: 1.6; }
.select-chip-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.select-chip { padding: 6px 14px; border: 1.5px solid var(--border); border-radius: 20px; font-size: 13px; cursor: pointer; transition: all .15s; background: #fff; user-select: none; }
.select-chip.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 500; }

/* ── TAGS / BADGES ── */
.tag { display: inline-block; padding: 2px 9px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.tag-blue { background: #DBEAFE; color: #1D4ED8; }
.tag-green { background: #D1FAE5; color: #065F46; }
.tag-gray { background: #F1F5F9; color: #475569; }
.tag-red { background: #FEE2E2; color: #DC2626; }
.tag-amber { background: #FEF3C7; color: #B45309; }
.risk-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.risk-high { background: #FEE2E2; color: #DC2626; }
.risk-medium { background: #FEF3C7; color: #D97706; }
.risk-low { background: #D1FAE5; color: #059669; }

/* ── CARD ── */
.card { background: #fff; border-radius: var(--r); border: 1px solid var(--border); }
.card-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h3 { font-size: 14px; font-weight: 600; }
.card-body { padding: 18px; }

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 4px; }

/* ═══════════════════════════════════════
   LOGIN
═══════════════════════════════════════ */
#login-page {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, #1E3A5F 0%, #2563EB 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-box { background: #fff; border-radius: 16px; padding: 48px 40px; width: 420px; box-shadow: 0 25px 50px rgba(0,0,0,.25); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { width: 64px; height: 64px; background: var(--primary-light); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 30px; margin-bottom: 12px; }
.login-logo h1 { font-size: 22px; font-weight: 700; }
.login-logo p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-hint { text-align: center; font-size: 12px; color: #94A3B8; margin-top: 14px; }

/* ═══════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════ */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar { width: 216px; min-width: 216px; background: var(--sidebar); display: flex; flex-direction: column; overflow: hidden; }
.sidebar-logo { padding: 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.sidebar-logo-icon { width: 36px; height: 36px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.sidebar-logo span { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.35; }
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; color: #475569; text-transform: uppercase; padding: 8px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 6px; color: #94A3B8; font-size: 13.5px; cursor: pointer; transition: all .15s; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ni { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.1); }
.status-row { display: flex; gap: 4px; background: rgba(255,255,255,.06); border-radius: 7px; padding: 4px; margin-bottom: 8px; }
.st-btn { flex: 1; padding: 5px 3px; border: none; border-radius: 5px; font-size: 11px; cursor: pointer; transition: all .15s; background: transparent; color: #94A3B8; font-family: inherit; }
.st-btn:hover { color: #fff; }
.st-btn.is-active { color: #fff; font-weight: 600; }
.st-btn.online.is-active { background: var(--success); }
.st-btn.away.is-active { background: var(--warning); }
.st-btn.offline.is-active { background: #475569; }
.user-card { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.user-av { width: 34px; height: 34px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.user-card-info { flex: 1; min-width: 0; }
.user-card-name { font-size: 13px; font-weight: 500; color: #fff; }
.user-card-role { font-size: 11px; color: #94A3B8; }

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: #fff; border-bottom: 1px solid var(--border); height: 54px; min-height: 54px; padding: 0 22px; display: flex; align-items: center; justify-content: space-between; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #94A3B8; }
.status-dot.online::before { background: var(--success); }
.status-dot.busy::before { background: var(--danger); animation: blink 1.2s infinite; }
.status-dot.away::before { background: var(--warning); }
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:.3; } }
.content { flex: 1; overflow-y: auto; padding: 22px; transition: margin-right .3s; }
.content.detail-view { overflow: hidden; display: flex; flex-direction: column; padding: 16px 22px 22px; }
.content.detail-view .detail-page { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.content.detail-view .detail-page .page-header { flex-shrink: 0; margin-bottom: 12px; }
.content.detail-view .ai-records-page { flex: 1; min-height: 0; overflow: hidden; }
.content.pre-call-open { margin-right: 360px; }

/* ── PRE-INC OVERLAY ── */
#pre-inc-overlay {
  position: fixed; right: 0; top: 0; bottom: 0; z-index: 900;
  width: 360px; display: flex; flex-direction: column;
  background: #fff; border-left: 3px solid #D97706;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
  overflow: hidden;
}
.pre-inc-header { background: linear-gradient(135deg,#78350F,#B45309); padding: 14px 16px; flex-shrink: 0; }
.pre-inc-main { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.pre-inc-history-inline { background: #F8FAFC; padding: 0 0 8px; }
.pre-inc-history-inline.hidden { display: none; }
.pre-inc-history-inline .pre-inc-hist-head { padding: 10px 12px 6px; }
.pre-inc-history-inline .fs-hist-list { padding: 0 8px; }
.pre-inc-hist-head h4 { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.pre-inc-hist-head p { font-size: 11px; color: var(--muted); }
.pre-inc-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: #FAFAFA; flex-shrink: 0; }

/* ═══════════════════════════════════════
   WORKSTATION
═══════════════════════════════════════ */
.ws-grid { display: flex; flex-direction: column; gap: 16px; }
.ws-grid-call { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.idle-box { display: flex; align-items: center; gap: 18px; padding: 20px 24px; }
.idle-icon { width: 56px; height: 56px; background: var(--primary-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.idle-box h2 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.idle-box p { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── STATUS CARD ── */
.status-card { display: flex; gap: 10px; padding: 20px; }
.status-option { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; border-radius: 10px; border: 2px solid var(--border); background: #fff; cursor: pointer; transition: all .18s; user-select: none; }
.status-option:hover { border-color: #94A3B8; transform: translateY(-1px); }
.status-option.so-active-online { border-color: var(--success); background: #F0FDF4; }
.status-option.so-active-away   { border-color: var(--warning); background: #FFFBEB; }
.status-option.so-active-offline{ border-color: #94A3B8; background: #F8FAFC; }
.so-dot { width: 12px; height: 12px; border-radius: 50%; }
.so-label { font-size: 13px; font-weight: 600; }
.so-desc  { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.4; }

/* ── CALLBACK LIST ── */
.cb-rich-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); transition: background .12s; }
.cb-rich-row:last-child { border-bottom: none; }
.cb-rich-row:hover { background: #F8FAFC; }
.cb-rich-av { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #3B82F6, #1D4ED8); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; }
.cb-rich-main { flex: 1; min-width: 0; }
.cb-rich-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; flex-wrap: wrap; }
.cb-rich-name { font-size: 14px; font-weight: 600; }
.cb-rich-meta { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.cb-rich-reason { font-size: 12px; color: var(--text); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cb-rich-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; align-items: stretch; min-width: 72px; }

/* ── PHONE CALL PANEL ── */
.phone-panel {
  background: linear-gradient(160deg, #0F172A 0%, #1E3A5F 60%, #1e4080 100%);
  border-radius: var(--r); overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 24px 32px; min-height: 380px; position: relative;
}
.phone-panel-bg {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.phone-panel-bg::before {
  content: ''; position: absolute;
  width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(37,99,235,.25) 0%, transparent 70%);
  top: -60px; left: 50%; transform: translateX(-50%);
}
.caller-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700; color: #fff;
  box-shadow: 0 0 0 6px rgba(59,130,246,.25), 0 0 0 12px rgba(59,130,246,.1);
  position: relative; z-index: 1; margin-bottom: 16px;
  animation: avatarPulse 2.5s ease-in-out infinite;
}
@keyframes avatarPulse {
  0%,100% { box-shadow: 0 0 0 6px rgba(59,130,246,.25), 0 0 0 12px rgba(59,130,246,.1); }
  50%      { box-shadow: 0 0 0 8px rgba(59,130,246,.3),  0 0 0 16px rgba(59,130,246,.12); }
}
.caller-name { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 4px; letter-spacing: .5px; position: relative; z-index: 1; }
.caller-id   { font-size: 13px; color: rgba(255,255,255,.55); margin-bottom: 24px; position: relative; z-index: 1; }
.phone-timer {
  font-size: 46px; font-weight: 300; letter-spacing: 4px;
  font-variant-numeric: tabular-nums; color: #fff;
  margin-bottom: 10px; position: relative; z-index: 1;
}
.rec-row { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; color: rgba(255,255,255,.6); margin-bottom: 36px; position: relative; z-index: 1; }
.rec-dot { width: 7px; height: 7px; border-radius: 50%; background: #EF4444; animation: blink 1s infinite; }
.hangup-btn {
  width: 68px; height: 68px; border-radius: 50%; background: #EF4444; border: none;
  color: #fff; font-size: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(239,68,68,.5);
  transition: all .2s; position: relative; z-index: 1;
}
.hangup-btn:hover { background: #DC2626; transform: scale(1.06); box-shadow: 0 6px 24px rgba(239,68,68,.6); }
.phone-secondary-btns { display: flex; gap: 12px; margin-bottom: 28px; position: relative; z-index: 1; }
.phone-sec-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: none; color: rgba(255,255,255,.85);
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s; backdrop-filter: blur(4px);
}
.phone-sec-btn:hover { background: rgba(255,255,255,.22); }
.phone-sec-btn.active { background: rgba(255,255,255,.9); color: var(--text); }

/* ── VISITOR INFO PANEL ── */
.visitor-panel { display: flex; flex-direction: column; gap: 14px; }
.info-section { background: #fff; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.info-section-header { padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.info-row { display: flex; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row-label { width: 80px; min-width: 80px; font-size: 12px; color: var(--muted); font-weight: 500; padding-top: 1px; }
.info-row-value { flex: 1; font-size: 13px; line-height: 1.5; }
.ai-summary-section { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--r); padding: 12px 14px; }
.ai-summary-title { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.ai-summary-text { font-size: 13px; color: var(--text); line-height: 1.7; }

/* old compat */
.call-info-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }

/* callback list */
.cb-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #FFF7ED; border: 1px solid #FED7AA; border-radius: var(--r); margin-bottom: 10px; }
.cb-info { flex: 1; }
.cb-name { font-size: 13.5px; font-weight: 600; }
.cb-reason { font-size: 12px; color: #92400E; margin-top: 2px; }

/* ═══════════════════════════════════════
   OVERLAYS & MODALS
═══════════════════════════════════════ */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 500; }
#inc-overlay { z-index: 1200; }
#call-switch-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s ease;
}
#call-switch-overlay.active { opacity: 1; pointer-events: all; }
.call-switch-ring {
  width: 76px; height: 76px; border-radius: 50%;
  background: linear-gradient(135deg, #7C3AED, #8B5CF6);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  box-shadow: 0 0 0 0 rgba(139,92,246,.5);
  animation: switchRingPulse 0.9s ease-out infinite;
}
@keyframes switchRingPulse {
  0%   { box-shadow: 0 0 0 0 rgba(139,92,246,.5); }
  70%  { box-shadow: 0 0 0 20px rgba(139,92,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(139,92,246,0); }
}
.modal { background: #fff; border-radius: 16px; box-shadow: 0 25px 50px rgba(0,0,0,.28); overflow: hidden; }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-header h2 { font-size: 16px; font-weight: 600; }
.modal-header-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: #fff; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* incoming call modal */
.inc-modal { width: 560px; max-width: 92vw; animation: slideUp .3s ease; display: flex; flex-direction: column; max-height: 90vh; }
.inc-modal-body { flex: 1; overflow-y: auto; min-height: 0; }
.inc-modal-history { background: #F8FAFC; border-top: 1px solid var(--border); padding: 0 0 10px; }
.inc-modal-history.hidden { display: none; }
.inc-modal-history .inc-hist-head { padding: 10px 22px 6px; display: flex; align-items: center; justify-content: space-between; }
.inc-modal-history .inc-hist-head h4 { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.inc-modal-history .inc-hist-head p { font-size: 11px; color: var(--muted); }
.inc-modal-history .fs-hist-list { padding: 0 14px; }
.inc-header { padding: 18px 22px; background: linear-gradient(135deg, #1E3A5F, #2563EB); color: #fff; }
.inc-ring-row { display: flex; align-items: center; gap: 12px; }
.ring-icon { width: 44px; height: 44px; background: rgba(255,255,255,.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; animation: swing .5s ease infinite alternate; flex-shrink: 0; }
@keyframes swing { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.inc-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px 22px 0; }
.inc-info-item.full { grid-column: 1 / -1; }
.inc-info-item { background: var(--bg); border-radius: 6px; padding: 8px 12px; }
.info-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }
.ai-summary-box { margin: 14px 22px 16px; background: var(--primary-light); border: 1px solid #BFDBFE; border-radius: var(--r); padding: 12px 14px; }
.ai-summary-label { font-size: 11px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.ai-summary-box p { font-size: 13px; line-height: 1.65; }
.inc-history-hint { margin: 0 22px 12px; background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--r); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #1D4ED8; }
.inc-actions { padding: 14px 22px; display: flex; gap: 12px; border-top: 1px solid var(--border); }

/* post-call form */
.post-modal { width: 520px; max-width: 92vw; max-height: 88vh; overflow-y: auto; animation: slideUp .3s ease; }

/* history modal */
.hist-modal { width: 560px; max-width: 92vw; max-height: 82vh; overflow-y: auto; z-index: 600; }
.hist-record { padding: 14px 0; border-bottom: 1px solid var(--border); }
.hist-record:last-child { border-bottom: none; }

/* ═══════════════════════════════════════
   RECORDS VIEW
═══════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 9px 14px; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr:hover { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

/* audio player */
.audio-player { background: var(--bg); border-radius: var(--r); padding: 10px 14px; display: flex; align-items: center; gap: 12px; }
.play-btn { width: 34px; height: 34px; background: var(--primary); border-radius: 50%; border: none; color: #fff; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .15s; }
.play-btn:hover { background: var(--primary-dark); }
.audio-track { flex: 1; }
.audio-bar { height: 4px; background: var(--border); border-radius: 2px; cursor: pointer; position: relative; margin-bottom: 4px; }
.audio-fill { height: 100%; background: var(--primary); border-radius: 2px; width: 0%; transition: width .25s linear; }
.audio-times { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

/* ═══════════════════════════════════════
   STATS VIEW
═══════════════════════════════════════ */
.stat-cards { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: 18px; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ═══════════════════════════════════════
   USER ROW
═══════════════════════════════════════ */
.user-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row-av { width: 40px; height: 40px; background: var(--primary-light); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--primary); flex-shrink: 0; }
.user-row-info { flex: 1; }
.user-row-name { font-size: 14px; font-weight: 500; }
.user-row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── EMPTY ── */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── ALERT ── */
.alert { padding: 10px 14px; border-radius: var(--r); font-size: 13px; margin-bottom: 14px; }
.alert-info { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1D4ED8; }
.alert-warn { background: #FFFBEB; border: 1px solid #FDE68A; color: #B45309; }

/* ── PAGE HEADER ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 700; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ── TOAST ── */
#toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); background: #1E293B; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; z-index: 9999; box-shadow: 0 4px 14px rgba(0,0,0,.2); transition: opacity .3s; white-space: nowrap; pointer-events: none; opacity: 0; }

/* ── FULLSCREEN CALL ── */
#call-fullscreen { position: fixed; inset: 0; z-index: 800; background: #F8FAFC; display: flex; flex-direction: column; overflow: hidden; }
.call-fs-topbar {
  height: 52px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 14px; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.call-fs-topbar .logo-mark { font-size: 18px; }
.call-fs-topbar .system-name { font-size: 14px; font-weight: 600; color: var(--text); }
.call-fs-topbar .call-badge { background: #EF4444; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; animation: blink 1.5s infinite; }
.call-fs-topbar .call-badge.ended { background: #64748B; animation: none; }
.call-fs-topbar .call-badge.dialing { background: #F59E0B; animation: blink 1.5s infinite; }
.call-fs-topbar .call-badge.completed { background: #22C55E; animation: none; }
.call-fs-topbar .fs-queue-badge {
  background: #FEF3C7;
  color: #92400E;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #F59E0B;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.call-fs-topbar .fs-queue-badge b {
  font-size: 14px;
  min-width: 1.2em;
  text-align: center;
}
.call-fs-topbar .fs-queue-badge.hot {
  background: #FEE2E2;
  color: #B91C1C;
  border-color: #EF4444;
  animation: blink 1.5s infinite;
}
.call-ended-status { font-size: 13px; font-weight: 600; color: #64748B; background: #F1F5F9; padding: 5px 14px; border-radius: 20px; margin-bottom: 12px; position: relative; z-index: 1; }
.call-ended-status.completed { background: #DCFCE7; color: #166534; }
.call-ended-completed-icon { font-size: 44px; margin-bottom: 10px; position: relative; z-index: 1; line-height: 1; }
.call-ended-meta { font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; margin-bottom: 20px; position: relative; z-index: 1; max-width: 100%; }
.call-ended-actions { width: 100%; padding: 0 4px; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }
.call-ended-actions.hidden { display: none; }
.call-ended-actions .btn { font-size: 12px; padding: 11px 8px; white-space: normal; line-height: 1.45; text-align: center; }
.call-ended-callback-btn { border: 2px solid #F59E0B; background: #FFFBEB; color: #92400E; font-weight: 600; }
.call-ended-callback-btn:hover { background: #FEF3C7; }
.dial-wait-timer { font-size: 40px; font-weight: 300; letter-spacing: 3px; font-variant-numeric: tabular-nums; color: var(--text); margin: 12px 0 6px; position: relative; z-index: 1; }
.dial-wait-hint { font-size: 11px; color: var(--muted); margin-bottom: 20px; position: relative; z-index: 1; text-align: center; line-height: 1.5; }
.call-fs-body { flex: 1; display: grid; grid-template-columns: 200px 3fr 2fr; gap: 0; overflow: hidden; min-height: 0; }
.call-fs-body.no-history { grid-template-columns: 200px 7fr 3fr; }
.call-fs-left { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 12px; position: relative; background: #fff; border-right: 1px solid var(--border); flex-shrink: 0; }
.call-fs-left::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(37,99,235,.06) 0%, transparent 65%); pointer-events: none; }
#call-active-panel, #call-callback-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; position: relative; z-index: 1; }
#call-active-panel.hidden, #call-callback-panel.hidden { display: none; }
#call-callback-panel .call-ended-status { background: #FEF3C7; color: #92400E; margin-bottom: 8px; }
.call-fs-center { background: #F1F5F9; overflow-y: auto; padding: 0; min-width: 0; min-height: 0; }
.call-fs-history { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-left: 1px solid var(--border); background: #fff; }
.call-fs-topbar .fs-hist-badge { margin-left: auto; font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; background: var(--bg); border-radius: 20px; }
.call-fs-topbar .fs-hist-badge .hist-count { background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; min-width: 18px; text-align: center; }
.fs-info-section { margin-bottom: 14px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.fs-info-section-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 9px 14px; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 6px; }
.fs-info-row { display: flex; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.fs-info-row:last-child { border-bottom: none; }
.fs-info-label { width: 78px; min-width: 78px; font-size: 12px; color: var(--muted); }
.fs-info-value { flex: 1; font-size: 13px; color: var(--text); line-height: 1.5; }
.fs-ai-box { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.fs-ai-title { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.fs-ai-text { font-size: 13px; color: var(--text); line-height: 1.7; }
.fs-hangup-btn {
  width: 72px; height: 72px; border-radius: 50%; background: #EF4444; border: none;
  color: #fff; font-size: 30px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(239,68,68,.35); transition: all .2s;
  position: relative; z-index: 1;
}
.fs-hangup-btn:hover { background: #DC2626; transform: scale(1.07); }
.fs-hangup-btn:disabled,
.fs-hangup-btn:disabled:hover {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
  background: #EF4444;
}
.fs-caller-av { width: 80px; height: 80px; border-radius: 50%; background: linear-gradient(135deg, #3B82F6, #1D4ED8); display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; color: #fff; box-shadow: 0 0 0 6px rgba(59,130,246,.15), 0 0 0 12px rgba(59,130,246,.06); animation: avatarPulse 2.5s ease-in-out infinite; margin-bottom: 14px; position: relative; z-index: 1; }
.fs-caller-name { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; position: relative; z-index: 1; }
.fs-caller-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; position: relative; z-index: 1; }
.fs-timer { font-size: 42px; font-weight: 300; letter-spacing: 4px; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 6px; position: relative; z-index: 1; }
.fs-rec { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); margin-bottom: 20px; position: relative; z-index: 1; }
.fs-sec-btns { display: flex; gap: 14px; margin-bottom: 20px; position: relative; z-index: 1; }
.fs-sec-btn { width: 48px; height: 48px; border-radius: 50%; background: #EFF6FF; border: 1.5px solid var(--primary); color: var(--primary); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.fs-sec-btn:hover { background: #DBEAFE; }
.fs-sec-btn.active { background: #F1F5F9; color: var(--muted); border-color: var(--border); }
.fs-hangup-btn { width: 60px; height: 60px; font-size: 26px; }

/* ── CONSULT RECORD FORM (in-call) ── */
.cr-form-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cr-form-toolbar .cr-form-title { margin-bottom: 0; font-size: 14px; }
.cr-form-toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cr-form-toolbar-actions #cr-save-btn {
  min-width: 120px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.detail-back-btn {
  min-width: 140px;
  padding: 12px 28px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}
.cr-form-wrap { padding: 12px 14px 20px; }
.cr-form-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cr-form-title span { font-size: 12px; font-weight: 500; color: var(--muted); }
.cr-section { background: #fff; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 12px; overflow: hidden; }
.cr-section-head { padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.cr-section-body { padding: 14px; }
.cr-grid-2 { display: grid; grid-template-columns: 1fr; gap: 10px; }
.cr-field { margin-bottom: 12px; }
.cr-field:last-child { margin-bottom: 0; }
.cr-field label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.cr-field input, .cr-field select, .cr-field textarea { padding: 8px 11px; font-size: 13px; }
.cr-field textarea { min-height: 72px; }
.cr-field input[readonly] { background: #F8FAFC; color: var(--muted); }
.cr-ai-ref { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--r); padding: 0; margin-bottom: 12px; font-size: 12px; line-height: 1.65; color: var(--text); overflow: hidden; }
.cr-ai-ref-toggle { width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; font-weight: 600; color: var(--primary); font-size: 12px; cursor: pointer; }
.cr-ai-ref-body { padding: 0 12px 12px; }
.cr-ai-ref.is-collapsed .cr-ai-ref-body { display: none; }
.cr-trigger-text { color: #DC2626; font-weight: 700; }
.cr-student-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-readonly { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.cr-readonly .info-label { font-size: 11px; color: var(--muted); }
.cr-readonly .mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.cr-inline-checks { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.cr-handle-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.cr-tag { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.cr-tag.is-active { border-color: var(--primary); background: #EFF6FF; color: var(--primary); font-weight: 600; }
.cr-risk-title { padding: 8px 12px; background: #FFFBEB; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.cr-risk-flags { display: flex; gap: 16px; padding: 10px 12px 0; }
.cr-risk-sits { padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.cr-risk-block .cr-field { padding: 0 12px 10px; }
.cr-risk-level { margin: 0 12px 10px; padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 700; text-align: center; background: #E2E8F0; color: var(--muted); }
.cr-risk-level.level-yellow { background: #EAB308; color: #fff; }
.cr-risk-level.level-orange { background: #F97316; color: #fff; }
.cr-risk-level.level-red { background: #EF4444; color: #fff; }
.cr-risk-level.level-action { background: #DC2626; color: #fff; }
.cr-risk-plan { padding: 0 12px 12px; }
.cr-plan-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.cr-plan-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 8px 0 4px; }
.cr-attach-list { list-style: none; padding: 0; margin: 8px 0 0; }
.cr-attach-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.cr-ro-row { margin-bottom: 12px; }
.cr-ro-row .info-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.cr-risk-ro { border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px; }
.row-draft { background: #FFFBEB !important; }
.records-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.records-tab { padding: 10px 16px; font-size: 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.records-tab.active { color: var(--primary); font-weight: 700; border-bottom-color: var(--primary); }
.filter-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.draft-banner { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1200; background: #1E293B; color: #fff; border-radius: 10px; padding: 14px 18px; min-width: 320px; max-width: 520px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.draft-banner .db-title { font-weight: 700; margin-bottom: 6px; }
.draft-banner .db-status { font-size: 12px; opacity: .85; margin-bottom: 10px; }
.draft-banner .db-actions { display: flex; gap: 10px; align-items: center; }
.detail-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.detail-two-col { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .detail-two-col { grid-template-columns: 1fr; } .cr-student-grid { grid-template-columns: 1fr; } }
.hist-card { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; background: #fff; }
.hist-card-head { padding: 12px; cursor: pointer; }
.hist-card-body { padding: 0 12px 12px; display: none; }
.hist-card.is-open .hist-card-body { display: block; }
.level-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: #E2E8F0; color: #64748B; }
.level-tag.yellow { background: #FEF08A; color: #A16207; }
.level-tag.orange { background: #FFEDD5; color: #C2410C; }
.level-tag.red { background: #FEE2E2; color: #B91C1C; }
.status-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.status-tag.filled { background: #DCFCE7; color: #15803D; }
.status-tag.draft { background: #FFEDD5; color: #C2410C; }
.status-tag.empty { background: #E2E8F0; color: #64748B; }
.missed-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.missed-tag.busy { background: #FFEDD5; color: #C2410C; }
.missed-tag.noanswer { background: #FEE2E2; color: #B91C1C; }
.missed-tag.noduty { background: #E2E8F0; color: #64748B; }
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-mask.hidden { display: none; }
.modal-panel { background: #fff; border-radius: 12px; width: min(920px, 100%); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-panel-body { padding: 16px 20px; overflow: auto; flex: 1; }
.modal-panel-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }
.export-fields { max-height: 360px; overflow: auto; }
.export-group { margin-bottom: 12px; }
.export-group h4 { font-size: 13px; margin-bottom: 6px; }
.rec-segment { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.transcript-line { font-size: 13px; line-height: 1.7; margin-bottom: 4px; }
.transcript-line a { color: var(--primary); text-decoration: none; font-family: monospace; margin-right: 6px; }
.transcript-role { display: inline-block; min-width: 3.5em; margin-right: 6px; font-weight: 600; }
.transcript-role.counselor { color: #1d4ed8; }
.transcript-role.visitor { color: #047857; }
.cr-risk-block { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; overflow: hidden; }
.cr-risk-block:last-child { margin-bottom: 0; }
.cr-risk-head { padding: 8px 12px; background: #FFFBEB; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.cr-risk-body { padding: 10px 12px; }
.cr-check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; font-size: 13px; line-height: 1.5; cursor: pointer; user-select: none; }
.cr-check:last-child { margin-bottom: 0; }
.cr-check input { margin-top: 3px; flex-shrink: 0; cursor: pointer; }
.cr-check.sub { margin-left: 22px; }
.cr-check.sub2 { margin-left: 44px; }
.cr-rating-bar { padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 700; text-align: center; margin: 10px 0; color: #fff; }
.cr-rating-bar.yellow { background: #EAB308; }
.cr-rating-bar.orange { background: #F97316; }
.cr-rating-bar.red { background: #EF4444; }
.cr-rating-bar.none { background: #E2E8F0; color: var(--muted); font-weight: 500; }
.cr-plan-group { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.cr-plan-label { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.cr-plan-label .tag-req { color: var(--danger); font-size: 11px; margin-left: 4px; }
.cr-plan-label .tag-opt { color: var(--muted); font-size: 11px; margin-left: 4px; }
.cr-handle-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cr-handle-chip { padding: 5px 12px; border: 1.5px solid var(--border); border-radius: 16px; font-size: 12px; cursor: pointer; background: #fff; transition: all .15s; }
.cr-handle-chip.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.cr-attach-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cr-attach-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--bg); border-radius: 6px; font-size: 12px; }
.cr-attach-item button { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 14px; }
.post-modal-wide { width: min(920px, 96vw); max-height: 92vh; display: flex; flex-direction: column; }
.post-modal-wide .modal-body { flex: 1; overflow-y: auto; padding: 0; }

/* ── IN-CALL HISTORY SIDEBAR (parallel with form) ── */
#fs-history-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.fs-hist-head { padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: #FAFBFC; }
.fs-hist-head h3 { font-size: 13px; font-weight: 700; margin-bottom: 1px; }
.fs-hist-head p { font-size: 11px; color: var(--muted); }
.fs-hist-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 10px; background: #F8FAFC; }
.fs-hist-list { display: flex; flex-direction: column; gap: 8px; }
.fs-hist-empty { text-align: center; padding: 32px 12px; color: var(--muted); font-size: 13px; }
.fs-hist-empty .empty-icon { font-size: 28px; margin-bottom: 8px; opacity: .45; }
.fs-hist-scroll.is-empty { display: flex; align-items: center; justify-content: center; }
.fs-hist-item { border: 1px solid var(--border); border-radius: var(--r); background: #fff; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.fs-hist-item:hover { border-color: #CBD5E1; }
.fs-hist-item.expanded { border-color: var(--primary); box-shadow: 0 2px 10px rgba(37,99,235,.08); }
.fs-hist-item-hd { padding: 10px 12px; cursor: pointer; user-select: none; display: flex; align-items: flex-start; gap: 8px; }
.fs-hist-item-hd:hover { background: #F8FAFC; }
.fs-hist-item.expanded .fs-hist-item-hd { background: var(--primary-light); }
.fs-hist-chevron { font-size: 9px; color: var(--muted); margin-top: 4px; flex-shrink: 0; transition: transform .15s; }
.fs-hist-item.expanded .fs-hist-chevron { transform: rotate(90deg); color: var(--primary); }
.fs-hist-item-main { flex: 1; min-width: 0; }
.fs-hist-item-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.fs-hist-item-time { font-size: 12px; font-weight: 600; flex-shrink: 0; }
.fs-hist-item-risks { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 3px; }
.fs-hist-item-risk-label { font-size: 10px; color: var(--muted); flex-shrink: 0; }
.fs-hist-item-meta { font-size: 11px; color: var(--muted); }
.fs-hist-item-preview { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 1; line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.fs-hist-item.expanded .fs-hist-item-preview { display: none; }
.fs-hist-item-bd { padding: 0 12px 14px; background: #fff; }
.fs-hist-item.expanded .fs-hist-item-hd { padding-bottom: 6px; }
.hist-ro-section { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; background: #FAFBFC; }
.hist-ro-section:last-child { margin-bottom: 0; }
.hist-ro-section-title { padding: 10px 12px; font-size: 13px; font-weight: 700; background: #EEF2FF; border-bottom: 1px solid var(--border); color: #1E293B; }
.hist-ro-body { padding: 4px 12px 12px; font-size: 12px; line-height: 1.6; }
.hist-ro-row { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid #F1F5F9; align-items: baseline; }
.hist-ro-row:last-child { border-bottom: none; padding-bottom: 0; }
.hist-ro-lbl { width: 92px; min-width: 92px; color: #64748B; flex-shrink: 0; font-size: 12px; font-weight: 600; line-height: 1.65; }
.hist-ro-val { flex: 1; color: var(--text); word-break: break-word; font-size: 13px; line-height: 1.65; background: transparent; border: none; padding: 8px 0; min-width: 0; }
.hist-ro-val.hist-ro-val--plain { background: transparent; border: none; padding: 0; }
.hist-ro-block { margin-bottom: 8px; background: #fff; border: 1px solid #E2E8F0; border-radius: 8px; overflow: hidden; }
.hist-ro-block:last-child { margin-bottom: 0; }
.hist-ro-block-title { font-size: 12px; font-weight: 700; color: #334155; padding: 8px 10px; background: #F8FAFC; border-bottom: 1px solid #E2E8F0; }
.hist-ro-block-body { padding: 8px 10px 10px; }
.hist-ro-field { margin-top: 10px; }
.hist-ro-field:first-child { margin-top: 0; }
.hist-ro-field-lbl { font-size: 11px; font-weight: 600; color: #64748B; margin-bottom: 6px; }
.hist-ro-field-val { font-size: 13px; line-height: 1.65; color: var(--text); background: #F8FAFC; border: 1px solid #E8EDF3; border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; }
.hist-ro-item { font-size: 13px; line-height: 1.65; color: var(--text); padding: 7px 10px 7px 12px; border-left: 3px solid #94A3B8; background: #F8FAFC; border-radius: 0 6px 6px 0; margin-bottom: 6px; }
.hist-ro-item:last-child { margin-bottom: 0; }
.hist-ro-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
.ts-details summary { cursor: pointer; font-size: 13px; color: var(--primary); padding: 4px 0; user-select: none; list-style: none; display: flex; align-items: center; gap: 6px; }
.ts-details summary::before { content: '▶'; font-size: 10px; transition: transform .15s; }
.ts-details[open] summary::before { transform: rotate(90deg); }
.ts-details summary:hover { opacity: .8; }
.ts-details[open] summary { margin-bottom: 10px; }
.ts-content { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; background: #FAFBFC; }
.ts-line { display: flex; gap: 8px; font-size: 12px; line-height: 1.6; }
.ts-time { color: var(--muted); font-family: monospace; flex-shrink: 0; width: 40px; }
.ts-time-seek { cursor: pointer; border-radius: 3px; padding: 0 2px; transition: color .15s, background .15s; }
.ts-time-seek:hover { color: var(--primary); background: var(--primary-light); }
.ts-speaker { font-weight: 600; flex-shrink: 0; width: 52px; }
.ts-counselor .ts-speaker { color: var(--primary); }
.ts-caller .ts-speaker { color: #059669; }
.ts-text { flex: 1; color: var(--text); }
.ts-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 18px 0; color: var(--muted); gap: 8px; font-size: 13px; }
.ts-loading-icon { font-size: 22px; animation: tsSpin 1.2s linear infinite; display: inline-block; }
@keyframes tsSpin { from{transform:rotate(0deg)} to{transform:rotate(360deg)} }
.ts-seg-header { font-size: 11px; font-weight: 700; color: var(--muted); padding: 4px 0 5px; display: flex; align-items: center; gap: 6px; letter-spacing: .03em; }
.ts-seg-time { font-weight: 400; font-size: 10px; font-family: monospace; color: var(--muted); }
.ts-seg-divider { border: none; border-top: 1px dashed var(--border); margin: 10px 0; }
.hist-ro-tag { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 10px; font-weight: 600; margin: 0 4px 4px 0; background: #F1F5F9; color: var(--muted); }
.hist-ro-tag.on { background: #FEF3C7; color: #B45309; }
.hist-attach-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 6px; margin-bottom: 6px; font-size: 12px; }
.detail-fs-body {
  display: grid; grid-template-columns: 3fr 2fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; flex: 1; min-height: 0; background: #fff;
}
.detail-consult-panel {
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: #F1F5F9; border-right: 1px solid var(--border); overflow: hidden;
}
.detail-consult-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 12px 14px 20px; }
.detail-consult-scroll.no-pad { padding: 0; }
.detail-history-panel {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: #fff;
}
.detail-panel-head {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 10px 14px; background: #fff;
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.detail-panel-head .detail-panel-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; line-height: 1.35; }
.detail-panel-head .detail-panel-title span { font-size: 12px; font-weight: 500; color: var(--muted); }
.detail-panel-head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-history-panel .fs-hist-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.detail-meta-bar { display: grid; grid-template-columns: repeat(3, 1fr); background: #fff; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 12px; }
.detail-meta-cell { padding: 11px 14px; border-bottom: 1px solid var(--border); }
.detail-meta-cell:nth-child(3n+1), .detail-meta-cell:nth-child(3n+2) { border-right: 1px solid var(--border); }
.detail-meta-cell:nth-last-child(-n+3) { border-bottom: none; }
.detail-record-body { background: #fff; border: 1px solid var(--border); border-radius: var(--r); padding: 14px; }

/* ── AI 小屋交流记录 ── */
.ai-records-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ai-records-body {
  display: grid; grid-template-columns: 340px 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r);
  overflow: hidden; flex: 1; min-height: 0; background: #fff;
}
.ai-records-list-panel {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  border-right: 1px solid var(--border); background: #F8FAFC;
}
.ai-records-list-head {
  flex-shrink: 0; padding: 12px 14px; border-bottom: 1px solid var(--border);
  background: #fff;
}
.ai-records-list-head h3 { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.ai-records-list-head p { font-size: 11px; color: var(--muted); }
.ai-records-search { margin-top: 10px; }
.ai-records-search input {
  width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--r);
  font-size: 13px; font-family: inherit; outline: none; background: #fff; color: var(--text);
}
.ai-records-search input:focus { border-color: var(--primary); }
.ai-records-list-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 10px; }
.ai-user-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.ai-user-card:hover { border-color: #CBD5E1; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.ai-user-card.active { border-color: var(--primary); box-shadow: 0 2px 10px rgba(37,99,235,.1); background: var(--primary-light); }
.ai-user-card-name { font-size: 14px; font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ai-user-card-school { font-size: 12px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ai-user-card-meta { font-size: 11px; color: var(--muted); line-height: 1.55; }
.ai-user-card-stats {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border);
  font-size: 11px;
}
.ai-user-card-stats .count { font-weight: 700; color: var(--primary); }
.ai-records-detail-panel {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: #fff;
}
.ai-records-detail-content {
  display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; overflow: hidden;
}
.ai-records-detail-head {
  flex-shrink: 0; padding: 14px 18px; border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
.ai-records-detail-head h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.ai-records-detail-head p { font-size: 12px; color: var(--muted); }
.ai-records-detail-scroll { flex: 1; overflow-y: auto; min-height: 0; padding: 14px 18px 20px; }
.ai-record-item {
  border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px;
  margin-bottom: 10px; background: #fff;
}
.ai-record-item:last-child { margin-bottom: 0; }
.ai-record-item-hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ai-record-seq {
  font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 3px 10px; border-radius: 20px;
}
.ai-record-time { font-size: 12px; color: var(--muted); }
.ai-record-summary { font-size: 13px; line-height: 1.65; color: var(--text); }
.ai-records-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 200px; color: var(--muted); font-size: 13px; text-align: center; padding: 24px;
}
.ai-records-empty .empty-icon { font-size: 36px; margin-bottom: 10px; opacity: .45; }

/* ── 人员管理 ── */
.user-name-cell { display: flex; align-items: center; gap: 10px; }
.user-list-av {
  width: 32px; height: 32px; border-radius: 50%; background: #DBEAFE; color: #1D4ED8;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.info-grid .info-label { margin-bottom: 4px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; display: block; min-height: 0; }
.form-group.has-error input { border-color: var(--danger); }
