:root {
  --bg-app: #080c14;
  --bg-panel: #0e1526;
  --bg-panel-hover: #131c33;
  --bg-surface: #141d33;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(222, 193, 72, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --gold: #dec148;
  --gold-glow: rgba(222, 193, 72, 0.15);
  --gold-hover: #ecd35e;
  
  --danger-bg: rgba(239, 68, 68, 0.1);
  --danger-border: rgba(239, 68, 68, 0.25);
  --danger-text: #f87171;
  
  --success: #10b981;
  --info: #38bdf8;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Ambient glow */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(222, 193, 72, 0.04) 0%, transparent 70%);
  top: -150px;
  left: 20%;
}
.glow-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.03) 0%, transparent 70%);
  bottom: -100px;
  right: 10%;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}

.header-inner {
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo {
  display: flex;
  align-items: baseline;
  gap: 2px;
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
}

.brand-dot {
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  display: inline-block;
}

.brand-tag {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.03);
}

/* Workspace */
.workspace {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2.25rem 2rem 4rem 2rem;
  position: relative;
  z-index: 1;
}

/* Top KPI Row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: var(--transition);
}
.kpi-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--bg-panel-hover);
}

.kpi-highlight {
  border-color: rgba(222, 193, 72, 0.25);
  background: linear-gradient(135deg, rgba(222, 193, 72, 0.03) 0%, var(--bg-panel) 100%);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-muted);
}

.kpi-num-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.kpi-num {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
  line-height: 1;
}

.text-gold {
  color: var(--gold) !important;
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Scan Bar Card */
.scan-bar-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.scan-bar-form {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr auto;
  gap: 1.25rem;
  align-items: flex-end;
}

.scan-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.scan-input-group label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.custom-select, .custom-input, .search-input, .field-input, .field-textarea, .filter-select {
  background: #080d18;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
  color-scheme: dark;
}

select option {
  background: #0d1424;
  color: #f8fafc;
}
.custom-select:focus, .custom-input:focus, .search-input:focus, .field-input:focus, .field-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}

.hidden {
  display: none !important;
}

.btn-scan {
  background: var(--gold);
  color: #0b0f19;
  border: none;
  padding: 0.68rem 1.35rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-scan:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(222, 193, 72, 0.25);
}
.btn-scan:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.scan-arrow {
  transition: transform 0.2s ease;
}
.btn-scan:hover .scan-arrow {
  transform: translateX(3px);
}

/* Progress Wrap */
.scan-progress-wrap {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: #090e1a;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.3s ease;
}

/* Leads Card */
.leads-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.leads-toolbar {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.count-pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.btn-ghost-danger {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #f87171;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 0.5rem;
}
.btn-ghost-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-wrap {
  position: relative;
  width: 260px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  padding-left: 2.1rem;
  font-size: 0.85rem;
}

.filter-select {
  width: auto;
  font-size: 0.85rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.leads-table th {
  padding: 0.85rem 1.5rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--border);
}

.leads-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.leads-table tbody tr {
  transition: var(--transition);
}
.leads-table tbody tr:hover {
  background: var(--bg-panel-hover);
}

.empty-row {
  text-align: center;
  padding: 3rem !important;
  color: var(--text-muted);
}

/* Table Elements */
.company-name {
  font-weight: 700;
  color: #fff;
  font-size: 0.95rem;
}

.company-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.link-website {
  color: var(--info);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}
.link-website:hover {
  text-decoration: underline;
}

.badge-platform {
  display: inline-block;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}

.issue-tag-primary {
  display: inline-block;
  color: var(--danger-text);
  font-weight: 600;
  font-size: 0.82rem;
}

.issue-tag-year {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.reviews-rating {
  font-weight: 600;
  color: #fbbf24;
  font-size: 0.85rem;
}

.status-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}
.status-new { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); }
.status-reviewed { background: rgba(56, 189, 248, 0.12); color: var(--info); }
.status-contacted { background: rgba(222, 193, 72, 0.15); color: var(--gold); }
.status-won { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.status-rejected { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }

.btn-detail {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.btn-detail:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: #0b0f19;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 12, 0.8);
  backdrop-filter: blur(12px);
}

.modal-dialog {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 760px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.8);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog-sm {
  max-width: 480px;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-top {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
}

.modal-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}
.btn-close:hover {
  color: #fff;
}

.modal-scroll-area {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Snapshot Row */
.snapshot-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.snap-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.snap-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.snap-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snap-link {
  color: var(--info);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.snap-link:hover {
  text-decoration: underline;
}

/* Issues Box */
.issues-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.box-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.issues-tags {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.issues-tags li {
  font-size: 0.84rem;
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  padding: 0.45rem 0.75rem;
  border-radius: 4px;
}

/* Email Draft Box */
.email-draft-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.email-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.email-box-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-action-sm {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
}
.btn-action-sm:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-action-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #0b0f19;
  font-weight: 700;
}
.btn-action-gold:hover {
  background: var(--gold-hover);
  color: #0b0f19;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}
.form-field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.field-textarea {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
}

/* Status Manage Box */
.status-manage-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.status-manage-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-ghost-sm {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition);
}
.btn-save {
  background: var(--gold);
  color: #0b0f19;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-save:hover {
  background: var(--gold-hover);
}

/* =======================================================
   MOBILE FIRST RESPONSIVE BREAKPOINTS (max-width: 768px)
   ======================================================= */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .brand {
    gap: 0.5rem;
  }

  .brand-tag {
    display: none; /* Hide on mobile to save space */
  }

  .header-right {
    gap: 0.5rem;
  }

  .system-status span:last-child {
    display: none; /* Only keep pulse dot on mobile */
  }

  .system-status {
    padding: 0.35rem 0.5rem;
  }

  .btn-ghost {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
  }

  .workspace {
    padding: 1rem 0.85rem 3rem 0.85rem;
  }

  /* KPI Grid */
  .kpi-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
  }

  .kpi-card {
    padding: 0.75rem 0.65rem;
    border-radius: var(--radius-sm);
  }

  .kpi-label {
    font-size: 0.65rem;
    letter-spacing: 0;
  }

  .kpi-num {
    font-size: 1.35rem;
  }

  .kpi-sub {
    font-size: 0.68rem;
    display: none; /* Cleaner on small screens */
  }

  /* Scan Form - Pure 1-column stack */
  .scan-bar-card {
    padding: 1rem;
    margin-bottom: 1.25rem;
  }

  .scan-bar-form {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .scan-input-group {
    max-width: 100% !important;
  }

  .btn-scan {
    width: 100%;
    justify-content: center;
    padding: 0.8rem;
    font-size: 0.95rem;
  }

  /* Toolbar */
  .leads-toolbar {
    padding: 1rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .toolbar-right {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .search-wrap {
    width: 100%;
  }

  .filter-select {
    width: 100%;
  }

  /* Transform Table to Native Mobile Cards */
  .leads-table, .leads-table thead, .leads-table tbody, .leads-table th, .leads-table td, .leads-table tr {
    display: block;
  }

  .leads-table thead {
    display: none; /* Hide header on mobile */
  }

  .leads-table tbody tr {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 0.85rem;
    padding: 1rem;
    position: relative;
  }

  .leads-table tbody tr:first-child {
    margin-top: 0.85rem;
  }

  .leads-table td {
    padding: 0.4rem 0 !important;
    border-bottom: none !important;
  }

  .leads-table td:last-child {
    margin-top: 0.75rem;
    padding-top: 0.75rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
  }

  .btn-detail {
    width: 100%;
    text-align: center;
    padding: 0.65rem;
    font-size: 0.85rem;
  }

  /* Mobile Bottom Sheet Modal */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
  }

  .modal-top {
    padding: 1rem 1.25rem;
  }

  .modal-scroll-area {
    padding: 1rem 1.25rem;
    gap: 1rem;
  }

  .snapshot-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .email-box-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .email-box-actions {
    width: 100%;
  }

  .email-box-actions button, .email-box-actions a {
    flex: 1;
    text-align: center;
  }

  .status-manage-box {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .status-manage-right {
    flex-direction: column;
    width: 100%;
  }

  .btn-save {
    width: 100%;
  }
}
