:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --ink: #151a18;
  --muted: #66726f;
  --line: #dfe6e2;
  --brand: #101514;
  --brand-2: #0f7569;
  --accent: #d44a2f;
  --gold: #c8922c;
  --green-soft: #eaf5f1;
  --red-soft: #fff0eb;
  --shadow: 0 18px 44px rgba(20, 28, 25, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: 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 { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(560px, 0.98fr) minmax(440px, 0.72fr);
  align-items: stretch;
  justify-content: center;
  gap: clamp(48px, 6vw, 112px);
  padding: clamp(30px, 4vw, 72px);
  background:
    radial-gradient(circle at 16% 18%, rgba(15, 117, 105, 0.15), transparent 30%),
    radial-gradient(circle at 86% 62%, rgba(200, 146, 44, 0.1), transparent 28%),
    linear-gradient(135deg, #fbfdfb 0%, #eef6f3 54%, #f7f8f3 100%);
  color: var(--ink);
}

.login-brand {
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0;
}

.login-brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(64px, 11vh, 128px);
}

.login-brand-top img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(20, 28, 25, 0.12);
}

.login-brand-top strong,
.login-brand-top span {
  display: block;
}

.login-brand-top strong {
  font-size: 18px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.login-brand .eyebrow { color: var(--brand-2); }

h1, h2, p { margin-top: 0; }

.login-brand h1 {
  max-width: 720px;
  margin-bottom: 18px;
  font-size: clamp(42px, 4.3vw, 62px);
  line-height: 1.08;
  letter-spacing: 0;
}

.tagline {
  max-width: 680px;
  color: #52615d;
  font-size: 19px;
  line-height: 1.45;
}

.login-showcase {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: min(700px, 100%);
  margin-top: 30px;
}

.login-showcase article {
  min-height: 122px;
  padding: 16px;
  border: 1px solid rgba(15, 117, 105, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 34px rgba(20, 28, 25, 0.07);
}

.login-showcase svg {
  color: var(--brand-2);
}

.login-showcase strong,
.login-showcase span {
  display: block;
}

.login-showcase strong {
  margin: 12px 0 4px;
  font-size: 27px;
}

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

.login-workflow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 10px;
  margin-top: 22px;
  color: #33413e;
}

.login-workflow span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.login-workflow svg {
  color: var(--brand-2);
}

.login-card {
  align-self: center;
  justify-self: center;
  width: min(100%, 520px);
  padding: 34px;
  border: 1px solid rgba(15, 117, 105, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: 0 28px 76px rgba(20, 28, 25, 0.14);
  backdrop-filter: blur(12px);
}

.login-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.login-card img {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  object-fit: cover;
}

.login-card h2 {
  margin: 0 0 4px;
  font-size: 29px;
}

.login-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 8px;
}

.check-label {
  display: flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.check-label input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--brand-2);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--brand-2);
  font-size: 13px;
  font-weight: 800;
}

.login-security {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green-soft);
  color: #31504a;
  font-size: 13px;
}

.login-security svg {
  color: var(--brand-2);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #101514;
  color: #f5fbf9;
}

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

.brand img {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.sidebar-card span,
.sidebar-card p {
  color: #adbbb6;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe6e2;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

svg { width: 18px; height: 18px; flex: 0 0 auto; }

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-card strong {
  display: block;
  margin: 6px 0;
  font-size: 24px;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar,
.topbar-actions,
.section-toolbar,
.panel-head,
.segmented,
.chat-head {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: 31px;
}

.topbar-actions { gap: 10px; }

.user-chip {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.search-wrap {
  width: min(390px, 36vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-button,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.login-card .primary-button {
  min-height: 48px;
  font-size: 15px;
  font-weight: 800;
}

.primary-button {
  padding: 0 15px;
  color: white;
  background: var(--brand-2);
}

.primary-button:hover { background: #0a5d54; }

.ghost-button {
  padding: 0 12px;
  border-color: var(--line);
  background: white;
}

.icon-button {
  width: 42px;
  border-color: var(--line);
  background: white;
}

.full { width: 100%; }

.view { display: none; }
.view.active { display: block; }

.metric-grid,
.dashboard-grid,
.split-layout,
.client-grid,
.integration-grid,
.report-grid,
.settings-grid,
.whatsapp-layout {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric,
.panel,
.client-card,
.integration-card,
.report-card,
.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span,
.metric em {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.metric strong {
  display: block;
  margin: 8px 0;
  font-size: 30px;
}

.panel { padding: 18px; }

.dashboard-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.55fr);
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head.compact { margin-bottom: 8px; }
.panel-head p, .panel p { color: var(--muted); margin-bottom: 0; }

.source-bars,
.action-list,
.role-tree,
.chat-list,
.messages {
  display: grid;
  gap: 10px;
}

.source-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) 62px;
  gap: 12px;
  align-items: center;
}

.source-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef3f0;
}

.source-fill { height: 100%; border-radius: inherit; }

.action-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.action-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--brand-2);
}

.action-item strong,
.client-card strong,
.integration-card strong,
.report-card strong,
.settings-card strong,
.rule-note strong {
  display: block;
  margin-bottom: 4px;
}

.section-toolbar {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.segmented button {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
}

.segmented button.active {
  color: white;
  background: var(--brand-2);
}

.split-layout { grid-template-columns: minmax(0, 1fr) 350px; }

#leads .split-layout {
  grid-template-columns: minmax(0, 1fr) 320px 320px;
}

.tasks-panel {
  margin-top: 16px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.task-item strong,
.task-item span,
.task-item em {
  display: block;
}

.task-item span,
.task-item em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mini-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
}

.mini-button:hover {
  border-color: var(--brand-2);
  background: var(--green-soft);
}
.table-panel { overflow-x: auto; }

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

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

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

.person strong,
.person span,
.badge,
.status-badge,
.role-node span {
  display: block;
}

.person span,
.role-node span,
.client-card span,
.integration-card p,
.report-card p,
.settings-card p,
.rule-note span,
.chat-item span {
  color: var(--muted);
  font-size: 13px;
}

.badge,
.status-badge {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #0a5d54;
  font-size: 12px;
  font-weight: 900;
}

.badge.hot { color: #a3311d; background: var(--red-soft); }

.form-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: white;
  color: var(--ink);
}

.login-card input {
  min-height: 43px;
  background: #fbfcfb;
}

.login-card label {
  gap: 8px;
}

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

.client-grid,
.integration-grid,
.report-grid,
.settings-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.client-card,
.integration-card,
.report-card,
.settings-card {
  padding: 16px;
  min-height: 158px;
}

.settings-admin {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 330px));
  gap: 16px;
  margin-top: 16px;
}

.settings-admin .table-panel {
  grid-column: 1 / -1;
}

.permission-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.check-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.check-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--teal);
}

.permission-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.permission-chips b {
  padding: 5px 7px;
  border-radius: 6px;
  background: #e8f3ef;
  color: #176c60;
  font-size: 11px;
  line-height: 1;
}

.client-card {
  display: grid;
  gap: 10px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(230px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.pipeline-column {
  min-height: 560px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
}

.pipeline-column h2 {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
}

.pipeline-stack { display: grid; gap: 10px; }

.pipeline-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.pipeline-card p {
  color: var(--muted);
  font-size: 13px;
}

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

.whatsapp-layout {
  grid-template-columns: 280px minmax(0, 1fr) 280px;
}

.chat-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.chat-item.active { border-color: var(--brand-2); background: var(--green-soft); }

.chat-head {
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.messages {
  min-height: 420px;
  align-content: start;
  padding: 14px 0;
}

.message {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef3f0;
}

.message small {
  display: block;
  margin-top: 6px;
  color: inherit;
  font-size: 11px;
  opacity: 0.72;
}

.message.out {
  justify-self: end;
  color: white;
  background: var(--brand-2);
}

.empty-chat {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfdfc;
}

.template-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 12px;
  border-top: 1px solid var(--line);
}

.template-chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand-2);
  background: #f8fbfa;
  font-size: 12px;
  font-weight: 800;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.rule-note {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  margin-bottom: 10px;
}

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

.timeline div {
  border-left: 3px solid var(--brand-2);
  padding: 0 10px;
}

.timeline strong {
  display: block;
  color: var(--brand-2);
  margin-bottom: 6px;
}

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

.role-node {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.role-node.depth-1 { margin-left: 28px; }
.role-node.depth-2 { margin-left: 56px; }
.role-node.depth-3 { margin-left: 84px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #101514;
  color: white;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1200px) {
  .metric-grid,
  .client-grid,
  .integration-grid,
  .report-grid,
  .settings-grid,
  .timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .split-layout,
  .whatsapp-layout,
  .settings-admin {
    grid-template-columns: 1fr;
  }

  #leads .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 86px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 18px; }
  .brand div, .nav-item span, .sidebar-card { display: none; }
  .nav-item { width: 48px; justify-content: center; padding: 0; }
  .login-screen {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .login-brand {
    min-height: auto;
    padding: 28px 8px 0;
  }
  .login-brand-top { margin-bottom: 28px; }
  .login-showcase { grid-template-columns: 1fr; }
  .login-card { margin: 0 0 20px; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    z-index: 5;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  .brand { min-width: 48px; }
  .nav-list { display: flex; }
  .main { padding: 18px; }
  .topbar, .topbar-actions, .section-toolbar { flex-direction: column; align-items: stretch; }
  .search-wrap { width: 100%; }
  .metric-grid, .client-grid, .integration-grid, .report-grid, .settings-grid, .timeline { grid-template-columns: 1fr; }
  .pipeline-board { grid-template-columns: repeat(7, 260px); }
  .login-workflow { grid-template-columns: 1fr; }
  .login-row { align-items: flex-start; flex-direction: column; }
}
