:root {
  --navy: #134e4a;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --accent: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal));
  display: grid; place-items: center; font-weight: 800;
}
.brand small { display: block; opacity: 0.75; font-size: 12px; }
.nav { display: flex; flex-wrap: wrap; gap: 8px; }
.nav a {
  color: #ccfbf1; padding: 8px 12px; border-radius: 8px; font-size: 14px; font-weight: 600;
  text-decoration: none;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,0.12); color: #fff; text-decoration: none; }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 14px; }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 0 16px 32px; }

.page-head {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 28px; color: var(--navy); }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.grid-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px;
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 6px; color: var(--navy); }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; color: var(--navy); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: #f8fafc;
}
table.data tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #e2e8f0; color: #334155;
}
.badge.new { background: #dbeafe; color: #1d4ed8; }
.badge.contacted { background: #ffedd5; color: #c2410c; }
.badge.confirmed { background: #ccfbf1; color: #0f766e; }
.badge.completed { background: #dcfce7; color: #15803d; }
.badge.lost { background: #fee2e2; color: #b91c1c; }
.badge.draft { background: #e2e8f0; color: #475569; }
.badge.sent, .badge.issued { background: #ccfbf1; color: #0f766e; }
.badge.paid { background: #dcfce7; color: #15803d; }
.badge.partial { background: #fef3c7; color: #b45309; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 8px;
  padding: 10px 14px; font-weight: 700; font-size: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--navy); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.25); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.alert {
  padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 600;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }

.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, #134e4a 0%, #0f766e 45%, #f1f5f9 45%);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-card h1 { margin: 0 0 6px; color: var(--navy); }
.login-card p { margin: 0 0 20px; color: var(--muted); }

.items-table input { width: 100%; }
.muted { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: end; }
.toolbar .form-group { min-width: 160px; }

/* —— Leads redesign —— */
.status-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: #fff; border: 1px solid var(--border); color: var(--muted); text-decoration: none;
}
.chip span {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: #f1f5f9; color: var(--navy); font-size: 12px;
  display: inline-grid; place-items: center;
}
.chip.active {
  background: var(--navy); border-color: var(--navy); color: #fff;
}
.chip.active span { background: rgba(255,255,255,0.18); color: #fff; }
.chip:hover { text-decoration: none; border-color: var(--teal); }

.leads-filter { margin-bottom: 16px; }
.search-wrap {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.search-wrap input {
  flex: 1; min-width: 220px; padding: 12px 14px; border-radius: 10px;
}

.leads-list { display: flex; flex-direction: column; gap: 12px; }
.lead-card {
  display: grid; grid-template-columns: 1fr auto; gap: 16px 24px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.lead-card:hover { border-color: #99f6e4; }
.lead-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.ref-pill {
  font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
  color: var(--teal-dark); background: #ccfbf1; padding: 4px 8px; border-radius: 6px;
}
.source-tag {
  font-size: 11px; font-weight: 600; color: var(--muted);
  background: #f8fafc; border: 1px solid var(--border); padding: 3px 8px; border-radius: 999px;
}
.lead-name { margin: 0 0 8px; font-size: 18px; color: var(--navy); }
.lead-name a { color: inherit; text-decoration: none; }
.lead-name a:hover { color: var(--teal-dark); text-decoration: underline; }
.lead-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 10px; }
.meta-item { font-size: 13px; color: var(--muted); }
a.meta-item:hover { color: var(--teal-dark); }
.lead-treat {
  font-size: 14px; color: var(--text);
  padding-top: 8px; border-top: 1px dashed var(--border);
}
.treat-label {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-right: 8px;
}
.lead-side {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 10px;
  min-width: 200px;
}
.lead-value { text-align: right; }
.val-est { font-size: 16px; font-weight: 800; color: var(--navy); }
.val-paid { font-size: 14px; font-weight: 700; color: var(--ok); margin-top: 2px; }
.val-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.lead-date { font-size: 12px; color: var(--muted); }
.lead-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.act {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; padding: 7px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 800; text-decoration: none; border: 1px solid transparent;
}
.act:hover { text-decoration: none; filter: brightness(0.97); }
.act-edit { background: #fff; border-color: var(--border); color: var(--navy); }
.act-quote { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.act-inv { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.act-rx { background: #f3e8ff; color: #7e22ce; border-color: #e9d5ff; }

.empty-state {
  text-align: center; padding: 48px 20px; background: #fff;
  border: 1px dashed var(--border); border-radius: 14px; color: var(--muted);
}
.empty-state strong { display: block; color: var(--navy); font-size: 18px; margin-bottom: 6px; }
.empty-state .btn { margin-top: 14px; }

@media (max-width: 720px) {
  .lead-card { grid-template-columns: 1fr; }
  .lead-side { align-items: flex-start; min-width: 0; }
  .lead-value, .lead-date { text-align: left; }
  .lead-actions { justify-content: flex-start; }
}

@media print {
  .topbar, .footer, .no-print, .alert { display: none !important; }
  body { background: #fff; }
  .container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
