:root {
  --bg: #f6f1e8;
  --bg-2: #efe5d8;
  --card: rgba(255, 252, 247, 0.92);
  --card-strong: #fffaf3;
  --ink: #1f1b17;
  --muted: #74675a;
  --line: rgba(155, 126, 85, 0.18);
  --gold: #caa36b;
  --gold-deep: #b28a52;
  --shadow: 0 22px 50px rgba(71, 51, 24, 0.12);
  --danger: #a44d3f;
  --success: #2e6b4c;
  --warning: #9a6b1f;
  --info: #345b7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(202, 163, 107, 0.22), transparent 25%),
    radial-gradient(circle at top right, rgba(31, 27, 23, 0.08), transparent 22%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
}

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

.page-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: inline-block;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 760px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 12px 16px;
  border-radius: 18px;
  background: rgba(255, 250, 243, 0.72);
  border: 1px solid var(--line);
}

.user-badge small {
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.nav-tabs a {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.75);
  border: 1px solid var(--line);
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
}

.flash-success { border-color: rgba(46, 107, 76, 0.28); }
.flash-error { border-color: rgba(164, 77, 63, 0.28); }
.flash-info { border-color: rgba(52, 91, 123, 0.28); }

.main-content {
  display: grid;
  gap: 18px;
}

.section-grid,
.two-column-layout {
  display: grid;
  gap: 18px;
}

.section-grid > *,
.two-column-layout > *,
.stats-grid > * {
  min-width: 0;
}

.section-grid {
  grid-template-columns: 1.3fr 1fr;
}

.two-column-layout {
  grid-template-columns: 1.2fr 0.8fr;
}

.panel-card,
.table-card,
.hero-card,
.login-card {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow);
  border-radius: 28px;
  padding: 24px;
  min-width: 0;
}

.panel-header,
.lead-card-top,
.activity-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--warning);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.12em;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.05;
}

h2 {
  font-size: 28px;
  line-height: 1.1;
}

h3 {
  font-size: 20px;
  line-height: 1.15;
}

.panel-text,
.muted-line,
.cell-subtitle,
.long-text {
  color: var(--muted);
}

.lead-summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.lead-summary.compact {
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 440px;
}

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

.stat-card {
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(247, 239, 226, 0.92));
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
}

.stat-card strong {
  font-size: 42px;
  line-height: 1;
}

.button-row,
.download-grid,
.badge-row,
.link-row,
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-grid {
  margin-top: 18px;
}

.top-gap {
  margin-top: 18px;
}

.download-grid a,
.text-link,
.inline-link {
  color: var(--warning);
}

button,
.inline-link {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.primary-button,
.secondary-button,
.ghost-button,
.inline-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.primary-button {
  background: var(--gold);
  color: var(--ink);
}

.secondary-button {
  background: var(--ink);
  color: #f8f2e7;
}

.ghost-button,
.inline-link {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

button:hover,
.inline-link:hover {
  transform: translateY(-1px);
}

.command-log {
  margin-top: 18px;
  padding: 18px;
  background: #221d19;
  color: #f6efe3;
  border-radius: 20px;
  overflow: hidden;
}

.command-log pre {
  margin: 12px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.lead-stack,
.mini-stack,
.activity-feed,
.task-list {
  display: grid;
  gap: 14px;
}

.lead-card,
.mini-card,
.activity-item,
.notes-box,
.form-card,
.task-row {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
}

.task-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.task-row h3 {
  margin-top: 10px;
}

.task-row p {
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.task-row-side {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 170px;
}

.task-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  width: min(360px, calc(100vw - 32px));
}

.task-widget.is-hidden {
  display: none;
}

.task-widget-close {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  background: rgba(248, 242, 231, 0.14);
  color: #f8f2e7;
  font-size: 22px;
  line-height: 1;
}

.task-widget details {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.48);
  box-shadow: 0 22px 48px rgba(31, 27, 23, 0.22);
  background: rgba(255, 252, 247, 0.96);
  backdrop-filter: blur(16px);
}

.task-widget summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 52px 14px 16px;
  background: var(--ink);
  color: #f8f2e7;
}

.task-widget summary::-webkit-details-marker {
  display: none;
}

.task-widget summary span {
  font-weight: 700;
}

.task-widget summary strong {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ink);
}

.task-widget-body {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding: 12px;
}

.task-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.task-item span {
  color: var(--warning);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.task-item strong,
.task-item small {
  overflow-wrap: anywhere;
}

.task-item small,
.task-widget-link {
  color: var(--muted);
  font-size: 13px;
}

.task-followup {
  border-color: rgba(154, 107, 31, 0.34);
}

.task-widget-link {
  padding: 8px 4px 2px;
  text-align: center;
  color: var(--warning);
  font-weight: 700;
}

.notes-box.compact {
  margin-top: 14px;
}

.danger-zone {
  border-color: rgba(164, 77, 63, 0.24);
  background: rgba(164, 77, 63, 0.06);
}

.danger-button {
  color: var(--danger);
  border-color: rgba(164, 77, 63, 0.32);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge-neutral { background: rgba(111, 101, 91, 0.12); color: #554d45; }
.badge-success { background: rgba(46, 107, 76, 0.12); color: var(--success); }
.badge-warning { background: rgba(154, 107, 31, 0.14); color: var(--warning); }
.badge-danger { background: rgba(164, 77, 63, 0.14); color: var(--danger); }
.badge-info { background: rgba(52, 91, 123, 0.14); color: var(--info); }

.meta-row,
.link-row {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.table-cell-stack {
  display: grid;
  gap: 6px;
}

.mono-text {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
}

.invite-code {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

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

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

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

th {
  background: rgba(247, 239, 226, 0.8);
  font-size: 14px;
  color: var(--muted);
}

.filters-grid,
.manual-grid,
.info-grid {
  display: grid;
  gap: 14px;
}

.filters-grid {
  grid-template-columns: minmax(280px, 2fr) minmax(180px, 1fr) auto;
  align-items: end;
}

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

.info-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.info-grid div {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.65);
  border: 1px solid var(--line);
}

.info-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255,255,255,0.86);
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.long-text,
.cell-subtitle,
.notes-box p,
.mini-card p,
.activity-item p {
  overflow-wrap: anywhere;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

.checkbox-row input {
  width: auto;
}

.login-layout {
  min-height: calc(100vh - 180px);
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
}

.hero-card {
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(34, 29, 25, 0.94), rgba(58, 47, 35, 0.92)),
    linear-gradient(180deg, rgba(202, 163, 107, 0.18), transparent);
  color: #f6efe3;
}

.hero-card p {
  margin-top: 18px;
  color: rgba(246, 239, 227, 0.78);
  max-width: 560px;
}

.login-card {
  max-width: 420px;
  justify-self: end;
  display: grid;
  gap: 16px;
}

.form-hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.login-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 28px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, rgba(34, 29, 25, 0.96), rgba(82, 63, 40, 0.92)),
    linear-gradient(180deg, rgba(202, 163, 107, 0.2), transparent);
  color: #f8f2e7;
}

.detail-hero p {
  margin-top: 10px;
  color: rgba(248, 242, 231, 0.78);
}

.empty-state {
  color: var(--muted);
  padding: 12px 0;
}

.manual-review-form,
.form-card {
  display: grid;
  gap: 14px;
}

.table-form {
  display: grid;
  gap: 12px;
  min-width: 280px;
}

.password-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.table-form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
}

.table-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-form button[disabled],
.table-form select[disabled] {
  cursor: not-allowed;
  opacity: 0.68;
}

.activity-feed.full .activity-item {
  background: rgba(255,255,255,0.55);
}

@media (max-width: 1100px) {
  .section-grid,
  .two-column-layout,
  .login-layout,
  .filters-grid {
    grid-template-columns: 1fr;
  }

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

  .login-card {
    justify-self: stretch;
    max-width: none;
  }
}

@media (max-width: 1320px) {
  .section-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) {
  .two-column-layout,
  .login-layout,
  .filters-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 14px 36px;
  }

  .topbar,
  .detail-hero {
    flex-direction: column;
  }

  .stats-grid,
  .manual-grid,
  .info-grid,
  .table-form-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 14px;
  }

  .brand {
    font-size: 30px;
  }

  .task-row {
    display: grid;
  }

  .task-row-side {
    justify-items: start;
    min-width: 0;
  }

  .task-widget {
    right: 12px;
    bottom: 12px;
  }
}
