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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background 0.2s, color 0.2s;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* ── LAYOUT ── */
.app-shell {
  display: flex;
  height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sidebar-logo {
  padding: 9px 15px 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Theme toggle */
.theme-toggle {
  margin-left: auto;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  border: none;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.theme-toggle.active {
  background: var(--accent);
}

.theme-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left 0.2s;
}

.theme-toggle.active::after {
  left: 18px;
}

/* Account selector — compact */
.account-section {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.account-section .section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .06em;
  margin-bottom: 4px;
  padding: 0 2px;
}

.account-item {
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.account-item:hover {
  background: var(--bg-hover);
}

.account-item.active {
  background: var(--bg-active);
  border-color: var(--accent-light);
}

.account-item .acc-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.account-item .acc-id {
  font-size: 10px;
  color: var(--text-muted);
}

.account-item.active .acc-name {
  color: var(--text-active);
}

.btn-add-account {
  width: 100%;
  margin-top: 4px;
  padding: 5px 8px;
  border: 1px dashed var(--border);
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  text-align: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
}

.btn-add-account:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Nav menu — compact, không flex:1 nữa */
.sidebar-nav {
  flex: 0;
  padding: 6px 8px;
  overflow: visible;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--text-active);
  font-weight: 500;
}

.nav-item .nav-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── RIGHT HISTORY PANEL ── */
.history-panel {
  width: 260px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease, opacity 0.2s ease;
  overflow: hidden;
}

.history-panel:not(.open) {
  width: 0;
  border-left: none;
  opacity: 0;
  pointer-events: none;
}

.history-panel.open {
  opacity: 1;
  pointer-events: auto;
}

.history-panel-header {
  padding: 17px 15px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-panel-header .section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: .03em;
}

.history-panel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-close-history {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.btn-close-history:hover {
  color: var(--text-danger);
  background: var(--bg-danger);
}

/* Toggle button (floating trên main content) */
.btn-toggle-history {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.15s;
}

.btn-toggle-history:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.session-header {
  padding: 7px 10px 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.session-header .section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .06em;
}

.btn-new-chat {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.15s;
}

.btn-new-chat:hover {
  color: var(--accent);
}

.session-list {
  flex: 1;
  /* scroll bên trong */
  overflow-y: auto;
  padding: 2px 8px 8px;
  min-height: 0;
}

.session-list::-webkit-scrollbar {
  width: 3px;
}

.session-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.session-item {
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.session-item:hover {
  background: var(--bg-hover);
}

.session-item.active {
  background: var(--bg-active);
}

.session-item .sess-title {
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.session-item.active .sess-title {
  color: var(--text-active);
  font-weight: 500;
}

.session-item .sess-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
}

.session-item .sess-meta span {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-del-sess {
  background: none;
  border: none;
  color: transparent;
  font-size: 10px;
  padding: 1px 3px;
  cursor: pointer;
  border-radius: 3px;
  line-height: 1;
  transition: all 0.15s;
}

.session-item:hover .btn-del-sess {
  color: var(--text-muted);
}

.btn-del-sess:hover {
  color: var(--text-danger) !important;
  background: var(--bg-danger);
}

/* User footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--text-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-info .user-role {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-logout {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}

.btn-logout:hover {
  color: var(--text-danger);
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
  position: relative;
}

.main-content>[ui-view] {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Page header */
.page-header {
  height: var(--header-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.page-header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-header .subtitle {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
}

/* ── CHAT PAGE ── */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-chat);
}

.chat-body::-webkit-scrollbar {
  width: 5px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Message */
.message {
  display: flex;
  gap: 10px;
  max-width: 78%;
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message.bot {
  margin-right: auto;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.message.bot .msg-avatar {
  background: var(--accent-light);
  color: var(--text-active);
}

.message.user .msg-avatar {
  background: var(--accent);
  color: #fff;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 4px 14px 14px 14px;
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

.message.bot .msg-bubble {
  background: var(--bg-bubble-ai);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  color: var(--text-primary);
}

.message.user .msg-bubble {
  background: var(--bg-bubble-user);
  border-radius: 14px 4px 14px 14px;
  color: var(--text-user);
}

/* Markdown in bubble */
.msg-bubble strong {
  color: var(--text-link);
}

.msg-bubble code {
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.msg-bubble pre {
  background: var(--bg-input);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
}

/* Typing */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.3s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Quick chips */
.quick-chips {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  background: var(--bg-main);
  flex-shrink: 0;
}

.quick-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ── KPI CARDS (Dashboard) ── */
.kpi-card {
  background: var(--bg-input);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.kpi-card-sm {
  background: var(--bg-input);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
}

.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── CONTENT CARD ── */
.content-card {
  position: relative;
}

.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  vertical-align: middle;
}

.btn-copy:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all .15s;
}

.btn-icon:hover {
  background: var(--bg-hover);
}

/* ── A/B TEST ── */
.winner-card {
  border-color: #eab308 !important;
  background: #fefce8;
}

[data-theme="dark"] .winner-card {
  background: #2d2500;
}

.log-unread {
  background: var(--bg-active);
}

/* Input bar */
.chat-input-bar {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg-main);
  flex-shrink: 0;
}

.chat-input-bar textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 25px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  min-height: auto;
  max-height: 120px;
  min-height: 42px;
  outline: none;
  transition: border-color 0.15s;
}

.chat-input-bar textarea:focus {
  border-color: var(--border-focus);
}

.chat-input-bar textarea::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 25px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--accent-hover);
}

.btn-send:disabled {
  background: var(--border);
  cursor: not-allowed;
}

/* ── SETTINGS / ADMIN PAGES ── */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  gap: 24px;
}

.settings-nav {
  width: 180px;
  flex-shrink: 0;
}

.settings-nav .snav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.settings-nav .snav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.settings-nav .snav-item.active {
  background: var(--bg-active);
  color: var(--text-active);
  font-weight: 500;
}

.settings-content {
  flex: 1;
  min-width: 0;
}

.settings-section {
  max-width: 680px;
}

.settings-section h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.card-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

/* Form elements — global base styles */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
input:not([type]),
select,
textarea {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* Select arrow custom */
select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  cursor: pointer;
}

/* Textarea specific */
textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

/* Form group layout */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--bg-danger);
  color: var(--text-danger);
  border: 1px solid var(--border-danger);
}

.btn-danger:hover {
  background: var(--border-danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Badge */
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-admin {
  background: var(--accent-light);
  color: var(--text-active);
}

.badge-user {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.badge-ok {
  background: #f0fdf4;
  color: #15803d;
}

.badge-warn {
  background: #fff7ed;
  color: #c2410c;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

/* ── LOGIN PAGE ── */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
}

.login-box {
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.login-box .login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-box .login-logo .logo-big {
  width: 52px;
  height: 52px;
  background: var(--accent);
  border-radius: 14px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.login-box .login-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.login-box .login-sub {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

.login-error {
  background: var(--bg-danger);
  border: 1px solid var(--border-danger);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-danger);
  margin-bottom: 12px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 13px;
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  min-width: 200px;
}

.toast.success {
  border-left: 3px solid #22c55e;
}

.toast.error {
  border-left: 3px solid #ef4444;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
}

.modal h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── UTILITIES ── */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.gap-2 {
  gap: 8px;
}

.ml-auto {
  margin-left: auto;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.text-sm {
  font-size: 12px;
}

.text-muted {
  color: var(--text-muted);
}

.fade-in {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ── PASSWORD TOGGLE ── */
.pw-wrap {
  position: relative;
}

.pw-wrap input {
  width: 100%;
  padding-right: 40px;
}

.pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  padding: 2px;
  line-height: 1;
  transition: color 0.15s;
}

.pw-toggle:hover {
  color: var(--text-primary);
}

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── ADMIN SIDEBAR ── */
.admin-sidebar {
  background: var(--bg-sidebar);
}

.admin-sidebar .logo-icon {
  background: #dc2626 !important;
}

/* ── ADMIN LOGIN ── */
.admin-login-page .login-box {
  border-top: 3px solid #dc2626;
}

/* ── PROMPT EDITOR ── */
.prompt-editor {
  width: 100%;
  min-height: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Courier New', monospace;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.prompt-editor:focus {
  border-color: var(--border-focus);
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
  }

  .account-section,
  .sidebar-footer {
    display: none;
  }

  .history-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: var(--shadow-md);
  }

  .history-panel:not(.open) {
    width: 0;
  }

  .history-panel.open {
    width: 280px;
  }
}