:root{
  --bg:#0b0b0c;
  --card:#0f1112;
  --muted:#9aa1a6;
  --accent:#60a5fa;
  --accent-strong:#1e40af;
  --danger:#ef4444;
  --radius:12px;
  --pad:20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color-scheme: dark;
}

/* base layout */
html,body{ height:100%; background:var(--bg); color:#e6eef8; margin:0; }
.container{ max-width:1100px; margin:18px auto; padding:0 18px; }

/* Topbar */
.topbar{ background:linear-gradient(90deg, #0f1316, #0b0b0c); border-bottom:1px solid rgba(255,255,255,0.04); }
.topbar-inner{ display:flex; align-items:center; justify-content:space-between; padding:18px 0; }
.brand h1{ margin:0; font-size:20px; color:#ffffff; }

/* Controls */
.controls{ display:flex; gap:12px; align-items:center; }
.btn{
  display:inline-block;
  background:transparent;
  border:1px solid rgba(255,255,255,0.06);
  padding:10px 14px;
  border-radius:10px;
  text-decoration:none;
  color:var(--muted);
  font-size:13px;
  cursor:pointer;
}
.btn.primary{
  background:linear-gradient(180deg,var(--accent), #3b82f6);
  color:#071129;
  border:none;
  box-shadow: 0 6px 22px rgba(96,165,250,0.12);
}

/* Summary */
.summary{ margin:22px 0; display:flex; align-items:center; justify-content:space-between; }
.muted{ color:var(--muted); font-size:13px; }

/* --- GMAIL-STYLE INBOX LAYOUT --- */

.inbox { margin-top: 8px; }

/* Header Row */
.gmail-header {
  display: grid;
  /* Columns: Icon(48px) | Sender(20%) | Content(Auto) | Time(120px) | Actions(100px) */
  grid-template-columns: 48px 240px 1fr 120px 100px;
  padding: 0 16px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gmail-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* The Row Card */
.gmail-row {
  display: grid;
  grid-template-columns: 48px 240px 1fr 120px 100px;
  align-items: center; 
  padding: 12px 16px;
  background: var(--card);
  border-radius: 4px; 
  border-bottom: 1px solid rgba(255,255,255,0.02);
  transition: background 0.1s ease;
  cursor: default;
}

.gmail-row:hover {
  background: rgba(255,255,255,0.03);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 1;
}

/* --- COLUMN STYLES --- */

/* 1. Icon Column (Envelope) */
.col-icon {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  color: var(--muted);
}

/* 2. Sender Column */
.col-sender {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 15px;
  overflow: hidden;
}
.sender-name {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.sender-email {
  font-size: 12px;
  color: var(--muted); 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 3. Content Column */
.col-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 20px;
  min-width: 0; 
}
.content-subject {
  font-size: 15px;
  margin-bottom: 3px; 
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content-snippet {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 4. Time Column */
.col-time {
  font-size: 12px;
  text-align: right;
  padding-right: 15px;
  white-space: nowrap;
}

/* 5. Actions Column */
.col-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  opacity: 0.4;
  transition: opacity 0.2s;
}
.gmail-row:hover .col-actions {
  opacity: 1;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  color: var(--accent);
  background: rgba(255,255,255,0.05);
}
.icon-btn.danger:hover {
  color: var(--danger);
}
.inline-form { display:inline; } 

/* --- READ vs UNREAD LOGIC --- */

/* UNREAD: Bright White, Bold, Accent Envelope */
.gmail-row.unread {
  background: rgba(255,255,255,0.02);
  border-left: 3px solid var(--accent);
}
.gmail-row.unread .col-icon {
  color: var(--accent); /* Blue envelope */
}
.gmail-row.unread .sender-name,
.gmail-row.unread .content-subject {
  color: #ffffff;
  font-weight: 700;
}
.gmail-row.unread .content-snippet {
  color: #9aa1a6;
}
.gmail-row.unread .col-time {
  color: #ffffff;
  font-weight: 600;
}

/* READ: Faint Grey, Muted Envelope */
.gmail-row.read {
  border-left: 3px solid transparent; 
}
.gmail-row.read .col-icon {
  color: #4a4d50; /* Very dark grey envelope */
}
.gmail-row.read .sender-name {
  color: #9aa1a6; 
  font-weight: 400;
}
.gmail-row.read .content-subject {
  color: #b0b3b8; 
  font-weight: 400;
}
.gmail-row.read .content-snippet,
.gmail-row.read .col-time {
  color: #636363; /* Faint grey */
}

/* Message Detail Page Tweaks */
.message-full pre{
  white-space:pre-wrap;
  background:#0b0d0e;
  padding:14px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,0.03);
  color:#e6eef8;
}
.empty{
  background:rgba(255,255,255,0.02);
  padding:22px;
  border-radius:10px;
  color:var(--muted);
}

/* --- LEADS PAGE STYLES --- */

/* --- ENHANCED LEADS CONTROLS --- */

.leads-controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}

.mini-upload-form { display:flex; gap:10px; align-items:center; }
.mini-upload-form input { color: var(--muted); font-size:13px; }

.search-form { display:flex; gap:8px; align-items:center; }
.search-form input[type="text"] {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  width: 200px;
}
.search-form input[type="text"]:focus { outline:none; border-color:var(--accent); }

/* Bulk Toolbar */
.bulk-toolbar {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
  background: rgba(255,255,255,0.02);
  border-radius: 8px;
  margin-bottom: 12px;
}

/* --- MAPPING PAGE --- */

.mapping-form {
  margin-top: 20px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.map-row {
  background: rgba(255,255,255,0.02);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
}
.map-row.required {
  border-left: 2px solid var(--accent);
}

.map-row label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}

.map-row select {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  color: white;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
}

.preview-section {
  margin-top: 40px;
}
.table-scroll {
  overflow-x: auto;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
}
.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: var(--muted);
}
.simple-table th, .simple-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
}
.simple-table th {
  background: rgba(255,255,255,0.05);
  color: #fff;
  font-weight: 600;
}

/* Leads Grid Update for Checkbox */
.leads-header {
  grid-template-columns: 32px 100px 1.5fr 1.5fr 1fr 80px; 
}
.lead-row {
  grid-template-columns: 32px 100px 1.5fr 1.5fr 1fr 80px; 
}

/* Edit Form Styles */
.edit-form {
  background: var(--card);
  padding: 30px;
  border-radius: var(--radius);
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid rgba(255,255,255,0.05);
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  box-sizing: border-box; /* Fixes width padding issue */
}
.form-group input:focus { border-color: var(--accent); outline:none; }
.form-actions { margin-top: 24px; text-align: right; }

.upload-section {
  background: var(--card);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 24px;
}
.upload-form {
  display: flex;
  gap: 12px;
  align-items: center;
}
.upload-form input[type="file"] {
  color: var(--muted);
}

.leads-header {
  display: grid;
  grid-template-columns: 100px 1.5fr 1.5fr 1fr 1fr; 
  /* Status, Company, Email, CEO, Website */
  padding: 0 16px 10px 16px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.lead-row {
  display: grid;
  grid-template-columns: 100px 1.5fr 1.5fr 1fr 1fr;
  gap: 18px;
  align-items: center;
  background: var(--card);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.02);
  color: #e6eef8;
  font-size: 14px;
  margin-bottom: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
}

.status-badge svg {
  width: 8px; height: 8px;
}

.status-badge.good {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399; /* Green */
}

.status-badge.bad {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171; /* Red */
}

.col-email {
  color: var(--muted);
  font-family: monospace;
  /* UPDATED: Allows text to wrap normally like a paragraph */
  white-space: normal; 
}

.muted-link {
  color: var(--muted);
  text-decoration: none;
}
.muted-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

/* Flash Messages */
.flash-messages {
  margin-bottom: 20px;
}
.alert {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.2);
  color: #93c5fd;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  margin-bottom: 40px;
}
.page-info {
  color: var(--muted);
  font-size: 13px;
}

/* --- GENERATOR PAGE --- */
.generator-header {
  display: grid;
  grid-template-columns: 200px 200px 1fr 60px; /* Name | Domain | Patterns | Action */
  gap: 18px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.generator-row {
  display: grid;
  grid-template-columns: 200px 200px 1fr 60px;
  gap: 18px;
  align-items: center;
  /* Reusing standard row styles */
  background: var(--card);
  padding: 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.02);
  color: #e6eef8;
  font-size: 14px;
  margin-bottom: 8px;
}

.col-patterns code {
  background: rgba(0,0,0,0.3);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
}