:root {
  --yellow: #fed13a;
  --yellow-deep: #f2b705;
  --ink: #0d0d0d;
  --ink-2: #171717;
  --ink-3: #262626;
  --paper: #f6f5f0;
  --card: #ffffff;
  --line: #e7e5dc;
  --muted: #6b6b65;
  --red: #c62828;
  --green: #1f9d55;
  --wa: #25d366;
  --radius: 16px;
  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
}
h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.ur {
  font-family: 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  line-height: 2.1;
}
:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

/* ---------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--card);
  border-color: var(--line);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover {
  border-color: var(--ink);
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}
.btn-primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn-primary:hover {
  background: #2a2a2a;
}
.btn-yellow {
  background: var(--yellow);
  border-color: var(--yellow);
  color: var(--ink);
}
.btn-yellow:hover {
  background: var(--yellow-deep);
  border-color: var(--yellow-deep);
}
.btn-danger {
  color: var(--red);
}
.btn-danger:hover {
  border-color: var(--red);
  background: #fff3f3;
}
.btn-wa {
  background: var(--wa);
  border-color: var(--wa);
  color: #fff;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---------- login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(60% 70% at 50% 40%, #ffe68c 0%, #fed13a 55%, #f0b400 100%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--ink);
  color: #fff;
  border-radius: 28px;
  padding: 36px 32px 32px;
  box-shadow: 0 40px 80px rgba(90, 60, 0, 0.35);
  display: grid;
  gap: 18px;
}
.login-card .brand img {
  filter: invert(1);
}
.login-card h1 {
  font-size: 1.5rem;
}
.login-card p {
  margin: 0;
  color: #a3a39b;
  font-size: 0.9rem;
}
.login-card label span {
  color: #d6d6d0;
}
.login-card input {
  background: #1d1d1d;
  border-color: #333;
  color: #fff;
}
.login-card input:focus {
  border-color: var(--yellow);
}
.login-card .btn {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
}
.error {
  background: #3a1414;
  color: #ffb4b4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
}

/* ---------- shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.side {
  background: var(--ink);
  color: #d6d6d0;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 18px;
}
.brand img {
  height: 26px;
  filter: invert(1);
}
.pk {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--yellow);
  color: var(--ink);
  padding: 2px 7px;
  border-radius: 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.93rem;
}
.nav a:hover {
  background: #1d1d1d;
  color: #fff;
}
.nav a[aria-current='page'] {
  background: var(--yellow);
  color: var(--ink);
}
.nav svg {
  width: 18px;
  height: 18px;
}
.nav .count {
  margin-inline-start: auto;
  background: var(--yellow);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 8px;
}
.nav a[aria-current='page'] .count {
  background: var(--ink);
  color: var(--yellow);
}
.side-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 0 6px;
  font-size: 0.85rem;
}
.side-foot .who {
  color: #8a8a83;
  padding: 0 6px;
}
.side-foot .btn {
  background: #1d1d1d;
  border-color: #2c2c2c;
  color: #fff;
}

.main {
  min-width: 0;
}
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  background: rgba(246, 245, 240, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 {
  font-size: 1.25rem;
  margin-inline-end: auto;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}
.status::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}
.status.dirty {
  color: #8a5a00;
}
.status.dirty::before {
  background: var(--yellow-deep);
  box-shadow: 0 0 0 4px rgba(242, 183, 5, 0.25);
}
.menu-btn {
  display: none;
}
.page {
  padding: 26px 28px 60px;
  max-width: 1200px;
}

/* ---------- common blocks */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar .grow {
  flex: 1;
  min-width: 200px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.82rem;
}
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: #efede5;
  white-space: nowrap;
  vertical-align: middle;
}
.badge.yellow {
  background: var(--yellow);
}
.badge.dark {
  background: var(--ink);
  color: var(--yellow);
}
.badge.sample {
  background: #ffe3e3;
  color: #a61b1b;
}
.badge.new {
  background: var(--yellow);
}
.badge.contacted {
  background: #dbeafe;
  color: #1e40af;
}
.badge.done {
  background: #dcfce7;
  color: #166534;
}
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
}
.chip[aria-pressed='true'] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ---------- dashboard */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  padding: 18px 20px;
  display: grid;
  gap: 4px;
  text-decoration: none;
}
.stat b {
  font-size: 2rem;
  line-height: 1.1;
}
.stat span {
  color: var(--muted);
  font-size: 0.85rem;
}
.stat.hl {
  background: var(--yellow);
  border-color: var(--yellow);
}
.stat.hl span {
  color: #3a3a36;
}
.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: start;
}
.panel {
  padding: 20px;
}
.panel h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
}
.publish-card {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.publish-card p {
  color: #a3a39b;
  margin: 0 0 16px;
  font-size: 0.9rem;
}

/* ---------- lists / tables */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table .actions {
  text-align: end;
  white-space: nowrap;
}
.table .actions .btn {
  margin-inline-start: 6px;
}
.table-wrap {
  overflow-x: auto;
}

.lead {
  padding: 16px 18px;
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.lead-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.lead-head h3 {
  font-size: 1rem;
  margin-inline-end: auto;
}
.lead dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0;
  font-size: 0.9rem;
}
.lead dt {
  color: var(--muted);
}
.lead dd {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.lead-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.lead-foot textarea {
  flex: 1;
  min-width: 220px;
  min-height: 38px;
  height: 38px;
  resize: vertical;
}

/* photo grid */
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.photo {
  overflow: hidden;
  display: grid;
}
.photo img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #e9e7de;
  display: block;
}
.photo .info {
  padding: 12px 14px 6px;
  display: grid;
  gap: 2px;
}
.photo .info b {
  font-size: 0.92rem;
}
.photo .bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px 12px;
  flex-wrap: wrap;
}
.photo .pos {
  margin-inline-start: auto;
  font-size: 0.75rem;
  color: var(--muted);
  align-self: center;
}

/* ---------- forms */
form {
  display: grid;
  gap: 14px;
}
label {
  display: grid;
  gap: 5px;
}
label > span {
  font-size: 0.82rem;
  font-weight: 600;
}
label > small {
  color: var(--muted);
  font-size: 0.78rem;
}
input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(254, 209, 58, 0.6);
}
input.ur,
textarea.ur {
  text-align: right;
  padding-block: 4px 8px;
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin: 0;
  display: grid;
  gap: 12px;
}
legend {
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 6px;
}
.map-pick {
  height: 260px;
  border-radius: 12px;
  border: 1px solid var(--line);
  z-index: 0;
}
.preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 12px;
  background: #efede5;
  display: block;
}
.drop {
  display: grid;
  place-items: center;
  gap: 6px;
  aspect-ratio: 16 / 10;
  border: 2px dashed #d4d1c4;
  border-radius: 12px;
  background: #faf9f4;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  padding: 20px;
}
.drop.over {
  border-color: var(--ink);
  background: #fff8dc;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}
.form-error {
  background: #fff1f1;
  color: var(--red);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
}
.form-error:empty {
  display: none;
}

/* ---------- dialog */
dialog.modal {
  width: min(720px, 94vw);
  max-height: 92vh;
  padding: 0;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.35);
}
dialog.modal::backdrop {
  background: rgba(13, 13, 13, 0.55);
  backdrop-filter: blur(3px);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}
.modal-head h2 {
  font-size: 1.1rem;
}
.modal-body {
  padding: 20px 22px 22px;
}

/* ---------- toasts */
#toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 1000;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
  animation: up 0.25s ease;
}
.toast.err {
  background: var(--red);
}
@keyframes up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
.log {
  background: #111;
  color: #cfcfc8;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.75rem;
  padding: 12px;
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ---------- responsive */
@media (max-width: 1000px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .two-col {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .side.open {
    transform: none;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.4);
  }
  .menu-btn {
    display: inline-flex;
  }
  .top,
  .page {
    padding-inline: 16px;
  }
  .row,
  .row3 {
    grid-template-columns: 1fr;
  }
  .table .hide-sm {
    display: none;
  }
  .top .status {
    display: none;
  }
}
