/* ============================================================
   HelperMatch Admin — Design System
   Neutral, dense, utilitarian — tuned for long multi-hour shifts.
   Distinct from the warm consumer brand: cooler ink, no sand,
   tighter radii, monospace for IDs/money.
   ============================================================ */

:root {
  /* Base */
  --a-bg:            #F4F5F7;
  --a-paper:         #FFFFFF;
  --a-paper-2:       #FAFBFC;
  --a-line:          #E4E7EC;
  --a-line-strong:   #D0D5DD;
  --a-ink:           #101828;
  --a-ink-soft:      #344054;
  --a-ink-muted:     #667085;
  --a-ink-faint:     #98A2B3;

  /* Accents */
  --a-primary:       #1A365D;   /* deep navy — dignified, admin-y */
  --a-primary-2:     #2A4A7F;
  --a-primary-50:    #EEF2F8;
  --a-primary-100:   #DCE5F1;

  --a-success:       #067647;
  --a-success-bg:    #ECFDF3;
  --a-success-line:  #ABEFC6;

  --a-warn:          #B54708;
  --a-warn-bg:       #FEF6EE;
  --a-warn-line:     #F9DBAF;

  --a-danger:        #B42318;
  --a-danger-bg:     #FEF3F2;
  --a-danger-line:   #FECDCA;

  --a-info:          #175CD3;
  --a-info-bg:       #EFF8FF;
  --a-info-line:     #B9E6FE;

  --a-violet:        #5925DC;
  --a-violet-bg:     #F4F3FF;
  --a-violet-line:   #D9D6FE;

  /* Brand bridge to consumer site for cross-links */
  --a-brand:         #E8856A;
  --a-trust:         oklch(0.46 0.12 275);

  /* Typography */
  --a-sans: 'Inter', 'Noto Sans TC', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --a-mono: 'JetBrains Mono', 'Menlo', 'SF Mono', ui-monospace, monospace;

  /* Shape */
  --a-r-sm: 4px;
  --a-r:    6px;
  --a-r-lg: 10px;
  --a-r-xl: 14px;

  /* Shadow */
  --a-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --a-shadow:    0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --a-shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08), 0 4px 8px rgba(16, 24, 40, 0.04);
  --a-shadow-pop:0 12px 40px rgba(16, 24, 40, 0.14), 0 4px 12px rgba(16, 24, 40, 0.06);
  --a-ring:      0 0 0 4px rgba(26, 54, 93, 0.12);

  /* Layout */
  --a-sidebar-w: 248px;
  --a-header-h:  56px;
  --a-subheader-h: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--a-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--a-ink);
  background: var(--a-bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

#admin-root { min-height: 100vh; }

/* ---------- Layout chrome ---------- */
.a-shell { display: grid; grid-template-columns: var(--a-sidebar-w) 1fr; min-height: 100vh; }

.a-sidebar {
  background: #0F1B30;
  color: #CBD5E1;
  padding: 14px 10px;
  border-right: 1px solid #0A1426;
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
}
.a-sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 18px;
  color: #fff;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
}
.a-sidebar-logo-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, #E8856A, #C0634B);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.a-nav-group {
  padding: 14px 10px 6px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748B;
  font-weight: 600;
}
.a-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #CBD5E1;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.a-nav-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.a-nav-item.active {
  background: rgba(232, 133, 106, 0.14);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 2px 0 0 #E8856A;
}
.a-nav-item .a-nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  background: #E8856A; color: #fff;
  min-width: 18px; text-align: center;
}

.a-main { display: flex; flex-direction: column; min-width: 0; }

.a-header {
  height: var(--a-header-h);
  background: var(--a-paper);
  border-bottom: 1px solid var(--a-line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 20;
}
.a-crumb {
  display: flex; align-items: center; gap: 6px;
  color: var(--a-ink-muted);
  font-size: 13px;
}
.a-crumb a, .a-crumb button { color: var(--a-ink-muted); text-decoration: none; border: none; background: none; cursor: pointer; font: inherit; padding: 0; }
.a-crumb a:hover, .a-crumb button:hover { color: var(--a-primary); }
.a-crumb-cur { color: var(--a-ink); font-weight: 600; }

.a-header-spacer { flex: 1; }

.a-env-pill {
  background: var(--a-warn-bg);
  border: 1px solid var(--a-warn-line);
  color: var(--a-warn);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 5px;
}
.a-env-pill::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--a-warn);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.a-user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s;
}
.a-user-chip:hover { background: var(--a-bg); }
.a-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--a-primary), var(--a-primary-2));
  color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
}
.a-user-chip-text { font-size: 13px; line-height: 1.2; }
.a-user-chip-text .role { font-size: 11px; color: var(--a-ink-muted); }

/* ---------- Page container ---------- */
.a-page {
  padding: 22px 24px 48px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}
.a-page-wide { max-width: none; }

.a-page-header {
  display: flex; align-items: flex-end; gap: 16px;
  margin-bottom: 20px;
}
.a-page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 2px;
  color: var(--a-ink);
}
.a-page-sub {
  color: var(--a-ink-muted);
  font-size: 13px;
  margin: 0;
}
.a-page-header-actions {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center;
}

/* ---------- Cards ---------- */
.a-card {
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: var(--a-r-lg);
  box-shadow: var(--a-shadow-sm);
}
.a-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--a-line);
  display: flex; align-items: center; gap: 12px;
}
.a-card-title {
  font-size: 14px; font-weight: 600;
  margin: 0;
  color: var(--a-ink);
  /* Inline flex so any combo of icon + label + count badge inside the
     title gets consistent spacing — without this the AIcon sat right
     against the text with only a single whitespace char between. */
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.a-card-sub {
  font-size: 12.5px;
  color: var(--a-ink-muted);
  margin: 2px 0 0;
}
.a-card-body { padding: 16px; }
.a-card-body-tight { padding: 12px; }
.a-card-body-flush { padding: 0; }
.a-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--a-line);
  background: var(--a-paper-2);
  display: flex; align-items: center; gap: 10px;
  border-radius: 0 0 var(--a-r-lg) var(--a-r-lg);
}

/* ---------- Stat card ---------- */
.a-stat {
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: var(--a-r-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.a-stat-label {
  font-size: 12px;
  color: var(--a-ink-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.a-stat-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--a-ink);
  font-feature-settings: 'tnum';
}
.a-stat-delta {
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}
.a-stat-delta.up { color: var(--a-success); }
.a-stat-delta.down { color: var(--a-danger); }
.a-stat-delta.flat { color: var(--a-ink-muted); }
.a-stat-foot {
  font-size: 11.5px;
  color: var(--a-ink-muted);
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.a-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: var(--a-r);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
  line-height: 1.2;
  white-space: nowrap;
}
.a-btn:focus-visible { outline: none; box-shadow: var(--a-ring); }
.a-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.a-btn-primary {
  background: var(--a-primary);
  color: #fff;
  border-color: var(--a-primary);
}
.a-btn-primary:hover:not(:disabled) {
  background: var(--a-primary-2);
  border-color: var(--a-primary-2);
}
.a-btn-default {
  background: var(--a-paper);
  color: var(--a-ink);
  border-color: var(--a-line-strong);
}
.a-btn-default:hover:not(:disabled) {
  background: var(--a-bg);
  border-color: #98A2B3;
}
.a-btn-ghost {
  background: transparent;
  color: var(--a-ink-soft);
  border-color: transparent;
}
.a-btn-ghost:hover:not(:disabled) { background: var(--a-bg); }

.a-btn-danger {
  background: var(--a-paper);
  color: var(--a-danger);
  border-color: var(--a-danger-line);
}
.a-btn-danger:hover:not(:disabled) {
  background: var(--a-danger-bg);
}
.a-btn-danger-solid {
  background: var(--a-danger);
  color: #fff;
  border-color: var(--a-danger);
}
.a-btn-danger-solid:hover:not(:disabled) { background: #902018; }

.a-btn-success-solid {
  background: var(--a-success);
  color: #fff;
  border-color: var(--a-success);
}
.a-btn-success-solid:hover:not(:disabled) { background: #04532F; }

.a-btn-warn-solid {
  background: var(--a-warn);
  color: #fff;
  border-color: var(--a-warn);
}
.a-btn-warn-solid:hover:not(:disabled) { background: #B8851A; }

.a-btn-sm { padding: 4px 9px; font-size: 12px; border-radius: var(--a-r-sm); }
.a-btn-xs { padding: 2px 7px; font-size: 11.5px; border-radius: var(--a-r-sm); }
.a-btn-lg { padding: 10px 16px; font-size: 14px; }
.a-btn-block { width: 100%; justify-content: center; }

.a-icon-btn {
  width: 30px; height: 30px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--a-r);
  background: transparent;
  border: 1px solid transparent;
  color: var(--a-ink-soft);
  cursor: pointer;
  transition: background 0.12s;
}
.a-icon-btn:hover { background: var(--a-bg); }

/* ---------- Form controls ---------- */
.a-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--a-ink-soft);
  margin-bottom: 5px;
}
.a-label-hint {
  font-weight: 400;
  color: var(--a-ink-muted);
  margin-left: 6px;
}
.a-input, .a-select, .a-textarea {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--a-r);
  border: 1px solid var(--a-line-strong);
  background: var(--a-paper);
  font-family: inherit;
  font-size: 13.5px;
  color: var(--a-ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.a-textarea { resize: vertical; min-height: 80px; }
.a-input-sm { padding: 5px 8px; font-size: 12.5px; }
.a-input:focus, .a-select:focus, .a-textarea:focus {
  outline: none;
  border-color: var(--a-primary);
  box-shadow: var(--a-ring);
}
.a-input[disabled], .a-select[disabled] {
  background: var(--a-bg);
  color: var(--a-ink-muted);
}
.a-input-mono { font-family: var(--a-mono); font-size: 12.5px; }

.a-input-group {
  display: flex; align-items: stretch;
  border: 1px solid var(--a-line-strong);
  border-radius: var(--a-r);
  background: var(--a-paper);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.a-input-group:focus-within { border-color: var(--a-primary); box-shadow: var(--a-ring); }
.a-input-group .a-input {
  border: none; box-shadow: none;
  border-radius: 0;
}
.a-input-group .a-input:focus { box-shadow: none; }
.a-input-group-prefix {
  display: grid; place-items: center;
  padding: 0 10px;
  color: var(--a-ink-muted);
  background: var(--a-paper-2);
  border-right: 1px solid var(--a-line);
  border-radius: var(--a-r) 0 0 var(--a-r);
  font-size: 13px;
}
.a-input-group-suffix {
  display: grid; place-items: center;
  padding: 0 10px;
  color: var(--a-ink-muted);
  background: var(--a-paper-2);
  border-left: 1px solid var(--a-line);
  border-radius: 0 var(--a-r) var(--a-r) 0;
  font-size: 13px;
}

.a-check {
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--a-ink);
}
.a-check input { accent-color: var(--a-primary); width: 15px; height: 15px; }

.a-radio-pill-group { display: inline-flex; border: 1px solid var(--a-line-strong); border-radius: var(--a-r); padding: 2px; background: var(--a-paper-2); }
.a-radio-pill { padding: 5px 11px; border-radius: 4px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--a-ink-soft); }
.a-radio-pill.active { background: var(--a-paper); color: var(--a-ink); box-shadow: var(--a-shadow-sm); }

/* ---------- Table ---------- */
.a-table-wrap {
  border: 1px solid var(--a-line);
  border-radius: var(--a-r-lg);
  background: var(--a-paper);
  overflow-x: auto;
}
.a-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.a-table thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--a-paper-2);
  border-bottom: 1px solid var(--a-line);
  color: var(--a-ink-muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.a-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--a-line);
  vertical-align: middle;
  color: var(--a-ink-soft);
}
.a-table tbody tr:last-child td { border-bottom: none; }
.a-table tbody tr { transition: background 0.08s; }
.a-table tbody tr:hover { background: var(--a-paper-2); }
.a-table tbody tr.clickable { cursor: pointer; }
.a-table-mono { font-family: var(--a-mono); font-size: 12px; color: var(--a-ink-soft); }
.a-table-num { text-align: right; font-variant-numeric: tabular-nums; }
.a-table-compact tbody td { padding: 8px 12px; }
.a-table-compact thead th { padding: 8px 12px; }

.a-table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--a-line);
  background: var(--a-paper-2);
  flex-wrap: wrap;
}

/* ---------- Badges / chips ---------- */
.a-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.a-badge-neutral { background: #F2F4F7; color: #344054; border-color: #E4E7EC; }
.a-badge-success { background: var(--a-success-bg); color: var(--a-success); border-color: var(--a-success-line); }
.a-badge-warn    { background: var(--a-warn-bg);    color: var(--a-warn);    border-color: var(--a-warn-line); }
.a-badge-danger  { background: var(--a-danger-bg);  color: var(--a-danger);  border-color: var(--a-danger-line); }
.a-badge-info    { background: var(--a-info-bg);    color: var(--a-info);    border-color: var(--a-info-line); }
.a-badge-violet  { background: var(--a-violet-bg);  color: var(--a-violet);  border-color: var(--a-violet-line); }
.a-badge-primary { background: var(--a-primary-50); color: var(--a-primary); border-color: var(--a-primary-100); }

/* Rich-text description rendered from the Post-a-Job "About" editor */
.a-rich-content p { margin: 0 0 10px; }
.a-rich-content p:last-child { margin-bottom: 0; }
.a-rich-content ul, .a-rich-content ol { margin: 0 0 10px; padding-left: 20px; }
.a-rich-content li { margin-bottom: 3px; }
.a-rich-content strong { font-weight: 600; }
.a-rich-content em { font-style: italic; }
.a-rich-content h1, .a-rich-content h2, .a-rich-content h3 { margin: 12px 0 6px; font-weight: 700; letter-spacing: -0.01em; }
.a-rich-content h1 { font-size: 16px; }
.a-rich-content h2 { font-size: 15px; }
.a-rich-content h3 { font-size: 14px; }

.a-dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.a-tier {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 5px;
  font-weight: 700; font-size: 11.5px;
  font-family: var(--a-mono);
}
.a-tier-A { background: #FEF0C7; color: #93370D; border: 1px solid #FEDF89; }
.a-tier-B { background: #D1FADF; color: #067647; border: 1px solid #A6F4C5; }
.a-tier-C { background: #EAECF0; color: #344054; border: 1px solid #D0D5DD; }
.a-tier-D { background: #FEE4E2; color: #912018; border: 1px solid #FECDCA; }

/* ---------- Misc ---------- */
.a-hr { border: none; border-top: 1px solid var(--a-line); margin: 16px 0; }
.a-mono { font-family: var(--a-mono); font-size: 12px; }
.a-tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--a-line);
  margin-bottom: 18px;
}
.a-tab {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--a-ink-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 7px;
}
.a-tab:hover { color: var(--a-ink); }
.a-tab.active {
  color: var(--a-primary);
  border-bottom-color: var(--a-primary);
  font-weight: 600;
}
.a-tab-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--a-bg);
  color: var(--a-ink-muted);
  font-weight: 600;
}
.a-tab.active .a-tab-count { background: var(--a-primary-50); color: var(--a-primary); }

.a-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--a-ink-muted);
}
.a-empty-ic {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--a-bg);
  display: inline-grid; place-items: center;
  margin-bottom: 12px;
  color: var(--a-ink-faint);
}
.a-empty-title { font-size: 14px; font-weight: 600; color: var(--a-ink); }
.a-empty-sub { font-size: 12.5px; margin-top: 3px; }

/* Definition list */
.a-dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13px; }
.a-dl dt { color: var(--a-ink-muted); font-weight: 500; }
.a-dl dd { color: var(--a-ink); margin: 0; font-weight: 500; }

/* Modal */
.a-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.55);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.a-modal {
  background: var(--a-paper);
  border-radius: var(--a-r-xl);
  box-shadow: var(--a-shadow-pop);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: pop-in 0.18s ease;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.a-modal-lg { max-width: 820px; }
.a-modal-xl { max-width: 1080px; }
.a-modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--a-line);
  display: flex; align-items: center; gap: 10px;
}
.a-modal-title { font-size: 15px; font-weight: 600; margin: 0; flex: 1; }
.a-modal-body { padding: 18px; overflow-y: auto; flex: 1; }
.a-modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--a-line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--a-paper-2);
  border-radius: 0 0 var(--a-r-xl) var(--a-r-xl);
}

/* Drawer (right side) */
.a-drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.45);
  z-index: 100;
  animation: fade-in 0.12s ease;
}
.a-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  max-width: 95vw;
  background: var(--a-paper);
  box-shadow: var(--a-shadow-pop);
  display: flex; flex-direction: column;
  animation: slide-in 0.2s ease;
  z-index: 101;
}
.a-drawer-lg { width: min(820px, 100vw); }
.a-drawer-xl { width: min(1080px, 100vw); }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .a-drawer { animation: none !important; } }
.a-drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--a-line);
  display: flex; align-items: center; gap: 10px;
}
.a-drawer-body { padding: 18px; overflow-y: auto; flex: 1; }
.a-drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--a-line);
  background: var(--a-paper-2);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* Toast */
.a-toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.a-toast {
  background: var(--a-ink);
  color: #fff;
  padding: 11px 14px;
  border-radius: var(--a-r);
  font-size: 13px;
  box-shadow: var(--a-shadow-lg);
  animation: slide-in 0.18s ease;
  max-width: 360px;
  display: flex; align-items: center; gap: 8px;
}
.a-toast-success { background: var(--a-success); }
.a-toast-danger { background: var(--a-danger); }
.a-toast-warn { background: var(--a-warn); }

/* Progress bar */
.a-progress {
  height: 6px; background: var(--a-bg); border-radius: 999px;
  overflow: hidden;
}
.a-progress-bar { height: 100%; background: var(--a-primary); transition: width 0.3s; }
.a-progress-bar.success { background: var(--a-success); }
.a-progress-bar.warn { background: var(--a-warn); }

/* Utility */
.flex { display: flex; }
.fcol { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.jc-between { justify-content: space-between; }
.jc-end { justify-content: flex-end; }
.jc-center { justify-content: center; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; } .mt-6 { margin-top: 6px; } .mt-8 { margin-top: 8px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-4 { margin-bottom: 4px; } .mb-6 { margin-bottom: 6px; } .mb-8 { margin-bottom: 8px; } .mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.text-muted { color: var(--a-ink-muted); }
.text-faint { color: var(--a-ink-faint); }
.text-danger { color: var(--a-danger); }
.text-success { color: var(--a-success); }
.text-warn { color: var(--a-warn); }
.text-primary { color: var(--a-primary); }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-13 { font-size: 13px; } .fs-14 { font-size: 14px; } .fs-16 { font-size: 16px; } .fs-18 { font-size: 18px; } .fs-20 { font-size: 20px; } .fs-24 { font-size: 24px; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.tnum { font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }

/* Scrollbar polish */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #D0D5DD; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #98A2B3; background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Login page ---------- */
.a-login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--a-bg);
}
.a-login-left {
  background: linear-gradient(180deg, #0F1B30 0%, #1A365D 100%);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.a-login-left::before {
  content: '';
  position: absolute;
  right: -120px; bottom: -120px;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232,133,106,0.3), transparent 70%);
}
.a-login-logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700;
  font-size: 16px;
}
.a-login-right {
  display: grid; place-items: center;
  padding: 40px;
}
.a-login-card {
  width: 100%; max-width: 420px;
}


/* ========== Phase E: Messaging UI ========== */
.a-msg-layout {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  height: calc(100vh - 60px);
  background: var(--a-paper);
}
.a-msg-layout.no-side {
  grid-template-columns: 320px 1fr;
}

/* Thread list */
.a-thread-list {
  border-right: 1px solid var(--a-line);
  display: flex; flex-direction: column;
  background: var(--a-paper-2);
  min-height: 0;
}
.a-thread-list-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--a-line);
  background: var(--a-paper);
}
.a-thread-filters {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--a-line);
  background: var(--a-paper);
}
.a-thread-filter {
  padding: 4px 10px; font-size: 11.5px; font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--a-line-strong);
  background: var(--a-paper);
  color: var(--a-ink-muted);
  cursor: pointer;
}
.a-thread-filter:hover { background: var(--a-bg); }
.a-thread-filter.active {
  background: var(--a-primary);
  color: #fff;
  border-color: var(--a-primary);
}
.a-thread-items {
  flex: 1; min-height: 0; overflow-y: auto;
}
.a-thread-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--a-line);
  cursor: pointer;
  display: flex; gap: 10px;
  position: relative;
  transition: background 0.1s;
}
.a-thread-item:hover { background: var(--a-bg); }
.a-thread-item.active {
  background: var(--a-primary-50);
  border-left: 3px solid var(--a-primary);
  padding-left: 11px;
}
.a-thread-item-ava {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #7A8DB3, #1A365D);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.a-thread-item-body {
  flex: 1; min-width: 0;
}
.a-thread-item-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.a-thread-item-name {
  font-size: 13px; font-weight: 600;
  color: var(--a-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.a-thread-item-time {
  font-size: 11px; color: var(--a-ink-faint);
  flex-shrink: 0;
}
.a-thread-item-snippet {
  font-size: 12px; color: var(--a-ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.a-thread-item-foot {
  display: flex; gap: 6px; align-items: center;
  flex-wrap: wrap;
}
.a-thread-item-badge {
  background: var(--a-danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}

/* Chat pane */
.a-chat {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--a-paper);
}
.a-chat-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--a-line);
  display: flex; align-items: center; gap: 12px;
  background: var(--a-paper);
}
.a-chat-head-ava {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #7A8DB3, #1A365D);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
}
.a-chat-stream {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 20px 24px;
  background: #FCFCFD;
  display: flex; flex-direction: column; gap: 10px;
}
.a-bubble-row {
  display: flex;
  gap: 8px;
  max-width: 76%;
}
.a-bubble-row.emp { align-self: flex-start; }
.a-bubble-row.cnd { align-self: flex-end; flex-direction: row-reverse; }
.a-bubble-row.admin, .a-bubble-row.system { align-self: center; max-width: 90%; }
.a-bubble-ava {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: #fff;
}
.a-bubble-ava.emp { background: linear-gradient(135deg, #7A8DB3, #1A365D); }
.a-bubble-ava.cnd { background: linear-gradient(135deg, #E8856A, #C86A4F); }
.a-bubble-ava.admin { background: #6941C6; }
.a-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}
.a-bubble.emp { background: #EEF2F8; color: var(--a-ink); border-bottom-left-radius: 4px; }
.a-bubble.cnd { background: #FCE8DF; color: #5C2F1A; border-bottom-right-radius: 4px; }
.a-bubble.admin { background: #F4EAFF; color: #4A2F87; border: 1px solid #D9BDFF; border-radius: 10px; font-size: 12.5px; }
.a-bubble.system { background: var(--a-bg); color: var(--a-ink-muted); font-size: 12px; font-style: italic; border-radius: 999px; padding: 4px 14px; }
.a-bubble.flagged::before {
  content: '⚠';
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--a-warn);
  color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 10px;
  display: grid; place-items: center;
  border: 2px solid var(--a-paper);
}
.a-bubble-time {
  font-size: 10px; color: var(--a-ink-faint);
  margin-top: 3px;
  text-align: right;
}
.a-bubble-row.emp .a-bubble-time { text-align: left; }

.a-chat-compose {
  border-top: 1px solid var(--a-line);
  padding: 14px 20px;
  background: var(--a-paper);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.a-chat-compose-modes {
  display: flex; gap: 8px;
}
.a-chat-compose-box {
  display: flex; gap: 8px; align-items: flex-end;
}
.a-chat-compose textarea {
  flex: 1;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--a-line-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  min-height: 42px;
  max-height: 120px;
}
.a-chat-compose textarea:focus { outline: none; border-color: var(--a-primary); box-shadow: var(--a-ring); }

/* Side panel */
.a-msg-side {
  border-left: 1px solid var(--a-line);
  padding: 16px;
  overflow-y: auto;
  background: var(--a-paper-2);
  min-height: 0;
}
.a-msg-side-section { margin-bottom: 20px; }
.a-msg-side-h {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--a-ink-muted);
  margin: 0 0 8px;
}

/* Empty state for chat */
.a-chat-empty {
  flex: 1;
  display: grid; place-items: center;
  color: var(--a-ink-muted);
  text-align: center;
  padding: 40px;
  background: #FCFCFD;
}

/* ========== Templates list ========== */
.a-template-card {
  padding: 14px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: var(--a-paper);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
  display: flex; flex-direction: column; gap: 8px;
}
.a-template-card:hover {
  border-color: var(--a-primary);
  box-shadow: 0 2px 8px rgba(26,54,93,0.08);
}
.a-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 4px;
  background: var(--a-bg);
  color: var(--a-ink-soft);
  border: 1px solid var(--a-line);
}
.a-chip.email { background: #EEF2F8; color: #1A365D; border-color: #DCE5F1; }
.a-chip.sms { background: #FEF3E7; color: #C86A1A; border-color: #F9D9AC; }
.a-chip.line { background: #E8F5E8; color: #067647; border-color: #B9E3BD; }
.a-chip.push { background: #F4EAFF; color: #6941C6; border-color: #E5D0FF; }

/* ========== BI dashboard ========== */
.a-bi-kpi {
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.a-bi-kpi-label {
  font-size: 11.5px; font-weight: 600;
  color: var(--a-ink-muted);
  letter-spacing: 0.01em;
}
.a-bi-kpi-value {
  font-size: 24px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--a-ink);
  font-variant-numeric: tabular-nums;
}
.a-bi-kpi-sub {
  font-size: 11.5px;
  color: var(--a-ink-muted);
  display: flex; align-items: center; gap: 4px;
}
.a-bi-kpi-sub.up { color: var(--a-success); }
.a-bi-kpi-sub.down { color: var(--a-danger); }

.a-bi-range {
  display: inline-flex; border: 1px solid var(--a-line-strong); border-radius: 7px; padding: 2px; background: var(--a-paper);
}
.a-bi-range button {
  padding: 5px 11px; font-size: 12.5px; font-weight: 500;
  background: transparent; border: none; color: var(--a-ink-muted);
  cursor: pointer; border-radius: 4px;
}
.a-bi-range button.active {
  background: var(--a-primary);
  color: #fff;
}

/* Cohort heatmap */
.a-cohort-table {
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.a-cohort-table th, .a-cohort-table td {
  padding: 8px 10px;
  text-align: center;
  border: 1px solid var(--a-line);
}
.a-cohort-table th {
  background: var(--a-paper-2);
  color: var(--a-ink-muted);
  font-weight: 600;
  font-size: 11px;
}
.a-cohort-table td.label {
  background: var(--a-paper-2);
  color: var(--a-ink);
  font-weight: 600;
  text-align: left;
}

/* ========== Keywords ========== */
.a-kw-category-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--a-paper-2);
  border-top: 1px solid var(--a-line);
  border-bottom: 1px solid var(--a-line);
  font-size: 12px; font-weight: 700;
  color: var(--a-ink-soft);
}

/* ========== Language switcher ========== */
.a-lang-switch {
  display: inline-flex; gap: 0;
  border: 1px solid var(--a-line-strong); border-radius: 6px;
  overflow: hidden;
}
.a-lang-switch button {
  padding: 4px 9px; font-size: 11.5px; font-weight: 600;
  background: var(--a-paper); border: none; color: var(--a-ink-muted);
  cursor: pointer;
  border-right: 1px solid var(--a-line);
}
.a-lang-switch button:last-child { border-right: none; }
.a-lang-switch button.active {
  background: var(--a-primary);
  color: #fff;
}


/* ========== Utility helpers added for templates ========== */
.text-right { text-align: right; }

/* ========== Toggle switch ========== */
.a-toggle {
  display: inline-block;
  width: 32px; height: 18px;
  background: var(--a-line-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.a-toggle.on { background: var(--a-success); }
.a-toggle-dot {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: left 0.15s;
}
.a-toggle.on .a-toggle-dot { left: 16px; }

/* ========== Language tabs (template editor) ========== */
.a-lang-tab {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--a-ink-muted);
  cursor: pointer;
  transition: all 0.12s;
}
.a-lang-tab:hover { border-color: var(--a-line-strong); color: var(--a-ink-soft); }
.a-lang-tab.active {
  background: var(--a-primary-50);
  border-color: var(--a-primary-2);
  color: var(--a-primary);
}
.a-lang-tab.empty { opacity: 0.6; }
.a-check-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--a-success);
  margin-left: 4px;
}

/* ========== Message previews (channel-specific) ========== */
.a-preview-email {
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--a-shadow-sm);
}
.a-preview-email-head {
  padding: 14px;
  background: var(--a-paper-2);
  border-bottom: 1px solid var(--a-line);
}
.a-preview-email-body {
  padding: 20px 18px;
  font-size: 13px; line-height: 1.65;
  color: var(--a-ink);
  white-space: pre-wrap;
  min-height: 200px;
}
.a-preview-email-foot {
  padding: 12px 14px;
  background: var(--a-paper-2);
  border-top: 1px solid var(--a-line);
  font-size: 10px;
  color: var(--a-ink-faint);
  text-align: center;
}
.a-preview-email-foot a { color: var(--a-info); cursor: pointer; text-decoration: underline; }

.a-preview-phone {
  background: #f2f3f5;
  border: 1px solid var(--a-line);
  border-radius: 14px;
  padding: 14px;
  max-width: 300px;
  margin: 0 auto;
  font-size: 12px;
}
.a-preview-phone-head {
  text-align: center; padding: 6px 0 12px;
  font-size: 10px; color: var(--a-ink-muted);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 10px;
}
.a-preview-sms-bubble {
  background: #e6e7eb;
  color: #1a1a1a;
  padding: 10px 12px;
  border-radius: 14px 14px 14px 2px;
  margin-right: 32px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.a-preview-line-bubble {
  background: #fff;
  color: #1a1a1a;
  padding: 10px 12px;
  border-radius: 12px 12px 12px 2px;
  margin-right: 32px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.a-preview-push-card {
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ========== Chip ========== */
.a-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  background: var(--a-paper-2);
  border: 1px solid var(--a-line);
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  color: var(--a-ink-soft);
  transition: all 0.12s;
}
.a-chip:hover {
  background: var(--a-primary-50);
  border-color: var(--a-primary-100);
  color: var(--a-primary);
}


/* ========== Template · Channel tabs (list view) ========== */
.a-tpl-chantabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--a-paper-2);
  border: 1px solid var(--a-line);
  border-radius: var(--a-r-lg);
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.a-tpl-chantab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: calc(var(--a-r-lg) - 4px);
  background: transparent;
  border: 1px solid transparent;
  color: var(--a-ink-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.a-tpl-chantab:hover {
  color: var(--a-ink);
  background: rgba(255,255,255,0.6);
}
.a-tpl-chantab.active {
  background: var(--tabAccentBg, var(--a-paper));
  color: var(--tabAccent, var(--a-ink));
  border-color: var(--tabAccentLine, var(--a-line));
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
  font-weight: 600;
}
.a-tpl-chantab-n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(16,24,40,0.08);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: inherit;
}
.a-tpl-chantab.active .a-tpl-chantab-n {
  background: rgba(255,255,255,0.7);
}

/* ========== Template · Channel pill ========== */
.a-tpl-ch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.4;
}


/* ========== Template · WhatsApp preview ========== */
.a-preview-phone-wa {
  background: #E5DDD5;
  padding: 0;
  overflow: hidden;
  max-width: 320px;
}
.a-preview-wa-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #075E54;
  color: #fff;
}
.a-preview-wa-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #25D366;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.a-preview-wa-body {
  padding: 18px 12px;
  background:
    radial-gradient(rgba(0,0,0,0.04) 1px, transparent 1px) 0 0/14px 14px,
    #E5DDD5;
  min-height: 200px;
}
.a-preview-wa-bubble {
  background: #DCF8C6;
  color: #1a1a1a;
  padding: 8px 10px 6px;
  border-radius: 10px 2px 10px 10px;
  margin-left: auto;
  max-width: 85%;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  position: relative;
  word-wrap: break-word;
}
.a-preview-wa-bubble strong { font-weight: 700; }
.a-preview-wa-bubble em { font-style: italic; }
.a-preview-wa-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 4px;
  font-size: 10px;
  color: rgba(0,0,0,0.45);
}
.a-preview-wa-meta :is(svg,i) { color: #4FC3F7; }


/* ===== Phase E-4: 違規關鍵字字典 + 自動標記 + 凍結機制 ===== */

/* Tab count pill */
.a-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  border-radius: 8px;
  background: var(--a-paper-2);
  color: var(--a-ink-muted);
}
.a-tab.active .a-tab-count { background: var(--a-primary-50); color: var(--a-primary); }

/* Category chip row */
.a-kw-catrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.a-kw-catchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--a-ink-muted);
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.a-kw-catchip:hover { background: var(--a-paper-2); color: var(--a-ink); }
.a-kw-catchip.active {
  background: var(--tabAccentBg, var(--a-primary-50));
  border-color: var(--tabAccentLine, var(--a-primary-100));
  color: var(--tabAccent, var(--a-primary));
}
.a-kw-catchip-n {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  background: rgba(0,0,0,0.06);
  color: inherit;
}
.a-kw-catchip.active .a-kw-catchip-n { background: rgba(0,0,0,0.08); }
.a-kw-catchip-hits {
  font-size: 10px;
  color: var(--a-ink-soft);
  margin-left: 2px;
  font-variant-numeric: tabular-nums;
}

/* Category inline badge (used in table rows + legend) */
.a-kw-catbadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 6px;
  line-height: 1.4;
}

/* Severity picker button */
.a-kw-sevpick {
  flex: 1;
  padding: 8px 6px;
  font-size: 12px;
  color: var(--a-ink-muted);
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.a-kw-sevpick:hover { background: var(--a-paper-2); }
.a-kw-sevpick.active { font-weight: 700; }

/* Rule row (per-category in tab 2) */
.a-kw-rulerow {
  padding: 14px 18px;
  border-bottom: 1px solid var(--a-line);
}
.a-kw-rulerow:last-child { border-bottom: none; }
.a-kw-rulerow-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.a-kw-rulerow-opts {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  padding-left: 52px;
}

/* Checkrow — checkbox + label combo */
.a-kw-checkrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--a-ink-muted);
  cursor: pointer;
  user-select: none;
}
.a-kw-checkrow input[type="checkbox"] {
  margin: 0;
  accent-color: var(--a-primary);
}
.a-kw-checkrow.disabled { opacity: 0.45; cursor: not-allowed; }
.a-kw-checkrow > div { flex: 1; }

/* Weight cards */
.a-kw-weightcard {
  padding: 14px;
  border-radius: 10px;
}

/* Frozen thread row */
.a-kw-frozenrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--a-line);
}
.a-kw-frozenrow:last-child { border-bottom: none; }
.a-kw-frozenrow-ava {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--a-primary), var(--a-primary-2, #1E4A7A));
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* At-risk row */
.a-kw-atriskrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--a-line);
}
.a-kw-atriskrow:last-child { border-bottom: none; }

/* Flow diagram */
.a-kw-flow {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.a-kw-flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12px;
  background: var(--a-paper-2);
  border: 1px solid var(--a-line);
  border-radius: 8px;
  color: var(--a-ink);
}
.a-kw-flow-step.danger {
  background: var(--a-danger-bg);
  border-color: var(--a-danger-line);
  color: var(--a-danger);
  font-weight: 600;
}
.a-kw-flow-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--a-paper);
  border: 1px solid var(--a-line);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--a-ink-muted);
}
.a-kw-flow-step.danger .a-kw-flow-num {
  background: #fff;
  border-color: var(--a-danger);
  color: var(--a-danger);
}
.a-kw-flow-arrow {
  width: 2px;
  height: 12px;
  background: var(--a-line);
  margin-left: 22px;
}

/* Ensure modal backdrop stacks above drawer backdrop */
.a-modal-backdrop { z-index: 1200; }
.a-modal { z-index: 1201; }


/* ============================================================
   Messaging — thread list + chat stream (read-only log viewer)
   ============================================================ */

.a-msg-log-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  height: 640px;
  background: var(--a-paper);
}
@media (max-width: 1100px) {
  .a-msg-log-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  .a-msg-side { display: none; }
}
@media (max-width: 820px) {
  .a-msg-log-layout { grid-template-columns: minmax(0, 1fr); }
  .a-thread-list-inline { display: none; }
}

.a-thread-list-inline {
  border-right: 1px solid var(--a-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--a-paper-2);
}

.a-thread-list-head {
  padding: 14px;
  border-bottom: 1px solid var(--a-line);
  background: var(--a-paper);
  flex: 0 0 auto;
}

.a-thread-filter {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--a-line);
  background: var(--a-paper);
  border-radius: 999px;
  cursor: pointer;
  color: var(--a-ink-muted);
  letter-spacing: 0.01em;
}
.a-thread-filter:hover { background: var(--a-paper-2); color: var(--a-ink); }
.a-thread-filter.active {
  background: var(--a-primary);
  color: #fff;
  border-color: var(--a-primary);
}

.a-thread-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.a-thread-item {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--a-line);
  cursor: pointer;
  transition: background 0.1s;
}
.a-thread-item:hover { background: #fff; }
.a-thread-item.active { background: var(--a-primary-50); border-left: 3px solid var(--a-primary); padding-left: 11px; }

.a-thread-item-ava {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--a-primary-100);
  color: var(--a-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex: 0 0 auto;
}

.a-thread-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.a-thread-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.a-thread-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--a-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.a-thread-item-time {
  font-size: 10px;
  color: var(--a-ink-faint);
  flex: 0 0 auto;
}

.a-thread-item-snippet {
  font-size: 12px;
  color: var(--a-ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.a-thread-item-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

/* ==== Chat pane ==== */
.a-chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--a-paper);
}

.a-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--a-ink-faint);
  text-align: center;
  padding: 40px;
}

.a-chat-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--a-line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  background: var(--a-paper);
}

.a-chat-head-ava {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--a-primary-100);
  color: var(--a-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.a-chat-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  background: #FAFBFC;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.a-chat-readonly-bar {
  padding: 10px 20px;
  border-top: 1px solid var(--a-line);
  background: var(--a-paper-2);
  font-size: 12px;
  color: var(--a-ink-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex: 0 0 auto;
}

/* ==== Bubbles ==== */
.a-bubble-row {
  display: flex;
  gap: 10px;
  max-width: 100%;
}
.a-bubble-row.emp { flex-direction: row; align-self: flex-start; max-width: 80%; }
.a-bubble-row.cnd { flex-direction: row-reverse; align-self: flex-end; max-width: 80%; }
.a-bubble-row.cnd > div:last-child { display: flex; flex-direction: column; align-items: flex-end; }

.a-bubble-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11px;
  flex: 0 0 auto;
}
.a-bubble-ava.emp { background: #DCE5F1; color: var(--a-primary); }
.a-bubble-ava.cnd { background: #FFE4D6; color: #C54B1C; }

.a-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  max-width: 100%;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.a-bubble.emp {
  background: #fff;
  border: 1px solid var(--a-line);
  color: var(--a-ink);
  border-top-left-radius: 4px;
}
.a-bubble.cnd {
  background: var(--a-primary);
  color: #fff;
  border-top-right-radius: 4px;
}

.a-bubble-time {
  font-size: 10px;
  color: var(--a-ink-faint);
  margin-top: 3px;
  padding: 0 4px;
}

/* ==== Side panel (metadata) ==== */
.a-msg-side {
  border-left: 1px solid var(--a-line);
  background: var(--a-paper-2);
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.a-msg-side-section {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--a-line);
}
.a-msg-side-section:last-child { border-bottom: none; padding-bottom: 0; }

.a-msg-side-h {
  font-size: 11px;
  font-weight: 600;
  color: var(--a-ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
}

/* ==== Templates — channel tabs & preview ==== */
.a-tpl-chantabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--a-paper-2);
  border: 1px solid var(--a-line);
  border-radius: 10px;
  margin-bottom: 16px;
  width: fit-content;
}

.a-tpl-chantab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--a-ink-muted);
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.a-tpl-chantab:hover { color: var(--a-ink); }
.a-tpl-chantab.active {
  background: #fff;
  color: var(--a-ink);
  box-shadow: 0 1px 2px rgba(16,24,40,0.08);
  font-weight: 600;
}
.a-tpl-chantab-n {
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  min-width: 18px;
  border-radius: 9px;
  background: var(--a-line);
  color: var(--a-ink-muted);
  text-align: center;
  line-height: 16px;
}
.a-tpl-chantab.active .a-tpl-chantab-n { background: var(--a-primary-50); color: var(--a-primary); }

.a-tpl-ch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 5px;
  white-space: nowrap;
}

.a-lang-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--a-ink-muted);
  background: var(--a-paper-2);
  border: 1px solid var(--a-line);
  border-radius: 6px;
  cursor: pointer;
}
.a-lang-tab:hover { color: var(--a-ink); }
.a-lang-tab.active {
  background: var(--a-primary-50);
  color: var(--a-primary);
  border-color: var(--a-primary-100);
  font-weight: 600;
}
.a-lang-tab.empty { opacity: 0.6; border-style: dashed; }
.a-lang-tab .a-check-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--a-success); margin-left: 4px;
}

.a-label-hint { font-size: 11px; color: var(--a-ink-muted); font-weight: 500; margin-left: 4px; }

.a-check-dot { display: inline-block; }

.a-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
  line-height: 1.55;
  border: 1px solid var(--a-line);
  border-radius: 6px;
  background: var(--a-paper);
  resize: vertical;
}
.a-textarea:focus { outline: none; border-color: var(--a-primary); box-shadow: 0 0 0 3px var(--a-primary-50); }

/* Preview */
.a-preview-email {
  background: #fff;
  border: 1px solid var(--a-line);
  border-radius: 8px;
  overflow: hidden;
}
.a-preview-email-head {
  padding: 10px 14px;
  background: var(--a-paper-2);
  border-bottom: 1px solid var(--a-line);
}
.a-preview-email-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--a-ink);
  min-height: 180px;
}
.a-preview-email-foot {
  padding: 10px 14px;
  background: var(--a-paper-2);
  border-top: 1px solid var(--a-line);
  font-size: 11px;
  color: var(--a-ink-muted);
}

.a-preview-phone {
  max-width: 300px;
  border-radius: 28px;
  padding: 24px 12px;
  overflow: hidden;
  border: 10px solid #1a1a2e;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.a-preview-phone-wa { background: #E5DED0; border-color: #0B141A; padding: 0; }
.a-preview-wa-head {
  background: #1F2C33;
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.a-preview-wa-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #25D366; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.a-preview-wa-body {
  padding: 14px 10px;
  background: #E5DED0;
  background-image: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.15), transparent);
  min-height: 200px;
}
.a-preview-wa-bubble {
  background: #DCF8C6;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.55;
  max-width: 85%;
  margin-left: auto;
  position: relative;
  color: #0B141A;
}
.a-preview-wa-meta {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: #667781;
  margin-top: 2px;
}
.a-preview-push-card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 0 6px;
}

/* Table toggle switch (duplicate removed — see line 1153 for canonical definition) */

.a-radio-pill-group { display: inline-flex; background: var(--a-paper-2); border: 1px solid var(--a-line); border-radius: 7px; padding: 2px; }
.a-radio-pill { padding: 5px 12px; font-size: 12px; font-weight: 600; border: none; background: transparent; cursor: pointer; color: var(--a-ink-muted); border-radius: 5px; }
.a-radio-pill.active { background: #fff; color: var(--a-ink); box-shadow: 0 1px 2px rgba(16,24,40,0.08); }

.a-mono { font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: 0.92em; }
.a-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: 11px; background: var(--a-paper-2); border: 1px solid var(--a-line); border-radius: 4px; color: var(--a-ink-muted); }

/* Drawer XL for template editor */
.a-drawer-xl { width: min(1100px, 90vw); }
.a-tabs { display: flex; gap: 16px; }
.a-tab { padding: 12px 2px; font-size: 13px; font-weight: 500; color: var(--a-ink-muted); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.a-tab:hover { color: var(--a-ink); }
.a-tab.active { color: var(--a-primary); border-bottom-color: var(--a-primary); font-weight: 600; }

.a-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; }
.a-drawer-footer { padding: 14px 24px; border-top: 1px solid var(--a-line); display: flex; justify-content: space-between; align-items: center; background: var(--a-paper-2); }
.a-drawer-header { padding: 18px 24px 14px; border-bottom: 1px solid var(--a-line); display: flex; align-items: flex-start; gap: 12px; }

/* Table wrap */
.a-table-wrap { background: var(--a-paper); border: 1px solid var(--a-line); border-radius: 10px; overflow-x: auto; }
.a-table-wrap .a-table { border: none; border-radius: 0; min-width: 100%; }

.text-right { text-align: right; }
.tnum { font-variant-numeric: tabular-nums; }
.gap-16 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.ml-auto { margin-left: auto; }
.mt-2 { margin-top: 2px; }
.mt-4 { margin-top: 4px; }
.mt-6 { margin-top: 6px; }
.mt-10 { margin-top: 10px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-2 { margin-bottom: 2px; }
.mb-4 { margin-bottom: 4px; }
.mb-6 { margin-bottom: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.w-full { width: 100%; }
.jc-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-10 { gap: 10px; }

/* Extra utilities used by messages/templates pages */
.inline-flex { display: inline-flex; }
.items-stretch { align-items: stretch; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.jc-start { justify-content: flex-start; }
.text-soft { color: var(--a-ink-soft); }
.text-ink { color: var(--a-ink); }
.text-center { text-align: center; }
.min-w-0 { min-width: 0; }
.fs-10 { font-size: 10px; }
.fs-15 { font-size: 15px; }
.fw-400 { font-weight: 400; }
.grid-cols-1 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.p-0 { padding: 0; }
.p-12 { padding: 12px; }
.p-16 { padding: 16px; }
