:root {
  --bg: #e7eef5;
  --surface: #ffffff;
  --surface-muted: #f5f9fc;
  --ink: #0b1f35;
  --ink-soft: #3f5164;
  --line: #d7e2ec;
  --brand: #0b5c96;
  --brand-strong: #0a4470;
  --teal: #098c91;
  --amber: #d1832f;
  --success: #20795d;
  --danger: #b9473b;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 9px;
  --shadow-lg: 0 22px 52px rgba(11, 31, 53, 0.14);
  --shadow-md: 0 10px 26px rgba(11, 31, 53, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #f8fbff 0%, var(--bg) 40%, #d8e6f3 100%);
  overflow-x: hidden;
}

.backdrop-orb {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.34;
  z-index: -3;
  animation: float 18s ease-in-out infinite;
}

.orb-a {
  background: #5aa9f6;
  top: -190px;
  left: -120px;
}

.orb-b {
  background: #2cb6a0;
  right: -180px;
  bottom: -180px;
  animation-delay: -7s;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(11, 31, 53, 0.04) 1px, transparent 1px);
  background-size: 5px 5px;
  opacity: 0.24;
  z-index: -2;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: #6d8298;
  margin: 0;
}

.muted {
  color: var(--ink-soft);
  margin: 0;
}

.badge {
  border-radius: 999px;
  padding: 0.22rem 0.72rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-soft {
  background: #deedf8;
  color: #084f82;
}

.badge-warn {
  background: #f8ead6;
  color: #97581e;
}

.badge-success {
  background: #dff4ec;
  color: #206147;
}

.badge-danger {
  background: #f8e4e2;
  color: #9a433a;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.56rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--teal));
  box-shadow: 0 8px 18px rgba(7, 72, 118, 0.26);
}

.btn-secondary {
  color: #fff;
  background: linear-gradient(120deg, #115b85, #0c7b84);
}

.btn-ghost {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.btn-danger {
  color: #fff;
  background: linear-gradient(120deg, #a33b31, #d25d4f);
  box-shadow: 0 8px 18px rgba(147, 53, 43, 0.24);
}

.btn-block {
  width: 100%;
}

.only-mobile {
  display: none;
}

input,
select,
textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.62rem 0.75rem;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(11, 92, 150, 0.2);
  border-color: #78aad0;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  max-width: 1080px;
  width: 100%;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 26px;
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  overflow: hidden;
}

.login-brand {
  padding: 3rem;
  background: linear-gradient(140deg, #0a233c 0%, #0d4f76 55%, #158f8b 100%);
  color: #f2f7fd;
}

.login-brand h1 {
  font-size: clamp(1.7rem, 2.8vw, 2.7rem);
  line-height: 1.08;
  margin: 0.8rem 0 1rem;
  letter-spacing: -0.02em;
}

.login-brand p {
  margin: 0;
  color: #d6e7f6;
}

.login-brand ul {
  margin-top: 1.5rem;
  padding-left: 1rem;
  color: #dff2fc;
  display: grid;
  gap: 0.7rem;
}

.login-form {
  padding: 2.1rem 2rem;
  display: grid;
  gap: 0.68rem;
  align-content: center;
  background: rgba(255, 255, 255, 0.88);
}

.login-form h2 {
  margin: 0 0 0.8rem;
  font-size: 1.38rem;
}

.login-help {
  font-size: 0.82rem;
  color: #6b7f95;
  margin-top: 0.45rem;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.4rem 0;
  font-size: 0.9rem;
}

.checkbox-line input {
  width: 16px;
  height: 16px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1rem;
  background: linear-gradient(170deg, #0a2037, #13385d 45%, #1b5678);
  color: #ddeefe;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 20;
}

.brand {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  padding: 0.55rem 0.45rem 1rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1cb7a4, #3a89f0);
  color: #fff;
  font-weight: 800;
}

.brand-title,
.brand-sub {
  margin: 0;
}

.brand-title {
  font-size: 1rem;
  font-weight: 800;
}

.brand-sub {
  color: #b3d7f4;
  font-size: 0.86rem;
}

.nav {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.nav-link {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #d9e8f8;
  text-align: left;
  border-radius: 10px;
  padding: 0.63rem 0.72rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.21);
  transform: translateX(2px);
}

.sidebar-footer {
  margin-top: auto;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 0.8rem;
  display: grid;
  gap: 0.35rem;
}

.sidebar-footer p {
  margin: 0;
  font-size: 0.84rem;
}

.shell-main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  margin: 1rem;
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.66);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-md);
}

.topbar h2 {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.search-wrap {
  display: block;
  width: min(360px, 48vw);
}

.search-wrap input {
  width: 100%;
}

.content {
  padding: 0 1rem 1rem;
}

.view {
  display: none;
  animation: reveal 0.36s ease;
}

.view.active {
  display: block;
}

.kpi-grid,
.grid {
  display: grid;
  gap: 0.85rem;
}

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

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 0.85rem;
}

.card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.card-head.wrap {
  flex-wrap: wrap;
}

.card-head h3 {
  margin: 0;
  font-size: 1.02rem;
}

.inline-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-filters input,
.inline-filters select {
  min-width: 140px;
}

.module-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.module-form input,
.module-form select,
.module-form textarea,
.module-form button {
  min-height: 40px;
}

.kpi-card {
  border-radius: var(--radius-md);
  padding: 0.85rem;
  background: linear-gradient(145deg, #fff, #f3f8fc);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
}

.kpi-title {
  color: #5d7185;
  font-size: 0.84rem;
}

.kpi-value {
  font-size: clamp(1.28rem, 2.4vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.015em;
}

.kpi-foot {
  color: #5f7284;
  font-size: 0.8rem;
}

.funnel-chart {
  display: grid;
  gap: 0.45rem;
}

.funnel-row {
  display: grid;
  gap: 0.25rem;
}

.funnel-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #485d71;
}

.funnel-track {
  height: 12px;
  border-radius: 999px;
  background: #e2edf6;
}

.funnel-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0b5c96, #0aa098);
}

.widget-list {
  display: grid;
  gap: 0.6rem;
}

.widget-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.65rem;
  background: var(--surface-muted);
}

.widget-item p {
  margin: 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.64rem 0.7rem;
  background: #fbfdff;
}

.list-item p {
  margin: 0;
}

.list-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.list.compact {
  gap: 0.45rem;
}

.table-wrap {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
  background: #fff;
}

th,
td {
  padding: 0.72rem 0.68rem;
  border-bottom: 1px solid #e8eef4;
  text-align: left;
  font-size: 0.86rem;
}

th {
  background: #f4f8fc;
  color: #5a7084;
  font-size: 0.79rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.pipeline-column {
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
  padding: 0.64rem;
  display: grid;
  gap: 0.58rem;
}

.pipeline-column h4 {
  margin: 0;
  font-size: 0.92rem;
}

.pipeline-drop {
  min-height: 130px;
  display: grid;
  gap: 0.52rem;
}

.pipeline-drop.drag-over {
  outline: 2px dashed #6ba5d1;
  outline-offset: 2px;
  border-radius: 10px;
}

.pipeline-card {
  background: #fff;
  border: 1px solid #d7e4ee;
  border-left: 4px solid #0b5c96;
  border-radius: 10px;
  padding: 0.56rem;
  box-shadow: 0 6px 14px rgba(11, 31, 53, 0.08);
  cursor: grab;
}

.pipeline-card h5,
.pipeline-card p {
  margin: 0;
}

.pipeline-card h5 {
  font-size: 0.89rem;
}

.pipeline-card p {
  font-size: 0.78rem;
  color: #5d7288;
}

.pipeline-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
}

.whatsapp-inbox,
.whatsapp-chat {
  min-height: 460px;
}

.inbox-list {
  display: grid;
  gap: 0.5rem;
  max-height: 510px;
  overflow: auto;
}

.inbox-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.6rem;
  cursor: pointer;
  background: #fff;
}

.inbox-item.active,
.inbox-item:hover {
  background: #e8f3fc;
  border-color: #9fc4e0;
}

.inbox-item p {
  margin: 0;
}

.chat-messages {
  height: 320px;
  overflow: auto;
  display: grid;
  gap: 0.45rem;
  padding-right: 0.2rem;
}

.bubble {
  max-width: 86%;
  border-radius: 12px;
  padding: 0.5rem 0.62rem;
  border: 1px solid var(--line);
}

.bubble.out {
  margin-left: auto;
  background: #dbf4ea;
  border-color: #abdac9;
}

.bubble.in {
  margin-right: auto;
  background: #f4f8fd;
}

.bubble p {
  margin: 0;
  font-size: 0.85rem;
}

.bubble small {
  color: #678096;
}

.chat-form {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.55rem;
}

.timeline-list {
  display: grid;
  gap: 0.6rem;
}

.timeline-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  background: #f9fcff;
}

.timeline-item p {
  margin: 0;
}

.item-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.item-actions .btn {
  padding: 0.42rem 0.6rem;
  font-size: 0.78rem;
}

.content-calendar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.content-entry {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.65rem;
  display: grid;
  gap: 0.4rem;
}

.content-entry p {
  margin: 0;
}

.task-board {
  display: grid;
  gap: 0.55rem;
}

.task-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.64rem;
  background: #f8fcff;
}

.task-row p {
  margin: 0;
}

.forecast-cards {
  display: grid;
  gap: 0.55rem;
}

.forecast-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.68rem;
  background: #fff;
}

.forecast-card h4,
.forecast-card p {
  margin: 0;
}

.bar-chart {
  display: grid;
  gap: 0.7rem;
}

.bar-row {
  display: grid;
  gap: 0.3rem;
}

.bar-row p {
  margin: 0;
  font-size: 0.84rem;
  color: #506477;
}

.bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e4edf4;
  overflow: hidden;
}

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

.queue {
  display: grid;
  gap: 0.55rem;
}

.queue-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  background: #fbfdff;
}

.queue-card p {
  margin: 0;
}

.queue-actions {
  margin-top: 0.52rem;
  display: flex;
  gap: 0.5rem;
}

.lead-drawer {
  position: fixed;
  top: 0;
  right: -620px;
  width: min(600px, 100vw);
  height: 100vh;
  background: #fff;
  box-shadow: -18px 0 40px rgba(11, 31, 53, 0.2);
  z-index: 60;
  display: grid;
  grid-template-rows: auto 1fr;
  transition: right 0.32s ease;
  border-left: 1px solid var(--line);
}

.lead-drawer.open {
  right: 0;
}

.drawer-scroll {
  overflow-y: auto;
  min-height: 0;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.drawer-head h3 {
  margin: 0.2rem 0 0;
  font-size: 1.1rem;
}

.drawer-actions {
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.drawer-actions label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.82rem;
  color: #556a7e;
}

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

.drawer-form-grid .span-2 {
  grid-column: 1 / -1;
}

.drawer-button-row {
  display: flex;
  gap: 0.55rem;
}

.drawer-button-row .btn {
  flex: 1;
}

.settings-form {
  display: grid;
  gap: 0.62rem;
}

.settings-form label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.84rem;
  color: #4d6277;
}

.settings-form .checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-provider-fields {
  display: grid;
  gap: 0.62rem;
}

.ai-provider-fields label {
  display: grid;
  gap: 0.28rem;
  font-size: 0.84rem;
  color: #4d6277;
}

.ai-provider-help {
  margin: 0;
  font-size: 0.75rem;
  color: #6b7f94;
}

.table-actions {
  display: flex;
  gap: 0.45rem;
}

.table-actions .btn {
  padding: 0.4rem 0.55rem;
  font-size: 0.76rem;
}

.permission-note {
  border: 1px dashed #d6e2ed;
  border-radius: 11px;
  padding: 0.6rem;
  color: #5e7287;
  background: #f8fbff;
}

.drawer-tabs {
  padding: 0.6rem 1rem;
  display: flex;
  gap: 0.45rem;
  overflow: auto;
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  border: 1px solid var(--line);
  background: #f8fbff;
  padding: 0.42rem 0.58rem;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  color: #fff;
  border-color: #0d5689;
  background: linear-gradient(120deg, #0d5b90, #118787);
}

.drawer-content {
  overflow: visible;
  padding: 0.9rem 1rem 1rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.info-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem;
}

.info-card p {
  margin: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  padding: 0.58rem 0.8rem;
  border-radius: 999px;
  background: #0f446d;
  color: #fff;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 90;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.reveal-up {
  animation: reveal-up 0.65s ease;
}

@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(20px, -20px, 0);
  }
}

@media (max-width: 1180px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .pipeline-board {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
  }
}

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

  .only-mobile {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.24s ease;
    width: min(84vw, 320px);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .topbar {
    margin-top: 0.6rem;
    margin-left: 0.6rem;
    margin-right: 0.6rem;
    flex-wrap: wrap;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-wrap {
    width: 100%;
  }

  .content {
    padding: 0 0.6rem 0.9rem;
  }

  .pipeline-board {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .login-brand {
    padding: 2rem;
  }

  .task-row {
    grid-template-columns: 1fr;
  }

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

  .content-calendar {
    grid-template-columns: 1fr;
  }

  .module-form {
    grid-template-columns: 1fr;
  }
}

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

  .pipeline-board {
    grid-template-columns: 1fr;
  }

  .drawer-tabs {
    padding-bottom: 0.4rem;
  }

  .drawer-form-grid {
    grid-template-columns: 1fr;
  }
}
