:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.button,
input,
select,
textarea {
  border-radius: 6px;
  font: inherit;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

button.primary,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button:hover,
.button:hover {
  border-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  padding: 22px 18px;
  background: #172033;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  font-size: 20px;
  font-weight: 800;
}

.org-switch {
  position: relative;
}

.org-switch span {
  display: block;
  color: #b9c2d0;
  font-size: 12px;
  margin-bottom: 6px;
}

.org-current {
  width: 100%;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  justify-content: flex-start;
}

.org-menu {
  display: none;
  position: absolute;
  z-index: 10;
  width: 100%;
  margin-top: 6px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.org-switch:hover .org-menu {
  display: block;
}

.org-menu a,
.sidebar nav a {
  display: block;
  padding: 10px 12px;
}

.sidebar nav a {
  color: #e7ecf4;
  border-radius: 6px;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.logout-form {
  margin-top: auto;
}

.logout-form button {
  width: 100%;
}

.app-main {
  margin-left: 244px;
  padding: 32px;
}

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

.login-panel,
.form-panel,
.details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
}

.login-panel h1,
.page-header h1 {
  margin: 0;
}

.page-header,
.section-title,
.actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header {
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-title {
  justify-content: space-between;
  margin: 28px 0 12px;
}

.section-title h2,
.details h2 {
  margin: 0;
  font-size: 18px;
}

.eyebrow,
.subtle,
.empty,
small {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.messages {
  margin-bottom: 16px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.success {
  border-color: #9ed7c2;
  background: #ecfdf5;
}

.message.error {
  border-color: #f2a8a1;
  background: #fef3f2;
}

.metrics,
.grid-two,
.form-grid,
.mapping-grid {
  display: grid;
  gap: 16px;
}

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

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

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

.metric,
.lead-row,
.followup-row,
.activity,
.status-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 34px;
}

.metric.urgent strong {
  color: var(--danger);
}

.lead-stack,
.activity-list,
.status-list {
  display: grid;
  gap: 10px;
}

.lead-row,
.followup-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.followup-row {
  grid-template-columns: minmax(0, 1.3fr) auto auto auto;
}

.lead-row strong,
.followup-row strong {
  display: block;
}

.pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  color: var(--ink);
  background: #fff;
  white-space: nowrap;
}

.status-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  gap: 10px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.wide {
  grid-column: 1 / -1;
}

.form-panel .actions {
  margin-top: 18px;
}

.stacked-form,
.note-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.note-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.details dl {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
}

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

.details dd {
  margin: 0;
}

.activity {
  padding: 14px;
}

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

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .app-main {
    margin-left: 0;
    padding: 20px;
  }

  .page-header,
  .actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .grid-two,
  .form-grid,
  .mapping-grid,
  .filters,
  .lead-row,
  .followup-row,
  .note-form {
    grid-template-columns: 1fr;
  }
}
