:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #242421;
  --muted: #686f6a;
  --line: #dce2dd;
  --accent: #236c53;
  --accent-strong: #174d3b;
  --accent-soft: #dff0e8;
  --bad: #b33b31;
  --bad-soft: #f5dfdc;
  --warn: #a86b13;
  --warn-soft: #f5ead8;
  --info: #326ca8;
  --info-soft: #dce9f5;
  --shadow: 0 12px 35px rgba(36, 36, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(35, 108, 83, 0.07), transparent 260px),
    var(--bg);
  color: var(--ink);
  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;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app {
  min-height: 100vh;
}

.login-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-head {
  padding: 24px 24px 14px;
  border-bottom: 1px solid var(--line);
}

.login-head h1,
.section-title h2,
.lead-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-head h1 {
  font-size: clamp(28px, 8vw, 44px);
  line-height: 1;
}

.login-head p {
  margin: 10px 0 0;
  color: var(--muted);
}

.login-form,
.stack-form {
  display: grid;
  gap: 14px;
}

.login-form {
  padding: 20px 24px 24px;
}

.field {
  display: grid;
  gap: 7px;
}

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

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

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 108, 83, 0.14);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 12px max(18px, calc((100vw - 1180px) / 2));
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong,
.user-chip strong {
  display: block;
}

.brand-copy span,
.user-chip span {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: grid;
  min-width: 150px;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 8px 10px;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 22px 18px 34px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(26px, 6vw, 38px);
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.section,
.lead-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 26px rgba(36, 36, 33, 0.05);
}

.section {
  overflow: hidden;
}

.section + .section {
  margin-top: 18px;
}

.section-title,
.lead-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.section-title h2,
.lead-title h2 {
  font-size: 19px;
}

.section-title p,
.lead-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-body,
.lead-body {
  padding: 16px;
}

.empty-state {
  display: grid;
  min-height: 310px;
  place-items: center;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 7vw, 40px);
  letter-spacing: 0;
}

.empty-state p {
  margin: 0 auto 20px;
  max-width: 460px;
  color: var(--muted);
}

.lead-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.lead-field {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfb;
  padding: 11px 12px;
}

.lead-field.full {
  grid-column: 1 / -1;
}

.lead-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.lead-field strong,
.lead-field p {
  overflow-wrap: anywhere;
}

.lead-field strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
}

.lead-field p {
  margin: 7px 0 0;
  line-height: 1.45;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tag {
  border-radius: 999px;
  background: var(--surface-soft);
  color: #3f4842;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.lead-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-strong);
}

.btn.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.btn.secondary:hover {
  background: #f0f4f1;
}

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

.btn.ghost:hover {
  background: #edf1ee;
  color: var(--ink);
}

.btn.good {
  background: var(--accent);
}

.btn.bad {
  background: var(--bad);
}

.btn.bad:hover {
  background: #8d2e27;
}

.btn.warn {
  background: var(--warn);
}

.btn.warn:hover {
  background: #7f500e;
}

.flash {
  margin-bottom: 14px;
  border: 1px solid var(--info);
  border-radius: 7px;
  background: var(--info-soft);
  color: #204c78;
  padding: 10px 12px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong {
  display: block;
}

.status-pill {
  display: inline-flex;
  min-width: 78px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.good {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.status-pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 18px;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
}

.mini-list span {
  color: var(--muted);
  font-size: 13px;
}

.danger-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 900px) {
  .summary-grid,
  .workbench,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .workbench {
    gap: 14px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .user-chip {
    width: 100%;
  }

  .top-actions {
    align-items: stretch;
  }

  .summary-grid,
  .lead-grid,
  .lead-actions,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .page {
    padding-inline: 12px;
  }

  .section-title,
  .lead-title {
    flex-direction: column;
  }
}
