:root {
  --navy-900: #0F1923;
  --navy-800: #1A2B4A;
  --navy-700: #1E3A5F;
  --navy-600: #2563A8;
  --gold-400: #E2B95A;
  --white:    #FFFFFF;
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-400: #94A3B8;
  --gray-600: #475569;
  --gray-800: #1E293B;
  --green:    #22C55E;
  --red:      #EF4444;
  --yellow:   #F59E0B;
  --blue:     #3B82F6;
  --radius:   10px;
  --shadow:   0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:0 8px 32px rgba(0,0,0,0.16);
  font-family: 'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--gray-50); color: var(--gray-800); }
a { color: var(--navy-600); }

/* ── Login ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-icon   { font-size: 3rem; text-align: center; margin-bottom: 10px; }
.login-title  { font-family: 'Playfair Display', serif; font-size: 1.6rem; color: var(--navy-800); text-align: center; margin-bottom: 6px; }
.login-sub    { font-size: 0.875rem; color: var(--gray-400); text-align: center; margin-bottom: 28px; }

/* ── Main App ─────────────────────────────────────────────── */
.app-wrap { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--navy-900); color: var(--white);
  padding: 0 20px; height: 56px;
  display: flex; align-items: center;
  gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem; color: var(--gold-400);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.topbar-nav { display: flex; gap: 4px; flex: 1; justify-content: center; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 0.875rem; flex-shrink: 0; margin-left: auto; }
.topbar-user span { color: rgba(255,255,255,0.7); }

/* On narrow screens, hide the username text but keep the button */
@media (max-width: 600px) {
  .topbar-user span { display: none; }
  .topbar-brand { font-size: 0.9rem; }
  .topbar-tab { padding: 6px 10px; font-size: 0.78rem; }
  .topbar { padding: 0 10px; gap: 6px; }
}
.btn-logout-top {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7); border-radius: 6px;
  padding: 6px 12px; font-size: 0.8rem; cursor: pointer;
  transition: all 0.15s;
}
.btn-logout-top:hover { background: rgba(239,68,68,0.2); color: #FCA5A5; }

.main { flex: 1; max-width: 900px; width: 100%; margin: 0 auto; padding: 32px 20px; }

/* ── Steps ────────────────────────────────────────────────── */
.steps { display: flex; gap: 8px; align-items: center; margin-bottom: 28px; }
.step {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--gray-400); font-weight: 500;
}
.step.active { color: var(--navy-800); }
.step.done   { color: var(--green); }
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.step.active .step-num { background: var(--navy-800); color: var(--white); }
.step.done   .step-num { background: var(--green); color: var(--white); }
.step-sep { color: var(--gray-300); font-size: 1rem; }

/* ── Card ─────────────────────────────────────────────────── */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px; margin-bottom: 20px;
}
.card-title { font-size: 1.05rem; font-weight: 600; color: var(--navy-800); margin-bottom: 6px; }
.card-sub   { font-size: 0.875rem; color: var(--gray-400); margin-bottom: 20px; }

/* ── Input Zone ───────────────────────────────────────────── */
.input-tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 2px solid var(--gray-100); }
.tab-btn {
  padding: 8px 18px; font-size: 0.875rem; font-weight: 500;
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all 0.15s;
}
.tab-btn.active { color: var(--navy-800); border-bottom-color: var(--navy-800); }

.ticket-textarea {
  width: 100%; min-height: 260px; padding: 14px;
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  font-size: 0.875rem; font-family: 'Courier New', monospace;
  line-height: 1.6; resize: vertical; outline: none;
  color: var(--gray-800); background: var(--gray-50);
}
.ticket-textarea:focus { border-color: var(--navy-600); background: var(--white); box-shadow: 0 0 0 3px rgba(37,99,168,0.08); }
.ticket-textarea::placeholder { color: var(--gray-400); font-family: 'Inter', sans-serif; }

.drop-zone {
  border: 2px dashed var(--gray-200); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--gray-50);
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--navy-600); background: #EFF6FF; }
.drop-icon  { font-size: 2.5rem; margin-bottom: 10px; }
.drop-label { font-size: 0.9rem; color: var(--gray-600); margin-bottom: 6px; }
.drop-hint  { font-size: 0.8rem; color: var(--gray-400); }
.drop-file-chosen { font-size: 0.875rem; color: var(--navy-800); font-weight: 500; margin-top: 14px; text-align: left; }
#file-input { display: none; }

.file-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
}
.file-list-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 6px; padding: 8px 10px;
  font-size: 0.82rem; font-weight: 400;
}
.file-remove-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 1rem; padding: 2px 6px;
  border-radius: 4px; transition: all 0.15s; flex-shrink: 0;
}
.file-remove-btn:hover { color: var(--red); background: #FEE2E2; }
.file-list-count {
  margin-top: 8px; font-size: 0.78rem; color: var(--gray-400);
  font-weight: 400; text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--navy-800); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: var(--white); border-color: var(--gray-200); color: var(--gray-800); }
.btn-outline:hover { background: var(--gray-100); }
.btn-green  { background: var(--green); color: var(--white); }
.btn-green:hover:not(:disabled) { background: #16A34A; }
.btn-green:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full   { width: 100%; justify-content: center; }
.btn-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ── Processing State ─────────────────────────────────────── */
.processing {
  text-align: center; padding: 48px 20px;
}
.processing-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--gray-100);
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto 16px;
}
.processing-label { font-size: 1rem; font-weight: 500; color: var(--navy-800); margin-bottom: 6px; }
.processing-sub   { font-size: 0.875rem; color: var(--gray-400); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Preview Table ────────────────────────────────────────── */
.preview-summary {
  display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.summary-pill {
  background: var(--gray-100); border-radius: 99px;
  padding: 6px 14px; font-size: 0.82rem; font-weight: 500; color: var(--gray-700);
}
.summary-pill strong { color: var(--navy-800); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); }
.table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 700px; }
.table th {
  background: var(--navy-800); color: var(--white);
  padding: 11px 14px; text-align: left;
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.table td {
  padding: 10px 14px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* ── Editable preview table fields ──────────────────────────── */
.edit-input, .edit-select, .edit-textarea {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.84rem;
  color: var(--gray-800);
  padding: 5px 7px;
  border-radius: 6px;
  outline: none;
  transition: all 0.15s;
}
.edit-input:hover, .edit-select:hover, .edit-textarea:hover {
  background: var(--gray-50);
  border-color: var(--gray-200);
}
.edit-input:focus, .edit-select:focus, .edit-textarea:focus {
  background: var(--white);
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(37,99,168,0.08);
}
.edit-input { min-width: 110px; }
.edit-select { min-width: 150px; cursor: pointer; }
.edit-textarea {
  min-width: 200px; max-width: 280px;
  resize: vertical; min-height: 40px;
  line-height: 1.4;
}

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 99px;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-red    { background: #FEE2E2; color: #DC2626; }
.badge-yellow { background: #FEF3C7; color: #D97706; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-blue   { background: #DBEAFE; color: #2563EB; }

.remove-btn {
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 1.1rem; padding: 2px 6px;
  border-radius: 4px; transition: all 0.15s;
}
.remove-btn:hover { color: var(--red); background: #FEE2E2; }

/* ── Success ──────────────────────────────────────────────── */
.success-wrap { text-align: center; padding: 40px 20px; }
.success-icon { font-size: 3.5rem; margin-bottom: 14px; }
.success-title { font-size: 1.3rem; font-weight: 700; color: var(--navy-800); margin-bottom: 8px; }
.success-sub   { font-size: 0.9rem; color: var(--gray-600); margin-bottom: 24px; line-height: 1.6; }
.success-link  {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--navy-800); color: var(--white);
  padding: 11px 22px; border-radius: 8px; font-weight: 600;
  text-decoration: none; font-size: 0.9rem; margin-bottom: 12px;
}
.success-link:hover { background: var(--navy-700); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--gray-600); margin-bottom: 5px; }
.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-200); border-radius: 6px;
  font-size: 0.875rem; font-family: inherit; outline: none;
}
.input:focus { border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(37,99,168,0.08); }

/* ── Alert ────────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 0.875rem; margin-bottom: 16px; }
.alert-error   { background: #FEE2E2; color: #DC2626; border: 1px solid #FECACA; }
.alert-warning { background: #FEF3C7; color: #D97706; border: 1px solid #FDE68A; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 8px; font-size: 0.875rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: slideIn 0.3s ease; max-width: 320px; }
.toast-success { background: #DCFCE7; color: #16A34A; border: 1px solid #BBF7D0; }
.toast-error   { background: #FEE2E2; color: #DC2626; border: 1px solid #FECACA; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── History ──────────────────────────────────────────────── */
.history-empty { text-align: center; padding: 32px; color: var(--gray-400); font-size: 0.9rem; }

/* ── Misc ─────────────────────────────────────────────────── */
.text-muted { color: var(--gray-400); }
.text-sm    { font-size: 0.82rem; }

@media (max-width: 600px) {
  .main { padding: 20px 14px; }
  .card { padding: 20px 16px; }
  .btn-actions { flex-direction: column; }
  .btn-actions .btn { width: 100%; justify-content: center; }
}

/* ── Topbar nav tabs ─────────────────────────────────────────── */
.topbar-nav { display: flex; gap: 4px; }
.topbar-tab {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7); border-radius: 6px;
  padding: 6px 14px; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.topbar-tab:hover { background: rgba(255,255,255,0.14); color: var(--white); }
.topbar-tab.active { background: var(--gold-400); color: var(--navy-900); border-color: var(--gold-400); }

.queue-badge {
  background: var(--red); color: var(--white);
  border-radius: 99px; font-size: 0.7rem; font-weight: 700;
  padding: 1px 6px; min-width: 18px; text-align: center;
}

/* ── Email Queue page ────────────────────────────────────────── */
.queue-actions-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.empty-queue { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.queue-batch { margin-bottom: 0; }
.queue-batch-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
.queue-batch-subject { font-weight: 600; font-size: 0.95rem; color: var(--navy-800); margin-bottom: 4px; }
.queue-meta { font-size: 0.78rem; color: var(--gray-400); }
.queue-batch-pills { display: flex; gap: 6px; flex-shrink: 0; }
.queue-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gray-200); border-top-color: var(--navy-700);
  border-radius: 50%; animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
.page-loading { text-align: center; padding: 60px 20px; color: var(--gray-400); }
