:root {
  --bg: #dfe9f6;
  --bg2: #f8fbff;
  --card: rgba(255, 255, 255, 0.90);
  --text: #172033;
  --muted: #667085;
  --line: rgba(119, 139, 170, 0.28);
  --primary: #3157d5;
  --primary-dark: #243fa3;
  --primary-soft: #edf2ff;
  --accent: #20b6a8;
  --amber: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 34px 90px rgba(20, 34, 73, 0.22), 0 10px 28px rgba(20, 34, 73, 0.08);
  --shadow-soft: 0 22px 55px rgba(20, 34, 73, 0.15), 0 7px 20px rgba(20, 34, 73, 0.07);
  --shadow-lift: 0 28px 70px rgba(20, 34, 73, 0.20), inset 0 1px 0 rgba(255,255,255,.88);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Arial, "Noto Sans", "Noto Sans TC", sans-serif;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, .08), rgba(15, 23, 42, 0) 28%, rgba(20, 38, 70, .08)),
    linear-gradient(118deg, #d5e0f2 0%, #f8fbff 42%, #d4eeea 100%);
  color: var(--text);
  position: relative;
  isolation: isolate;
}
body::before {
  content: "";
  position: fixed;
  inset: 76px 0 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(49, 87, 213, .10), rgba(255,255,255,0) 36%, rgba(32, 182, 168, .13)),
    linear-gradient(180deg, rgba(255,255,255,.35), rgba(18, 33, 66, .08));
  box-shadow: inset 0 110px 170px rgba(15, 23, 42, .08);
}
button {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #5b7cfa);
  color: white;
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 10px 24px rgba(49, 87, 213, .20);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(49, 87, 213, .25); }
button:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }

.settings-mode-notice {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #b9d7ff;
  border-radius: 12px;
  background: #eef6ff;
  color: #27476f;
  font-size: .9rem;
  line-height: 1.55;
}

#avatarSettingsSection.mode-disabled .settings-fields {
  opacity: .62;
}
button.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
button.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border: 2px solid rgba(255,255,255,.42);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: button-spin .72s linear infinite;
}
button.secondary.is-loading::before {
  border-color: rgba(34,48,74,.24);
  border-top-color: currentColor;
}
@keyframes button-spin { to { transform: rotate(360deg); } }
button.secondary { background: #eef2f7; color: #22304a; box-shadow: none; }
button.secondary:hover { background: #e3e8f0; }
button.highlight { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 10px 24px rgba(245, 158, 11, .18); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  font-size: 15px;
  background: rgba(255,255,255,.94);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(20,34,73,.05), 0 1px 0 rgba(255,255,255,.65);
  transition: border .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}
input:focus, textarea:focus, select:focus { border-color: rgba(49, 87, 213, .55); box-shadow: 0 0 0 4px rgba(49,87,213,.09), 0 10px 24px rgba(20,34,73,.08); background: white; }
textarea { min-height: 92px; resize: vertical; }
#messageInput { min-height: 50px; max-height: 150px; resize: none; overflow-y: auto; line-height: 1.55; }
.hidden { display: none !important; }
.topbar {
  height: 76px;
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(180px, 980px) auto;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  box-shadow: 0 14px 42px rgba(20,34,73,.10);
  position: sticky;
  top: 0;
  z-index: 5;
}
.logo { font-size: 18px; font-weight: 900; display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark { width: 38px; height: 38px; border-radius: 14px; display: grid; place-items: center; color: white; background: linear-gradient(135deg, #3157d5, #20b6a8); box-shadow: 0 12px 28px rgba(49, 87, 213, .24); font-size: 14px; }
.logo-mark.has-image {
  color: transparent;
  background-color: white;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}
.announcement-marquee {
  min-width: 0;
  width: 100%;
  max-width: 980px;
  height: 42px;
  margin: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(247,250,255,.72));
  border: 1px solid rgba(119,139,170,.20);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 10px 24px rgba(20,34,73,.07);
}
.announcement-marquee.hidden {
  visibility: hidden;
}
.announcement-marquee-track {
  display: inline-flex;
  gap: 56px;
  white-space: nowrap;
  color: #344054;
  font-size: 15px;
  font-weight: 800;
  padding-left: 100%;
  animation: marquee-scroll 24s linear infinite;
}
.announcement-marquee-track span::before {
  content: "•";
  color: var(--accent);
  margin-right: 12px;
}
@keyframes marquee-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}
.topbar nav { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.nav-btn { background: rgba(255,255,255,.82); color: #344054; border: 1px solid var(--line); box-shadow: none; }
.nav-btn.active { background: #172033; color: white; border-color: transparent; }
.admin-language-control {
  height: 42px;
  min-width: 154px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  padding: 0 10px;
  color: #344054;
}
.admin-language-control svg {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.admin-language-control select {
  width: auto;
  min-width: 100px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 18px 0 0;
  color: #344054;
  font-size: 14px;
  font-weight: 800;
  box-shadow: none;
}
.admin-language-control select:focus {
  box-shadow: none;
  background: transparent;
}
.admin-version-badge {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
#userBadge { color: var(--muted); font-size: 14px; }
.language-landing {
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.language-panel {
  width: min(1040px, 100%);
  max-height: min(780px, calc(100vh - 124px));
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(250,252,255,.92));
  border: 1px solid rgba(255,255,255,.86);
  border-radius: 26px;
  box-shadow: var(--shadow-lift);
  padding: 34px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.language-panel::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 25px;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.95), inset 0 -22px 42px rgba(49,87,213,.035);
}
.language-panel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
}
.language-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 26px;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 8px 4px;
  scrollbar-gutter: stable;
}
.language-option {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 18px 20px;
  text-align: left;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff, #f3f7fc);
  border: 1px solid rgba(119,139,170,.25);
  border-radius: 16px;
  box-shadow: 0 14px 30px rgba(20,34,73,.08), inset 0 1px 0 rgba(255,255,255,.92);
}
.language-option:hover {
  color: white;
  background: linear-gradient(135deg, #3157d5, #20b6a8);
  transform: translateY(-3px);
  box-shadow: 0 20px 42px rgba(49,87,213,.24), inset 0 1px 0 rgba(255,255,255,.28);
}
.language-option strong {
  font-size: 20px;
  line-height: 1.2;
}
.language-flag {
  width: 48px;
  height: 32px;
  flex: 0 0 48px;
  display: block;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid rgba(79, 99, 132, .18);
  box-shadow: 0 4px 10px rgba(20, 34, 73, .12);
  background: #fff;
}
.language-flag.is-neutral {
  object-fit: contain;
  padding: 3px;
  background: #eef5ff;
}
.main-layout { display: grid; grid-template-columns: 390px minmax(0, 1fr); gap: 24px; padding: 24px; max-width: 1380px; height: calc(100vh - 76px); min-height: 0; margin: 0 auto; }
.avatar-panel, .chat-panel, .admin-card {
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(249,252,255,.86));
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,.78);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
  outline: 1px solid rgba(119,139,170,.12);
}
.avatar-panel { padding: 24px; text-align: center; position: relative; overflow: auto; min-height: 0; }
.assistant-card { position: relative; width: min(280px, 100%); margin: 0 auto; padding-top: 8px; }
.avatar-glow { position: absolute; inset: 34px 20px 16px; background: linear-gradient(135deg, rgba(49,87,213,.20), rgba(32,182,168,.22)); filter: blur(24px); border-radius: 35px; }
.avatar { position: relative; width: 244px; max-width: 100%; border-radius: 34px; object-fit: cover; box-shadow: 0 34px 70px rgba(20,34,73,.24), 0 10px 24px rgba(32,182,168,.10); animation: float 4.5s ease-in-out infinite; border: 4px solid rgba(255,255,255,.86); }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.status-pill { position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(255,255,255,.92); border: 1px solid rgba(148,163,184,.22); border-radius: 999px; font-size: 13px; font-weight: 800; color: #344054; box-shadow: 0 10px 28px rgba(31,50,102,.12); }
.status-pill span { width: 8px; height: 8px; border-radius: 999px; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.14); }
.avatar-panel h2 { margin: 24px 0 8px; font-size: 32px; letter-spacing: -.03em; }
.assistant-intro { color: var(--muted); line-height: 1.7; margin: 0 auto 16px; max-width: 310px; }
.capability-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0; }
.capability-row span { padding: 8px 10px; border-radius: 999px; background: rgba(49,87,213,.08); color: #3157d5; font-size: 12px; font-weight: 900; }
.quick-actions { display: grid; gap: 10px; margin-top: 20px; }
.quick-question { background: linear-gradient(180deg, #ffffff, #f7faff); color: #22304a; text-align: left; border: 1px solid rgba(119,139,170,.18); box-shadow: 0 10px 22px rgba(20,34,73,.06), inset 0 1px 0 rgba(255,255,255,.9); font-weight: 750; }
.quick-question:hover { background: white; box-shadow: 0 16px 30px rgba(20,34,73,.10), inset 0 1px 0 rgba(255,255,255,.95); }
.chat-panel { height: 100%; min-height: 0; padding: 18px; display: flex; flex-direction: column; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 10px 16px; border-bottom: 1px solid rgba(148,163,184,.16); }
.chat-header h1 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.voice-toggle { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid rgba(148,163,184,.22); border-radius: 999px; background: rgba(255,255,255,.82); cursor: pointer; user-select: none; }
.chat-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.small-action { min-height: 42px; padding: 9px 13px; font-size: 13px; border-radius: 999px; }
.voice-toggle input { display: none; }
.toggle-track { width: 52px; height: 30px; border-radius: 999px; background: #d8dee9; position: relative; transition: background .18s ease; }
.toggle-thumb { position: absolute; width: 24px; height: 24px; top: 3px; left: 3px; border-radius: 999px; background: white; box-shadow: 0 3px 8px rgba(0,0,0,.20); transition: transform .18s ease; }
.voice-toggle input:checked + .toggle-track { background: linear-gradient(135deg, var(--accent), #3bcf81); }
.voice-toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(22px); }
.voice-toggle strong { font-size: 13px; color: #344054; min-width: 66px; text-align: left; }
.messages { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 18px 10px; scroll-behavior: smooth; overscroll-behavior: contain; }
.license-gate { flex: 1 1 auto; min-height: 0; display: grid; place-items: center; padding: 18px 10px; }
.license-card {
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid rgba(148,163,184,.22);
  border-radius: 18px;
  background: rgba(255,255,255,.90);
  box-shadow: 0 14px 34px rgba(31,50,102,.10);
}
.license-card h2 { margin: 0; font-size: 22px; }
.license-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.license-controls { display: grid; gap: 12px; }
.license-connection-notice {
  flex: 0 0 auto;
  margin: 10px 10px 0;
  padding: 10px 14px;
  border: 1px solid rgba(217,119,6,.25);
  border-radius: 12px;
  background: rgba(255,247,237,.94);
  color: #9a3412;
  font-size: 13px;
  line-height: 1.5;
}
.message { max-width: 78%; padding: 13px 16px; border-radius: 18px; line-height: 1.65; white-space: pre-line; box-shadow: 0 14px 34px rgba(20,34,73,.10), inset 0 1px 0 rgba(255,255,255,.72); }
.message.user { align-self: flex-end; background: linear-gradient(135deg, #3157d5, #6a83f7); color: white; border-bottom-right-radius: 6px; box-shadow: 0 16px 36px rgba(49,87,213,.24); }
.message.assistant { align-self: flex-start; background: linear-gradient(180deg, #ffffff, #f9fbff); color: var(--text); border-bottom-left-radius: 6px; border: 1px solid rgba(119,139,170,.16); }
.message.assistant::before { content: attr(data-assistant-label); display: block; color: #3157d5; font-size: 12px; font-weight: 900; margin-bottom: 4px; letter-spacing: .03em; }
.message-table-wrap { max-width: 100%; overflow-x: auto; margin: 10px 0; white-space: normal; border: 1px solid rgba(119,139,170,.18); border-radius: 14px; box-shadow: inset 0 1px 0 rgba(255,255,255,.65); }
.message-table { width: 100%; min-width: 620px; border-collapse: collapse; background: rgba(255,255,255,.86); font-size: 13px; line-height: 1.45; }
.message-table th, .message-table td { padding: 9px 10px; border-bottom: 1px solid rgba(119,139,170,.16); border-right: 1px solid rgba(119,139,170,.12); text-align: left; vertical-align: top; }
.message-table th:last-child, .message-table td:last-child { border-right: 0; }
.message-table tr:last-child td { border-bottom: 0; }
.message-table th { background: rgba(49,87,213,.08); color: #172033; font-weight: 900; white-space: nowrap; }
.voice-hint { color: var(--muted); font-size: 13px; margin: 2px 10px 10px; min-height: 20px; }
.input-row { flex: 0 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; border-top: 1px solid rgba(119,139,170,.16); padding: 14px 6px 0; align-items: end; background: linear-gradient(180deg, rgba(255,255,255,.76), rgba(255,255,255,.50)); }
.icon-btn { width: 50px; height: 50px; display: grid; place-items: center; padding: 0; font-size: 20px; border-radius: 18px; flex-shrink: 0; }
.btn-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mic-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #0f9f8f, #25c26e);
  box-shadow: 0 12px 28px rgba(32, 182, 168, .24);
}
.mic-btn::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.24);
  pointer-events: none;
}
.mic-btn .btn-icon { position: relative; z-index: 1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.16)); }
.mic-btn.listening {
  background: linear-gradient(135deg, #ef4444, #f97316);
  box-shadow: 0 12px 28px rgba(239, 68, 68, .24);
  animation: pulse 1s infinite;
}
.home-btn {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  color: #22304a;
  background: #eef2f7;
  box-shadow: none;
}
.home-btn:hover {
  color: white;
  background: linear-gradient(135deg, #3157d5, #20b6a8);
}
.send-btn { background: linear-gradient(135deg, #3157d5, #7c5cff); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.chat-actions { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 6px 2px; }
.admin-layout { display: grid; gap: 20px; padding: 24px; max-width: 1180px; margin: 0 auto; }
.admin-login-layout { min-height: calc(100vh - 76px); display: grid; place-items: center; padding: 24px; }
.admin-login-card { width: min(420px, 100%); display: grid; gap: 12px; }
.admin-login-card h2 { margin: 0 0 4px; }
.password-reset-panel {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.admin-tabs {
  position: sticky;
  top: 88px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(148,163,184,.18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(249,252,255,.82));
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(20,34,73,.12), inset 0 1px 0 rgba(255,255,255,.88);
}
.admin-main-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
.admin-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -2px 0 18px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}
.admin-tab-btn,
.admin-subtab-btn {
  background: transparent;
  color: #344054;
  border: 1px solid transparent;
  box-shadow: none;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.admin-tab-btn {
  min-width: 132px;
}
.admin-subtab-btn {
  min-height: 38px;
  padding: 9px 12px;
  font-size: 13px;
  background: rgba(238,242,247,.78);
}
.admin-tab-btn.active,
.admin-subtab-btn.active {
  background: #172033;
  color: white;
}
.notify-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: 900;
}
.notify-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(239, 68, 68, .22);
  border-radius: 14px;
  background: #fff1f2;
  color: #172033;
}
.notify-banner span {
  color: var(--muted);
  flex: 1;
}
.notify-banner button {
  flex: 0 0 auto;
}
.admin-card { padding: 22px; }
.admin-card h2 { margin: 0 0 14px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.admin-actions select { width: auto; min-width: 220px; }
button.danger { color: #b42318; background: #fee4e2; }
button.danger:hover { background: #fecdca; }
.icon-text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.icon-text-btn span[aria-hidden="true"] {
  font-size: 16px;
  line-height: 1;
}
.form-grid { display: grid; gap: 12px; }
.settings-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.settings-header h2 { margin-bottom: 4px; }
.settings-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.settings-header button {
  flex: 0 0 auto;
  min-width: 140px;
}
.settings-layout {
  display: grid;
  gap: 0;
}
.settings-section {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(0, 1fr);
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.settings-section-title h3 {
  margin: 0 0 6px;
  color: #172033;
  font-size: 16px;
}
.settings-section-title p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}
.settings-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.settings-advanced {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(245, 248, 252, 0.72);
  overflow: hidden;
}
.settings-advanced > summary {
  cursor: pointer;
  padding: 13px 16px;
  color: #344054;
  font-weight: 900;
  user-select: none;
}
.settings-advanced[open] > summary { border-bottom: 1px solid var(--line); }
.settings-advanced-fields { padding: 16px; }
.faq-index-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(245, 248, 252, 0.72);
}
.faq-index-bar button { flex: 0 0 auto; }
.settings-language-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(280px, 1fr);
  gap: 18px;
  align-items: end;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
}
.settings-translate-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
}
.settings-translate-option input { width: auto; }
.form-field {
  display: grid;
  gap: 8px;
}
.form-field span {
  color: #172033;
  font-size: 14px;
  font-weight: 900;
}
.form-field small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.checkbox-field {
  align-content: start;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  color: #172033;
  font-weight: 800;
}
.inline-check input {
  width: auto;
}
.field-wide {
  grid-column: 1 / -1;
}
.settings-status {
  margin-top: 14px;
  min-height: 20px;
}
.knowledge-sync-field {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(245, 248, 252, 0.72);
}
.knowledge-sync-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.knowledge-sync-actions button { flex: 0 0 auto; }
.message-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(119,139,170,.18);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
}
.message-sources strong { color: #344054; }
.message-source { display: block; overflow-wrap: anywhere; }
.faq-save-status {
  min-height: 24px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}
.faq-save-status:empty {
  min-height: 0;
  padding: 0;
}
.faq-save-status.is-saving { color: #3157d5; }
.faq-save-status.is-success { color: #15803d; }
.faq-save-status.is-error { color: #b42318; }
.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.file-upload-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.92);
}
.file-upload-control button {
  flex: 0 0 auto;
}
.file-upload-control span {
  min-width: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.license-create-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.account-layout {
  display: grid;
  gap: 0;
}
.account-section:last-child {
  border-bottom: 0;
}
.openai-grid {
  gap: 16px;
  padding-top: 22px;
}
.ai-usage-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.ai-usage-summary > div {
  padding: 14px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #f7f9fc;
}
.ai-usage-summary span, .ai-usage-summary strong { display: block; }
.ai-usage-summary span { color: var(--muted); font-size: 13px; }
.ai-usage-summary strong { margin-top: 5px; font-size: 18px; }
.dashboard-layout {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}
.dashboard-section {
  display: grid;
  gap: 12px;
}
.dashboard-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.dashboard-section-header h3 {
  margin: 0;
}
.dashboard-section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.metric-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(119,139,170,.18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(246,250,255,.84));
  box-shadow: 0 14px 30px rgba(20,34,73,.08), inset 0 1px 0 rgba(255,255,255,.9);
}
.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.metric-card strong {
  color: #172033;
  font-size: 34px;
  line-height: 1;
}
.dashboard-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, .8fr) minmax(220px, .8fr);
  gap: 12px;
}
.dashboard-chart-card {
  min-height: 230px;
  padding: 16px;
  border: 1px solid rgba(119,139,170,.18);
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 0%, rgba(78,112,255,.12), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(242,247,255,.86));
  box-shadow: 0 18px 36px rgba(20,34,73,.1), inset 0 1px 0 rgba(255,255,255,.92);
}
.dashboard-chart-title {
  color: #172033;
  font-size: 15px;
  font-weight: 900;
  margin-bottom: 16px;
}
.dashboard-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: -8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.dashboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-shadow: 0 5px 12px rgba(20,34,73,.14);
}
.legend-conversations {
  background: #3157d5;
}
.legend-requests {
  background: #22c7a9;
}
.bar-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  min-height: 160px;
}
.bar-group {
  display: grid;
  align-items: end;
  gap: 7px;
  min-width: 0;
}
.bar-stack {
  height: 118px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
}
.bar-fill {
  width: 14px;
  min-height: 4px;
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #4f6ff4, #2445c7);
  box-shadow: 0 8px 16px rgba(49,87,213,.22);
}
.bar-fill.requests {
  background: linear-gradient(180deg, #22c7a9, #079178);
  box-shadow: 0 8px 16px rgba(7,145,120,.18);
}
.bar-label,
.bar-values {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}
.bar-values {
  color: #172033;
}
.gauge-chart,
.donut-chart {
  width: min(160px, 72%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  margin: 10px auto 0;
  border-radius: 50%;
  background: conic-gradient(#22c55e var(--gauge-value, 0%), #e4ebf5 0);
  box-shadow: 0 18px 34px rgba(20,34,73,.12), inset 0 1px 0 rgba(255,255,255,.9);
}
.donut-chart {
  background: conic-gradient(#f97316 var(--pending-value, 0%), #22c55e 0);
}
.gauge-chart::before,
.donut-chart::before {
  content: "";
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #f8fbff);
  box-shadow: inset 0 2px 10px rgba(20,34,73,.08);
}
.gauge-chart span,
.donut-chart span {
  position: relative;
  z-index: 1;
  color: #172033;
  font-size: 20px;
  font-weight: 900;
  text-align: center;
}
.gauge-chart small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}
.status-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.status-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 6px 14px rgba(20,34,73,.16);
}
.status-dot.online {
  background: #22c55e;
}
.status-dot.offline {
  background: #f87171;
}
.status-dot.licensed {
  background: #94a3b8;
}
.dashboard-device-usage {
  padding: 14px;
  border: 1px solid rgba(119,139,170,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 10px 24px rgba(20,34,73,.06), inset 0 1px 0 rgba(255,255,255,.86);
}
.usage-row {
  display: grid;
  grid-template-columns: minmax(130px, 220px) 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.usage-row:first-of-type {
  margin-top: 0;
}
.usage-label {
  min-width: 0;
  overflow: hidden;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.usage-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef7;
  box-shadow: inset 0 1px 3px rgba(20,34,73,.08);
}
.usage-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c7a9, #3157d5);
  box-shadow: 0 8px 16px rgba(49,87,213,.18);
}
.usage-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.dashboard-list {
  display: grid;
  gap: 10px;
}
.dashboard-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(119,139,170,.18);
  border-radius: 16px;
  background: rgba(255,255,255,.82);
  box-shadow: 0 10px 24px rgba(20,34,73,.06), inset 0 1px 0 rgba(255,255,255,.86);
}
.dashboard-task {
  justify-content: flex-start;
  color: #7a2e0e;
  background: linear-gradient(180deg, rgba(255,247,237,.95), rgba(255,251,245,.86));
  border-color: rgba(251,146,60,.22);
  font-weight: 800;
}
.dashboard-analysis-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.manual-layout {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}
.manual-section {
  overflow: hidden;
  border: 1px solid rgba(119,139,170,.18);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,251,255,.82));
  box-shadow: 0 12px 28px rgba(20,34,73,.07), inset 0 1px 0 rgba(255,255,255,.9);
}
.manual-section summary {
  cursor: pointer;
  padding: 16px 18px;
  color: #172033;
  font-weight: 900;
  list-style: none;
}
.manual-section summary::-webkit-details-marker {
  display: none;
}
.manual-section summary::after {
  content: "+";
  float: right;
  color: #3157d5;
  font-weight: 900;
}
.manual-section[open] summary::after {
  content: "-";
}
.manual-section h3 {
  margin: 14px 18px 8px;
  font-size: 15px;
}
.manual-section p,
.manual-section li {
  color: var(--muted);
  line-height: 1.7;
}
.manual-section p {
  margin: 8px 18px 16px;
}
.manual-section ol,
.manual-section ul {
  margin: 8px 18px 16px;
  padding-left: 24px;
}
.manual-section strong {
  color: #172033;
}
.license-key-actions {
  margin-top: 18px;
}
.faq-tools {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}
.list { display: grid; gap: 12px; margin-top: 16px; }
.scroll-list {
  max-height: calc(100vh - 285px);
  min-height: 260px;
  overflow: auto;
  padding-right: 6px;
  overscroll-behavior: contain;
}
.item { background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(248,251,255,.82)); border: 1px solid rgba(119,139,170,.18); border-radius: 18px; padding: 14px; line-height: 1.6; box-shadow: 0 12px 28px rgba(20,34,73,.07), inset 0 1px 0 rgba(255,255,255,.9); }
.category-heading {
  padding: 10px 2px 0;
  color: #344054;
  font-weight: 900;
}
.item-title { font-weight: 900; margin-bottom: 4px; }
.item-meta, .admin-note { color: var(--muted); font-size: 13px; line-height: 1.55; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.item-actions button { padding: 8px 12px; border-radius: 10px; }
.message a, .item a { color: #3157d5; font-weight: 900; text-decoration: underline; text-underline-offset: 3px; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.58); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 18px; z-index: 20; }
.modal-card { width: min(520px, 100%); display: grid; gap: 12px; background: linear-gradient(180deg, #ffffff, #f8fbff); border: 1px solid rgba(255,255,255,.78); border-radius: 28px; padding: 24px; box-shadow: 0 38px 95px rgba(9,18,38,.32), inset 0 1px 0 rgba(255,255,255,.9); position: relative; }
.modal-close { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 0; background: #eef2f7; color: #172033; box-shadow: none; font-family: Arial, sans-serif; font-size: 25px; font-weight: 500; line-height: 1; }
.modal-card h2 { margin: 0; }
.modal-card p { margin: 0; color: var(--muted); line-height: 1.6; }
@media (max-width: 980px) {
  .main-layout { grid-template-columns: 1fr; height: auto; min-height: calc(100vh - 76px); }
  .metric-grid, .dashboard-analysis-metrics, .dashboard-chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .avatar-panel { order: 2; }
  .chat-panel { height: calc(100vh - 124px); min-height: 620px; }
  .ai-usage-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-aspect-ratio: 4 / 3) {
  .language-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (orientation: portrait) {
  .language-panel { width: min(760px, 100%); }
  .language-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { height: auto; padding: 14px; grid-template-columns: 1fr; align-items: stretch; gap: 12px; }
  .announcement-marquee { width: 100%; max-width: none; margin: 0; }
  .topbar nav { justify-content: stretch; }
  .nav-btn { flex: 1; }
  .main-layout, .admin-layout, .admin-login-layout { padding: 14px; }
  .main-layout { min-height: calc(100vh - 126px); }
  .language-landing { padding: 14px; }
  .language-panel { padding: 24px 18px; max-height: calc(100vh - 164px); }
  .language-panel h1 { font-size: 29px; }
  .language-options { gap: 10px; }
  .language-option { min-height: 88px; padding: 14px 12px; gap: 10px; }
  .language-option strong { font-size: 17px; }
  .language-flag { width: 40px; height: 27px; flex-basis: 40px; }
  .chat-panel { height: calc(100vh - 154px); min-height: 520px; padding: 14px; }
  .chat-header { align-items: flex-start; flex-direction: column; }
  .input-row { grid-template-columns: 1fr auto auto; }
  .message { max-width: 92%; }
  .chat-actions { flex-direction: column; align-items: stretch; }
  .admin-tabs { top: 126px; }
  .admin-tab-btn, .admin-subtab-btn { flex: 1 1 100%; }
  .admin-actions { align-items: stretch; flex-direction: column; }
  .settings-header { flex-direction: column; }
  .settings-header button { width: 100%; }
  .settings-section { grid-template-columns: 1fr; gap: 12px; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-language-toolbar { grid-template-columns: 1fr; }
  .metric-grid, .dashboard-analysis-metrics, .dashboard-chart-grid { grid-template-columns: 1fr; }
  .dashboard-row, .dashboard-section-header { flex-direction: column; }
  .usage-row { grid-template-columns: 1fr; }
  .license-create-grid { grid-template-columns: 1fr; }
  .faq-tools { grid-template-columns: 1fr; }
  .faq-index-bar { align-items: stretch; flex-direction: column; }
  .scroll-list { max-height: calc(100vh - 360px); }
  .ai-usage-summary { grid-template-columns: 1fr; }
}
