:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #d9dee9;
  --blue: #2563eb;
  --green: #119c66;
  --yellow: #b7791f;
  --red: #d92d20;
  --ink: #0f172a;
  --shadow: 0 18px 50px rgba(22, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.7fr);
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.78), rgba(37, 99, 235, 0.4)),
    url("https://images.unsplash.com/photo-1556761175-b413da4baf72?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-hero {
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: end;
  padding: clamp(32px, 7vw, 86px);
}

.login-hero h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.95;
  letter-spacing: 0;
}

.login-hero p {
  max-width: 590px;
  margin: 24px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(17px, 2vw, 22px);
}

.login-panel {
  align-self: center;
  margin: 28px;
  padding: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-panel h2,
.panel h2 {
  margin: 0;
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 16px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.btn.secondary {
  background: #edf1f7;
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn.full {
  width: 100%;
  margin-top: 20px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #101828;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 18px;
  font-weight: 900;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
}

.nav {
  display: grid;
  gap: 7px;
  margin-top: 34px;
}

.nav button {
  justify-content: start;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
}

.nav button.active {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.account {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.account strong {
  display: block;
}

.account small {
  color: rgba(255, 255, 255, 0.62);
}

.content {
  padding: clamp(18px, 3vw, 34px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat,
.panel,
.lead-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(16, 24, 40, 0.04);
}

.stat {
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lead-list,
.user-list {
  display: grid;
  gap: 12px;
}

.rotation-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 13px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.rotation-summary strong {
  text-align: right;
}

.lead-card {
  padding: 15px;
}

.lead-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.lead-card h3 {
  margin: 0;
  font-size: 18px;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  background: #edf1f7;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.pill.new {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.contacted {
  background: #fef3c7;
  color: var(--yellow);
}

.pill.won {
  background: #dcfce7;
  color: var(--green);
}

.pill.lost {
  background: #fee2e2;
  color: var(--red);
}

.lead-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.user-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-row > div:nth-child(2) {
  flex: 1 1 160px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-row .btn {
  white-space: nowrap;
}

.user-row.next {
  border-color: #93c5fd;
  background: #f8fbff;
}

.row-position {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #edf1f7;
  color: var(--ink);
  font-weight: 900;
}

.icon-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.icon-btn {
  min-height: 36px;
  padding: 8px;
}

.btn:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.switch input {
  width: auto;
}

.code {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #dbeafe;
  padding: 13px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #101828;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

.lead-details {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
}

.lead-details dt {
  color: var(--muted);
}

.lead-details dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.log-list {
  display: grid;
}

.log-row {
  display: grid;
  grid-template-columns: 150px 80px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.log-row:last-child {
  border-bottom: 0;
}

.log-row time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.log-row .pill {
  justify-content: center;
}

.pill.log-lead {
  background: #dbeafe;
  color: #1d4ed8;
}

.pill.log-mail {
  background: #ede9fe;
  color: #6d28d9;
}

.pill.log-auth {
  background: #dcfce7;
  color: var(--green);
}

.pill.log-error {
  background: #fee2e2;
  color: var(--red);
}

a.btn {
  text-decoration: none;
}

.btn.whatsapp {
  background: #16a34a;
  color: #fff;
}

.btn.danger {
  background: var(--red);
  color: #fff;
}

.small {
  font-size: 12px;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.back-btn {
  margin-bottom: 12px;
  padding-left: 0;
}

.stack {
  display: grid;
  gap: 18px;
}

.file-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 1fr);
}

.note-list,
.template-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.note,
.template {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.note p,
.template p {
  margin: 8px 0 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.template .toolbar {
  margin-top: 10px;
}

.note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.note-head strong {
  color: var(--text);
}

.template-form {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.template-form h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.credentials {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #86efac;
  border-radius: 8px;
  background: #f0fdf4;
}

.credentials .code {
  margin: 10px 0;
  white-space: pre-wrap;
}

.danger-zone {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.access-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.access-row.locked,
.user-row.locked {
  background: #fef2f2;
}

@media (max-width: 980px) {
  .login-shell,
  .app-shell,
  .grid,
  .file-grid {
    grid-template-columns: 1fr;
  }

  .login-hero {
    min-height: 42vh;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .account {
    position: static;
    margin-top: 24px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .login-panel {
    margin: 0;
    border-radius: 0;
  }

  .content {
    padding: 14px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .stats,
  .lead-actions,
  .user-row,
  .log-row,
  .access-row {
    grid-template-columns: 1fr;
  }

  .log-row {
    gap: 6px;
  }

  .log-row .pill {
    justify-self: start;
  }

  .rotation-summary {
    align-items: start;
    flex-direction: column;
  }

  .rotation-summary strong {
    text-align: left;
  }

  .lead-main {
    flex-direction: column;
  }
}
