/* ============================================================================
   极简扁平风格 - Minimalist Flat Design

   核心原则�?   - 纯白背景
   - 黑色边框和文�?   - 无阴影、无渐变、无圆角
   - 大量留白
   - 扁平设计
   ============================================================================ */

:root {
  --white: #ffffff;
  --black: #000000;
  --beige-50: #faf8f5;
  --beige-100: #f4f1eb;
  --beige-200: #e8e3d8;
  --beige-300: #d4ccbb;
  --gray-700: #5a5a5a;
  --accent: #d97757;
  --success: #00cc66;
  --warning: #ff9933;
  --danger: #cc4444;
}

/* ============================================================================
   基础样式
   ============================================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--beige-50);
  color: var(--black);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ============================================================================
   登录页面
   ============================================================================ */

.auth-shell {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--white);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 3rem;
  background: var(--white);
  border: 2px solid var(--black);
}

.brand-mark {
  width: 60px;
  height: 60px;
  margin-bottom: 1.5rem;
  border: 2px solid var(--black);
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.eyebrow {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--black);
}

h1 {
  margin-bottom: 0.5rem;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--black);
}

h2 {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--black);
}

.auth-description,
.page-description,
.modal-description {
  margin-bottom: 1rem;
  color: var(--gray-700);
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 2rem;
}

.field-label {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--black);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  background: var(--white);
  border: 2px solid var(--black);
  color: var(--black);
  transition: border-color 0.2s;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--accent);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

input::placeholder,
textarea::placeholder {
  color: var(--gray-700);
}

textarea {
  min-height: 200px;
  resize: vertical;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 3rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--black);
  transition: background 0.2s;
}

.icon-button:hover {
  background: var(--beige-100);
}

.input-icon {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
}

.input-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.form-error,
.mail-error {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--danger);
}

/* ============================================================================
   按钮
   ============================================================================ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.5rem;
  font-weight: 700;
  background: var(--white);
  border: 2px solid var(--black);
  color: var(--black);
  transition: all 0.2s;
}

.button:hover:not(:disabled) {
  background: var(--black);
  color: var(--white);
}

.button svg {
  width: 1.25rem;
  height: 1.25rem;
}

.button-primary {
  background: var(--black);
  color: var(--white);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}

.button-secondary {
  background: var(--white);
  color: var(--black);
}

.button-danger {
  background: var(--white);
  border-color: var(--danger);
  color: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger);
  color: var(--white);
}

.button-quiet {
  border: none;
}

.button-small {
  min-height: 40px;
  padding: 0 1rem;
  font-size: 0.875rem;
}

.button-full {
  width: 100%;
  margin-top: 1rem;
}

.button-spinner {
  display: none;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button.is-loading .button-spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   顶部导航�?   ============================================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 0 2rem;
  background: var(--white);
  border-bottom: 2px solid var(--black);
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
  color: var(--black);
  text-decoration: none;
}

.topbar-brand > span:last-child {
  display: inline-block;
  line-height: 40px;
}

.brand-mark-small {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  line-height: 0;
  border: 2px solid var(--black);
}

.brand-mark-small img {
  display: block;
  width: 100%;
  height: 100%;
}

.topbar-actions,
.session-state,
.heading-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.session-state {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.session-state i {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--success);
  border: 2px solid var(--success);
  border-radius: 50%;
}

/* ============================================================================
   主内容区
   ============================================================================ */

.content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--black);
}

.page-heading h1 {
  margin-bottom: 0.5rem;
}

/* ============================================================================
   面板和表�?   ============================================================================ */

.panel {
  background: var(--white);
  border: 2px solid var(--black);
}

.account-panel {
  margin-top: 2rem;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--beige-100);
  border-bottom: 2px solid var(--black);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 400px;
  height: 48px;
  padding: 0 1rem;
  background: var(--white);
  border: 2px solid var(--black);
}

.search-box:focus-within {
  border-color: var(--accent);
}

.search-box svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--black);
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  background: transparent;
  border: none;
}

/* 隐藏浏览器原生 type="search" 内置的清除按钮，避免与自定义的 .clear-search 重复 */
.search-box input[type='search']::-webkit-search-cancel-button,
.search-box input[type='search']::-webkit-search-decoration,
.search-box input[type='search']::-webkit-search-results-button,
.search-box input[type='search']::-webkit-search-results-decoration {
  display: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-box input:focus {
  outline: none;
  border: none;
}

.clear-search {
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--beige-200);
  border: none;
  color: var(--black);
}

.clear-search:hover {
  background: var(--gray-700);
  color: var(--white);
}

.selected-count {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.table-scroll {
  position: relative;
  min-height: 300px;
  overflow-x: auto;
}

.accounts-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.accounts-table th {
  padding: 1rem;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--white);
  border-bottom: 2px solid var(--black);
  color: var(--black);
  text-align: center;
}

.accounts-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--beige-200);
  color: var(--black);
  text-align: center;
  vertical-align: middle;
}

.accounts-table tbody tr:hover {
  background: var(--beige-100);
}

.accounts-table tbody tr:last-child td {
  border-bottom: none;
}

.checkbox-cell {
  width: 50px;
  text-align: center;
}

input[type='checkbox'] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--black);
  vertical-align: middle;
}

.email-cell {
  min-width: 360px;
  width: 40%;
  font-weight: 700;
  text-align: left;
}

.email-header {
  text-align: left;
}

.email-value {
  display: inline-block;
  max-width: 100%;
  padding: 0.25rem 0;
  font: inherit;
  text-align: left;
  word-break: break-all;
  background: transparent;
  border: none;
  cursor: pointer;
}

.email-value:hover:not(:disabled) {
  color: var(--accent);
  text-decoration: none;
}

.expiry-cell {
  min-width: 150px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.auto-refresh-cell {
  width: 100px;
  text-align: center;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--beige-200);
  border: 2px solid var(--black);
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--black);
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--success);
  border-color: var(--black);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
  background: var(--black);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.note-cell {
  min-width: 160px;
  text-align: center;
}

.note-input {
  width: 100%;
  max-width: 200px;
  padding: 0.5rem;
  font-size: 0.875rem;
  background: var(--white);
  border: 1px solid var(--beige-200);
  color: var(--black);
  transition: border-color 0.2s;
}

.note-input:hover {
  border-color: var(--black);
}

.note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.actions-cell {
  width: 380px;
  text-align: center;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  justify-content: center;
}

.row-action {
  flex: 0 0 auto;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--white);
  border: 1px solid var(--black);
  color: var(--black);
  transition: all 0.2s;
}

.row-action:hover:not(:disabled) {
  background: var(--black);
  color: var(--white);
}

.row-action-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.row-action-danger:hover:not(:disabled) {
  background: var(--danger);
  color: var(--white);
}

/* ============================================================================
   空状态和加载状�?   ============================================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 3rem;
  text-align: center;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 1.5rem;
  border: 2px solid var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg {
  width: 50px;
  height: 50px;
  color: var(--black);
}

#empty-title {
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
  font-weight: 900;
}

#empty-description {
  margin-bottom: 1.5rem;
  color: var(--gray-700);
}

.table-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 1rem;
  font-weight: 600;
  color: var(--black);
}

.loader {
  width: 24px;
  height: 24px;
  border: 3px solid var(--beige-200);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================================
   分页
   ============================================================================ */

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  background: var(--beige-100);
  border-top: 2px solid var(--black);
}

.pagination-summary {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pagination-button {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.5rem;
  font-weight: 900;
  background: var(--white);
  border: 2px solid var(--black);
  color: var(--black);
}

.pagination-button:hover:not(:disabled) {
  background: var(--black);
  color: var(--white);
}

.pagination-button:disabled {
  opacity: 0.3;
}

.page-indicator {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--black);
}

/* ============================================================================
   模态框
   ============================================================================ */

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.95);
}

/* 确认对话框需置于其它模态框之上（如 API Key 管理、查看等） */
#confirm-modal {
  z-index: 120;
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: auto;
  background: var(--white);
  border: 2px solid var(--black);
}

.modal-wide {
  max-width: 800px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2rem;
  border-bottom: 2px solid var(--black);
}

.modal-close {
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  background: transparent;
  border: 2px solid var(--black);
}

.modal-close:hover {
  background: var(--black);
  color: var(--white);
}

.entry-tabs {
  display: flex;
  border-bottom: 2px solid var(--black);
}

.entry-tab {
  flex: 1;
  padding: 1rem;
  font-weight: 700;
  background: var(--beige-100);
  border: none;
  border-right: 2px solid var(--black);
  color: var(--gray-700);
}

.entry-tab:last-child {
  border-right: none;
}

.entry-tab.is-active {
  background: var(--white);
  color: var(--black);
}

.entry-tab:hover {
  background: var(--white);
}

.entry-panel {
  padding: 2rem;
}

.modal-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--black);
}

.input-hint {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 2rem;
  background: var(--beige-100);
  border: 2px dashed var(--black);
  cursor: pointer;
  transition: all 0.2s;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  background: var(--white);
  border-color: var(--accent);
}

.drop-icon {
  width: 60px;
  height: 60px;
  margin-bottom: 1rem;
}

.drop-icon svg {
  width: 100%;
  height: 100%;
  color: var(--black);
}

#file-name {
  font-weight: 700;
  color: var(--black);
}

#file-help {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.confirm-modal {
  max-width: 400px;
}

.compact-header {
  padding: 1.5rem;
}

.confirm-description {
  padding: 1.5rem;
  color: var(--gray-700);
}

.confirm-actions {
  display: flex;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 2px solid var(--black);
}

.confirm-actions .button {
  flex: 1;
}

/* ============================================================================
   Toast 通知
   ============================================================================ */

.toast-region {
  position: fixed;
  z-index: 200;
  top: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
}

.toast {
  padding: 1rem 1.5rem;
  font-weight: 600;
  background: var(--white);
  border: 2px solid var(--black);
  color: var(--black);
  animation: slideIn 0.3s ease;
}

.toast.toast-error {
  border-color: var(--danger);
  color: var(--danger);
}

.toast.toast-warning {
  border-color: var(--warning);
  color: var(--warning);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================================
   响应�?   ============================================================================ */

@media (max-width: 768px) {
  .topbar {
    padding: 0 1rem;
  }

  .content {
    padding: 2rem 1rem;
  }

  .page-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .row-actions {
    flex-direction: column;
  }

  .actions-cell {
    width: auto;
  }
}

/* ============================================================================
   邮件查看器优�?- 紧凑布局
   ============================================================================ */

.modal-mail {
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
}

.mail-modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 2px solid var(--black);
}

.mail-modal-header .eyebrow {
  margin-bottom: 0.25rem;
  font-size: 0.65rem;
}

.mail-modal-header h2 {
  margin-bottom: 0.25rem;
  font-size: 1.25rem;
}

.mail-account {
  margin: 0;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.mail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--beige-100);
  border-bottom: 2px solid var(--black);
}

.mail-folder-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
}

.mail-folder-label select {
  min-width: 150px;
  padding: 0.5rem;
  font-size: 0.875rem;
  background: var(--white);
  border: 2px solid var(--black);
}

.mail-status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--gray-700);
}

.mail-error {
  margin: 0;
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  background: var(--white);
  border-bottom: 2px solid var(--danger);
  color: var(--danger);
}

.mail-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mail-list-panel {
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--black);
  overflow: hidden;
}

.mail-state {
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  color: var(--gray-700);
  text-align: center;
}

.mail-message-list {
  flex: 1;
  overflow-y: auto;
}

.mail-message-item {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: var(--white);
  border: 2px solid var(--black);
  border-bottom: 2px solid var(--black);
  margin-bottom: -2px;
  transition: all 0.2s;
}

.mail-message-item:hover {
  background: var(--beige-100);
  border-color: var(--black);
  z-index: 1;
  position: relative;
}

.mail-message-item.is-selected {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
  z-index: 2;
  position: relative;
}

.mail-message-item.is-unread {
  font-weight: 700;
}

.mail-message-subject {
  margin: 0 0 0.25rem 0;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
}

.mail-message-item.is-selected .mail-message-subject {
  color: var(--white);
}

.mail-message-preview {
  margin: 0 0 0.25rem 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--gray-700);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.mail-message-item.is-selected .mail-message-preview {
  color: var(--beige-200);
}

.mail-message-from {
  margin: 0;
  padding: 0;
  font-size: 0.75rem;
  color: var(--gray-700);
  line-height: 1.4;
}

.mail-message-item.is-selected .mail-message-from {
  color: var(--beige-200);
}

.mail-detail-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mail-detail-panel > .mail-state {
  padding: 2rem;
}

#mail-detail-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.mail-detail-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--black);
  background: var(--beige-100);
}

.mail-detail-header h3 {
  margin-bottom: 1rem;
  font-size: 1.125rem;
  font-weight: 900;
}

.mail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.mail-meta dt {
  font-weight: 700;
  color: var(--black);
}

.mail-meta dd {
  margin: 0;
  color: var(--gray-700);
  word-break: break-word;
}

.mail-detail-body-container {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--white);
}

.mail-detail-body-container iframe {
  width: 100%;
  min-height: 400px;
  border: 1px solid var(--beige-200);
}

/* 邮件列表加载状�?*/
#mail-message-state.is-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
}

#mail-message-state.is-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--beige-200);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ============================================================================
   用户悬浮菜单 + API Key 管理 + API 文档
   ============================================================================ */

.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.75rem;
  background: transparent;
  border: 2px solid var(--black);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
}

.user-menu-toggle .dot {
  flex: 0 0 auto;
  align-self: center;
  display: block;
  width: 10px;
  height: 10px;
  background: var(--success);
  border: 2px solid var(--success);
  border-radius: 50%;
}

.user-menu-toggle > .dot,
.user-menu-toggle > .chevron {
  display: block;
}

.user-menu-toggle #session-username {
  color: var(--black);
  font-weight: 600;
}

.user-menu-toggle #session-username:empty {
  display: none;
}

.user-menu-toggle:hover {
  background: var(--black);
  color: var(--white);
}

.user-menu-toggle:hover .dot {
  background: var(--white);
  border-color: var(--white);
}

.user-menu-toggle:hover #session-username {
  color: var(--white);
}

.user-menu-toggle .chevron {
  display: block;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}

.user-menu-toggle[aria-expanded='true'] .chevron {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 220px;
  background: var(--white);
  border: 2px solid var(--black);
}

.user-dropdown[hidden] {
  display: none;
}

.user-dropdown button {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--beige-200);
  color: var(--black);
}

.user-dropdown button:last-child {
  border-bottom: none;
}

.user-dropdown button:hover {
  background: var(--beige-100);
}

.user-dropdown svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.modal-apikey {
  max-width: 620px;
}

.apikey-generate {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 2px solid var(--black);
  background: var(--beige-50);
}

.apikey-name-row {
  flex: 1;
}

.apikey-name-row .field-label {
  margin-bottom: 0.4rem;
}

.apikey-name-row input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--black);
  background: var(--white);
  font-size: 0.875rem;
}

.apikey-result {
  padding: 1.25rem 1.5rem;
  background: var(--beige-100);
  border-bottom: 2px solid var(--black);
}

.apikey-result-title {
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent);
}

.apikey-value-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.apikey-value {
  flex: 1;
  padding: 0.7rem 0.9rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.8125rem;
  word-break: break-all;
  background: var(--white);
  border: 2px solid var(--black);
}

.apikey-reveal-hint {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--gray-700);
}

.apikey-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  border-bottom: 2px solid var(--black);
}

.apikey-list {
  padding: 0.75rem 1.5rem 1.5rem;
}

.apikey-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--beige-200);
}

.apikey-item:last-child {
  border-bottom: none;
}

.apikey-item-info {
  flex: 1;
  min-width: 0;
}

.apikey-item-name {
  font-size: 0.875rem;
  font-weight: 700;
}

.apikey-item-meta {
  font-size: 0.75rem;
  color: var(--gray-700);
}

.apikey-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.modal-reveal {
  max-width: 440px;
}

.reveal-password-field {
  margin-top: 1rem;
}

.reveal-password-field input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--black);
  font-size: 0.875rem;
}

.reveal-actions {
  margin-top: 1.5rem;
}

.reveal-actions .button {
  flex: 1;
}

@media (max-width: 480px) {
  .apikey-generate {
    flex-direction: column;
    align-items: stretch;
  }
  .apikey-value-row {
    flex-direction: column;
    align-items: stretch;
  }
  .apikey-item {
    flex-direction: column;
    align-items: flex-start;
  }
}

