* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
  background: #f4f7fb;
  color: #182235;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  background: #101827;
  color: #fff;
}

header h1 {
  font-size: 22px;
  margin: 0;
}

nav {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

a {
  color: #2563eb;
  text-decoration: none;
}

nav a {
  color: #fff;
}

main {
  padding: 24px;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 18px;
}

.login-card {
  background: #fff;
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
  width: 380px;
  max-width: 100%;
}

.login-card h1 {
  margin-top: 0;
}

.login-card label,
.edit-card label {
  display: block;
  margin-top: 14px;
  font-weight: bold;
}

.login-card input,
.filters input,
.filters select,
td select,
textarea,
.edit-card input,
.edit-card select,
.edit-card textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #d7dce5;
  border-radius: 8px;
  background: #fff;
  color: #182235;
  font: inherit;
}

.edit-card input,
.edit-card select,
.edit-card textarea {
  margin-top: 6px;
}

.login-card button,
.filters button,
.button,
.row-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  white-space: nowrap;
}

.login-card button {
  width: 100%;
  margin-top: 18px;
}

button:hover,
.button:hover {
  opacity: 0.92;
}

.secondary {
  background: #64748b !important;
}

.danger {
  background: #dc2626 !important;
}

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

.hint {
  color: #64748b;
  font-size: 13px;
}

/* Top metric row */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  align-items: stretch;
}

.stats div,
.product-tile {
  background: #fff;
  padding: 18px 22px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
  flex: 1 1 180px;
  min-width: 180px;
  border: 1px solid #edf2f7;
}

.stats b {
  font-size: 28px;
  display: block;
  color: #0f172a;
}

.stats span {
  color: #64748b;
}

/* Product tiles should appear like header metric cards */
.product-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: -2px 0 18px 0;
  align-items: stretch;
}

.product-tile {
  flex: 1 1 220px;
  min-width: 220px;
}

.product-tile strong {
  display: block;
  margin-bottom: 10px;
  color: #0f172a;
  font-size: 15px;
}

.product-tile div {
  display: inline-block;
  margin-right: 16px;
  margin-bottom: 4px;
  vertical-align: top;
}

.product-tile b {
  font-size: 24px;
  display: block;
  color: #111827;
}

.product-tile span {
  color: #64748b;
  font-size: 13px;
}

/* If product tiles are printed directly under stats without CSS wrapper */
.stats + .product-tiles {
  margin-top: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  background: #fff;
  padding: 14px;
  border-radius: 14px;
  margin-bottom: 18px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
  align-items: flex-end;
}

.filters > * {
  flex: 1 1 140px;
}

.filters input[type="text"],
.filters input[name="q"],
.filters .search {
  flex-basis: 280px;
}

.filters button,
.filters .button {
  flex: 0 0 auto;
}

.table-wrap {
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #eef1f6;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  white-space: nowrap;
}

tr:hover td {
  background: #fbfdff;
}

.empty {
  text-align: center;
  color: #64748b;
  padding: 40px;
}

.pagination {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.pagination a {
  background: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.pagination .active {
  background: #2563eb;
  color: #fff;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.row-actions form {
  margin: 0;
  display: inline-flex;
}

/* Compact icon buttons for Edit/Delete actions */
.button.small,
.row-actions button.small,
.row-actions .button,
.row-actions button {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 0;
  border-radius: 9px;
  margin: 0;
  position: relative;
}

.row-actions .button::before,
.row-actions button::before {
  font-size: 16px;
  line-height: 1;
}

.row-actions .button[href*="edit"]::before,
.row-actions .button.edit::before,
.row-actions .button.small:not(.danger)::before,
.row-actions button.edit::before {
  content: "✎";
}

.row-actions form button::before,
.row-actions button.danger::before,
.row-actions .button.danger::before {
  content: "🗑";
  font-size: 14px;
}

.row-actions .button[href*="edit"],
.row-actions .button.edit,
.row-actions .button.small:not(.danger),
.row-actions button.edit {
  background: #2563eb;
}

.row-actions form button,
.row-actions button.danger,
.row-actions .button.danger {
  background: #dc2626;
}

.edit-card {
  background: #fff;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.05);
  max-width: 980px;
}

.edit-card h2 {
  margin-top: 0;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.form-grid label {
  flex: 1 1 45%;
}

.form-grid .full,
.edit-card label.full {
  flex-basis: 100%;
}

.meta-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  color: #475569;
  line-height: 1.5;
}

.actions-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.actions-row .button,
.actions-row button {
  width: auto;
  height: auto;
  min-width: 0;
  padding: 10px 16px;
  font-size: inherit;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0ecff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .filters > * {
    flex-basis: 30%;
  }

  .filters input[type="text"],
  .filters input[name="q"],
  .filters .search {
    flex-basis: 100%;
  }

  .stats div,
  .product-tile {
    flex-basis: 190px;
  }
}

@media (max-width: 760px) {
  main {
    padding: 16px;
  }

  header {
    display: block;
    padding: 16px;
  }

  nav {
    margin-top: 10px;
  }

  .stats div,
  .product-tile {
    flex-basis: 100%;
  }

  .filters > *,
  .form-grid label,
  .form-grid .full,
  .edit-card label.full {
    flex-basis: 100%;
  }

  .row-actions {
    display: flex;
    flex-wrap: nowrap;
  }

  th,
  td {
    padding: 10px;
  }
}

/* ===== Real-open tracking dashboard refinements ===== */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: stretch;
}

.stats > div,
.stats .product-tile {
  flex: 1 1 170px;
  min-width: 170px;
}

.stats .product-tile {
  border-left: 4px solid #2563eb;
}

.product-tile small {
  display: block;
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
}

.row-actions {
  gap: 6px;
  flex-wrap: nowrap;
}

.row-actions form {
  display: inline-flex;
}

.row-actions .button.small,
.row-actions button.small {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 0;
  border-radius: 9px;
  margin: 0;
  position: relative;
}

.row-actions .button.small::before,
.row-actions button.small::before {
  font-size: 16px;
  line-height: 1;
}

.row-actions .button.edit::before,
.row-actions .button.small:not(.danger)::before {
  content: "✎";
}

.row-actions button.delete::before,
.row-actions button.danger::before {
  content: "🗑";
  font-size: 14px;
}

@media (max-width: 760px) {
  .stats > div,
  .stats .product-tile {
    flex-basis: 100%;
  }

  .row-actions {
    display: flex;
    flex-wrap: nowrap;
  }
}

/* Lead source tabs */
.lead-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px 0;
}

.lead-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #182235;
  border: 1px solid #d7dce5;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.lead-tab.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.lead-tab span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.14);
  font-size: 12px;
}

.lead-tab.active span {
  background: rgba(255, 255, 255, 0.22);
}

.channel-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: #e0f2fe;
  color: #075985;
}

.channel-badge.email {
  background: #fef3c7;
  color: #92400e;
}

.channel-badge.social_media {
  background: #dcfce7;
  color: #166534;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0 !important;
  font-size: 16px;
}
