/* ==========================================================================
   H-Beyond CMS · UI 组件与通用控件 (UI Components)
   ========================================================================== */
.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  position: relative;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--subtle); color: var(--ink); border-color: #cbd5e1; }
.top-action { position: relative; }
.notification-dot {
  position: absolute;
  right: -4px;
  top: -4px;
  background: var(--orange);
  color: #fff;
  border: 2px solid var(--paper);
  font-size: 9px;
  min-width: 17px;
  height: 17px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 600;
}

.role-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5 0%, #312e81 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.avatar-clickable:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}
.avatar-badge-edit::after {
  content: "📷";
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 15px;
  height: 15px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  pointer-events: none;
}
/* 头像选择器弹窗：纯净拖拽与选区裁切 */
.modal:has(.avatar-modal-container) {
  width: min(380px, 100%);
}
.avatar-modal-container {
  width: 100%;
  margin: 0 auto;
}
.avatar-dropzone {
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: var(--radius-card);
  padding: 44px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 240px;
}
.avatar-dropzone:hover,
.avatar-dropzone.dragover {
  border-color: var(--orange);
  background: var(--orange-soft);
}
.avatar-dropzone-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e0e7ff;
  color: #4338ca;
  display: grid;
  place-items: center;
}
.avatar-dropzone-icon svg {
  width: 22px;
  height: 22px;
}
.avatar-dropzone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.avatar-dropzone-sub {
  font-size: 12px;
  color: var(--muted);
}

/* 交互裁切与选区 */
.avatar-crop-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.avatar-crop-canvas-wrap {
  position: relative;
  width: 280px;
  height: 280px;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border: 1px solid var(--line);
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.avatar-crop-canvas-wrap:active {
  cursor: grabbing;
}
.avatar-zoom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 280px;
}
.avatar-zoom-slider {
  flex: 1;
  accent-color: var(--orange);
  cursor: pointer;
  height: 4px;
}
.avatar-crop-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 280px;
  gap: 12px;
  margin-top: 4px;
}
.avatar-crop-actions .btn {
  flex: 1;
}
.role-copy { line-height: 1.25; }
.role-copy b { font-weight: 600; font-size: 13px; }
.role-copy small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }
.role-switch select { border: 0; background: transparent; font-weight: 600; max-width: 100px; cursor: pointer; }

.btn {
  height: 34px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0 14px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}
.btn:hover { background: #f3f4f6; border-color: rgba(0,0,0,0.14); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: #111827; border-color: #111827; color: #ffffff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); font-weight: 600; }
.btn.primary:hover { background: #1f2937; border-color: #1f2937; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #ffffff; }
.btn.dark:hover { background: #1e293b; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red-border); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 11px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Attio 风格交互胶囊按钮 (Quiet Pill Action Buttons) */
.link-btn {
  border: 0;
  background: #f1f5f9;
  color: #334155;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  line-height: 1.35;
  text-decoration: none;
}
.link-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  text-decoration: none;
}
.link-btn.orange {
  background: #eef2ff;
  color: #4338ca;
}
.link-btn.orange:hover {
  background: #e0e7ff;
  color: #312e81;
}
.link-btn.danger {
  background: #fee2e2;
  color: #b91c1c;
}
.link-btn.danger:hover {
  background: #fecaca;
  color: #991b1b;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top-left-radius: var(--radius-card);
  border-top-right-radius: var(--radius-card);
  border-bottom: 0;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.search-box { position: relative; min-width: 240px; }
.search-box .svg-icon {
  position: absolute;
  left: 10px;
  top: 9px;
  width: 15px;
  color: var(--muted);
  pointer-events: none;
}
.search-box input {
  height: 32px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--subtle);
  padding: 0 10px 0 32px;
  border-radius: var(--radius);
  font-size: 12px;
  transition: all 0.15s ease;
}
.search-box input:focus {
  background: var(--paper);
  border-color: var(--orange);
  outline: none;
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.select, .input {
  height: 32px;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 0 10px;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--ink);
  transition: all 0.15s ease;
}
.select:focus, .input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-soft);
  outline: none;
}
.input { width: 100%; height: 36px; }
textarea.input { height: auto; min-height: 80px; padding: 10px; resize: vertical; }
.select { min-width: 116px; }

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.tab {
  height: 38px;
  border: 0;
  background: transparent;
  padding: 0 16px;
  position: relative;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s ease;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tab:hover { color: var(--ink); background: rgba(226, 232, 240, 0.4); }
.tab.active { color: var(--orange); font-weight: 600; }
.tab.active:after {
  content: "";
  height: 2px;
  background: var(--orange);
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  border-radius: 2px;
}
.tab .tab-count {
  font-size: 11px;
  margin-left: 6px;
  padding: 1px 6px;
  background: var(--subtle);
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-weight: normal;
}
.tab.active .tab-count { background: var(--orange-soft); color: var(--orange); }

.table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  overflow: auto;
  border-bottom-left-radius: var(--radius-card);
  border-bottom-right-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}
.toolbar + .table-wrap {
  border-top: 1px solid var(--line);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
table { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 12px; }
th {
  text-align: left;
  height: 38px;
  padding: 0 14px;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td {
  height: 52px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-light);
  vertical-align: middle;
  color: var(--ink-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fafc; }
tbody tr.highlight td { background: var(--purple-soft); }

/* Attio 核心特性 1：实体公司品牌徽章 (Entity Logo Avatar) */
.entity-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}
.entity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  letter-spacing: -0.02em;
  user-select: none;
}

.cell-main { font-weight: 600; color: var(--ink); font-size: 13px; }
.cell-sub { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.3; }
.cell-link {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-block;
  transition: color 0.15s ease;
}
.cell-link:hover { color: var(--orange); text-decoration: underline; text-underline-offset: 3px; }

.amount {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.row-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.table-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: #fafbfd;
}

/* Attio 核心特性 2：无描边马卡龙纯净胶囊 (Macaron Status Pills) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2.5px 10px;
  border: 0 !important;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.badge::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}
.badge.gray { background: #f3f4f6; color: #4b5563; }
.badge.blue { background: #e0e7ff; color: #4338ca; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.yellow { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.purple { background: #f3e8ff; color: #7e22ce; }
.badge.orange { background: #ffedd5; color: #c2410c; }

.empty {

padding: 64px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.empty .svg-icon { width: 32px; height: 32px; color: #94a3b8; margin-bottom: 12px; }
.empty h3 { color: var(--ink); font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.empty p { margin: 0; font-size: 12px; color: var(--muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--paper);
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  animation: slideUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.wide { width: min(900px, 100%); }
.modal-head {
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.modal-head p { font-size: 11px; color: var(--muted); margin: 0; }
.modal-body { padding: 22px; }
.modal-foot {
  position: sticky;
  bottom: 0;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field.full { grid-column: 1 / -1; }
.field label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.field label .required { color: var(--orange); margin-left: 2px; }
.field select, .field input, .field textarea { width: 100%; }
.field-help { font-size: 11px; color: var(--muted); margin-top: 5px; }

.check-row { display: flex; align-items: flex-start; gap: 9px; padding: 6px 0; font-size: 12px; cursor: pointer; }
.check-row input { accent-color: var(--orange); margin-top: 3px; width: 15px; height: 15px; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 90;
  animation: fadeIn 0.15s ease;
}
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(640px, 95vw);
  background: var(--paper);
  z-index: 91;
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  animation: slideLeft 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: #fafbfd;
}
.drawer-head h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: var(--ink); }
.drawer-head p { margin: 0; color: var(--muted); font-size: 12px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.drawer-foot {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafbfd;
}

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.detail-item {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  overflow-wrap: anywhere;
}
.detail-item small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-bottom: 4px; }
.detail-item b { font-size: 13px; font-weight: 600; color: var(--ink); }

.section-label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.04em; margin: 22px 0 10px; }
.mini-list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mini-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-light);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.mini-row:last-child { border-bottom: 0; }
.mini-row b { font-size: 13px; font-weight: 600; color: var(--ink); }
.mini-row small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #0f172a;
  color: #ffffff;
  min-width: 280px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 12px;
}
.toast .svg-icon { color: #34d399; margin-top: 2px; }
.toast small { display: block; color: #cbd5e1; margin-top: 3px; }

.permission-note {
  padding: 12px 16px;
  background: var(--yellow-soft);
  border: 1px solid var(--yellow-border);
  border-radius: var(--radius);
  font-size: 12px;
  color: #92400e;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}
